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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom ImportDeclaration 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 ImportDeclaration convertImport(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) {
    final ImportDeclaration importDeclaration = new ImportDeclaration(this.ast);
    final boolean onDemand = (importReference.bits
            & org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0;
    final char[][] tokens = importReference.tokens;
    int length = importReference.tokens.length;
    final long[] positions = importReference.sourcePositions;
    if (length > 1) {
        importDeclaration.setName(setQualifiedNameNameAndSourceRanges(tokens, positions, importReference));
    } else {/*from w  w w.  j  a v a2  s  .co  m*/
        final SimpleName name = new SimpleName(this.ast);
        name.internalSetIdentifier(new String(tokens[0]));
        final int start = (int) (positions[0] >>> 32);
        final int end = (int) (positions[0] & 0xFFFFFFFF);
        name.setSourceRange(start, end - start + 1);
        name.index = 1;
        importDeclaration.setName(name);
        if (this.resolveBindings) {
            recordNodes(name, importReference);
        }
    }
    importDeclaration.setSourceRange(importReference.declarationSourceStart,
            importReference.declarationEnd - importReference.declarationSourceStart + 1);
    importDeclaration.setOnDemand(onDemand);
    int modifiers = importReference.modifiers;
    if (modifiers != ClassFileConstants.AccDefault) {
        switch (this.ast.apiLevel) {
        case AST.JLS2_INTERNAL:
            importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED);
            break;
        default:
            if (modifiers == ClassFileConstants.AccStatic) {
                importDeclaration.setStatic(true);
            } else {
                importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED);
            }
        }
    }
    if (this.resolveBindings) {
        recordNodes(importDeclaration, importReference);
    }
    return importDeclaration;
}