Package com.sun.source.tree

Examples of com.sun.source.tree.BlockTree


        found = true;
        break;
      }
    }
    assert(found);      // should always find an enclosing block
    BlockTree block = (BlockTree)curr;

    // find next statement
    List<? extends StatementTree> stmts = block.getStatements();
    int ifStmtIdx = stmts.indexOf(prev);
    StatementTree nextStmt = null;
    if (ifStmtIdx < stmts.size() - 1) {  // TODO(user): off by one?
      nextStmt = stmts.get(ifStmtIdx + 1);
    }
View Full Code Here


      return Description.NO_MATCH;
    }
  }

  private boolean tryTreeMatches(TryTree tryTree, VisitorState state) {
    BlockTree tryBlock = tryTree.getBlock();
    List<? extends StatementTree> statements = tryBlock.getStatements();
    if (statements.isEmpty()) {
      return false;
    }

    // Check if any of the statements is a fail or assert* method (i.e. any
View Full Code Here

  }

  public static final Tree firstStatement(Tree tree) {
    Tree first;
    if (tree.getKind() == Tree.Kind.BLOCK) {
      BlockTree block = (BlockTree) tree;
      if (block.getStatements().isEmpty()) {
        first = block;
      } else {
        first = block.getStatements().iterator().next();
      }
    } else {
      first = tree;
    }
    return first;
View Full Code Here

    }
  }

  @Override
  public Void visit(CheckVisitor visitor, NewClassTree tree, GenerationContext<Void> context) {
    BlockTree initBlock = NewClassWriter.getDoubleBracesBlock(tree);
    TreeWrapper<ClassTree, Void> tw = context.getCurrentWrapper();

    if (initBlock == null && !tw.child(tree.getIdentifier()).isSyntheticType()) {
      return null;
    }

    if (initBlock != null) {
      for (StatementTree stmt : initBlock.getStatements()) {
        checkStatement(stmt, context);
      }
    }
    return null;
  }
View Full Code Here

      return null;
    }
    for (Tree member : tree.getClassBody().getMembers()) {
      if (member instanceof BlockTree) {
        // XXX I should be sure it's not the one generated by the compiler
        BlockTree block = (BlockTree) member;
        if (!block.isStatic()) {
          return block;
        }
      }
    }
    return null;
View Full Code Here

  /**
   * special construction for object initialization new Object(){{x = 1; y = 2; }};
   */
  private JS getObjectInitializer(WriterVisitor<JS> visitor, TreeWrapper<NewClassTree, JS> tw) {
    NewClassTree tree = tw.getTree();
    BlockTree initBlock = getDoubleBracesBlock(tree);
    if (initBlock == null && !tw.child(tree.getIdentifier()).isSyntheticType()) {
      return null;
    }

    List<NameValue<JS>> props = new ArrayList<NameValue<JS>>();
    if (initBlock != null) {
      for (StatementTree stmt : initBlock.getStatements()) {
        // check the right type of statements x=y is done in NewClassObjectInitCheck
        AssignmentTree assign = (AssignmentTree) ((ExpressionStatementTree) stmt).getExpression();
        props.add(NameValue.of(getPropertyName(assign.getVariable()), visitor.scan(assign.getExpression(), tw.getContext())));
      }
    }
View Full Code Here

TOP

Related Classes of com.sun.source.tree.BlockTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.