FeaturesPluginsDocs & SupportCommunityPartners

Pull Up Refactoring Specification

$Id: pullup.html,v 1.9 2005/08/25 14:25:00 jbecicka Exp $ (see full CVS history)

Refactoring feature that allows to "pull up" members of a class (methods, fields, inner classes) and interfaces in the implements clause into a supertype.
Implementation of this refactoring is tracked in issue 56135.

Pre-Conditions

  1. A single type or 1 to many members of a single type are selected.

Pre-Checks

  1. Error: The selected type (or the parent type of the selected members) has no supertypes from the currently opened projects.
  2. Error: The selected type and its supertypes have no members.

Parameters

  1. Supertype to pull members up to.
  2. List of members and implemented interfaces to pull up to the supertype.
  3. For each method to be pulled up a boolean parameter to indicate whether it should be declared abstract in the supertype.

Fast Parameters Check

  1. [4.2] Error: No member selected for pulling up.
  2. [4.2] Error: Check if the target type is not null.

Parameters Check

  1. [4.2] Error: Selected target type is a legal (i.e. from the opened projects) supertype of the source type.
  2. Error: One of the members is not a member that could be pulled up (it is not declared in the source type or one of its supertypes that are subtypes of the target type.
  3. [4.2] Error: One of the selected members already exists in the supertype.
  4. Warning: Member selected to be pulled up uses other members of the class that are currently not selected for pulling up.
  5. Warning: A method marked as "Make Abstract" is private or package private. (it will be changed to protected)
  6. Warning: Member is used by other members of the type that are currently not selected for pulling up and it will not be visible from the current type after pulling (since it is private or package private). (member visibility will be changed to protected)
  7. Warning: The target type is in a different package and the member selected to be pulled references some package private elements from other classes.
  8. Warning: Abstract methods are to be created in the target type. The target type is not abstract, so it has to be made abstract. But there currently exists a code that instantiates it or there are subtypes of the target type that are not abstract and should be after this change.

Changes To Be Made

  1. Remove the elements to be pulled up from their current parent type (except for the methods with "Make Abstract" checked).
  2. Modify visibility of private and package private methods marked as "Make Abstract" to protected.
  3. Add the elements to be pulled up to the selected supertype. The elements should be moved unchanged with the exception of:
    • When the element is a method that has "Make Abstract" checked just a declaration will be added.
    • Modifiers of the element will be changed to make the element protected if necessary (see Parameters Check)
  4. Add abstract modifier to the target supertype if an abstract method was added to it.

Checks During Changes Preparation

No specific checks.

Refactoring UI

Menu item: Pull Up...
Action title: Pull Up Members of "ClassName"

The panel should display a combo-box for selecting a supertype and a table containing all members in the current type and its supertypes up to the selected supertype (see the picture below). If the selected supertype is an interface, all methods should have "Make Abstract" checked and the "Make Abstract" checkboxes should be disabled.
When a user selects a different superclass, the table content should be refreshed.

----------------------------------------------------
|                        ------------------------- |
| Destination Supertype: | Foo (project)       |v| |
|                        ------------------------- |
| Members to Pull Up:                              |
| ------------------------------------------------ |
| |  | Member                    | Make Abstract | |
| ------------------------------------------------ |
| | o field1                     |               | |
| | x field2                     |               | |
| | o field3                     |               | |
| | o field4                     |               | |
| | x method1                    |       o       | |
| | o method2                    |       o       | |
| | x method3                    |       x       | |
| | o InnerClass                 |               | |
| | o implements IFoo            |               | |
| | o implements IBar            |               | |
| ------------------------------------------------ |
----------------------------------------------------
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by