Class NamingConventions
- java.lang.Object
-
- org.eclipse.jdt.core.NamingConventions
-
public final class NamingConventions extends Object
Provides methods for computing Java-specific names.The behavior of the methods is dependent of several JavaCore options.
The possible options are :
-
JavaCore.CODEASSIST_FIELD_PREFIXES: Define the Prefixes for Field Name. -
JavaCore.CODEASSIST_FIELD_SUFFIXES: Define the Suffixes for Field Name. -
JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES: Define the Prefixes for Static Field Name. -
JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES: Define the Suffixes for Static Field Name. -
JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES: Define the Prefixes for Static Final Field Name. -
JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES: Define the Suffixes for Static Final Field Name. -
JavaCore.CODEASSIST_LOCAL_PREFIXES: Define the Prefixes for Local Variable Name. -
JavaCore.CODEASSIST_LOCAL_SUFFIXES: Define the Suffixes for Local Variable Name. -
JavaCore.CODEASSIST_ARGUMENT_PREFIXES: Define the Prefixes for Argument Name. -
JavaCore.CODEASSIST_ARGUMENT_SUFFIXES: Define the Suffixes for Argument Name.
For a complete description of the configurable options, see
JavaCore.getDefaultOptions(). To programmatically change these options, seeJavaCore.setOptions(java.util.Hashtable).This class provides static methods and constants only.
- Since:
- 2.1
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()- Restriction:
- This class is not intended to be instantiated by clients.
-
-
-
Field Summary
Fields Modifier and Type Field Description static intBK_NAMEThe base name associated to this base name kind is a simple name.static intBK_TYPE_NAMEThe base name associated to this base name kind is a simple type name.static intVK_INSTANCE_FIELDVariable kind which represents an instance field.static intVK_LOCALVariable kind which represents a local variable.static intVK_PARAMETERVariable kind which represents an argument.static intVK_STATIC_FIELDVariable kind which represents a static field.static intVK_STATIC_FINAL_FIELDVariable kind which represents a static final field.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringgetBaseName(int variableKind, String variableName, IJavaProject javaProject)Returns a base name which could be used to generate the given variable name withsuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean).static char[]removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_PARAMETERas variable kind.static StringremovePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_PARAMETERas variable kind.static char[]removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.static StringremovePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.static char[]removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_LOCALas variable kind.static StringremovePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName)Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_LOCALas variable kind.static char[][]suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_PARAMETERas variable kind.static String[]suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_PARAMETERas variable kind.static char[][]suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.static String[]suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.static char[]suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)Suggest name for a getter method.static StringsuggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)Suggest name for a getter method.static char[][]suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_LOCALas variable kind.static String[]suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_LOCALas variable kind.static char[]suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)Suggest name for a setter method.static StringsuggestSetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)Suggest name for a setter method.static String[]suggestVariableNames(int variableKind, int baseNameKind, String baseName, IJavaProject javaProject, int dim, String[] excluded, boolean evaluateDefault)Suggests names for a variable.
-
-
-
Field Detail
-
VK_STATIC_FIELD
public static final int VK_STATIC_FIELD
Variable kind which represents a static field.- Since:
- 3.5
- See Also:
- Constant Field Values
-
VK_INSTANCE_FIELD
public static final int VK_INSTANCE_FIELD
Variable kind which represents an instance field.- Since:
- 3.5
- See Also:
- Constant Field Values
-
VK_STATIC_FINAL_FIELD
public static final int VK_STATIC_FINAL_FIELD
Variable kind which represents a static final field.- Since:
- 3.5
- See Also:
- Constant Field Values
-
VK_PARAMETER
public static final int VK_PARAMETER
Variable kind which represents an argument.- Since:
- 3.5
- See Also:
- Constant Field Values
-
VK_LOCAL
public static final int VK_LOCAL
Variable kind which represents a local variable.- Since:
- 3.5
- See Also:
- Constant Field Values
-
BK_NAME
public static final int BK_NAME
The base name associated to this base name kind is a simple name. When this base name is used the whole name is considered.
-
BK_TYPE_NAME
public static final int BK_TYPE_NAME
The base name associated to this base name kind is a simple type name. When this base name is used all the words of the name are considered.
-
-
Method Detail
-
removePrefixAndSuffixForArgumentName
public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_PARAMETERas variable kind.Remove prefix and suffix from an argument name.If argument name prefix is
preand argument name suffix issufthen for an argument namedpreArgsufthe result of this method isarg. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreArgsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the argument.argumentName- argument's name.- Returns:
- char[] the name without prefix and suffix.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
removePrefixAndSuffixForArgumentName
public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_PARAMETERas variable kind.Remove prefix and suffix from an argument name.If argument name prefix is
preand argument name suffix issufthen for an argument namedpreArgsufthe result of this method isarg. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreArgsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the argument.argumentName- argument's name.- Returns:
- char[] the name without prefix and suffix.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
removePrefixAndSuffixForFieldName
public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.Remove prefix and suffix from a field name.If field name prefix is
preand field name suffix issufthen for a field namedpreFieldsufthe result of this method isfield. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreFieldsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES} ,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the field.fieldName- field's name.modifiers- field's modifiers as defined by the classFlags.- Returns:
- char[] the name without prefix and suffix.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
removePrefixAndSuffixForFieldName
public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.Remove prefix and suffix from a field name.If field name prefix is
preand field name suffix issufthen for a field namedpreFieldsufthe result of this method isfield. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreFieldsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the field.fieldName- field's name.modifiers- field's modifiers as defined by the classFlags.- Returns:
- char[] the name without prefix and suffix.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
removePrefixAndSuffixForLocalVariableName
public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_LOCALas variable kind.Remove prefix and suffix from a local variable name.If local variable name prefix is
preand local variable name suffix issufthen for a local variable namedpreLocalsufthe result of this method islocal. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreLocalsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the variable.localName- variable's name.- Returns:
- char[] the name without prefix and suffix.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
removePrefixAndSuffixForLocalVariableName
public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName)
Deprecated.UsegetBaseName(int, String, IJavaProject)instead withVK_LOCALas variable kind.Remove prefix and suffix from a local variable name.If local variable name prefix is
preand local variable name suffix issufthen for a local variable namedpreLocalsufthe result of this method islocal. If there is no prefix or suffix defined in JavaCore options the result is the unchanged namepreLocalsuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the variable.localName- variable's name.- Returns:
- char[] the name without prefix and suffix.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
getBaseName
public static String getBaseName(int variableKind, String variableName, IJavaProject javaProject)
Returns a base name which could be used to generate the given variable name withsuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean).e.g.
If the variable is aVK_LOCALand the variable name isvariableNamethen the base name will bevariableName.
If the variable is aVK_STATIC_FINAL_FIELDand the variable name isVARIABLE_NAMEthen the base name will bevariableName.
Prefixes and suffixes defined in JavaCore options will be also removed from the variable name.
Each variable kind is affected by the following JavaCore options:VK_PARAMETER:JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXESVK_LOCAL:JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXESVK_INSTANCE_FIELD:JavaCore.CODEASSIST_FIELD_PREFIXESandJavaCore.CODEASSIST_FIELD_SUFFIXESVK_STATIC_FIELD:JavaCore.CODEASSIST_STATIC_FIELD_PREFIXESandJavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESVK_STATIC_FINAL_FIELD:JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXESandJavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES
e.g.
If the variable is aVK_LOCAL, the variable name ispreVariableNamesuf, a possible prefix ispreand a possible suffix issufthen the base name will bevariableName.
- Parameters:
variableKind- specifies what type the variable is:VK_LOCAL,VK_PARAMETER,VK_STATIC_FIELD,VK_INSTANCE_FIELDorVK_STATIC_FINAL_FIELD.variableName- a variable namejavaProject- project which contains the variable ornullto take into account only workspace settings.- Since:
- 3.5
- See Also:
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
-
suggestArgumentNames
public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_PARAMETERas variable kind.Suggest names for an argument. The name is computed from argument's type and possible prefixes or suffixes are added.If the type of the argument is
TypeName, the prefix for argument ispreand the suffix for argument issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the argument.packageName- package of the argument's type.qualifiedTypeName- argument's type.dim- argument's dimension (0 if the argument is not an array).excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestArgumentNames
public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_PARAMETERas variable kind.Suggest names for an argument. The name is computed from argument's type and possible prefixes or suffixes are added.If the type of the argument is
TypeName, the prefix for argument ispreand the suffix for argument issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the argument.packageName- package of the argument's type.qualifiedTypeName- argument's type.dim- argument's dimension (0 if the argument is not an array).excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestFieldNames
public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.Suggest names for a field. The name is computed from field's type and possible prefixes or suffixes are added.If the type of the field is
TypeName, the prefix for field ispreand the suffix for field issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESand for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the field.packageName- package of the field's type.qualifiedTypeName- field's type.dim- field's dimension (0 if the field is not an array).modifiers- field's modifiers as defined by the classFlags.excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestFieldNames
public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_INSTANCE_FIELDorVK_STATIC_FIELDas variable kind.Suggest names for a field. The name is computed from field's type and possible prefixes or suffixes are added.If the type of the field is
TypeName, the prefix for field ispreand the suffix for field issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESand for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the field.packageName- package of the field's type.qualifiedTypeName- field's type.dim- field's dimension (0 if the field is not an array).modifiers- field's modifiers as defined by the classFlags.excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestGetterName
public static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
Suggest name for a getter method. The name is computed from field's name and possible prefixes or suffixes are removed.If the field name is
preFieldNamesufand the prefix for field ispreand the suffix for field issufthen the prosposed name isisFieldNamefor boolean field orgetFieldNamefor others. If there is no prefix and suffix the proposal isisPreFieldNamesuffor boolean field orgetPreFieldNamesuffor others.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
project- project which contains the field.fieldName- field's name's.modifiers- field's modifiers as defined by the classFlags.isBoolean-trueif the field's type is booleanexcludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[] a name.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestGetterName
public static String suggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)
Suggest name for a getter method. The name is computed from field's name and possible prefixes or suffixes are removed.If the field name is
preFieldNamesufand the prefix for field ispreand the suffix for field issufthen the prosposed name isisFieldNamefor boolean field orgetFieldNamefor others. If there is no prefix and suffix the proposal isisPreFieldNamesuffor boolean field orgetPreFieldNamesuffor others.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
project- project which contains the field.fieldName- field's name's.modifiers- field's modifiers as defined by the classFlags.isBoolean-trueif the field's type is booleanexcludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[] a name.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestLocalVariableNames
public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_LOCALas variable kind.Suggest names for a local variable. The name is computed from variable's type and possible prefixes or suffixes are added.If the type of the local variable is
TypeName, the prefix for local variable ispreand the suffix for local variable issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the variable.packageName- package of the variable's type.qualifiedTypeName- variable's type.dim- variable's dimension (0 if the variable is not an array).excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestLocalVariableNames
public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)
Deprecated.UsesuggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)instead withVK_LOCALas variable kind.Suggest names for a local variable. The name is computed from variable's type and possible prefixes or suffixes are added.If the type of the local variable is
TypeName, the prefix for local variable ispreand the suffix for local variable issufthen the proposed names arepreTypeNamesufandpreNamesuf. If there is no prefix or suffix the proposals aretypeNameandname.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXES.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
javaProject- project which contains the variable.packageName- package of the variable's type.qualifiedTypeName- variable's type.dim- variable's dimension (0 if the variable is not an array).excludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestSetterName
public static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
Suggest name for a setter method. The name is computed from field's name and possible prefixes or suffixes are removed.If the field name is
preFieldNamesufand the prefix for field ispreand the suffix for field issufthen the proposed name issetFieldName. If there is no prefix and suffix the proposal issetPreFieldNamesuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
project- project which contains the field.fieldName- field's name's.modifiers- field's modifiers as defined by the classFlags.isBoolean-trueif the field's type is booleanexcludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[] a name.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestSetterName
public static String suggestSetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)
Suggest name for a setter method. The name is computed from field's name and possible prefixes or suffixes are removed.If the field name is
preFieldNamesufand the prefix for field ispreand the suffix for field issufthen the proposed name issetFieldName. If there is no prefix and suffix the proposal issetPreFieldNamesuf.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES,JavaCore.CODEASSIST_FIELD_SUFFIXESfor instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESfor static field.For a complete description of these configurable options, see
getDefaultOptions. For programmaticaly change these options, seeJavaCore#setOptions().- Parameters:
project- project which contains the field.fieldName- field's name's.modifiers- field's modifiers as defined by the classFlags.isBoolean-trueif the field's type is booleanexcludedNames- a list of names which cannot be suggested (already used names). Can benullif there is no excluded names.- Returns:
- char[] a name.
- See Also:
Flags,JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
suggestVariableNames
public static String[] suggestVariableNames(int variableKind, int baseNameKind, String baseName, IJavaProject javaProject, int dim, String[] excluded, boolean evaluateDefault)
Suggests names for a variable. The name is computed from a base name and possible prefixes or suffixes are added.The base name is used to compute the variable name. Some different kinds of base names are possible and each kind is associated to a different heuristic to compute variable names.
The heuristic depends also on the kind of the variable. Each kind of variable is identified by a constant starting withVK_.
When a prefix and a suffix can be added then all combinations of prefix and suffix are suggested. If the name isname, the prefix ispreand the suffix issufthen the suggested names will beprenamesuf,prename,namesufandname.
The different kinds of base names are:BK_NAME: the base name is a Java name and the whole base name is considered to compute the variable names. A prefix and a suffix can be added.
There is a heuristic by variable kind.VK_PARAMETER,VK_LOCAL,VK_INSTANCE_FIELDandVK_STATIC_FIELD:
In this case the first word will be converted to lower case and the other characters won't be changed.
If the base name isSimpleNamethen the suggested name will besimpleName.VK_STATIC_FINAL_FIELD:
In this case all letters of the name will be converted to upper case and words will be separated by an underscore ("_").
If the base name isSimpleNamethen the suggested name will beSIMPLE_NAME.
BK_TYPE_NAME: the base name is a Java simple type name (e.g.HashMap) and all the words of the base name are considered to compute the variable names. A prefix and a suffix can be added to these names.
There is a heuristic by variable kind.VK_PARAMETER,VK_LOCAL,VK_INSTANCE_FIELDandVK_STATIC_FIELD:
In this case a variable name will contain some words of the base name and the first word will be converted to lower case.
If the type isTypeNamethen the suggested names will betypeNameandname.VK_STATIC_FINAL_FIELD:
In this case a variable name will contain some words of the base name, all letters of the name will be converted to upper case and segments will be separated by a underscore ("_").
If the base name isTypeNamethen the suggested name will beTYPE_NAMEandNAME.
Each variable kind is affected by the following JavaCore options:
VK_PARAMETER:JavaCore.CODEASSIST_ARGUMENT_PREFIXESandJavaCore.CODEASSIST_ARGUMENT_SUFFIXESVK_LOCAL:JavaCore.CODEASSIST_LOCAL_PREFIXESandJavaCore.CODEASSIST_LOCAL_SUFFIXESVK_INSTANCE_FIELD:JavaCore.CODEASSIST_FIELD_PREFIXESandJavaCore.CODEASSIST_FIELD_SUFFIXESVK_STATIC_FIELD:JavaCore.CODEASSIST_STATIC_FIELD_PREFIXESandJavaCore.CODEASSIST_STATIC_FIELD_SUFFIXESVK_STATIC_FINAL_FIELD:JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXESandJavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES
For a complete description of these configurable options, see
JavaCore.getDefaultOptions(). To programmatically change these options, seeJavaCore.setOptions(java.util.Hashtable)andIJavaProject.setOptions(java.util.Map)Proposed names are sorted by relevance (best proposal first).
The names are proposed in the following order:- Names with prefix and suffix. Longer names are proposed first
- Names with prefix. Longer names are proposed first
- Names with suffix. Longer names are proposed first
- Names without prefix and suffix. Longer names are proposed first
- Parameters:
variableKind- specifies what type the variable is:VK_LOCAL,VK_PARAMETER,VK_STATIC_FIELD,VK_INSTANCE_FIELDorVK_STATIC_FINAL_FIELD.baseNameKind- specifies what type the base name is:BK_NAMEorBK_TYPE_NAMEbaseName- name used to compute the suggested names.javaProject- project which contains the variable ornullto take into account only workspace settings.dim- variable dimension (0 if the field is not an array).excluded- a list of names which cannot be suggested (already used names). Can benullif there are no excluded names.evaluateDefault- iftrue, the result is guaranteed to contain at least one result. Iffalse, the result can be an empty array.- Returns:
- String[] an array of names.
- Since:
- 3.5
- See Also:
JavaCore.setOptions(java.util.Hashtable),JavaCore.getDefaultOptions()
-
-