use of com.github.javaparser.ast.stmt.BreakStmt in project drools by kiegroup.
the class PropagatorCompilerHandler method extractMethod.
private void extractMethod(SwitchEntry switchEntry) {
String label = switchEntry.getLabels().stream().map(Node::toString).collect(Collectors.joining());
SwitchStmt switchStatement = switchEntry.findAncestor(SwitchStmt.class).orElseThrow(() -> new CouldNotCreateAlphaNetworkCompilerException("SwitchEntry without SwitchStatement"));
int index = switchStatement.getEntries().indexOf(switchEntry);
String selectorString = switchStatement.getSelector().toString();
String newMethodName = String.format("extractedPropagated_%s_%d", md5Hash(selectorString), index);
// First statement is actual block, second statement is break
BlockStmt switchEntryStatements = (BlockStmt) switchEntry.getStatements().get(0);
MethodDeclaration extractedMethod = new MethodDeclaration().setModifiers(nodeList(Modifier.publicModifier())).setName(newMethodName).setParameters(methodParameters()).setType(new VoidType()).setBody(switchEntryStatements);
extractedMethod.setComment(new LineComment(selectorString + " " + label));
MethodCallExpr callExtractedMethod = new MethodCallExpr().setName(newMethodName).setArguments(arguments());
switchEntry.setStatements(nodeList(new ExpressionStmt(callExtractedMethod), new BreakStmt()));
extractedMethods.add(extractedMethod);
}
use of com.github.javaparser.ast.stmt.BreakStmt in project checker-framework by typetools.
the class JointJavacJavaParserVisitor method visitBreak.
@Override
public Void visitBreak(BreakTree javacTree, Node javaParserNode) {
BreakStmt node = castNode(BreakStmt.class, javaParserNode, javacTree);
processBreak(javacTree, node);
return null;
}
use of com.github.javaparser.ast.stmt.BreakStmt in project checker-framework by typetools.
the class DoubleJavaParserVisitor method visit.
@Override
public void visit(final BreakStmt node1, final Node other) {
BreakStmt node2 = (BreakStmt) other;
defaultAction(node1, node2);
node1.getLabel().ifPresent(l -> l.accept(this, node2.getLabel().get()));
}
Aggregations