Class NamingConventions
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, see JavaCore.setOptions(java.util.Hashtable)
.
This class provides static methods and constants only.
- Since:
- 2.1
- See Also:
- Restriction:
- This class is not intended to be instantiated by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The base name associated to this base name kind is a simple name.static final int
The base name associated to this base name kind is a simple type name.static final int
Variable kind which represents an instance field.static final int
Variable kind which represents a local variable.static final int
Variable kind which represents an argument.static final int
Variable kind which represents a static field.static final int
Variable kind which represents a static final field. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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)
.static char[]
removePrefixAndSuffixForArgumentName
(IJavaProject javaProject, char[] argumentName) Deprecated.static String
removePrefixAndSuffixForArgumentName
(IJavaProject javaProject, String argumentName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_PARAMETER
as variable kind.static char[]
removePrefixAndSuffixForFieldName
(IJavaProject javaProject, char[] fieldName, int modifiers) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_INSTANCE_FIELD
orVK_STATIC_FIELD
as variable kind.static String
removePrefixAndSuffixForFieldName
(IJavaProject javaProject, String fieldName, int modifiers) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_INSTANCE_FIELD
orVK_STATIC_FIELD
as variable kind.static char[]
removePrefixAndSuffixForLocalVariableName
(IJavaProject javaProject, char[] localName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_LOCAL
as variable kind.static String
removePrefixAndSuffixForLocalVariableName
(IJavaProject javaProject, String localName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_LOCAL
as 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_PARAMETER
as 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_PARAMETER
as 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_FIELD
orVK_STATIC_FIELD
as 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_FIELD
orVK_STATIC_FIELD
as variable kind.static char[]
suggestGetterName
(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) Suggest name for a getter method.static String
suggestGetterName
(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_LOCAL
as 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_LOCAL
as variable kind.static char[]
suggestSetterName
(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) Suggest name for a setter method.static String
suggestSetterName
(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 Details
-
VK_STATIC_FIELD
public static final int VK_STATIC_FIELDVariable kind which represents a static field.- Since:
- 3.5
- See Also:
-
VK_INSTANCE_FIELD
public static final int VK_INSTANCE_FIELDVariable kind which represents an instance field.- Since:
- 3.5
- See Also:
-
VK_STATIC_FINAL_FIELD
public static final int VK_STATIC_FINAL_FIELDVariable kind which represents a static final field.- Since:
- 3.5
- See Also:
-
VK_PARAMETER
public static final int VK_PARAMETERVariable kind which represents an argument.- Since:
- 3.5
- See Also:
-
VK_LOCAL
public static final int VK_LOCALVariable kind which represents a local variable.- Since:
- 3.5
- See Also:
-
BK_NAME
public static final int BK_NAMEThe 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_NAMEThe 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 Details
-
removePrefixAndSuffixForArgumentName
public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_PARAMETER
as variable kind.Remove prefix and suffix from an argument name.If argument name prefix is
pre
and argument name suffix issuf
then for an argument namedpreArgsuf
the 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_PREFIXES
andJavaCore.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:
-
removePrefixAndSuffixForArgumentName
public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_PARAMETER
as variable kind.Remove prefix and suffix from an argument name.If argument name prefix is
pre
and argument name suffix issuf
then for an argument namedpreArgsuf
the 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_PREFIXES
andJavaCore.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:
-
removePrefixAndSuffixForFieldName
public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_INSTANCE_FIELD
orVK_STATIC_FIELD
as variable kind.Remove prefix and suffix from a field name.If field name prefix is
pre
and field name suffix issuf
then for a field namedpreFieldsuf
the 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_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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:
-
removePrefixAndSuffixForFieldName
public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_INSTANCE_FIELD
orVK_STATIC_FIELD
as variable kind.Remove prefix and suffix from a field name.If field name prefix is
pre
and field name suffix issuf
then for a field namedpreFieldsuf
the 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_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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:
-
removePrefixAndSuffixForLocalVariableName
public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_LOCAL
as variable kind.Remove prefix and suffix from a local variable name.If local variable name prefix is
pre
and local variable name suffix issuf
then for a local variable namedpreLocalsuf
the 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_PREFIXES
andJavaCore.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:
-
removePrefixAndSuffixForLocalVariableName
public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) Deprecated.UsegetBaseName(int, String, IJavaProject)
instead withVK_LOCAL
as variable kind.Remove prefix and suffix from a local variable name.If local variable name prefix is
pre
and local variable name suffix issuf
then for a local variable namedpreLocalsuf
the 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_PREFIXES
andJavaCore.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:
-
getBaseName
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_LOCAL
and the variable name isvariableName
then the base name will bevariableName
.
If the variable is aVK_STATIC_FINAL_FIELD
and the variable name isVARIABLE_NAME
then 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_PREFIXES
andJavaCore.CODEASSIST_ARGUMENT_SUFFIXES
VK_LOCAL
:JavaCore.CODEASSIST_LOCAL_PREFIXES
andJavaCore.CODEASSIST_LOCAL_SUFFIXES
VK_INSTANCE_FIELD
:JavaCore.CODEASSIST_FIELD_PREFIXES
andJavaCore.CODEASSIST_FIELD_SUFFIXES
VK_STATIC_FIELD
:JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
andJavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
VK_STATIC_FINAL_FIELD
:JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES
andJavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES
e.g.
If the variable is aVK_LOCAL
, the variable name ispreVariableNamesuf
, a possible prefix ispre
and a possible suffix issuf
then the base name will bevariableName
.
- Parameters:
variableKind
- specifies what type the variable is:VK_LOCAL
,VK_PARAMETER
,VK_STATIC_FIELD
,VK_INSTANCE_FIELD
orVK_STATIC_FINAL_FIELD
.variableName
- a variable namejavaProject
- project which contains the variable ornull
to take into account only workspace settings.- Since:
- 3.5
- See Also:
-
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_PARAMETER
as 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 ispre
and the suffix for argument issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXES
andJavaCore.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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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_PARAMETER
as 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 ispre
and the suffix for argument issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_ARGUMENT_PREFIXES
andJavaCore.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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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_FIELD
orVK_STATIC_FIELD
as 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 ispre
and the suffix for field issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES
,JavaCore.CODEASSIST_FIELD_SUFFIXES
and for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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_FIELD
orVK_STATIC_FIELD
as 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 ispre
and the suffix for field issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES
,JavaCore.CODEASSIST_FIELD_SUFFIXES
and for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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
preFieldNamesuf
and the prefix for field ispre
and the suffix for field issuf
then the prosposed name isisFieldName
for boolean field orgetFieldName
for others. If there is no prefix and suffix the proposal isisPreFieldNamesuf
for boolean field orgetPreFieldNamesuf
for others.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES
,JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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
-true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names). Can benull
if there is no excluded names.- Returns:
- char[] a name.
- See Also:
-
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
preFieldNamesuf
and the prefix for field ispre
and the suffix for field issuf
then the prosposed name isisFieldName
for boolean field orgetFieldName
for others. If there is no prefix and suffix the proposal isisPreFieldNamesuf
for boolean field orgetPreFieldNamesuf
for others.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_FIELD_PREFIXES
,JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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
-true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names). Can benull
if there is no excluded names.- Returns:
- char[] a name.
- See Also:
-
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_LOCAL
as 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 ispre
and the suffix for local variable issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXES
andJavaCore.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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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_LOCAL
as 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 ispre
and the suffix for local variable issuf
then the proposed names arepreTypeNamesuf
andpreNamesuf
. If there is no prefix or suffix the proposals aretypeName
andname
.This method is affected by the following JavaCore options :
JavaCore.CODEASSIST_LOCAL_PREFIXES
andJavaCore.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 benull
if there is no excluded names.- Returns:
- char[][] an array of names.
- See Also:
-
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
preFieldNamesuf
and the prefix for field ispre
and the suffix for field issuf
then 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_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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
-true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names). Can benull
if there is no excluded names.- Returns:
- char[] a name.
- See Also:
-
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
preFieldNamesuf
and the prefix for field ispre
and the suffix for field issuf
then 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_SUFFIXES
for instance field andJavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
,JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
for 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
-true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names). Can benull
if there is no excluded names.- Returns:
- char[] a name.
- See Also:
-
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 ispre
and the suffix issuf
then the suggested names will beprenamesuf
,prename
,namesuf
andname
.
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_FIELD
andVK_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 isSimpleName
then 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 isSimpleName
then 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_FIELD
andVK_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 isTypeName
then the suggested names will betypeName
andname
.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 isTypeName
then the suggested name will beTYPE_NAME
andNAME
.
Each variable kind is affected by the following JavaCore options:
VK_PARAMETER
:JavaCore.CODEASSIST_ARGUMENT_PREFIXES
andJavaCore.CODEASSIST_ARGUMENT_SUFFIXES
VK_LOCAL
:JavaCore.CODEASSIST_LOCAL_PREFIXES
andJavaCore.CODEASSIST_LOCAL_SUFFIXES
VK_INSTANCE_FIELD
:JavaCore.CODEASSIST_FIELD_PREFIXES
andJavaCore.CODEASSIST_FIELD_SUFFIXES
VK_STATIC_FIELD
:JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
andJavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
VK_STATIC_FINAL_FIELD
:JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES
andJavaCore.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_FIELD
orVK_STATIC_FINAL_FIELD
.baseNameKind
- specifies what type the base name is:BK_NAME
orBK_TYPE_NAME
baseName
- name used to compute the suggested names.javaProject
- project which contains the variable ornull
to 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 benull
if 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:
-
getBaseName(int, String, IJavaProject)
instead withVK_PARAMETER
as variable kind.