org.eclipse.wst.jsdt.core

## Class JavaScriptConventions

- java.lang.Object
- - org.eclipse.wst.jsdt.core.JavaScriptConventions

    public final class JavaScriptConventions
    extends java.lang.Object

Provides methods for checking JavaScript-specific conventions such as name syntax.

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

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

All Methods Static Methods Concrete Methods Deprecated Methods
`static IStatus` `validateClassFileName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)`
`static IJavaScriptModelStatus` `validateClasspath(IJavaScriptProject javaProject, IIncludePathEntry[] rawClasspath)` Validate a given includepath location for a project, using the following rules: Includepath entries cannot collide with each other; that is, all entry paths must be unique.

`static IJavaScriptModelStatus`

`validateClasspathEntry(IJavaScriptProject project, IIncludePathEntry entry, boolean checkSourceAttachment)`
Returns a JavaScript model status describing the problem related to this includepath entry if any, a status object with code `IStatus.OK` if the entry is fine (that is, if the given includepath entry denotes a valid element to be referenced onto a includepath).

`static IStatus` `validateCompilationUnitName(java.lang.String name)` Deprecated. Use `validateCompilationUnitName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateCompilationUnitName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given javaScript unit name for the given source and compliance levels.
`static IStatus` `validateFieldName(java.lang.String name)` Deprecated. Use `validateFieldName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateFieldName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given var or field name for the given source and compliance levels.
`static IStatus` `validateFunctionName(java.lang.String name)` Deprecated. Use `validateFunctionName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateFunctionName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given function name for the given source and compliance levels.
`static IStatus` `validateIdentifier(java.lang.String id)` Deprecated. Use `validateIdentifier(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateIdentifier(java.lang.String id, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given JavaScript identifier for the given source and compliance levels The identifier must not have the same spelling as a JavaScript keyword, boolean literal (`"true"`, `"false"`), or null literal (`"null"`).
`static IStatus` `validateImportDeclaration(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given import declaration name for the given source and compliance levels.
`static IStatus` `validateJavaScriptTypeName(java.lang.String name)` Deprecated. Use `validateJavaScriptTypeName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateJavaScriptTypeName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given JavaScript type name, either simple or qualified, for the given source and compliance levels.
`static IStatus` `validatePackageName(java.lang.String name)` Deprecated. Use `validatePackageName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validatePackageName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given package name for the given source and compliance levels.
`static IStatus` `validateTypeVariableName(java.lang.String name)` Deprecated. Use `validateTypeVariableName(String id, String sourceLevel, String complianceLevel)` instead
`static IStatus` `validateTypeVariableName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)` Validate the given type variable name for the given source and compliance levels.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### validateCompilationUnitName

    public static IStatus validateCompilationUnitName(java.lang.String name)

Deprecated. Use `validateCompilationUnitName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given javaScript unit name.

A javaScript unit name must obey the following rules:

- it must not be null
- it must be suffixed by a dot ('.') followed by one of the `JavaScript-like extensions`
- its prefix must be a valid identifier
- it must not contain any characters or substrings that are not valid on the file system on which workspace root is located.

Parameters:
  `name` - the name of a javaScript unit
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a javaScript unit name, otherwise a status object indicating what is wrong with the name

#### validateCompilationUnitName

    public static IStatus validateCompilationUnitName(java.lang.String name,
                                                      java.lang.String sourceLevel,
                                                      java.lang.String complianceLevel)

Validate the given javaScript unit name for the given source and compliance levels.

A javaScript unit name must obey the following rules:

- it must not be null
- it must be suffixed by a dot ('.') followed by one of the `JavaScript-like extensions`
- its prefix must be a valid identifier
- it must not contain any characters or substrings that are not valid on the file system on which workspace root is located.

Parameters:
  `name` - the name of a javaScript unit
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a javaScript unit name, otherwise a status object indicating what is wrong with the name

#### validateClassFileName

    public static IStatus validateClassFileName(java.lang.String name,
                                                java.lang.String sourceLevel,
                                                java.lang.String complianceLevel)

#### validateFieldName

    public static IStatus validateFieldName(java.lang.String name)

Deprecated. Use `validateFieldName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given var or field name.

Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3). For example, `"x"`.

Parameters:
  `name` - the name of a field
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a field name, otherwise a status object indicating what is wrong with the name

#### validateFieldName

    public static IStatus validateFieldName(java.lang.String name,
                                            java.lang.String sourceLevel,
                                            java.lang.String complianceLevel)

Validate the given var or field name for the given source and compliance levels.

Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3). For example, `"x"`.

Parameters:
  `name` - the name of a field
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a field name, otherwise a status object indicating what is wrong with the name

#### validateIdentifier

    public static IStatus validateIdentifier(java.lang.String id)

Deprecated. Use `validateIdentifier(String id, String sourceLevel, String complianceLevel)` instead
Validate the given JavaScript identifier. The identifier must not have the same spelling as a JavaScript keyword, boolean literal (`"true"`, `"false"`), or null literal (`"null"`). A valid identifier can act as a simple type name, method name or field name.

Parameters:
  `id` - the JavaScript identifier
Returns:
  a status object with code `IStatus.OK` if the given identifier is a valid JavaScript identifier, otherwise a status object indicating what is wrong with the identifier

#### validateIdentifier

    public static IStatus validateIdentifier(java.lang.String id,
                                             java.lang.String sourceLevel,
                                             java.lang.String complianceLevel)

Validate the given JavaScript identifier for the given source and compliance levels The identifier must not have the same spelling as a JavaScript keyword, boolean literal (`"true"`, `"false"`), or null literal (`"null"`). A valid identifier can act as a simple type name, method name or field name.

Parameters:
  `id` - the JavaScript identifier
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given identifier is a valid JavaScript identifier, otherwise a status object indicating what is wrong with the identifier

#### validateImportDeclaration

    public static IStatus validateImportDeclaration(java.lang.String name,
                                                    java.lang.String sourceLevel,
                                                    java.lang.String complianceLevel)

Validate the given import declaration name for the given source and compliance levels.

The name of an import corresponds to a fully qualified type name.

Note: This Method only applies to ECMAScript 4 which is not yet supported

Parameters:
  `name` - the import declaration
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as an import declaration, otherwise a status object indicating what is wrong with the name

#### validateJavaScriptTypeName

    public static IStatus validateJavaScriptTypeName(java.lang.String name)

Deprecated. Use `validateJavaScriptTypeName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given JavaScript type name, either simple or qualified.

Parameters:
  `name` - the name of a type
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a JavaScript type name, a status with code `IStatus.WARNING` indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name

#### validateJavaScriptTypeName

    public static IStatus validateJavaScriptTypeName(java.lang.String name,
                                                     java.lang.String sourceLevel,
                                                     java.lang.String complianceLevel)

Validate the given JavaScript type name, either simple or qualified, for the given source and compliance levels.

Parameters:
  `name` - the name of a type
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a JavaScript type name, a status with code `IStatus.WARNING` indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name

#### validateFunctionName

    public static IStatus validateFunctionName(java.lang.String name)

Deprecated. Use `validateFunctionName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given function name.

Parameters:
  `name` - the name of a method
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a method name, otherwise a status object indicating what is wrong with the name

#### validateFunctionName

    public static IStatus validateFunctionName(java.lang.String name,
                                               java.lang.String sourceLevel,
                                               java.lang.String complianceLevel)

Validate the given function name for the given source and compliance levels.

Parameters:
  `name` - the name of a method
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a method name, otherwise a status object indicating what is wrong with the name

#### validatePackageName

    public static IStatus validatePackageName(java.lang.String name)

Deprecated. Use `validatePackageName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given package name.

The syntax of a package name corresponds to PackageName as defined by PackageDeclaration.

Note that the given name must be a non-empty package name (that is, attempting to validate the default package will return an error status.) Also it must not contain any characters or substrings that are not valid on the file system on which workspace root is located.

Note: This Method only applies to ECMAScript 4 which is not yet supported

Parameters:
  `name` - the name of a package
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a package name, otherwise a status object indicating what is wrong with the name

#### validatePackageName

    public static IStatus validatePackageName(java.lang.String name,
                                              java.lang.String sourceLevel,
                                              java.lang.String complianceLevel)

Validate the given package name for the given source and compliance levels.

The syntax of a package name corresponds to PackageName as defined by PackageDeclaration.

Note that the given name must be a non-empty package name (that is, attempting to validate the default package will return an error status.) Also it must not contain any characters or substrings that are not valid on the file system on which workspace root is located.

Note: This Method only applies to ECMAScript 4 which is not yet supported

Parameters:
  `name` - the name of a package
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a package name, otherwise a status object indicating what is wrong with the name

#### validateClasspath

    public static IJavaScriptModelStatus validateClasspath(IJavaScriptProject javaProject,
                                                           IIncludePathEntry[] rawClasspath)

Validate a given includepath location for a project, using the following rules:

- Includepath entries cannot collide with each other; that is, all entry paths must be unique.
- A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
- Includepath entries cannot coincidate or be nested in each other, except for the following scenarii listed below:
- A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one.

Note that the includepath entries are not validated automatically. Only bound variables or containers are considered in the checking process (this allows to perform a consistency check on a includepath which has references to yet non existing projects, folders, ...).

This validation is intended to anticipate includepath issues prior to assigning it to a project. In particular, it will automatically be performed during the includepath setting operation (if validation fails, the includepath setting will not complete).

Parameters:
  `javaProject` - the given javaScript project
  `rawClasspath` - the given includepath
Returns:
  a status object with code `IStatus.OK` if the given includepath are compatible, otherwise a status object indicating what is wrong with the includepath

#### validateClasspathEntry

    public static IJavaScriptModelStatus validateClasspathEntry(IJavaScriptProject project,
                                                                IIncludePathEntry entry,
                                                                boolean checkSourceAttachment)

Returns a JavaScript model status describing the problem related to this includepath entry if any, a status object with code `IStatus.OK` if the entry is fine (that is, if the given includepath entry denotes a valid element to be referenced onto a includepath).

Parameters:
  `project` - the given javaScript project
  `entry` - the given includepath entry
  `checkSourceAttachment` - a flag to determine if source attachement should be checked
Returns:
  a javaScript model status describing the problem related to this includepath entry if any, a status object with code `IStatus.OK` if the entry is fine

#### validateTypeVariableName

    public static IStatus validateTypeVariableName(java.lang.String name)

Deprecated. Use `validateTypeVariableName(String id, String sourceLevel, String complianceLevel)` instead
Validate the given type variable name.

Note: This Method only applies to ECMAScript 4 which is not yet supported

Parameters:
  `name` - the name of a type variable
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a type variable name, otherwise a status object indicating what is wrong with the name

#### validateTypeVariableName

    public static IStatus validateTypeVariableName(java.lang.String name,
                                                   java.lang.String sourceLevel,
                                                   java.lang.String complianceLevel)

Validate the given type variable name for the given source and compliance levels.

Note: This Method only applies to ECMAScript 4 which is not yet supported

Parameters:
  `name` - the name of a type variable
  `sourceLevel` - the source level
  `complianceLevel` - the compliance level
Returns:
  a status object with code `IStatus.OK` if the given name is valid as a type variable name, otherwise a status object indicating what is wrong with the name