cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

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

  1. Inner class (non-anonymous) residing in an editable source code base must be selected.

Pre-Checks

Parameters

  1. New name for the class.
  2. Name of the instance field that may be generated to keep reference to the original outer class.

Fast Parameters Check

  1. [4.2] Error: New name of the class is not a valid identifier.
  2. [4.2] Error: The selected name of the class would cause a name clash in the new scope.
  3. [4.2] Error: Name for the instance field is not a valid identifier.
  4. [4.2] Error: Name for the instance field clashes with a name of an existing field.

Parameters Check

  1. [4.2] Warning: The instance field will hide a field from the superclass.
  2. [4.2] Warning: Field to the outer class is necessary, but its name was not set (client did not choose to generate it).
  3. [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

  1. Rename class (if necessary).
  2. Move the class to the outer level.
  3. Add declaration of the field pointing to the outer class, update constructors to take this field as a parameter. (if applicable)
  4. Fix super constructor invocations in subclasses' constructors. (if applicable)
  5. 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()").
  6. 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: ____________________________ |
-------------------------------------------------

Companion
Projects:
MySQL Database Server   GlassFish Community: an Open Source Application Server   Open Solaris  Open JDK: an Open SourceJDK   Mobile & Embedded Community     Sponsored by 
Sponsored by Sun Microsystems