@Override public Node visit(ExpressionStmt _n, Object _arg) { Expression expr = cloneNodes(_n.getExpression(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); ExpressionStmt r = new ExpressionStmt( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), expr ); r.setComment(comment); return r; }
public void setExpression(final Expression expr) { this.expr = expr; setAsParentNodeOf(this.expr); } }
@Override public Node visit(final ExpressionStmt n, final A arg) { n.setExpression((Expression) n.getExpression().accept(this, arg)); return n; }
@Override public void visit(final ExpressionStmt n, final A arg) { visitComment(n.getComment(), arg); n.getExpression().accept(this, arg); }
/** * Adds the given expression to the specified block. The list of statements * will be initialized if it is <code>null</code>. * * @param block * @param stmt */ public static void addStmt(BlockStmt block, Expression expr) { addStmt(block, new ExpressionStmt(expr)); }
@Override public Boolean visit(final ExpressionStmt n1, final Node arg) { final ExpressionStmt n2 = (ExpressionStmt) arg; if (!nodeEquals(n1.getExpression(), n2.getExpression())) { return Boolean.FALSE; } return Boolean.TRUE; }
Collections.singletonList(new Parameter(new ClassOrInterfaceType(simpleTypeName), new VariableDeclaratorId(attrName)))); setter.setBody(new BlockStmt(Collections.<Statement>singletonList(new ExpressionStmt( new AssignExpr(new FieldAccessExpr(new ThisExpr(), attrName), new NameExpr(attrName), AssignExpr.Operator.assign))))); members.add(setter);
@Override public void visit(final ExpressionStmt n, final Object arg) { printJavaComment(n.getComment(), arg); n.getExpression().accept(this, arg); printer.print(";"); }
@Override public R visit(final ExpressionStmt n, final A arg) { { R result = n.getExpression().accept(this, arg); if (result != null) { return result; } } return null; }
private NodeAndImports<MethodDeclaration> createPrimaryKeyEquals(Collection<FieldDescriptor> primaryKeyDescriptors, String enclosingClassName) { final MethodDeclaration equals = new MethodDeclaration(ModifierSet.PUBLIC, new PrimitiveType(PrimitiveType.Primitive.Boolean), "equals", Collections.singletonList(new Parameter(new ClassOrInterfaceType("Object"), new VariableDeclaratorId("other")))); equals.setAnnotations(Collections.<AnnotationExpr>singletonList(new MarkerAnnotationExpr(new NameExpr("Override")))); final Statement ifEqualNullStmt = new IfStmt(new BinaryExpr(new NameExpr("other"), new NullLiteralExpr(), BinaryExpr.Operator.equals), new ReturnStmt(new BooleanLiteralExpr(false)), null); final Statement ifEqualThisStmt = new IfStmt(new BinaryExpr(new NameExpr("other"), new ThisExpr(), BinaryExpr.Operator.equals), new ReturnStmt(new BooleanLiteralExpr(true)), null); final Statement ifEqualClassStmt = new IfStmt(new BinaryExpr(new MethodCallExpr(new NameExpr("other"), "getClass"), new MethodCallExpr(new ThisExpr(), "getClass"), BinaryExpr.Operator.notEquals), new ReturnStmt(new BooleanLiteralExpr(false)), null); final Statement rhsStmt = new ExpressionStmt(new VariableDeclarationExpr(ModifierSet.FINAL, new ClassOrInterfaceType(enclosingClassName), Collections.singletonList(new VariableDeclarator( new VariableDeclaratorId("rhs"), new CastExpr(new ClassOrInterfaceType(enclosingClassName), new NameExpr("other")))))); Expression equalsBuilderExpr = new ObjectCreationExpr(null, new ClassOrInterfaceType("EqualsBuilder"), Collections.<Expression>emptyList()); for (FieldDescriptor f : primaryKeyDescriptors) { final List<Expression> args = new ArrayList<Expression>(); args.add(new FieldAccessExpr(new ThisExpr(), f.getAttributeName())); args.add(new FieldAccessExpr(new NameExpr("rhs"), f.getAttributeName())); equalsBuilderExpr = new MethodCallExpr(equalsBuilderExpr, "append", args); } equalsBuilderExpr = new MethodCallExpr(equalsBuilderExpr, "isEquals"); final List<Statement> statements = new ArrayList<Statement>(); statements.add(ifEqualNullStmt); statements.add(ifEqualThisStmt); statements.add(ifEqualClassStmt); statements.add(rhsStmt); statements.add(new ReturnStmt(equalsBuilderExpr)); final BlockStmt equalsBody = new BlockStmt(statements); equals.setBody(equalsBody); return new NodeAndImports<MethodDeclaration>(equals, Collections.singleton(new ImportDeclaration(new QualifiedNameExpr(new NameExpr("org.apache.commons.lang.builder"), "EqualsBuilder"), false, false))); }
public void visit(ExpressionStmt n, Object arg) { n.getExpression().accept(this, arg); printer.print(";"); }
expr = VariableDeclarationExpression(); jj_consume_token(SEMICOLON); ret = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
expr = VariableDeclarationExpression(); jj_consume_token(SEMICOLON); ret = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
ExpressionStmt tmp = new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr);
{if (true) return new ExpressionStmt(expr.getBeginLine(), expr.getBeginColumn(), token.endLine, token.endColumn, expr);} throw new Error("Missing return statement in function");