com.sun.source.tree.ContinueTree Java Examples

The following examples show how to use com.sun.source.tree.ContinueTree. 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: TreeDuplicator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public Tree visitContinue(ContinueTree tree, Void p) {
        ContinueTree n = make.Continue(tree.getLabel());
//        model.setType(n, model.getType(tree));
        comments.copyComments(tree, n);
        model.setPos(n, model.getPos(tree));
        return n;
    }
 
Example #2
Source File: MoreTrees.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<TreePath> visitContinue(@Nullable ContinueTree node, Void v) {
  if (node == null) {
    return Optional.absent();
  } else if (isMatch(node, node.getLabel())) {
    return currentPathPlus(node);
  }

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

  checkForDiff(namesEqual(expected.getLabel(), other.get().getLabel()),
      "Expected label on continue 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 convertContinueStatement(ContinueTree node) {
  ContinueStatement newNode = new ContinueStatement();
  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 visitContinue(ContinueTree node, Void unused) {
  sync(node);
  builder.open(plusFour);
  token("continue");
  if (node.getLabel() != null) {
    builder.breakOp(" ");
    visit(node.getLabel());
  }
  token(";");
  builder.close();
  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 visitContinue(ContinueTree node, Void unused) {
    sync(node);
    builder.open(plusFour);
    token("continue");
    if (node.getLabel() != null) {
        builder.breakOp(" ");
        visit(node.getLabel());
    }
    token(";");
    builder.close();
    return null;
}
 
Example #7
Source File: ScanStatement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitContinue(ContinueTree node, Void p) {
    if (isMethodCode() && phase == PHASE_INSIDE_SELECTION && !treesSeensInSelection.contains(info.getTreeUtilities().getBreakContinueTarget(getCurrentPath()))) {
        selectionExits.add(getCurrentPath());
        hasContinues = true;
    }
    return super.visitContinue(node, p);
}
 
Example #8
Source File: TryCatchFinally.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitContinue(ContinueTree node, Collection<TreePath> trees) {
    if (!analyzeThrows && !seenTrees.contains(info.getTreeUtilities().getBreakContinueTarget(getCurrentPath()))) {
        trees.add(getCurrentPath());
    }
    return null;
}
 
Example #9
Source File: PreconditionsChecker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isIfWithContinueOnly(ContinueTree that) {
    TreePath currentTreePath = this.getCurrentPath();
    TreePath parentPath = currentTreePath.getParentPath();
    Tree parentTree = parentPath.getLeaf();
    if (parentTree.getKind() == Tree.Kind.IF) {
        return true;
    } else if (parentTree.getKind() == Tree.Kind.BLOCK) {
        BlockTree parentBlock = (BlockTree) parentTree;
        if (parentBlock.getStatements().size() == 1) {
            return true;
        }
    }
    return false;
}
 
Example #10
Source File: PreconditionsChecker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Tree visitContinue(ContinueTree that, Trees trees) {
    if (that.getLabel() != null || !isIfWithContinueOnly(that)) {
        this.hasContinue = true;
    }
    return super.visitContinue(that, trees);
}
 
Example #11
Source File: TreeNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitContinue(ContinueTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitContinue(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
Example #12
Source File: BreakContinueTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testContinue158130() throws Exception {
    String test = "public class Test { void m(int p) { loop: while (true) { if (p == 0) { con|tinue loop; } } } }";
    String golden = "public class Test { void m(int p) { loop: while (true) { if (p == 0) { continue; } } } }";
    testHelper(test, golden, Kind.CONTINUE, new Delegate() {

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

    //XXX: check labels
    return true;
}
 
Example #15
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitContinue(ContinueTree node, Void unused) {
    sync(node);
    builder.open(plusFour);
    token("continue");
    if (node.getLabel() != null) {
        builder.breakOp(" ");
        visit(node.getLabel());
    }
    token(";");
    builder.close();
    return null;
}
 
Example #16
Source File: InfiniteRecursion.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public State visitContinue(ContinueTree node, Void p) {
    StatementTree target = ci.getTreeUtilities().getBreakContinueTarget(getCurrentPath());
    breakContinueJumps.add(target);
    return State.NO;
}
 
Example #17
Source File: Flow.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Boolean visitContinue(ContinueTree node, ConstructorData p) {
    StatementTree loop = info.getTreeUtilities().getBreakContinueTarget(getCurrentPath());

    if (loop == null) {
        super.visitContinue(node, p);
        return null;
    }

    Tree resumePoint;

    if (loop.getKind() == Kind.LABELED_STATEMENT) {
        loop = ((LabeledStatementTree) loop).getStatement();
    }
    
    switch (loop.getKind()) {
        case WHILE_LOOP:
            resumePoint = ((WhileLoopTree) loop).getCondition();
            break;
        case FOR_LOOP: {
                ForLoopTree flt = (ForLoopTree)loop;
                resumePoint = null;
                if (flt.getUpdate() != null && !flt.getUpdate().isEmpty()) {
                    // resume will react on the 1st Tree of the update statement (always processed left to right)
                    resumePoint = flt.getUpdate().get(0);
                } 
                if (resumePoint == null) {
                    resumePoint = flt.getCondition();
                }
                if (resumePoint == null) {
                    resumePoint = flt.getStatement();
                }
        }
            break;
        case DO_WHILE_LOOP:
            resumePoint = ((DoWhileLoopTree) loop).getCondition();
            break;
        case ENHANCED_FOR_LOOP:
            resumePoint = ((EnhancedForLoopTree) loop).getStatement();
            break;
        default:
            resumePoint = null;
            break;
    }

    if (resumePoint != null) {
        recordResume(resumeBefore, resumePoint, variable2State);
    }

    variable2State = new HashMap< Element, State>();

    super.visitContinue(node, p);
    return null;
}
 
Example #18
Source File: CyclomaticComplexityVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitContinue(ContinueTree node, Object p) {
    complexity++;
    return super.visitContinue(node, p);
}
 
Example #19
Source File: Utilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visitContinue(ContinueTree node, Void p) {
    return visitBreak(null, 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> visitContinue(ContinueTree node, Object p) {
    return null;
}
 
Example #21
Source File: NCLOCVisitor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Object visitContinue(ContinueTree node, Object p) {
    statements++;
    return super.visitContinue(node, p);
}
 
Example #22
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 #23
Source File: VisitContinueHook.java    From kan-java with Eclipse Public License 1.0 4 votes vote down vote up
void visit(ContinueTree node, List<ErrMsg> errMsgs, GlobalContext globalCtx, Closure<List<Map<String, Long>>> resolveRowAndCol,
Closure<Void> setError);
 
Example #24
Source File: Breadcrumbs.java    From compile-testing with Apache License 2.0 4 votes vote down vote up
@Override
public String visitContinue(ContinueTree reference, Void v) {
  return (reference != null) ? detailedKindString(reference, reference.getLabel()) : "";
}