public final class NamingConventions extends Object
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.
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
Modifier and Type | Field and Description |
---|---|
static int |
BK_NAME
The base name associated to this base name kind is a simple name.
|
static int |
BK_TYPE_NAME
The base name associated to this base name kind is a simple type name.
|
static int |
VK_INSTANCE_FIELD
Variable kind which represents an instance field.
|
static int |
VK_LOCAL
Variable kind which represents a local variable.
|
static int |
VK_PARAMETER
Variable kind which represents an argument.
|
static int |
VK_STATIC_FIELD
Variable kind which represents a static field.
|
static int |
VK_STATIC_FINAL_FIELD
Variable kind which represents a static final field.
|
Modifier and Type | Method and Description |
---|---|
static String |
getBaseName(int variableKind,
String variableName,
IJavaProject javaProject)
Returns a base name which could be used to generate the given variable name with
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) . |
static char[] |
removePrefixAndSuffixForArgumentName(IJavaProject javaProject,
char[] argumentName)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead with VK_PARAMETER as variable kind. |
static String |
removePrefixAndSuffixForArgumentName(IJavaProject javaProject,
String argumentName)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead with VK_PARAMETER as variable kind. |
static char[] |
removePrefixAndSuffixForFieldName(IJavaProject javaProject,
char[] fieldName,
int modifiers)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead
with VK_INSTANCE_FIELD or VK_STATIC_FIELD as variable kind. |
static String |
removePrefixAndSuffixForFieldName(IJavaProject javaProject,
String fieldName,
int modifiers)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead
with VK_INSTANCE_FIELD or VK_STATIC_FIELD as variable kind. |
static char[] |
removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject,
char[] localName)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead with VK_LOCAL as variable kind. |
static String |
removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject,
String localName)
Deprecated.
Use
getBaseName(int, String, IJavaProject) instead with VK_LOCAL as variable kind. |
static char[][] |
suggestArgumentNames(IJavaProject javaProject,
char[] packageName,
char[] qualifiedTypeName,
int dim,
char[][] excludedNames)
Deprecated.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead with VK_PARAMETER as variable kind. |
static String[] |
suggestArgumentNames(IJavaProject javaProject,
String packageName,
String qualifiedTypeName,
int dim,
String[] excludedNames)
Deprecated.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead with VK_PARAMETER as variable kind. |
static char[][] |
suggestFieldNames(IJavaProject javaProject,
char[] packageName,
char[] qualifiedTypeName,
int dim,
int modifiers,
char[][] excludedNames)
Deprecated.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead
with VK_INSTANCE_FIELD or VK_STATIC_FIELD as variable kind. |
static String[] |
suggestFieldNames(IJavaProject javaProject,
String packageName,
String qualifiedTypeName,
int dim,
int modifiers,
String[] excludedNames)
Deprecated.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead
with VK_INSTANCE_FIELD or VK_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.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead with VK_LOCAL as variable kind. |
static String[] |
suggestLocalVariableNames(IJavaProject javaProject,
String packageName,
String qualifiedTypeName,
int dim,
String[] excludedNames)
Deprecated.
Use
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean) instead with VK_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.
|
public static final int VK_STATIC_FIELD
public static final int VK_INSTANCE_FIELD
public static final int VK_STATIC_FINAL_FIELD
public static final int VK_PARAMETER
public static final int VK_LOCAL
public static final int BK_NAME
public static final int BK_TYPE_NAME
public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName)
getBaseName(int, String, IJavaProject)
instead with VK_PARAMETER
as variable kind.
If argument name prefix is pre
and argument name suffix is suf
then for an argument named preArgsuf
the result of this method is arg
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preArgsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES
and
JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
javaProject
- project which contains the argument.argumentName
- argument's name.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName)
getBaseName(int, String, IJavaProject)
instead with VK_PARAMETER
as variable kind.
If argument name prefix is pre
and argument name suffix is suf
then for an argument named preArgsuf
the result of this method is arg
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preArgsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES
and
JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
javaProject
- project which contains the argument.argumentName
- argument's name.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers)
getBaseName(int, String, IJavaProject)
instead
with VK_INSTANCE_FIELD
or VK_STATIC_FIELD
as variable kind.
If field name prefix is pre
and field name suffix is suf
then for a field named preFieldsuf
the result of this method is field
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preFieldsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
} ,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
javaProject
- project which contains the field.fieldName
- field's name.modifiers
- field's modifiers as defined by the class
Flags
.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers)
getBaseName(int, String, IJavaProject)
instead
with VK_INSTANCE_FIELD
or VK_STATIC_FIELD
as variable kind.
If field name prefix is pre
and field name suffix is suf
then for a field named preFieldsuf
the result of this method is field
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preFieldsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
javaProject
- project which contains the field.fieldName
- field's name.modifiers
- field's modifiers as defined by the class
Flags
.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName)
getBaseName(int, String, IJavaProject)
instead with VK_LOCAL
as variable kind.
If local variable name prefix is pre
and local variable name suffix is suf
then for a local variable named preLocalsuf
the result of this method is local
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preLocalsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES
and
JavaCore.CODEASSIST_LOCAL_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
javaProject
- project which contains the variable.localName
- variable's name.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName)
getBaseName(int, String, IJavaProject)
instead with VK_LOCAL
as variable kind.
If local variable name prefix is pre
and local variable name suffix is suf
then for a local variable named preLocalsuf
the result of this method is local
.
If there is no prefix or suffix defined in JavaCore options the result is the unchanged
name preLocalsuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES
and
JavaCore.CODEASSIST_LOCAL_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
javaProject
- project which contains the variable.localName
- variable's name.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String getBaseName(int variableKind, String variableName, IJavaProject javaProject)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
.
e.g.
If the variable is a VK_LOCAL
and the variable name is variableName
then the base name will be variableName
.
If the variable is a VK_STATIC_FINAL_FIELD
and the variable name is VARIABLE_NAME
then the base name will be variableName
.
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
and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
VK_LOCAL
: JavaCore.CODEASSIST_LOCAL_PREFIXES
and JavaCore.CODEASSIST_LOCAL_SUFFIXES
VK_INSTANCE_FIELD
: JavaCore.CODEASSIST_FIELD_PREFIXES
and JavaCore.CODEASSIST_FIELD_SUFFIXES
VK_STATIC_FIELD
: JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
and JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
VK_STATIC_FINAL_FIELD
: JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES
and JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES
e.g.
If the variable is a VK_LOCAL
, the variable name is preVariableNamesuf
, a possible prefix is pre
and a possible suffix is suf
then the base name will be variableName
.
variableKind
- specifies what type the variable is: VK_LOCAL
, VK_PARAMETER
, VK_STATIC_FIELD
,
VK_INSTANCE_FIELD
or VK_STATIC_FINAL_FIELD
.variableName
- a variable namejavaProject
- project which contains the variable or null
to take into account only workspace settings.suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead with VK_PARAMETER
as variable kind.
If the type of the argument is TypeName
, the prefix for argument is pre
and the suffix for argument is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES
and
JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
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 be null
if there is no excluded names.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead with VK_PARAMETER
as variable kind.
If the type of the argument is TypeName
, the prefix for argument is pre
and the suffix for argument is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_ARGUMENT_PREFIXES
and
JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
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 be null
if there is no excluded names.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead
with VK_INSTANCE_FIELD
or VK_STATIC_FIELD
as variable kind.
If the type of the field is TypeName
, the prefix for field is pre
and the suffix for field is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
and for instance field and JavaCore.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, see JavaCore#setOptions()
.
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 class
Flags
.excludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead
with VK_INSTANCE_FIELD
or VK_STATIC_FIELD
as variable kind.
If the type of the field is TypeName
, the prefix for field is pre
and the suffix for field is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
and for instance field and JavaCore.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, see JavaCore#setOptions()
.
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 class
Flags
.excludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
If the field name is preFieldNamesuf
and the prefix for field is pre
and
the suffix for field is suf
then the prosposed name is isFieldName
for boolean field or
getFieldName
for others. If there is no prefix and suffix the proposal is isPreFieldNamesuf
for boolean field or getPreFieldNamesuf
for others.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
project
- project which contains the field.fieldName
- field's name's.modifiers
- field's modifiers as defined by the class
Flags
.isBoolean
- true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String suggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)
If the field name is preFieldNamesuf
and the prefix for field is pre
and
the suffix for field is suf
then the prosposed name is isFieldName
for boolean field or
getFieldName
for others. If there is no prefix and suffix the proposal is isPreFieldNamesuf
for boolean field or getPreFieldNamesuf
for others.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
project
- project which contains the field.fieldName
- field's name's.modifiers
- field's modifiers as defined by the class
Flags
.isBoolean
- true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead with VK_LOCAL
as variable kind.
If the type of the local variable is TypeName
, the prefix for local variable is pre
and the suffix for local variable is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES
and
JavaCore.CODEASSIST_LOCAL_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
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 be null
if there is no excluded names.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames)
suggestVariableNames(int, int, String, IJavaProject, int, String[], boolean)
instead with VK_LOCAL
as variable kind.
If the type of the local variable is TypeName
, the prefix for local variable is pre
and the suffix for local variable is suf
then the proposed names are preTypeNamesuf
and preNamesuf
. If there is no prefix or suffix the proposals are typeName
and name
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_LOCAL_PREFIXES
and
JavaCore.CODEASSIST_LOCAL_SUFFIXES
.
For a complete description of these configurable options, see getDefaultOptions
.
For programmaticaly change these options, see JavaCore#setOptions()
.
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 be null
if there is no excluded names.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
If the field name is preFieldNamesuf
and the prefix for field is pre
and
the suffix for field is suf
then the proposed name is setFieldName
.
If there is no prefix and suffix the proposal is setPreFieldNamesuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
project
- project which contains the field.fieldName
- field's name's.modifiers
- field's modifiers as defined by the class
Flags
.isBoolean
- true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String suggestSetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames)
If the field name is preFieldNamesuf
and the prefix for field is pre
and
the suffix for field is suf
then the proposed name is setFieldName
.
If there is no prefix and suffix the proposal is setPreFieldNamesuf
.
This method is affected by the following JavaCore options : JavaCore.CODEASSIST_FIELD_PREFIXES
,
JavaCore.CODEASSIST_FIELD_SUFFIXES
for instance field and JavaCore.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, see JavaCore#setOptions()
.
project
- project which contains the field.fieldName
- field's name's.modifiers
- field's modifiers as defined by the class
Flags
.isBoolean
- true
if the field's type is booleanexcludedNames
- a list of names which cannot be suggested (already used names).
Can be null
if there is no excluded names.Flags
,
JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
public static String[] suggestVariableNames(int variableKind, int baseNameKind, String baseName, IJavaProject javaProject, int dim, String[] excluded, boolean evaluateDefault)
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 with VK_
.
When a prefix and a suffix can be added then all combinations of prefix and suffix are suggested.
If the name is name
, the prefix is pre
and the suffix is suf
then the suggested names will be
prenamesuf
, prename
, namesuf
and name
.
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.VK_PARAMETER
, VK_LOCAL
, VK_INSTANCE_FIELD
and VK_STATIC_FIELD
:SimpleName
then the suggested name will be simpleName
.VK_STATIC_FINAL_FIELD
:"_"
).SimpleName
then the suggested name will be SIMPLE_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.VK_PARAMETER
, VK_LOCAL
, VK_INSTANCE_FIELD
and VK_STATIC_FIELD
:TypeName
then the suggested names will be typeName
and name
.VK_STATIC_FINAL_FIELD
:"_"
).TypeName
then the suggested name will be TYPE_NAME
and NAME
.Each variable kind is affected by the following JavaCore options:
VK_PARAMETER
: JavaCore.CODEASSIST_ARGUMENT_PREFIXES
and JavaCore.CODEASSIST_ARGUMENT_SUFFIXES
VK_LOCAL
: JavaCore.CODEASSIST_LOCAL_PREFIXES
and JavaCore.CODEASSIST_LOCAL_SUFFIXES
VK_INSTANCE_FIELD
: JavaCore.CODEASSIST_FIELD_PREFIXES
and JavaCore.CODEASSIST_FIELD_SUFFIXES
VK_STATIC_FIELD
: JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES
and JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES
VK_STATIC_FINAL_FIELD
: JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES
and JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES
For a complete description of these configurable options, see JavaCore.getDefaultOptions()
.
To programmatically change these options, see JavaCore.setOptions(java.util.Hashtable)
and IJavaProject.setOptions(java.util.Map)
Proposed names are sorted by relevance (best proposal first).
The names are proposed in the following order:
variableKind
- specifies what type the variable is: VK_LOCAL
, VK_PARAMETER
, VK_STATIC_FIELD
,
VK_INSTANCE_FIELD
or VK_STATIC_FINAL_FIELD
.baseNameKind
- specifies what type the base name is: BK_NAME
or BK_TYPE_NAME
baseName
- name used to compute the suggested names.javaProject
- project which contains the variable or null
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 be null
if there are no excluded names.evaluateDefault
- if true
, the result is guaranteed to contain at least one result. If false
, the result can be an empty array.JavaCore.setOptions(java.util.Hashtable)
,
JavaCore.getDefaultOptions()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.