Package com.sun.source.tree

Examples of com.sun.source.tree.StatementTree


    }

    // loop outside synchronized block -> move synchronized outside
    List<Class<? extends StatementTree>> loopClasses = Arrays.asList(WhileLoopTree.class, ForLoopTree.class,
        EnhancedForLoopTree.class, DoWhileLoopTree.class);
    StatementTree enclosingLoop = null;
    for (Class<? extends StatementTree> loopClass : loopClasses) {
      enclosingLoop = ASTHelpers.findEnclosingNode(state.getPath().getParentPath(), loopClass);
      if (enclosingLoop != null) {
        break;
      }
View Full Code Here


    this.matcher = matcher;
  }

  @Override
  public boolean matches(List<StatementTree> statements, VisitorState state) {
    StatementTree last = statements.get(statements.size() - 1);
    return matcher.matches(last, state);
  }
View Full Code Here

    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);
    }

    return matcher.matches(nextStmt, state);
View Full Code Here

    if (((Integer) rightOperand.getValue()) != 0) {
      return Description.NO_MATCH;
    }

    // Find and replace enclosing Statement.
    StatementTree enclosingStmt =
        ASTHelpers.findEnclosingNode(state.getPath(), StatementTree.class);
    return (enclosingStmt != null)
        ? describeMatch(tree,
            SuggestedFix.replace(enclosingStmt, "throw new ArithmeticException(\"/ by zero\");"))
        : describeMatch(tree);
View Full Code Here

  public Description matchNewClass(NewClassTree newClassTree, VisitorState state) {
    if (!MATCHER.matches(newClassTree, state)) {
      return Description.NO_MATCH;
    }

    StatementTree parent = (StatementTree) state.getPath().getParentPath().getLeaf();

    boolean isLastStatement = anyOf(
        new Enclosing.BlockOrCase<>(lastStatement(Matchers.<StatementTree>isSame(parent))),
        // it could also be a bare if statement with no braces
        parentNode(parentNode(kindIs(IF))))
View Full Code Here

            cond = scan(node.getCondition(), p);
            if (cond != null) {
                lastCond = cond.get(cond.size() - 1);
            }
        }
        StatementTree thent = node.getThenStatement();
        StatementTree elset = node.getElseStatement();
        List<Tree> thenr = null;
        if (isCurrentTree(thent)) {
            thenr = scan(thent, p);
            if (lastCond != null && thenr != null) {
                p.addNextExpression(lastCond, thenr.get(0));
View Full Code Here

  public static final boolean containsThisConstructorInvocation(MethodTree node) {
    if (!TreeUtils.isConstructor(node) || node.getBody().getStatements().isEmpty()) {
      return false;
    }

    StatementTree st = node.getBody().getStatements().get(0);
    if (!(st instanceof ExpressionStatementTree) || !(((ExpressionStatementTree) st).getExpression() instanceof MethodInvocationTree)) {
      return false;
    }

    MethodInvocationTree invocation = (MethodInvocationTree) ((ExpressionStatementTree) st).getExpression();
View Full Code Here

TOP

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

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.