Clean-up Refactoring Specification
Author:
Leon Chiver
$Id: cleanup.html,v 1.5 2005/08/27 14:03:36 leonchiver Exp $ (see full
CVS history)
This refactoring looks for code which is not used (or is not necessary) and removes it. Candidates for the refactoring are:
- private unused fields, methods, constructors, classes, local variables
- redundant casts
- unused imports
Pre-Conditions
- One ore more java classes, packages, source directories or projects are selected. The refactoring
will be applied on all editable java files from the selected elements
Pre-Checks
- Error: No files selected for the refactoring
Parameters
- List of java files to be cleaned up. Only the editable files are shown in the list. By default, all files are selected
- Type of changes which should be made in each java file: remove unused code, redundant casts and unused imports
- How should the cleanup action look like: comment out the unused code or remove it
All parameters excepting the selected files should be remembered throughout invocation (and even IDE restarts)
Fast Parameters Check
- At least one java file needs to be selected
- At least one cleanup action needs to be selected
- Show a warning that the refactoring might remove parts of code, which even if not
used currently might be used later. Ask for a review of the changes shown in the refactoring preview
- If more than one files are selected show a warning saying that it's easier
to review changes if only one file is refactored. This warning is a slighltly different version
of the previous one
Parameters Check
No specific checks
Changes To Be Made
- Remove (or comment) the checked artifacts (code, imports, casts) from the selected files
Checks During Changes Preparation
No specific checks.
Refactoring UI
Menu item:
Clean-up
Action title:
Clean-up
The panel should display a list with all selected files which can be cleaned up. Read-only files should
not appear in the list. The files can come from selected java files, packages, source paths or projects.
PS: it might be better to show package nodes, source folders or projects in the list (instead of the java files they contain),
thus keeping the number of elements in the list limited
+-------------------------------------------------------+
| Files to clean-up: |
| +---+-----------------------------------------------+ |
| | | Files | |
| +---+-----------------------------------------------+ |
| |[ ]| org/netbeans/File1.java | |
| |[x]| org/netbeans/module/File2.java | |
| |[ ]| org/netbeans/module/File3.java | |
| +---+-----------------------------------------------+ |
| |
| [x] Remove unused elements |
| [ ] Remove redundant casts |
| [x] Remove unused imports |
| |
| [x] Comment out code instead of removing it |
| |
+-------------------------------------------------------+