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

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

Introduction

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

Prototype

public Javadoc getJavadoc() 

Source Link

Document

Returns the doc comment node (added in JLS3 API).

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 www  .  j  av  a2s .co  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:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess2.java

License:Open Source License

private static Javadoc getPackageJavadocNode(IJavaElement element, String cuSource) {
    CompilationUnit cu = createAST(element, cuSource);
    if (cu != null) {
        PackageDeclaration packDecl = cu.getPackage();
        if (packDecl != null) {
            return packDecl.getJavadoc();
        }//from   www  .  j  a  v  a2 s .c o  m
    }
    return null;
}

From source file:br.uff.ic.gems.resources.ast.Visitor.java

public int beginLine(PackageDeclaration node) {
    int beginLine = cu.getLineNumber(node.getStartPosition());

    Javadoc javadoc = node.getJavadoc();
    int javadocBegin = INVALID_LINE;

    if (javadoc != null) {
        javadocBegin = cu.getLineNumber(javadoc.getStartPosition());
    }//  w  w w .  j  av  a  2 s  .c  o  m

    if (beginLine == javadocBegin) {
        beginLine = cu.getLineNumber(javadoc.getStartPosition() + javadoc.getLength() + 1);
    }

    return beginLine;
}

From source file:br.uff.ic.gems.resources.ast.Visitor.java

public int beginColunm(PackageDeclaration node) {
    int beginColumn = cu.getColumnNumber(node.getStartPosition());

    Javadoc javadoc = node.getJavadoc();
    int javadocBegin = INVALID_JAVADOC;

    if (javadoc != null) {
        javadocBegin = cu.getColumnNumber(javadoc.getStartPosition());
    }//from   w  w  w  . j a  va 2 s.co  m

    if (beginColumn == javadocBegin) {
        beginColumn = cu.getColumnNumber(javadoc.getStartPosition() + javadoc.getLength() + 1);
    }

    return beginColumn;
}

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);
        }/* w  w w .  j  av a  2 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.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);
        }//from  w ww.  j  a  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: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());
        doVisitChildren(node.annotations());
    }//from ww  w.  j  ava 2s .  c  o  m
    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());
        doVisitChildren(node.annotations());
    }/*from w ww.  ja  v  a 2 s  .co m*/
    return false;
}

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

License:Open Source License

public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc,
        PackageDeclaration packageDeclaration) {
    switch (this.ast.apiLevel) {
    case AST.JLS2_INTERNAL:
        return;/*from   w w w  .  j a  va2 s  .c om*/
    }
    if (packageDeclaration.getJavadoc() == null) {
        if (javadoc != null) {
            if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
                this.commentMapper = new DefaultCommentMapper(this.commentsTable);
            }
            Comment comment = this.commentMapper.getComment(javadoc.sourceStart);
            if (comment != null && comment.isDocComment() && comment.getParent() == null) {
                Javadoc docComment = (Javadoc) comment;
                if (this.resolveBindings) {
                    recordNodes(docComment, javadoc);
                    // resolve member and method references binding
                    Iterator tags = docComment.tags().listIterator();
                    while (tags.hasNext()) {
                        recordNodes(javadoc, (TagElement) tags.next());
                    }
                }
                packageDeclaration.setJavadoc(docComment);
            }
        }
    }
}

From source file:org.eclipse.jdt.internal.core.CopyResourceElementsOperation.java

License:Open Source License

private void updatePackageStatement(CompilationUnit astCU, String[] pkgName, ASTRewrite rewriter,
        ICompilationUnit cu) throws JavaModelException {
    boolean defaultPackage = pkgName.length == 0;
    AST ast = astCU.getAST();/*from ww w .j  a  va  2s  .c  om*/
    if (defaultPackage) {
        // remove existing package statement
        PackageDeclaration pkg = astCU.getPackage();
        if (pkg != null) {
            int pkgStart;
            Javadoc javadoc = pkg.getJavadoc();
            if (javadoc != null) {
                pkgStart = javadoc.getStartPosition() + javadoc.getLength() + 1;
            } else {
                pkgStart = pkg.getStartPosition();
            }
            int extendedStart = astCU.getExtendedStartPosition(pkg);
            if (pkgStart != extendedStart) {
                // keep the comments associated with package declaration
                // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=247757
                String commentSource = cu.getSource().substring(extendedStart, pkgStart);
                ASTNode comment = rewriter.createStringPlaceholder(commentSource, ASTNode.PACKAGE_DECLARATION);
                rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, comment, null);
            } else {
                rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, null, null);
            }
        }
    } else {
        org.eclipse.jdt.core.dom.PackageDeclaration pkg = astCU.getPackage();
        if (pkg != null) {
            // rename package statement
            Name name = ast.newName(pkgName);
            rewriter.set(pkg, PackageDeclaration.NAME_PROPERTY, name, null);
        } else {
            // create new package statement
            pkg = ast.newPackageDeclaration();
            pkg.setName(ast.newName(pkgName));
            rewriter.set(astCU, CompilationUnit.PACKAGE_PROPERTY, pkg, null);
        }
    }
}