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

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

Introduction

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

Prototype

public final int getNodeType() 

Source Link

Document

Returns an integer value identifying the type of this concrete AST node.

Usage

From source file:org.evolizer.changedistiller.jdt.ASTCommentVisitor.java

License:Apache License

/**
 * Uses some regex patterns to guess whether a comment is actually commented source code and - if this is the case -
 * removes it from the set of comments.//w  ww  . j  a v a 2  s  .c o m
 */
private void removeCommentedSourceCode() {
    Vector<Comment> cleanComments = new Vector<Comment>();
    for (Comment comment : fComments) {
        Matcher matcher = sPatternCatchAll.matcher(getCommentString(comment));

        if ((comment.getNodeType() == ASTNode.JAVADOC) || !matcher.matches()) { // Javadocs often contain source
            // code examples
            cleanComments.add(comment);
        }
    }
    fComments = cleanComments;
    fClean = true;
}

From source file:org.whole.lang.java.util.JDTCommentsMapper.java

License:Open Source License

protected boolean isLineComment(Comment comment) {
    return comment.getNodeType() == ASTNode.LINE_COMMENT || !containsNewLineChar(getText(comment));
}

From source file:org.whole.lang.java.util.JDTCommentsMapper.java

License:Open Source License

public String getText(Comment comment) {
    int start = comment.getStartPosition();
    switch (comment.getNodeType()) {
    case ASTNode.LINE_COMMENT:
        return sourceSubString(start + 2, start + comment.getLength());
    case ASTNode.BLOCK_COMMENT:
        return sourceSubString(start + 2, start + comment.getLength() - 2);
    case ASTNode.JAVADOC:
    default://from   w  w w .j  a va 2 s .  c o m
        return sourceSubString(start + 3, start + comment.getLength() - 2);
    }
}

From source file:parser.wrapper.NamedCompilationUnit.java

License:Open Source License

public List<Comment> getLineAndBlockComment() {
    if (this.compilationUnit != null) {
        @SuppressWarnings("unchecked")
        final List<Comment> comments = this.compilationUnit.getCommentList();
        if (comments != null) {
            final List<Comment> lineAndBlockComments = new ArrayList<Comment>();
            for (final Comment comment : comments) {
                if (comment.getNodeType() != ASTNode.JAVADOC) {
                    lineAndBlockComments.add(comment);
                }//from   ww  w  . j  a va  2  s . c om
            }
            return Collections.unmodifiableList(lineAndBlockComments);
        }
    }
    return null;
}