| java.lang.Object org.eclipse.jdt.internal.corext.refactoring.rename.RenamingNameSuggestor
RenamingNameSuggestor | public class RenamingNameSuggestor (Code) | | This class contains methods for suggesting new names for variables or methods
whose name consists at least partly of the name of their declaring type (or
in case of methods, the return type or a parameter type).
The methods return the newly suggested method or variable name in case of a
match, or null in case nothing matched.
In any case, prefixes and suffixes are removed from variable names. As method
names have no configurable suffixes or prefixes, they are left unchanged. The
remaining name is called "stripped element name".
After the match according to the strategy, prefixes and suffixes are
reapplied to the names.
EXACT STRATEGY (always performed).
----------------------------------------------------------------
The stripped element name is directly compared with the type name:
a) the first character must match case-insensitive
b) all other characters must match case-sensitive
In case of a match, the new type name is returned (first character adapted,
respectively). Suffixes/Prefixes are reapplied.
Note that this also matches fields with names like "SomeField", "fsomeField",
and method names like "JavaElement()".
EMBEDDED STRATEGY (performed second if chosen by user).
----------------------------------------------------------------
A search is performed in the stripped element name for the old type name:
a) the first character must match case-insensitive
b) all other characters must match case-sensitive
c) the stripped element name must end after the type name, or the next
character must be a non-letter, or the next character must be upper cased.
In case of a match, the new type is inserted into the stripped element name,
replacing the old type name, first character adapted to the correct case.
Suffixes/Prefixes are reapplied.
Note that this also matches methods with names like "createjavaElement()" or
fields like "fjavaElementCache".
SUFFIX STRATEGY (performed third if chosen by user)
----------------------------------------------------------------
The new and old type names are analyzed for "camel case suffixes", that is,
substrings which begin with an uppercased letter. For example,
"SimpleJavaElement" is split into the three hunks "Simple",
"Java", and "Element". If one type name has more suffixes than the
other, both are stripped to the smaller size.
Then, a search is performed in the stripped variable name hunks from back to
front. At least the last hunk must be found, others may then extend the match.
Each hunk must match like in the exact strategy, i.e.
a) the first character must match case-insensitive
b) all other characters must match case-sensitive
In case of a match, the matched hunks of the new type replace
the hunks of the old type. Suffixes/Prefixes are reapplied.
Note that numbers and other non-letter characters belong to the previous
camel case substring.
since: 3.2 |
Method Summary | |
public String | suggestNewFieldName(IJavaProject project, String oldFieldName, boolean isStatic, String oldTypeName, String newTypeName) | public String | suggestNewLocalName(IJavaProject project, String oldLocalName, boolean isArgument, String oldTypeName, String newTypeName) | public String | suggestNewMethodName(String oldMethodName, String oldTypeName, String newTypeName) | public String | suggestNewVariableName(String[] prefixes, String[] suffixes, String oldVariableName, String oldTypeName, String newTypeName) |
STRATEGY_EMBEDDED | final public static int STRATEGY_EMBEDDED(Code) | | |
STRATEGY_EXACT | final public static int STRATEGY_EXACT(Code) | | |
STRATEGY_SUFFIX | final public static int STRATEGY_SUFFIX(Code) | | |
RenamingNameSuggestor | public RenamingNameSuggestor()(Code) | | |
RenamingNameSuggestor | public RenamingNameSuggestor(int strategy)(Code) | | |
|
|