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

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

Introduction

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

Prototype

ASTNode.NodeList annotations

To view the source code for org.eclipse.jdt.core.dom PackageDeclaration annotations.

Click Source Link

Document

The annotations (element type: Annotation ).

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(PackageDeclaration node) {
    if (node.getAST().apiLevel() >= JLS3) {
        if (node.getJavadoc() != null) {
            node.getJavadoc().accept(this);
        }/*from   ww  w.j a v  a  2 s . c o m*/
        for (Iterator<Annotation> it = node.annotations().iterator(); it.hasNext();) {
            Annotation p = it.next();
            p.accept(this);
            this.fBuffer.append(" ");//$NON-NLS-1$
        }
    }
    this.fBuffer.append("package ");//$NON-NLS-1$
    node.getName().accept(this);
    this.fBuffer.append(";");//$NON-NLS-1$
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(CompilationUnit node) {
    //      b.setPosition(pos.build());
    PackageDeclaration pkg = node.getPackage();
    if (pkg == null) {
        b.setName("");
    } else {//from w ww.  j  av a2  s .  c  o  m
        b.setName(pkg.getName().getFullyQualifiedName());
        for (Object a : pkg.annotations()) {
            ((Annotation) a).accept(this);
            b.addModifiers(modifiers.pop());
        }
    }
    for (Object i : node.imports()) {
        ImportDeclaration id = (ImportDeclaration) i;
        String imp = "";
        if (id.isStatic())
            imp += "static ";
        imp += id.getName().getFullyQualifiedName();
        if (id.isOnDemand())
            imp += ".*";
        imports.add(imp);
    }
    for (Object t : node.types()) {
        declarations.push(new ArrayList<boa.types.Ast.Declaration>());
        ((AbstractTypeDeclaration) t).accept(this);
        for (boa.types.Ast.Declaration d : declarations.pop())
            b.addDeclarations(d);
    }
    for (Object c : node.getCommentList())
        ((org.eclipse.jdt.core.dom.Comment) c).accept(this);
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(PackageDeclaration node) {
    if (node.getAST().apiLevel() >= AST.JLS3) {
        if (node.getJavadoc() != null) {
            node.getJavadoc().accept(this);
        }/*from  w ww.  ja  va2 s. c o m*/
        for (Iterator it = node.annotations().iterator(); it.hasNext();) {
            Annotation p = (Annotation) it.next();
            p.accept(this);
            this.buffer.append(" ");//$NON-NLS-1$
        }
    }
    printIndent();
    this.buffer.append("package ");//$NON-NLS-1$
    node.getName().accept(this);
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.LineBreaksPreparator.java

License:Open Source License

@Override
public boolean visit(PackageDeclaration node) {
    int blanks = this.options.blank_lines_before_package;
    if (blanks > 0) {
        List<Annotation> annotations = node.annotations();
        int firstTokenIndex = annotations.isEmpty() ? this.tm.firstIndexBefore(node.getName(), TokenNamepackage)
                : this.tm.firstIndexIn(annotations.get(0), -1);
        this.tm.get(firstTokenIndex).putLineBreaksBefore(blanks + 1);
    }//from  w  ww  . j  a va2 s  . c om
    this.tm.lastTokenIn(node, TokenNameSEMICOLON)
            .putLineBreaksAfter(this.options.blank_lines_after_package + 1);
    this.declarationModifierVisited = false;
    return true;
}

From source file:com.google.devtools.j2objc.jdt.BindingConverter.java

License:Apache License

/**
 * JDT package bindings do not include annotations, so add them from the
 * package's AST node./*from ww w  . j  av a  2s  .  co m*/
 */
public static JdtPackageElement getPackageElement(PackageDeclaration pkg) {
    IPackageBinding binding = pkg.resolveBinding();
    JdtPackageElement pkgElement = (JdtPackageElement) getElement(binding);
    if (pkgElement.getAnnotationMirrors().isEmpty() && pkg.annotations().size() > 0) {
        for (Object modifier : pkg.annotations()) {
            IAnnotationBinding annotation = ((org.eclipse.jdt.core.dom.Annotation) modifier)
                    .resolveAnnotationBinding();
            pkgElement.addAnnotation(new JdtAnnotationMirror(annotation));
        }
    }
    return pkgElement;
}

From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java

License:Apache License

/** Visitor method for {@link PackageDeclaration}s. */
@Override//w  w  w .j  a v a  2 s .c  o  m
public boolean visit(PackageDeclaration node) {
    sync(node);
    visitAndBreakModifiers(node.annotations(), Direction.VERTICAL, Optional.<BreakTag>absent());
    builder.open(plusFour);
    token("package");
    builder.space();
    visitName(node.getName(), BreakOrNot.NO);
    builder.close();
    token(";");
    return false;
}

From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java

License:Open Source License

public boolean visit(PackageDeclaration node) {
    IValue name = values.string(node.getName().getFullyQualifiedName());

    IValueList annotations = new IValueList(values);
    if (node.getAST().apiLevel() >= AST.JLS3) {
        for (Iterator it = node.annotations().iterator(); it.hasNext();) {
            Annotation p = (Annotation) it.next();
            annotations.add(visitChild(p));
        }/*from ww w .  j  a  va  2  s.c  om*/
    }

    ownValue = constructRascalNode(node, name, annotations.asList());
    return false;
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

public boolean visit(PackageDeclaration node) {
    if (node.getAST().apiLevel() >= JLS3) {
        if (node.getJavadoc() != null) {
            node.getJavadoc().accept(this);
        }//w  ww . j  av  a2  s. c  o m
        for (Iterator it = node.annotations().iterator(); it.hasNext();) {
            Annotation p = (Annotation) it.next();
            p.accept(this);
            this.buffer.append(" ");//$NON-NLS-1$
        }
    }
    printIndent();
    this.buffer.append("package ");//$NON-NLS-1$
    node.getName().accept(this);
    this.buffer.append(";\n");//$NON-NLS-1$
    return false;
}

From source file:org.eclipse.emf.texo.generator.ImportReferenceCollector.java

License:Open Source License

@Override
public boolean visit(final PackageDeclaration node) {
    packageName = node.getName().getFullyQualifiedName();
    if (node.getAST().apiLevel() >= GeneratorUtils.getASTLevel()) {
        doVisitNode(node.getJavadoc());/*  w  w w  .  j  ava  2 s.  c  o  m*/
        doVisitChildren(node.annotations());
    }
    return false;
}

From source file:org.eclipse.emf.texo.generator.ImportReferencesCollector.java

License:Open Source License

@Override
public boolean visit(final PackageDeclaration node) {
    if (node.getAST().apiLevel() >= AST.JLS3) {
        doVisitNode(node.getJavadoc());/*from   ww  w  .  java 2s.  c o  m*/
        doVisitChildren(node.annotations());
    }
    return false;
}