use of net.sourceforge.pmd.lang.java.ast.ASTAssertStatement in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTExpression node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
String loggerTag = "parent";
Node parent = node.jjtGetParent();
// TODO what about throw stmts?
if (parent instanceof ASTIfStatement) {
// START IF
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.IF_EXPR, dataFlow.getLast());
tryToLog(loggerTag, NodeType.IF_EXPR, node);
} else if (parent instanceof ASTWhileStatement) {
// START WHILE
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.WHILE_EXPR, dataFlow.getLast());
tryToLog(loggerTag, NodeType.WHILE_EXPR, node);
} else if (parent instanceof ASTSwitchStatement) {
// START SWITCH
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.SWITCH_START, dataFlow.getLast());
tryToLog(loggerTag, NodeType.SWITCH_START, node);
} else if (parent instanceof ASTForStatement) {
// FOR EXPR
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.FOR_EXPR, dataFlow.getLast());
tryToLog(loggerTag, NodeType.FOR_EXPR, node);
} else if (parent instanceof ASTDoStatement) {
// DO EXPR
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.DO_EXPR, dataFlow.getLast());
tryToLog(loggerTag, NodeType.DO_EXPR, node);
} else if (parent instanceof ASTAssertStatement) {
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.ASSERT_STATEMENT, dataFlow.getLast());
tryToLog(loggerTag, NodeType.ASSERT_STATEMENT, node);
}
return super.visit(node, data);
}
Aggregations