use of org.eclipse.jdt.internal.compiler.ast.Initializer in project che by eclipse.
the class SourceTypeConverter method convert.
/*
* Convert an initializerinfo into a parsed initializer declaration
*/
private Initializer convert(InitializerElementInfo initializerInfo, CompilationResult compilationResult) throws JavaModelException {
Block block = new Block(0);
Initializer initializer = new Initializer(block, ClassFileConstants.AccDefault);
int start = initializerInfo.getDeclarationSourceStart();
int end = initializerInfo.getDeclarationSourceEnd();
initializer.sourceStart = initializer.declarationSourceStart = start;
initializer.sourceEnd = initializer.declarationSourceEnd = end;
initializer.modifiers = initializerInfo.getModifiers();
/* convert local and anonymous types */
IJavaElement[] children = initializerInfo.getChildren();
int typesLength = children.length;
if (typesLength > 0) {
Statement[] statements = new Statement[typesLength];
for (int i = 0; i < typesLength; i++) {
SourceType type = (SourceType) children[i];
TypeDeclaration localType = convert(type, compilationResult);
if ((localType.bits & ASTNode.IsAnonymousType) != 0) {
QualifiedAllocationExpression expression = new QualifiedAllocationExpression(localType);
expression.type = localType.superclass;
localType.superclass = null;
localType.superInterfaces = null;
localType.allocation = expression;
statements[i] = expression;
} else {
statements[i] = localType;
}
}
block.statements = statements;
}
return initializer;
}
Aggregations