Move Method Refactoring Specification
$Id: movemethod.html,v 1.5 2005/06/07 14:59:42 jbecicka Exp $ (see full
CVS
history)
Refactoring feature that allows to move a static method to another
class or an instance method to one of the method's parameter types.
Implementation of this refactoring is tracked in issue
57767.
Pre-Conditions
- A method is selected.
Pre-Checks
- An instance method that does not have any class type parameter is
selected.
Parameters
- Target class (for static method) or one of the class types of the
method parameters (for instance method).
- Name of the method.
- Modifiers of the method.
- Name of the new parameter which is added in the case of an
instance method.
Fast Parameters Check
- Name of the new parameter clashes with one of the other parameter
names.
Parameters Check
- Fatal: Check if the moved method will not cause ambiguities in
the target.
- Non-fatal: Check if all members the method accesses will be
vissible after it is moved.
- Non-fatal: Check if the method is visible after it is moved for
all its usages.
- Non-fatal: Check whether the moved method does not override or is
not overriden.
Changes To Be Made
- If the method is static it is moved into the target class.
References to the method are updated accordingly.
- If the method is instance (and thus moved into parameter type),
the method parameter corresponding to the selected target is removed
(in the method body, it is replaced by "this") and a new parameter is
added - its type equals the original class. The original method is
changed to delegate on the new method.
Checks During Changes Preparation
No specific checks.
Refactoring UI
Menu item:
Move Method...
Action title:
Move Method - method_name
If a static method is selected, the panel should display a label
with name of the selected class, a text field for name of the target
(it can be optionally chosen in browser which is invoked by Browse
button) and a combo for selecting the visibility
modifier. If an instance method is selected, the target class is chosen
from a combo of parameter types that are classes. There is also an
additional text field for entering name of the new method parameter.
Schemas of panels for a static and instance method follow.
-----------------------------------------
| Move from: pkg.OriginalClass |
| ------------------- |
| Move to: | pkg.TargetClass | [...] |
| ------------------- |
| _________________ |
| Access: | public [v]| |
| |-----------------| |
--------------| protected |--------
| <default> |
| private |
-------------------
-----------------------------------------
| Move from: pkg.OriginalClass |
| --------------------| |
| Move to: | ParamType_1 [v] | |
| --------------------- |
| --------------------- |
| Parameter Name: | paramName | |
| --------------------- |
| ___________________ |
| Access: | public [v]| |
| |-------------------| |
------------------| protected |--
| <default> |
| private |
---------------------