public class CodeGeneration
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_BODY_TEMPLATE_ID
Constant ID for the type kind to be used in
getTypeBody(String, IJavaScriptUnit, String, String) to get the code template used
for a new class type body. |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getCompilationUnitContent(IJavaScriptUnit cu,
java.lang.String typeComment,
java.lang.String typeContent,
java.lang.String lineDelimiter)
Returns the content for a new compilation unit using the 'new JavaScript file' code template.
|
static java.lang.String |
getCompilationUnitContent(IJavaScriptUnit cu,
java.lang.String fileComment,
java.lang.String typeComment,
java.lang.String typeContent,
java.lang.String lineDelimiter)
Returns the content for a new compilation unit using the 'new JavaScript file' code template.
|
static java.lang.String |
getFieldComment(IJavaScriptUnit cu,
java.lang.String typeName,
java.lang.String fieldName,
java.lang.String lineDelimiter)
Returns the content for a new field comment using the 'field comment' code template.
|
static java.lang.String |
getFileComment(IJavaScriptUnit cu,
java.lang.String lineDelimiter)
Returns the content for a new file comment using the 'file comment' code template.
|
static java.lang.String |
getGetterComment(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
java.lang.String fieldName,
java.lang.String fieldType,
java.lang.String bareFieldName,
java.lang.String lineDelimiter)
Returns the comment for a getter method using the getter comment template.
|
static java.lang.String |
getGetterMethodBodyContent(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
java.lang.String fieldName,
java.lang.String lineDelimiter)
Returns the content of body for a getter method using the getter method body template.
|
static java.lang.String |
getMethodBodyContent(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
boolean isConstructor,
java.lang.String bodyStatement,
java.lang.String lineDelimiter)
Returns the content of the body for a method or constructor using the method body templates.
|
static java.lang.String |
getMethodComment(IFunction method,
IFunction overridden,
java.lang.String lineDelimiter)
Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
|
static java.lang.String |
getMethodComment(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
FunctionDeclaration decl,
boolean isDeprecated,
java.lang.String overriddenMethodName,
java.lang.String overriddenMethodDeclaringTypeName,
java.lang.String[] overriddenMethodParameterTypeNames,
java.lang.String lineDelimiter)
Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
|
static java.lang.String |
getMethodComment(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
FunctionDeclaration decl,
IFunctionBinding overridden,
java.lang.String lineDelimiter)
Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
|
static java.lang.String |
getMethodComment(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
java.lang.String[] paramNames,
java.lang.String[] excTypeSig,
java.lang.String retTypeSig,
IFunction overridden,
java.lang.String lineDelimiter)
Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
|
static java.lang.String |
getSetterComment(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
java.lang.String fieldName,
java.lang.String fieldType,
java.lang.String paramName,
java.lang.String bareFieldName,
java.lang.String lineDelimiter)
Returns the comment for a setter method using the setter method body template.
|
static java.lang.String |
getSetterMethodBodyContent(IJavaScriptUnit cu,
java.lang.String declaringTypeName,
java.lang.String methodName,
java.lang.String fieldName,
java.lang.String paramName,
java.lang.String lineDelimiter)
Returns the content of body for a setter method using the setter method body template.
|
static java.lang.String |
getTypeBody(java.lang.String typeKind,
IJavaScriptUnit cu,
java.lang.String typeName,
java.lang.String lineDelim)
Returns the content of a new new type body using the 'type body' code templates.
|
static java.lang.String |
getTypeComment(IJavaScriptUnit cu,
java.lang.String typeQualifiedName,
java.lang.String lineDelimiter)
Returns the content for a new type comment using the 'type comment' code template.
|
public static final java.lang.String CLASS_BODY_TEMPLATE_ID
getTypeBody(String, IJavaScriptUnit, String, String)
to get the code template used
for a new class type body.public static java.lang.String getCompilationUnitContent(IJavaScriptUnit cu, java.lang.String typeComment, java.lang.String typeContent, java.lang.String lineDelimiter) throws CoreException
cu
- The compilation unit to create the source for. The compilation unit does not need to exist.typeComment
- The comment for the type to be created. Used when the code template contains a ${typecomment} variable. Can be null
if
no comment should be added.typeContent
- The code of the type, including type declaration and body.lineDelimiter
- The line delimiter to be used.null
if the template is undefined or empty.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getCompilationUnitContent(IJavaScriptUnit cu, java.lang.String fileComment, java.lang.String typeComment, java.lang.String typeContent, java.lang.String lineDelimiter) throws CoreException
cu
- The compilation unit to create the source for. The compilation unit does not need to exist.fileComment
- The file comment to be used when the code template contains a ${filecomment} variable. Can be null
if
no comment should be added.typeComment
- The comment for the type to be created. Used when the code template contains a ${typecomment} variable. Can be null
if
no comment should be added.typeContent
- The code of the type, including type declaration and body.lineDelimiter
- The line delimiter to be used.null
if the template is undefined or empty.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getFileComment(IJavaScriptUnit cu, java.lang.String lineDelimiter) throws CoreException
cu
- The compilation unit to add the comment to. The compilation unit does not need to exist.lineDelimiter
- The line delimiter to be used.null
if the code template is undefined or empty. The returned content is unformatted and is not indented.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getTypeComment(IJavaScriptUnit cu, java.lang.String typeQualifiedName, java.lang.String lineDelimiter) throws CoreException
cu
- The compilation unit where the type is contained. The compilation unit does not need to exist.typeQualifiedName
- The name of the type to which the comment is added. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.lineDelimiter
- The line delimiter to be used.null
if the code template is undefined or empty. The returned content is unformatted and is not indented.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getTypeBody(java.lang.String typeKind, IJavaScriptUnit cu, java.lang.String typeName, java.lang.String lineDelim) throws CoreException
typeKind
- The type kind ID of the body template. Valid values are CLASS_BODY_TEMPLATE_ID
, #INTERFACE_BODY_TEMPLATE_ID
,
#ENUM_BODY_TEMPLATE_ID
and #ANNOTATION_BODY_TEMPLATE_ID
.cu
- The compilation unit where the type is contained. The compilation unit does not need to exist.typeName
- The name of the type(for embedding in the template as a user variable).lineDelim
- The line delimiter to be used.null
if the code template is undefined or empty. The returned content is unformatted and is not indented.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getFieldComment(IJavaScriptUnit cu, java.lang.String typeName, java.lang.String fieldName, java.lang.String lineDelimiter) throws CoreException
cu
- The compilation unit where the field is contained. The compilation unit does not need to exist.typeName
- The name of the field declared type.fieldName
- The name of the field to which the comment is added.lineDelimiter
- The line delimiter to be used.null
if the code template is undefined or empty. The returned content is unformatted and is not indented.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getMethodComment(IJavaScriptUnit cu, java.lang.String declaringTypeName, FunctionDeclaration decl, IFunctionBinding overridden, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.decl
- The FunctionDeclaration AST node that will be added as new
method. The node does not need to exist in an AST (no parent needed) and does not need to resolve.
See AST.newFunctionDeclaration()
for how to create such a node.overridden
- The binding of the method to which to add an "@see" link or
null
if no link should be created.lineDelimiter
- The line delimiter to be used.null
if the
code template is empty. The returned content is unformatted and not indented (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getMethodComment(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, java.lang.String[] paramNames, java.lang.String[] excTypeSig, java.lang.String retTypeSig, IFunction overridden, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
Exception types and return type are in signature notation. e.g. a source method declared as public void foo(String text, int length)
would return the array {"QString;","I"}
as parameter types. See Signature
.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- Name of the method.paramNames
- Names of the parameters for the method.excTypeSig
- Thrown exceptions (Signature notation).retTypeSig
- Return type (Signature notation) or null
for constructors.overridden
- The method that will be overridden by the created method or
null
for non-overriding methods. If not null
, the method must exist.lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned content is unformatted and not indented (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getMethodComment(IFunction method, IFunction overridden, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
method
- The method to be documented. The method must exist.overridden
- The method that will be overridden by the created method or
null
for non-overriding methods. If not null
, the method must exist.lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getMethodComment(IJavaScriptUnit cu, java.lang.String declaringTypeName, FunctionDeclaration decl, boolean isDeprecated, java.lang.String overriddenMethodName, java.lang.String overriddenMethodDeclaringTypeName, java.lang.String[] overriddenMethodParameterTypeNames, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.decl
- The FunctionDeclaration AST node that will be added as new
method. The node does not need to exist in an AST (no parent needed) and does not need to resolve.
See AST.newFunctionDeclaration()
for how to create such a node.isDeprecated
- If set, the method is deprecatedoverriddenMethodName
- If a method is overridden, the simple name of the overridden method, or null
if no method is overridden.overriddenMethodDeclaringTypeName
- If a method is overridden, the fully qualified type name of the overridden method's declaring type,
or null
if no method is overridden.overriddenMethodParameterTypeNames
- If a method is overridden, the fully qualified parameter type names of the overridden method,
or null
if no method is overridden.lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getMethodBodyContent(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, boolean isConstructor, java.lang.String bodyStatement, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- Name of the method.isConstructor
- Defines if the created body is for a constructor.bodyStatement
- The code to be entered at the place of the variable ${body_statement}.lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getGetterMethodBodyContent(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, java.lang.String fieldName, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- The name of the getter method.fieldName
- The name of the field to get in the getter method, corresponding to the template variable for ${field}.lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getSetterMethodBodyContent(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, java.lang.String fieldName, java.lang.String paramName, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- The name of the setter method.fieldName
- The name of the field to be set in the setter method, corresponding to the template variable for ${field}.paramName
- The name of the parameter passed to the setter method, corresponding to the template variable for $(param).lineDelimiter
- The line delimiter to be used.null
if
the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getGetterComment(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, java.lang.String fieldName, java.lang.String fieldType, java.lang.String bareFieldName, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- Name of the method.fieldName
- Name of the field to get.fieldType
- The type of the field to get.bareFieldName
- The field name without prefix or suffix.lineDelimiter
- The line delimiter to be used.null
if the
code template is empty. The returned content is not indented.CoreException
- Thrown when the evaluation of the code template fails.public static java.lang.String getSetterComment(IJavaScriptUnit cu, java.lang.String declaringTypeName, java.lang.String methodName, java.lang.String fieldName, java.lang.String fieldType, java.lang.String paramName, java.lang.String bareFieldName, java.lang.String lineDelimiter) throws CoreException
null
is returned if the template is empty.
The returned string is unformatted and not indented.
cu
- The compilation unit to which the method belongs. The compilation unit does not need to exist.declaringTypeName
- Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
types names (dot separated). See IType.getTypeQualifiedName(char)
.methodName
- Name of the method.fieldName
- Name of the field that is set.fieldType
- The type of the field that is to set.paramName
- The name of the parameter that used to set.bareFieldName
- The field name without prefix or suffix.lineDelimiter
- The line delimiter to be used.null
if the
code template is empty. The returned comment is not indented.CoreException
- Thrown when the evaluation of the code template fails.Copyright (c) IBM Corp. and others 2000, 2010. All Rights Reserved.