public final class JavaScriptConventions
extends java.lang.Object
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.Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
public static IStatus validateCompilationUnitName(java.lang.String name)
validateCompilationUnitName(String id, String sourceLevel, String complianceLevel)
insteadA javaScript unit name must obey the following rules:
JavaScript-like extensions
name
- the name of a javaScript unitIStatus.OK
if
the given name is valid as a javaScript unit name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateCompilationUnitName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
A javaScript unit name must obey the following rules:
JavaScript-like extensions
name
- the name of a javaScript unitsourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as a javaScript unit name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateClassFileName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
public static IStatus validateFieldName(java.lang.String name)
validateFieldName(String id, String sourceLevel, String complianceLevel)
instead
Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
For example, "x"
.
name
- the name of a fieldIStatus.OK
if
the given name is valid as a field name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateFieldName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
For example, "x"
.
name
- the name of a fieldsourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as a field name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateIdentifier(java.lang.String id)
validateIdentifier(String id, String sourceLevel, String complianceLevel)
instead"true"
, "false"
), or null literal ("null"
).
A valid identifier can act as a simple type name, method name or field name.id
- the JavaScript identifierIStatus.OK
if
the given identifier is a valid JavaScript identifier, otherwise a status
object indicating what is wrong with the identifierpublic static IStatus validateIdentifier(java.lang.String id, java.lang.String sourceLevel, java.lang.String complianceLevel)
"true"
, "false"
), or null literal ("null"
).
A valid identifier can act as a simple type name, method name or field name.id
- the JavaScript identifiersourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given identifier is a valid JavaScript identifier, otherwise a status
object indicating what is wrong with the identifierpublic static IStatus validateImportDeclaration(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
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
name
- the import declarationsourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as an import declaration, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateJavaScriptTypeName(java.lang.String name)
validateJavaScriptTypeName(String id, String sourceLevel, String complianceLevel)
insteadname
- the name of a typeIStatus.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 namepublic static IStatus validateJavaScriptTypeName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
name
- the name of a typesourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.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 namepublic static IStatus validateFunctionName(java.lang.String name)
validateFunctionName(String id, String sourceLevel, String complianceLevel)
insteadname
- the name of a methodIStatus.OK
if
the given name is valid as a method name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateFunctionName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
name
- the name of a methodsourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as a method name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validatePackageName(java.lang.String name)
validatePackageName(String id, String sourceLevel, String complianceLevel)
insteadThe 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
name
- the name of a packageIStatus.OK
if
the given name is valid as a package name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validatePackageName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
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
name
- the name of a packagesourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as a package name, otherwise a status
object indicating what is wrong with the namepublic static IJavaScriptModelStatus validateClasspath(IJavaScriptProject javaProject, IIncludePathEntry[] rawClasspath)
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).
javaProject
- the given javaScript projectrawClasspath
- the given includepathIStatus.OK
if
the given includepath are compatible, otherwise a status
object indicating what is wrong with the includepathpublic static IJavaScriptModelStatus validateClasspathEntry(IJavaScriptProject project, IIncludePathEntry entry, boolean checkSourceAttachment)
IStatus.OK
if the entry is fine (that is, if the
given includepath entry denotes a valid element to be referenced onto a includepath).project
- the given javaScript projectentry
- the given includepath entrycheckSourceAttachment
- a flag to determine if source attachement should be checkedIStatus.OK
if the entry is finepublic static IStatus validateTypeVariableName(java.lang.String name)
validateTypeVariableName(String id, String sourceLevel, String complianceLevel)
instead
Note: This Method only applies to ECMAScript 4 which is not yet supported
name
- the name of a type variableIStatus.OK
if
the given name is valid as a type variable name, otherwise a status
object indicating what is wrong with the namepublic static IStatus validateTypeVariableName(java.lang.String name, java.lang.String sourceLevel, java.lang.String complianceLevel)
Note: This Method only applies to ECMAScript 4 which is not yet supported
name
- the name of a type variablesourceLevel
- the source levelcomplianceLevel
- the compliance levelIStatus.OK
if
the given name is valid as a type variable name, otherwise a status
object indicating what is wrong with the nameCopyright (c) IBM Corp. and others 2000, 2016. All Rights Reserved.