net.sourceforge.pmd.lang.java.ast.ASTBlock Maven / Gradle / Ivy
The newest version!
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.java.ast.ASTList.ASTMaybeEmptyListOf;
/**
* A block of code. This is a {@linkplain ASTStatement statement} that
* contains other statements.
*
*
*
* Block ::= "{" {@link ASTStatement Statement}* "}"
*
*
*/
public final class ASTBlock extends ASTMaybeEmptyListOf
implements ASTSwitchArrowRHS, ASTStatement {
ASTBlock(int id) {
super(id, ASTStatement.class);
}
@Override
public R acceptVisitor(JavaVisitor super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
public boolean containsComment() {
JavaccToken t = getLastToken().getPreviousComment();
while (t != null) {
if (JavaComment.isComment(t)) {
return true;
}
t = t.getPreviousComment();
}
return false;
}
}