org.eclipse.cdt.core
Class CConventions

java.lang.Object
  extended by org.eclipse.cdt.core.CConventions

public class CConventions
extends java.lang.Object

Author:
hamer

Constructor Summary
CConventions()
           
 
Method Summary
static boolean isLegalIdentifier(java.lang.String name)
           
static boolean isValidIdentifier(java.lang.String name)
           
static org.eclipse.core.runtime.IStatus validateClassName(java.lang.String name)
          Validate the given CPP class name, either simple or qualified.
static org.eclipse.core.runtime.IStatus validateEnumName(java.lang.String name)
          Validate the given CPP enum name, either simple or qualified.
static org.eclipse.core.runtime.IStatus validateFieldName(java.lang.String name)
          Validate the given field name.
static org.eclipse.core.runtime.IStatus validateFileName(java.lang.String name)
          Validate the given file name.
static org.eclipse.core.runtime.IStatus validateHeaderFileName(org.eclipse.core.resources.IProject project, java.lang.String name)
          Validate the given header file name.
static org.eclipse.core.runtime.IStatus validateIdentifier(java.lang.String id)
          Validate the given C identifier.
static org.eclipse.core.runtime.IStatus validateIncludeName(org.eclipse.core.resources.IProject project, java.lang.String name)
          Validate the given include name.
static org.eclipse.core.runtime.IStatus validateMethodName(java.lang.String name)
          Validate the given method name.
static org.eclipse.core.runtime.IStatus validateNamespaceName(java.lang.String name)
          Validate the given CPP namespace name, either simple or qualified.
static org.eclipse.core.runtime.IStatus validateScopeName(java.lang.String name)
          Validate the given scope name.
static org.eclipse.core.runtime.IStatus validateSourceFileName(org.eclipse.core.resources.IProject project, java.lang.String name)
          Validate the given source file name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CConventions

public CConventions()
Method Detail

isLegalIdentifier

public static boolean isLegalIdentifier(java.lang.String name)

validateClassName

public static org.eclipse.core.runtime.IStatus validateClassName(java.lang.String name)
Validate the given CPP class name, either simple or qualified. For example, "A::B::C", or "C".

Parameters:
name - the name of a class
Returns:
a status object with code IStatus.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 name

validateNamespaceName

public static org.eclipse.core.runtime.IStatus validateNamespaceName(java.lang.String name)
Validate the given CPP namespace name, either simple or qualified. For example, "A::B::C", or "C".

Parameters:
name - the name of a namespace
Returns:
a status object with code IStatus.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 name

validateScopeName

public static org.eclipse.core.runtime.IStatus validateScopeName(java.lang.String name)
Validate the given scope name.

Returns:
a status object with code IStatus.OK if the given name is valid as a class name, otherwise a status object indicating what is wrong with the name

validateFieldName

public static org.eclipse.core.runtime.IStatus validateFieldName(java.lang.String name)
Validate the given 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

validateIdentifier

public static org.eclipse.core.runtime.IStatus validateIdentifier(java.lang.String id)
Validate the given C identifier. The identifier must not have the same spelling as a C keyword, boolean literal ("true", "false"), or null literal ("null"). See section 3.8 of the C Language Specification, Second Edition (JLS2). A valid identifier can act as a simple type name, method name or field name.

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

validateMethodName

public static org.eclipse.core.runtime.IStatus validateMethodName(java.lang.String name)
Validate the given method name. The special names "<init>" and "<clinit>" are not valid.

The syntax for a method name is defined by Identifier of MethodDeclarator (JLS2 8.4). For example "println".

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

validateIncludeName

public static org.eclipse.core.runtime.IStatus validateIncludeName(org.eclipse.core.resources.IProject project,
                                                                   java.lang.String name)
Validate the given include name.

The name of an include without the surroounding double quotes or brakets For example, stdio.h or iostream.

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

isValidIdentifier

public static boolean isValidIdentifier(java.lang.String name)

validateFileName

public static org.eclipse.core.runtime.IStatus validateFileName(java.lang.String name)
Validate the given file name. The name must be the short file name (including the extension). It should not contain any prefix or path delimiters.

Parameters:
name - the file name
Returns:
a status object with code IStatus.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 name

validateHeaderFileName

public static org.eclipse.core.runtime.IStatus validateHeaderFileName(org.eclipse.core.resources.IProject project,
                                                                      java.lang.String name)
Validate the given header file name. The name must be the short file name (including the extension). It should not contain any prefix or path delimiters.

Parameters:
name - the header file name
Returns:
a status object with code IStatus.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 name

validateSourceFileName

public static org.eclipse.core.runtime.IStatus validateSourceFileName(org.eclipse.core.resources.IProject project,
                                                                      java.lang.String name)
Validate the given source file name. The name must be the short file name (including the extension). It should not contain any prefix or path delimiters.

Parameters:
name - the source file name
Returns:
a status object with code IStatus.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 name

validateEnumName

public static org.eclipse.core.runtime.IStatus validateEnumName(java.lang.String name)
Validate the given CPP enum name, either simple or qualified. For example, "A::B::C", or "C".

Parameters:
name - the name of a enum
Returns:
a status object with code IStatus.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 name
Since:
4.0