org.eclipse.wst.jsdt.core
Class NamingConventions

java.lang.Object
  extended by org.eclipse.wst.jsdt.core.NamingConventions

public final class NamingConventions
extends java.lang.Object

Provides methods for computing JavaScript-specific names.

The behavior of the methods is dependent of several JavaScriptCore options.

The possible options are :

For a complete description of the configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

This class provides static methods and constants only; it is not intended to be instantiated or subclassed by clients.

See Also:
JavaScriptCore.setOptions(java.util.Hashtable), Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Method Summary
static char[] removePrefixAndSuffixForArgumentName(IJavaScriptProject javaProject, char[] argumentName)
          Remove prefix and suffix from an argument name.
static java.lang.String removePrefixAndSuffixForArgumentName(IJavaScriptProject javaProject, java.lang.String argumentName)
          Remove prefix and suffix from an argument name.
static char[] removePrefixAndSuffixForFieldName(IJavaScriptProject javaProject, char[] fieldName, int modifiers)
          Remove prefix and suffix from a field name.
static java.lang.String removePrefixAndSuffixForFieldName(IJavaScriptProject javaProject, java.lang.String fieldName, int modifiers)
          Remove prefix and suffix from a field name.
static char[] removePrefixAndSuffixForLocalVariableName(IJavaScriptProject javaProject, char[] localName)
          Remove prefix and suffix from a local variable name.
static java.lang.String removePrefixAndSuffixForLocalVariableName(IJavaScriptProject javaProject, java.lang.String localName)
          Remove prefix and suffix from a local variable name.
static char[][] suggestArgumentNames(IJavaScriptProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
          Suggest names for an argument.
static java.lang.String[] suggestArgumentNames(IJavaScriptProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, java.lang.String[] excludedNames)
          Suggest names for an argument.
static char[][] suggestFieldNames(IJavaScriptProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames)
          Suggest names for a field.
static java.lang.String[] suggestFieldNames(IJavaScriptProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, int modifiers, java.lang.String[] excludedNames)
          Suggest names for a field.
static char[] suggestGetterName(IJavaScriptProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
          Suggest name for a getter method.
static java.lang.String suggestGetterName(IJavaScriptProject project, java.lang.String fieldName, int modifiers, boolean isBoolean, java.lang.String[] excludedNames)
          Suggest name for a getter method.
static char[][] suggestLocalVariableNames(IJavaScriptProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames)
          Suggest names for a local variable.
static java.lang.String[] suggestLocalVariableNames(IJavaScriptProject javaProject, java.lang.String packageName, java.lang.String qualifiedTypeName, int dim, java.lang.String[] excludedNames)
          Suggest names for a local variable.
static char[] suggestSetterName(IJavaScriptProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames)
          Suggest name for a setter method.
static java.lang.String suggestSetterName(IJavaScriptProject project, java.lang.String fieldName, int modifiers, boolean isBoolean, java.lang.String[] excludedNames)
          Suggest name for a setter method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removePrefixAndSuffixForArgumentName

public static char[] removePrefixAndSuffixForArgumentName(IJavaScriptProject javaProject,
                                                          char[] argumentName)
Remove prefix and suffix from an argument name.

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 JavaScriptCore options the result is the unchanged name preArgsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_ARGUMENT_PREFIXES and JavaScriptCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the argument.
argumentName - argument's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

removePrefixAndSuffixForArgumentName

public static java.lang.String removePrefixAndSuffixForArgumentName(IJavaScriptProject javaProject,
                                                                    java.lang.String argumentName)
Remove prefix and suffix from an argument name.

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 JavaScriptCore options the result is the unchanged name preArgsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_ARGUMENT_PREFIXES and JavaScriptCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the argument.
argumentName - argument's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

removePrefixAndSuffixForFieldName

public static char[] removePrefixAndSuffixForFieldName(IJavaScriptProject javaProject,
                                                       char[] fieldName,
                                                       int modifiers)
Remove prefix and suffix from a field name.

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 JavaScriptCore options the result is the unchanged name preFieldsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES } , JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the field.
fieldName - field's name.
modifiers - field's modifiers as defined by the class Flags.
Returns:
char[] the name without prefix and suffix.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

removePrefixAndSuffixForFieldName

public static java.lang.String removePrefixAndSuffixForFieldName(IJavaScriptProject javaProject,
                                                                 java.lang.String fieldName,
                                                                 int modifiers)
Remove prefix and suffix from a field name.

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 JavaScriptCore options the result is the unchanged name preFieldsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the field.
fieldName - field's name.
modifiers - field's modifiers as defined by the class Flags.
Returns:
char[] the name without prefix and suffix.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

removePrefixAndSuffixForLocalVariableName

public static char[] removePrefixAndSuffixForLocalVariableName(IJavaScriptProject javaProject,
                                                               char[] localName)
Remove prefix and suffix from a local variable name.

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 JavaScriptCore options the result is the unchanged name preLocalsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_LOCAL_PREFIXES and JavaScriptCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the variable.
localName - variable's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

removePrefixAndSuffixForLocalVariableName

public static java.lang.String removePrefixAndSuffixForLocalVariableName(IJavaScriptProject javaProject,
                                                                         java.lang.String localName)
Remove prefix and suffix from a local variable name.

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 JavaScriptCore options the result is the unchanged name preLocalsuf.

This method is affected by the following JavaScriptCore options : JavaScriptCore.CODEASSIST_LOCAL_PREFIXES and JavaScriptCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
javaProject - project which contains the variable.
localName - variable's name.
Returns:
char[] the name without prefix and suffix.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestArgumentNames

public static char[][] suggestArgumentNames(IJavaScriptProject javaProject,
                                            char[] packageName,
                                            char[] qualifiedTypeName,
                                            int dim,
                                            char[][] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_ARGUMENT_PREFIXES and JavaScriptCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestArgumentNames

public static java.lang.String[] suggestArgumentNames(IJavaScriptProject javaProject,
                                                      java.lang.String packageName,
                                                      java.lang.String qualifiedTypeName,
                                                      int dim,
                                                      java.lang.String[] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_ARGUMENT_PREFIXES and JavaScriptCore.CODEASSIST_ARGUMENT_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestFieldNames

public static char[][] suggestFieldNames(IJavaScriptProject javaProject,
                                         char[] packageName,
                                         char[] qualifiedTypeName,
                                         int dim,
                                         int modifiers,
                                         char[][] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES and for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 class Flags.
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestFieldNames

public static java.lang.String[] suggestFieldNames(IJavaScriptProject javaProject,
                                                   java.lang.String packageName,
                                                   java.lang.String qualifiedTypeName,
                                                   int dim,
                                                   int modifiers,
                                                   java.lang.String[] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES and for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 class Flags.
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestLocalVariableNames

public static char[][] suggestLocalVariableNames(IJavaScriptProject javaProject,
                                                 char[] packageName,
                                                 char[] qualifiedTypeName,
                                                 int dim,
                                                 char[][] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_LOCAL_PREFIXES and JavaScriptCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestLocalVariableNames

public static java.lang.String[] suggestLocalVariableNames(IJavaScriptProject javaProject,
                                                           java.lang.String packageName,
                                                           java.lang.String qualifiedTypeName,
                                                           int dim,
                                                           java.lang.String[] excludedNames)
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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_LOCAL_PREFIXES and JavaScriptCore.CODEASSIST_LOCAL_SUFFIXES.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#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 be null if there is no excluded names.
Returns:
char[][] an array of names.
See Also:
JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestGetterName

public static char[] suggestGetterName(IJavaScriptProject 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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
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 boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestGetterName

public static java.lang.String suggestGetterName(IJavaScriptProject project,
                                                 java.lang.String fieldName,
                                                 int modifiers,
                                                 boolean isBoolean,
                                                 java.lang.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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
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 boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestSetterName

public static char[] suggestSetterName(IJavaScriptProject 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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
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 boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()

suggestSetterName

public static java.lang.String suggestSetterName(IJavaScriptProject project,
                                                 java.lang.String fieldName,
                                                 int modifiers,
                                                 boolean isBoolean,
                                                 java.lang.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 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 JavaScriptCore options : JavaScriptCore.CODEASSIST_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_FIELD_SUFFIXES for instance field and JavaScriptCore.CODEASSIST_STATIC_FIELD_PREFIXES, JavaScriptCore.CODEASSIST_STATIC_FIELD_SUFFIXES for static field.

For a complete description of these configurable options, see getDefaultOptions. For programmaticaly change these options, see JavaScriptCore#setOptions().

Parameters:
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 boolean
excludedNames - a list of names which cannot be suggested (already used names). Can be null if there is no excluded names.
Returns:
char[] a name.
See Also:
Flags, JavaScriptCore.setOptions(java.util.Hashtable), JavaScriptCore.getDefaultOptions()