The refactorings in the Refactoring Browser can be classified into three sections: class based refactorings, method based refactorings, and code based refactorings. The class based refactorings operate on classes, instance variables, and class variables and are defined off the class menu. The method based refactorings are defined off the selector menu. Finally the code based refactorings operate on individual statements and are available through the context sensitive menus in the code tool. Many of the class based refactorings are also available in the context sensitive menus in the code tools.
- Create subclass: This refactoring allows you to insert a new class into an existing hierarchy. For example, you can insert a new class between object and all of its subclasses by using the refactoring (although I wouldn't recommend it). To use the refactoring, simple select the superclass for the new class and then execute the create subclass refactoring.
- Rename: This refactoring renames a class and also renames every reference to the class in the code. Even symbols with the same name as the class will also be renamed so that "Smalltalk at: ..." will work. However, if you are constructing class names using the asSymbol message, then those strings will not be renamed. In ENVY the renamed class will also contain all the stored ENVY attributes that the original class contained, including the classes part builder records in VA. However, currently the browser does not rename class references in these stored attributes.
- Safe Remove: This refactoring checks for references to a class, and if there are no references, it will remove the class. If you reference the class by using constructed symbols and "Smalltalk at: ...", it may remove your class even though your code still uses it.
- Convert to Sibling: ...
- Add instance/class variable: Add a variable to the class. In ENVY it will check that the variable is not already defined as a temporary in one of the class' methods.
- Rename instance/class variable: Renames a variable and all references to the variable. If you are using instVarAt:'s, then this might break your code, since currently the new variable's name is always at the end.
- Remove instance/class variable: Removes a variable only if it is not referenced. Again, if you are using instVarAt:'s, this refactoring can remove a variable that is actually used.
- Push Down instance/class variable: Moves a variable definition from the currently selected class to only those subclasses that use the variable (removing the variable if no subclass has a reference to the variable). This will only be allowed, if the selected class contains no references to the variable. For class variables, it can only push the variable down into one subclass. Otherwise, it will have split the one class variable into two and possibly broken the code. As will the other variable refactorings, this refactoring will not work with instVarAt:'s.
- Pull Up instance/class variable: Move a variable definition from a subclass of the currently selected class into the currently selected class.
- Create instance/class variable Accessors: Creates getter and setter methods for a variable. The methods are named with the name of the variable. If a method with that name already exists, then it will add a number to the name, until it no longer conflicts.
- Abstract instance/class variable: Performs the create accessors refactoring and then converts all direct variable to use the accessor methods.
- Protect/Concrete instance variable: Converts all variable accessor sends to direct variable references. If the accessor is no longer used then it will be removed.
- Convert to ValueHolder: This refactoring is only available for VW. It will convert a variable into a ValueHolder. This was more useful for converting old interfaces used in OW4.1 to the new VW style.
- Move to Component: Moves a method to another object (defined by an argument or instance variable).
- Rename: Renames all implementors of a method, all senders, and all symbols references. In addition to strict renaming, it also allows you to rearrange the parameters. However, when rearranging the parameters, it cannot permute any symbols that are performed.
- Safe Remove: Removes a method if there are no senders of the method or there are no symbol that reference the method name. Also, it will remove a method if it is equivalent to the superclass' definition.
- Add Parameter: Adds a default parameter to all implementors of the method.
- Inline all Self Sends: Inlines all senders within the class of the method. If there are no more senders after all inlines have been performed, then it will remove the method.
- Push Up: Pushes a method up into the superclass. If the superclass is abstract and already defines the method, then the superclass' method will be copied down into the other subclasses (assuming they don't already define the method).
- Push Down: Pushes a method down into all subclasses that don't implement the method. This can only be allowed if the class is abstract.
- Extract Method: Extracts the selected code as a separate method. This refactoring determines what temporary variables are needed in the new method, and prompts for a selector that takes these arguments.
- Inline Temporary: Removes the assignment of a variable and replaces all references to the variable with the right hand side of the assignment.
- Convert to Instance Variable: Converts a temporary into an instance variable.
- Remove Parameter: Removes an unused parameter from all implementors of the method, and removes it from the message sends.
- Inline Parameter: Remove a parameter from the method, and adds an assignment at the beginning of the method. This can only be performed if all senders of the method have the same value for the parameter.
- Rename Temporary: Renames a temporary variable.
- Move to Inner Scope: Moves a temporary variable definition into the tightest scope that contains both the variable assignment and references. This is useful for converting unoptimized blocks into optimized ones.
- Extract to Temporary: Extracts a message into an assignment statement. For example, if you have something like
self someMessage anotherMessage foo: 1 bar: 2
You can extract "self someMessage" to a temporary named, "temp", and get:
| temp |
temp := self someMessage.
temp anotherMessage foo: 1 bar: 2
- Inline Message: Inlines a message send. If there are multiple implementors of the message, it will prompt for the implementation that should be inlined.
If you have any comments or suggestions, Contact Us