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

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

Introduction

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

Prototype

public final Object getProperty(String propertyName) 

Source Link

Document

Returns the value of the named property of this node, or null if none.

Usage

From source file:org.eclipse.wb.internal.core.utils.ast.AstEditor.java

License:Open Source License

/**
 * @return the {@link List} of {@link Comment}'s in this {@link CompilationUnit}.
 *///  ww  w  .  j  a  v a  2 s.c  om
public List<Comment> getCommentList() throws Exception {
    List<Comment> comments = Lists.newArrayList();
    comments.addAll(DomGenerics.getCommentList(m_astUnit));
    // clean up
    int documentLength = m_document.getLength();
    for (Iterator<Comment> I = comments.iterator(); I.hasNext();) {
        Comment comment = I.next();
        if (comment.getProperty(REMOVED_COMMENT) != null) {
            I.remove();
            continue;
        }
        if (AstNodeUtils.getSourceBegin(comment) < 0 || AstNodeUtils.getSourceEnd(comment) > documentLength) {
            I.remove();
        } else if (comment instanceof LineComment) {
            if (!getSource(comment).startsWith("//")) {
                I.remove();
            }
        } else if (comment instanceof BlockComment) {
            if (!getSource(comment).startsWith("/*")) {
                I.remove();
            }
        }
    }
    // protect from modifications
    return Collections.unmodifiableList(comments);
}