Move Inner To Outer Level Refactoring Specification
$Id: convertinnertotoplevel.html,v 1.1 2005/03/16 14:43:11 dprusa Exp
$ (see full
CVS
history)
Refactoring feature that allows to move inner class to outer level - i.e. convert an inner class
to a top-level class, or convert an inner class of an inner class to an inner class, etc.
Implementation of this refactoring is tracked in issue
56475.
Pre-Conditions
- Inner class (non-anonymous) residing in an editable source code base must be selected.
Pre-Checks
Parameters
- New name for the class.
- Name of the instance field that may be generated to keep reference to the original outer class.
Fast Parameters Check
- [4.2] Error: New name of the class is not a valid identifier.
- [4.2] Error: The selected name of the class would cause a name clash in the new scope.
- [4.2] Error: Name for the instance field is not a valid identifier.
- [4.2] Error: Name for the instance field clashes with a name of an existing field.
Parameters Check
- [4.2] Warning: The instance field will hide a field from the superclass.
- [4.2] Warning: Field to the outer class is necessary, but its name was not set (client did not choose to generate it).
- [4.2] Warning: The class will hide another inner class of its target outer class' superclass (if moving a class nested several levels).
Changes To Be Made
- Rename class (if necessary).
- Move the class to the outer level.
- Add declaration of the field pointing to the outer class, update constructors to take this field as a parameter. (if applicable)
- Fix super constructor invocations in subclasses' constructors. (if applicable)
- If the class references any elements from its current outer class, add reference to the field pointing to the outer class
to the element reference (e.g. convert "soSomething()" to "outer.doSomething()").
- Update all reference to the class and its constructors.
Checks During Changes Preparation
No specific checks.
Refactoring UI
Menu item:
Move Inner to Outer Level...
Action title:
Move Inner to Outer Level - OldName
The panel should display a text field for editing the name of the
class being moved. The name is preset to be the current name. Next, there should be a check box for selecting whether to
generate an instance field for the current outer class and pass the outer class' to constructors or not. And
finally, a text field for editing the name of the outer class' instance field.
-------------------------------------------------
| Class Name: _OldName_________________________ |
| |
| [ ] Declare Field For The Current Outer Class |
| |
| Field Name: ____________________________ |
-------------------------------------------------