com.sun.source.tree.BreakTree Java Examples

The following examples show how to use com.sun.source.tree.BreakTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TryCatchFinally.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree node, Collection<TreePath> trees) {
    if (!analyzeThrows && !seenTrees.contains(info.getTreeUtilities().getBreakContinueTarget(getCurrentPath()))) {
        trees.add(getCurrentPath());
    }
    return null;
}
 
Example #2
Source File: MoreTrees.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<TreePath> visitBreak(@Nullable BreakTree node, Void v) {
  if (node == null) {
    return Optional.absent();
  }

  return isMatch(node, node.getLabel()) ? currentPathPlus(node) : Optional.<TreePath>absent();
}
 
Example #3
Source File: TreeDiffer.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree expected, Tree actual) {
  Optional<BreakTree> other = checkTypeAndCast(expected, actual);
  if (!other.isPresent()) {
    addTypeMismatch(expected, actual);
    return null;
  }

  checkForDiff(namesEqual(expected.getLabel(), other.get().getLabel()),
      "Expected label on break statement to be <%s> but was <%s>.",
      expected.getLabel(), other.get().getLabel());
  return null;
}
 
Example #4
Source File: TreeConverter.java    From j2objc with Apache License 2.0 5 votes vote down vote up
private TreeNode convertBreakStatement(BreakTree node) {
  BreakStatement newNode = new BreakStatement();
  Object label = node.getLabel();
  if (label != null) {
    newNode.setLabel(
        (SimpleName) new SimpleName(label.toString()).setPosition(getPosition(node)));
  }
  return newNode;
}
 
Example #5
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree node, Void unused) {
  sync(node);
  builder.open(plusFour);
  token("break");
  if (node.getLabel() != null) {
    builder.breakOp(" ");
    visit(node.getLabel());
  }
  builder.close();
  token(";");
  return null;
}
 
Example #6
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree node, Void unused) {
    sync(node);
    builder.open(plusFour);
    token("break");
    if (node.getLabel() != null) {
        builder.breakOp(" ");
        visit(node.getLabel());
    }
    builder.close();
    token(";");
    return null;
}
 
Example #7
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean visitBreak(BreakTree node, Void p) {
    Tree target = info.getTreeUtilities().getBreakContinueTarget(getCurrentPath());
    boolean known = seenTrees.contains(target);
    if (known) {
        targetTrees.add(target);
    }
    return !known;
}
 
Example #8
Source File: ScanStatement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree node, Void p) {
    if (isMethodCode() && phase == PHASE_INSIDE_SELECTION && !treesSeensInSelection.contains(info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath()))) {
        selectionExits.add(getCurrentPath());
        hasBreaks = true;
    }
    return super.visitBreak(node, p);
}
 
Example #9
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree node, Void unused) {
    sync(node);
    builder.open(plusFour);
    token("break");
    if (node.getLabel() != null) {
        builder.breakOp(" ");
        visit(node.getLabel());
    }
    builder.close();
    token(";");
    return null;
}
 
Example #10
Source File: TreeNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitBreak(BreakTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitBreak(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
Example #11
Source File: CyclomaticComplexityVisitor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitBreak(BreakTree node, Object p) {
    // do not count the break, if it is nested in a switch 'case' statement.
    if (node.getLabel() != null || !switchCase) {
        complexity++;
    }
    return super.visitBreak(node, p);
}
 
Example #12
Source File: BreakContinueTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testBreak166327() throws Exception {
    String test =
            "public class Test {" +
            "    public static void test(int y) {" +
            "        for (int u = y;;) {" +
            "            if (y == 0)" +
            "                br|eak;" +
            "            else" +
            "                y++;" +
            "        }" +
            "    }" +
            "}";
    String golden = 
            "public class Test {" +
            "    public static void test(int y) {" +
            "        for (int u = y;;) {" +
            "            if (y == 0)" +
            "                break;" +
            "            else" +
            "                y++;" +
            "        }" +
            "    }" +
            "}";

    testHelper(test, golden, Kind.BREAK, new Delegate() {

        public void run(WorkingCopy copy, Tree tree) {
            BreakTree oldBt = (BreakTree) tree;
            BreakTree newBt = copy.getTreeMaker().Break(null);
            copy.rewrite(oldBt, newBt);
        }
        
    });
}
 
Example #13
Source File: BreakContinueTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testBreak158130() throws Exception {
    String test = "public class Test { void m(int p) { loop: while (true) { if (p == 0) { b|reak loop; } } } }";
    String golden = "public class Test { void m(int p) { loop: while (true) { if (p == 0) { break; } } } }";
    testHelper(test, golden, Kind.BREAK, new Delegate() {

        public void run(WorkingCopy copy, Tree tree) {
            BreakTree original = (BreakTree) tree;
            TreeMaker make = copy.getTreeMaker();
            BreakTree modified = make.Break(null);
            copy.rewrite(original, modified);
        }
    });
}
 
Example #14
Source File: LabelsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Void visitBreak(BreakTree node, Object p) {
    System.err.println("visitBreak: " + node.getLabel());
    super.visitBreak(node, p);
    BreakTree copy = make.setLabel(node, node.getLabel() + "0");
    this.copy.rewrite(node, copy);
    return null;
}
 
Example #15
Source File: CopyFinder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Boolean visitBreak(BreakTree node, TreePath p) {
    if (p == null) {
        super.visitBreak(node, p);
        return false;
    }

    //XXX: check labels
    return true;
}
 
Example #16
Source File: TreeDuplicator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public Tree visitBreak(BreakTree tree, Void p) {
        BreakTree n = make.Break(tree.getLabel());
//        model.setType(n, model.getType(tree));
        comments.copyComments(tree, n);
        model.setPos(n, model.getPos(tree));
        return n;
    }
 
Example #17
Source File: PreconditionsChecker.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Tree visitBreak(BreakTree that, Trees trees) {
    this.hasBreaks = true;
    return super.visitBreak(that, trees);

}
 
Example #18
Source File: InfiniteRecursion.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public State visitBreak(BreakTree node, Void p) {
    Tree target = ci.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
    breakContinueJumps.add(target);
    return State.NO;
}
 
Example #19
Source File: NCLOCVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitBreak(BreakTree node, Object p) {
    statements++;
    return super.visitBreak(node, p);
}
 
Example #20
Source File: ExpectedTypeResolver.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public List<? extends TypeMirror> visitBreak(BreakTree node, Object p) {
    return null;
}
 
Example #21
Source File: CompletenessStressTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private boolean isLegal(StatementTree st) {
    return !(st instanceof ReturnTree) &&
            !(st instanceof ContinueTree) && !(st instanceof BreakTree);
}
 
Example #22
Source File: VisitBreakHook.java    From kan-java with Eclipse Public License 1.0 4 votes vote down vote up
void visit(BreakTree node, List<ErrMsg> errMsgs, GlobalContext globalCtx, Closure<List<Map<String, Long>>> resolveRowAndCol,
Closure<Void> setError);
 
Example #23
Source File: Breadcrumbs.java    From compile-testing with Apache License 2.0 4 votes vote down vote up
@Override
public String visitBreak(BreakTree reference, Void v) {
  return (reference != null) ? detailedKindString(reference, reference.getLabel()) : "";
}
 
Example #24
Source File: Flow.java    From netbeans with Apache License 2.0 3 votes vote down vote up
public Boolean visitBreak(BreakTree node, ConstructorData p) {
    super.visitBreak(node, p);

    Tree target = info.getTreeUtilities().getBreakContinueTargetTree(getCurrentPath());
    
    resumeAfter(target, variable2State);

    variable2State = new HashMap< Element, State>();
    
    return null;
}
 
Example #25
Source File: GeneratorUtilities.java    From netbeans with Apache License 2.0 votes vote down vote up
@Override public Object visitBreak(BreakTree node, Object p) { return null; }