use of com.github.javaparser.ast.stmt.SwitchEntry in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitCase.
@Override
public Void visitCase(CaseTree javacTree, Node javaParserNode) {
SwitchEntry node = castNode(SwitchEntry.class, javaParserNode, javacTree);
processCase(javacTree, node);
// Java 12 introduced multiple label cases:
List<Expression> labels = node.getLabels();
List<? extends ExpressionTree> treeExpressions = org.checkerframework.javacutil.TreeUtils.caseTreeGetExpressions(javacTree);
assert node.getLabels().size() == treeExpressions.size() : String.format("node.getLabels() = %s, treeExpressions = %s", node.getLabels(), treeExpressions);
for (int i = 0; i < treeExpressions.size(); i++) {
treeExpressions.get(i).accept(this, labels.get(i));
}
if (javacTree.getStatements() == null) {
Tree javacBody = TreeUtils.caseTreeGetBody(javacTree);
Statement nodeBody = node.getStatement(0);
if (javacBody.getKind() == Kind.EXPRESSION_STATEMENT) {
javacBody.accept(this, node.getStatement(0));
} else if (nodeBody.isExpressionStmt()) {
javacBody.accept(this, nodeBody.asExpressionStmt().getExpression());
} else {
javacBody.accept(this, nodeBody);
}
} else {
processStatements(javacTree.getStatements(), node.getStatements());
}
return null;
}
use of com.github.javaparser.ast.stmt.SwitchEntry in project checker-framework by typetools.
the class DoubleJavaParserVisitor method visit.
@Override
public void visit(final SwitchEntry node1, final Node other) {
SwitchEntry node2 = (SwitchEntry) other;
defaultAction(node1, node2);
visitLists(node1.getLabels(), node2.getLabels());
visitLists(node1.getStatements(), node2.getStatements());
}
Aggregations