Example usage for org.eclipse.jdt.core.dom SuperConstructorInvocation setFlags

List of usage examples for org.eclipse.jdt.core.dom SuperConstructorInvocation setFlags

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom SuperConstructorInvocation setFlags.

Prototype

public final void setFlags(int flags) 

Source Link

Document

Sets the flags associated with this node to the given value.

Usage

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

public Statement convert(org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall statement) {
    Statement newStatement;/*w w  w  .  j a v  a 2  s. com*/
    int sourceStart = statement.sourceStart;
    if (statement.isSuperAccess() || statement.isSuper()) {
        SuperConstructorInvocation superConstructorInvocation = new SuperConstructorInvocation(this.ast);
        if (statement.qualification != null) {
            superConstructorInvocation.setExpression(convert(statement.qualification));
        }
        org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
        if (arguments != null) {
            int length = arguments.length;
            for (int i = 0; i < length; i++) {
                superConstructorInvocation.arguments().add(convert(arguments[i]));
            }
        }
        if (statement.typeArguments != null) {
            if (sourceStart > statement.typeArgumentsSourceStart) {
                sourceStart = statement.typeArgumentsSourceStart;
            }
            switch (this.ast.apiLevel) {
            case AST.JLS2_INTERNAL:
                superConstructorInvocation.setFlags(superConstructorInvocation.getFlags() | ASTNode.MALFORMED);
                break;
            default:
                for (int i = 0, max = statement.typeArguments.length; i < max; i++) {
                    superConstructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
                }
                break;
            }
        }
        newStatement = superConstructorInvocation;
    } else {
        ConstructorInvocation constructorInvocation = new ConstructorInvocation(this.ast);
        org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = statement.arguments;
        if (arguments != null) {
            int length = arguments.length;
            for (int i = 0; i < length; i++) {
                constructorInvocation.arguments().add(convert(arguments[i]));
            }
        }
        if (statement.typeArguments != null) {
            if (sourceStart > statement.typeArgumentsSourceStart) {
                sourceStart = statement.typeArgumentsSourceStart;
            }
            switch (this.ast.apiLevel) {
            case AST.JLS2_INTERNAL:
                constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
                break;
            default:
                for (int i = 0, max = statement.typeArguments.length; i < max; i++) {
                    constructorInvocation.typeArguments().add(convertType(statement.typeArguments[i]));
                }
                break;
            }
        }
        if (statement.qualification != null) {
            // this is an error
            constructorInvocation.setFlags(constructorInvocation.getFlags() | ASTNode.MALFORMED);
        }
        newStatement = constructorInvocation;
    }
    newStatement.setSourceRange(sourceStart, statement.sourceEnd - sourceStart + 1);
    if (this.resolveBindings) {
        recordNodes(newStatement, statement);
    }
    return newStatement;
}