Exemplo n.º 1
0
 @Override
 public AstNode addStatement(AstNode blockOrStatement, AstNode statement) {
   if (blockOrStatement instanceof Block) {
     ((Block) blockOrStatement).addStatement(statement);
     return blockOrStatement;
   }
   Block block = new Block();
   if (blockOrStatement != null) {
     block.addStatement(blockOrStatement);
   }
   if (statement != null) {
     block.addStatement(statement);
   }
   return block;
 }
Exemplo n.º 2
0
 @Override
 public AstNode addStatementBeginning(AstNode blockOrStatement, AstNode statement) {
   if (blockOrStatement instanceof Block) {
     if (statement != null) {
       blockOrStatement.addChildrenToFront(statement);
       statement.setParent(blockOrStatement);
     }
     return blockOrStatement;
   }
   Block block = new Block();
   if (statement != null) {
     block.addStatement(statement);
   }
   if (blockOrStatement != null) {
     block.addStatement(blockOrStatement);
   }
   return block;
 }
Exemplo n.º 3
0
 @Override
 public AstNode block(Iterable<AstNode> statements) {
   Block block = new Block();
   for (AstNode stmt : statements) {
     if (stmt != null) {
       block.addStatement(stmt);
     }
   }
   return block;
 }
Exemplo n.º 4
0
 @Override
 public AstNode catchClause(AstNode varName, AstNode body) {
   CatchClause c = new CatchClause();
   c.setVarName(cast(varName, Name.class));
   if (body instanceof Block) {
     c.setBody((Block) body);
   } else {
     Block b = new Block();
     b.addStatement(body);
     c.setBody(b);
   }
   return c;
 }