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
- A single type or 1 to many members of a single type are selected.
Pre-Checks
- Error: The selected type (or the parent type of the selected members) has no supertypes from the currently
opened projects.
- Error: The selected type and its supertypes have no members.
Parameters
- Supertype to pull members up to.
- List of members and implemented interfaces to pull up to the supertype.
- For each method to be pulled up a boolean parameter to indicate whether it should be declared abstract in the
supertype.
Fast Parameters Check
- [4.2] Error: No member selected for pulling up.
- [4.2] Error: Check if the target type is not null.
Parameters Check
- [4.2] Error: Selected target type is a legal (i.e. from the opened projects) supertype of the source type.
- 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.
- [4.2] Error: One of the selected members already exists in the supertype.
- Warning: Member selected to be pulled up uses other members of the class that are currently not selected for
pulling up.
- Warning: A method marked as "Make Abstract" is private or package private. (it will be changed to protected)
- 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)
- Warning: The target type is in a different package and the member selected to be pulled references some
package private elements from other classes.
- 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
- Remove the elements to be pulled up from their current parent type (except for the methods with "Make Abstract"
checked).
- Modify visibility of private and package private methods marked as "Make Abstract" to protected.
- 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)
- 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 | | |
| ------------------------------------------------ |
----------------------------------------------------