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

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

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom PackageDeclaration 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 PackageDeclaration convertPackage(
        org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration compilationUnitDeclaration) {
    org.eclipse.jdt.internal.compiler.ast.ImportReference importReference = compilationUnitDeclaration.currentPackage;
    final PackageDeclaration packageDeclaration = new PackageDeclaration(this.ast);
    final char[][] tokens = importReference.tokens;
    final int length = importReference.tokens.length;
    long[] positions = importReference.sourcePositions;
    if (length > 1) {
        packageDeclaration.setName(setQualifiedNameNameAndSourceRanges(tokens, positions, importReference));
    } else {/*w  ww  .  ja  va 2s.c  o  m*/
        final SimpleName name = new SimpleName(this.ast);
        name.internalSetIdentifier(new String(tokens[0]));
        int start = (int) (positions[0] >>> 32);
        int end = (int) (positions[length - 1] & 0xFFFFFFFF);
        name.setSourceRange(start, end - start + 1);
        name.index = 1;
        packageDeclaration.setName(name);
        if (this.resolveBindings) {
            recordNodes(name, compilationUnitDeclaration);
        }
    }
    packageDeclaration.setSourceRange(importReference.declarationSourceStart,
            importReference.declarationEnd - importReference.declarationSourceStart + 1);
    org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = importReference.annotations;
    if (annotations != null) {
        switch (this.ast.apiLevel) {
        case AST.JLS2_INTERNAL:
            packageDeclaration.setFlags(packageDeclaration.getFlags() & ASTNode.MALFORMED);
            break;
        default:
            for (int i = 0, max = annotations.length; i < max; i++) {
                packageDeclaration.annotations().add(convert(annotations[i]));
            }
        }
    }
    if (this.resolveBindings) {
        recordNodes(packageDeclaration, importReference);
    }
    // Set javadoc
    convert(compilationUnitDeclaration.javadoc, packageDeclaration);
    return packageDeclaration;
}