public class CConventions extends Object
Constructor and Description |
---|
CConventions() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isLegalIdentifier(String name) |
static boolean |
isValidIdentifier(String name) |
static org.eclipse.core.runtime.IStatus |
validateClassName(String name)
Validate the given CPP class name, either simple or qualified.
|
static org.eclipse.core.runtime.IStatus |
validateEnumName(String name)
Validate the given C++ enum name, either simple or qualified.
|
static org.eclipse.core.runtime.IStatus |
validateFieldName(String name)
Validate the given field name.
|
static org.eclipse.core.runtime.IStatus |
validateFileName(String name)
Validate the given file name.
|
static org.eclipse.core.runtime.IStatus |
validateHeaderFileName(org.eclipse.core.resources.IProject project,
String name)
Validate the given header file name.
|
static org.eclipse.core.runtime.IStatus |
validateIdentifier(String id)
Deprecated.
Notice that the identifier is not being checked against language keywords.
Use validateIdentifier(String id, AbstractCLikeLanguage language) instead.
|
static org.eclipse.core.runtime.IStatus |
validateIdentifier(String id,
AbstractCLikeLanguage language)
Validate the given C or C++ identifier.
|
static org.eclipse.core.runtime.IStatus |
validateIncludeName(org.eclipse.core.resources.IProject project,
String name)
Validate the given include name.
|
static org.eclipse.core.runtime.IStatus |
validateMethodName(String name)
Validate the given method name.
|
static org.eclipse.core.runtime.IStatus |
validateNamespaceName(String name)
Validate the given CPP namespace name, either simple or qualified.
|
static org.eclipse.core.runtime.IStatus |
validateScopeName(String name)
Validate the given scope name.
|
static org.eclipse.core.runtime.IStatus |
validateSourceFileName(org.eclipse.core.resources.IProject project,
String name)
Validate the given source file name.
|
public static boolean isLegalIdentifier(String name)
public static org.eclipse.core.runtime.IStatus validateClassName(String name)
"A::B::C"
, or "C"
.
name
- the name of a classIStatus.OK
if
the given name is valid as a CPP class 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 org.eclipse.core.runtime.IStatus validateNamespaceName(String name)
"A::B::C"
, or "C"
.
name
- the name of a namespaceIStatus.OK
if
the given name is valid as a CPP class 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 org.eclipse.core.runtime.IStatus validateScopeName(String name)
IStatus.OK
if
the given name is valid as a class name, otherwise a status
object indicating what is wrong with the namepublic static org.eclipse.core.runtime.IStatus validateFieldName(String name)
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 name@Deprecated public static org.eclipse.core.runtime.IStatus validateIdentifier(String id)
id
- the C identifierIStatus.OK
if
the given identifier is a valid C identifier, otherwise a status
object indicating what is wrong with the identifierpublic static org.eclipse.core.runtime.IStatus validateIdentifier(String id, AbstractCLikeLanguage language)
id
- the C identifierIStatus.OK
if
the given identifier is a valid C identifier, otherwise a status
object indicating what is wrong with the identifierpublic static org.eclipse.core.runtime.IStatus validateMethodName(String name)
The syntax for a method name is defined by Identifier of MethodDeclarator (JLS2 8.4). For example "println".
name
- 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 org.eclipse.core.runtime.IStatus validateIncludeName(org.eclipse.core.resources.IProject project, String name)
The name of an include without the surrounding double quotes or brackets
For example, stdio.h
or iostream
.
name
- the include declarationIStatus.OK
if
the given name is valid as an include name, otherwise a status
object indicating what is wrong with the namepublic static boolean isValidIdentifier(String name)
public static org.eclipse.core.runtime.IStatus validateFileName(String name)
name
- the file nameIStatus.OK
if
the given name is valid as a C/C++ file 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 org.eclipse.core.runtime.IStatus validateHeaderFileName(org.eclipse.core.resources.IProject project, String name)
name
- the header file nameIStatus.OK
if
the given name is valid as a C/C++ header file 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 org.eclipse.core.runtime.IStatus validateSourceFileName(org.eclipse.core.resources.IProject project, String name)
name
- the source file nameIStatus.OK
if
the given name is valid as a C/C++ source file 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 org.eclipse.core.runtime.IStatus validateEnumName(String name)
"A::B::C"
, or "C"
.
name
- the name of a enumIStatus.OK
if
the given name is valid as a CPP enum name,
a status with code IStatus.WARNING
indicating why the given name is discouraged,
otherwise a status object indicating what is wrong with
the nameCopyright (c) IBM Corp. and others 2004, 2020. All Rights Reserved.