Search in sources :

Example 1 with WhileStmt

use of com.github.javaparser.ast.stmt.WhileStmt in project drools by kiegroup.

the class WhileStmtT method toJavaExpression.

@Override
public Node toJavaExpression() {
    WhileStmt stmt = new WhileStmt();
    stmt.setCondition((Expression) condition.toJavaExpression());
    stmt.setBody((Statement) body.toJavaExpression());
    return stmt;
}
Also used : WhileStmt(com.github.javaparser.ast.stmt.WhileStmt)

Example 2 with WhileStmt

use of com.github.javaparser.ast.stmt.WhileStmt in project checker-framework by typetools.

the class JointJavacJavaParserVisitor method visitWhileLoop.

@Override
public Void visitWhileLoop(WhileLoopTree javacTree, Node javaParserNode) {
    WhileStmt node = castNode(WhileStmt.class, javaParserNode, javacTree);
    processWhileLoop(javacTree, node);
    // While loop conditions are always parenthesized in javac but never in JavaParser.
    assert javacTree.getCondition().getKind() == Tree.Kind.PARENTHESIZED;
    ExpressionTree condition = ((ParenthesizedTree) javacTree.getCondition()).getExpression();
    condition.accept(this, node.getCondition());
    javacTree.getStatement().accept(this, node.getBody());
    return null;
}
Also used : WhileStmt(com.github.javaparser.ast.stmt.WhileStmt) ParenthesizedTree(com.sun.source.tree.ParenthesizedTree) LambdaExpressionTree(com.sun.source.tree.LambdaExpressionTree) ConditionalExpressionTree(com.sun.source.tree.ConditionalExpressionTree) ExpressionTree(com.sun.source.tree.ExpressionTree)

Example 3 with WhileStmt

use of com.github.javaparser.ast.stmt.WhileStmt in project checker-framework by typetools.

the class DoubleJavaParserVisitor method visit.

@Override
public void visit(final WhileStmt node1, final Node other) {
    WhileStmt node2 = (WhileStmt) other;
    defaultAction(node1, node2);
    node1.getBody().accept(this, node2.getBody());
    node1.getCondition().accept(this, node2.getCondition());
}
Also used : WhileStmt(com.github.javaparser.ast.stmt.WhileStmt)

Aggregations

WhileStmt (com.github.javaparser.ast.stmt.WhileStmt)3 ConditionalExpressionTree (com.sun.source.tree.ConditionalExpressionTree)1 ExpressionTree (com.sun.source.tree.ExpressionTree)1 LambdaExpressionTree (com.sun.source.tree.LambdaExpressionTree)1 ParenthesizedTree (com.sun.source.tree.ParenthesizedTree)1