Example usage for org.eclipse.jdt.core.dom Comment getParent

List of usage examples for org.eclipse.jdt.core.dom Comment getParent

Introduction

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

Prototype

public final ASTNode getParent() 

Source Link

Document

Returns this node's parent node, or null if this is the root node.

Usage

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, BodyDeclaration bodyDeclaration) {
    if (bodyDeclaration.getJavadoc() == null) {
        if (javadoc != null) {
            if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) {
                this.commentMapper = new DefaultCommentMapper(this.commentsTable);
            }//  w ww .  j  a v  a  2 s .  c  o  m
            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());
                    }
                }
                bodyDeclaration.setJavadoc(docComment);
            }
        }
    }
}

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. ja v a 2 s.  co  m
    }
    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.xtend.core.javaconverter.JavaASTFlattener.java

License:Open Source License

private Iterable<Comment> unAssignedComments(final CompilationUnit cu) {
    final Function1<Comment, Boolean> _function = (Comment c) -> {
        return Boolean.valueOf(((!(c.isDocComment() && (c.getParent() != null))) && this.notAssigned(c)));
    };//  w  w  w  .  j a v  a 2s .  co m
    return IterableExtensions.<Comment>filter(cu.getCommentList(), _function);
}

From source file:org.rascalmpl.library.lang.java.m3.internal.EclipseJavaCompiler.java

License:Open Source License

protected IValue convertToM3(TypeStore store, Map<String, ISourceLocation> cache, ISourceLocation loc,
        CompilationUnit cu) {//  ww  w  . java  2s . c om
    SourceConverter converter = new SourceConverter(store, cache);
    converter.convert(cu, cu, loc);
    for (Object cm : cu.getCommentList()) {
        Comment comment = (Comment) cm;
        // Issue 720: changed condition to only visit comments without a parent (includes line, block and misplaced javadoc comments).
        if (comment.getParent() != null)
            continue;
        converter.convert(cu, comment, loc);
    }
    return converter.getModel(true);
}