当前位置: 首页>>代码示例>>Java>>正文


Java WhileLoopTree类代码示例

本文整理汇总了Java中com.sun.source.tree.WhileLoopTree的典型用法代码示例。如果您正苦于以下问题:Java WhileLoopTree类的具体用法?Java WhileLoopTree怎么用?Java WhileLoopTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WhileLoopTree类属于com.sun.source.tree包,在下文中一共展示了WhileLoopTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Void visitWhileLoop(WhileLoopTree node, Void p) {
    super.visitWhileLoop(node, p);
    if (isMethodCode() && phase == PHASE_AFTER_SELECTION) {
        //#109663&#112552:
        //the selection was inside the while-loop, the variables inside the
        //condition&statement of the while loop need to be considered to be used again after the loop:
        if (!secondPass) {
            secondPass = true;
            scan(node.getCondition(), p);
            scan(node.getStatement(), p);
            secondPass = false;
            stopSecondPass = false;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ScanStatement.java

示例2: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Mirror visitWhileLoop(WhileLoopTree arg0, EvaluationContext evaluationContext) {
    ExpressionTree condition = arg0.getCondition();
    Tree statement = arg0.getStatement();
    Mirror result = null;
    while (evaluateCondition(arg0, evaluationContext, condition)) {
        try {
            evaluationContext.pushBlock();
            Mirror res = statement.accept(this, evaluationContext);
            if (res instanceof Break) {
                break;
            } else if (res instanceof Continue) {
                continue;
            }
            if (res != null) {
                result = res;
            }
        } finally {
            evaluationContext.popBlock();
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EvaluatorVisitor.java

示例3: testBlock

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
private boolean testBlock(StringWriter writer, SourcePositions sp, String text, CompilationUnitTree cut, BlockTree blockTree) {
    boolean success = true;
    for (StatementTree st : blockTree.getStatements()) {
        if (isLegal(st)) {
            success &= testStatement(writer, sp, text, cut, st);
        }
        if (st instanceof IfTree) {
            IfTree ifTree = (IfTree) st;
            success &= testBranch(writer, sp, text, cut, ifTree.getThenStatement());
            success &= testBranch(writer, sp, text, cut, ifTree.getElseStatement());
        } else if (st instanceof WhileLoopTree) {
            WhileLoopTree whileLoopTree = (WhileLoopTree) st;
            success &= testBranch(writer, sp, text, cut, whileLoopTree.getStatement());
        } else if (st instanceof DoWhileLoopTree) {
            DoWhileLoopTree doWhileLoopTree = (DoWhileLoopTree) st;
            success &= testBranch(writer, sp, text, cut, doWhileLoopTree.getStatement());
        } else if (st instanceof ForLoopTree) {
            ForLoopTree forLoopTree = (ForLoopTree) st;
            success &= testBranch(writer, sp, text, cut, forLoopTree.getStatement());
        } else if (st instanceof LabeledStatementTree) {
            LabeledStatementTree labelTree = (LabeledStatementTree) st;
            success &= testBranch(writer, sp, text, cut, labelTree.getStatement());
        } else if (st instanceof SwitchTree) {
            SwitchTree switchTree = (SwitchTree) st;
            for (CaseTree caseTree : switchTree.getCases()) {
                for (StatementTree statementTree : caseTree.getStatements()) {
                    success &= testBranch(writer, sp, text, cut, statementTree);
                }
            }
        }
    }
    return success;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:34,代码来源:CompletenessStressTest.java

示例4: testVisitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Test
public void testVisitWhileLoop() throws ParseException, BadLocationException, IOException {
    List<ReformatOption> optionsToReformat = new ArrayList<>();
    CompilationUnitTree unit = getCompilationUnitTree(INPUT_FILE);
    MethodTree methodTree = TreeNavigationUtils.findMethodTreeByName("doSomething", unit).get(0);
    WhileLoopTree whileLoopTree = (WhileLoopTree) getStatementTreeByClassName(WhileLoopTree.class, methodTree);

    if (whileLoopTree == null) {
        fail(ERROR_MESSAGE);
    }

    ReformatTreeVisitor reformatTreeVisitor = getReformatTreeVisitor(INPUT_FILE);
    reformatTreeVisitor.visitWhileLoop(whileLoopTree, optionsToReformat);

    assertFalse(optionsToReformat.isEmpty());
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:17,代码来源:ReformatTreeVisitorTest.java

示例5: testVisitWhileLoopNotReformat

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Test
public void testVisitWhileLoopNotReformat() throws ParseException, BadLocationException, IOException {
    List<ReformatOption> optionsToReformat = new ArrayList<>();
    CompilationUnitTree unit = getCompilationUnitTree(INPUT_FILE);
    MethodTree methodTree = TreeNavigationUtils.findMethodTreeByName("doSomething", unit).get(0);
    WhileLoopTree whileLoopTree = (WhileLoopTree) getStatementTreeByClassName(WhileLoopTree.class, methodTree);

    if (whileLoopTree == null) {
        fail(ERROR_MESSAGE);
    }

    ReformatTreeVisitor reformatTreeVisitor = getReformatTreeVisitor(INPUT_FILE, 0, 10);
    reformatTreeVisitor.visitWhileLoop(whileLoopTree, optionsToReformat);

    assertTrue(optionsToReformat.isEmpty());
}
 
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:17,代码来源:ReformatTreeVisitorTest.java

示例6: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Boolean visitWhileLoop(WhileLoopTree tree, Void unused) {
  Boolean condValue = ASTHelpers.constValue(tree.getCondition(), Boolean.class);
  if (!Objects.equals(condValue, false)) {
    scan(tree.getStatement());
  }
  // (1)
  if (!Objects.equals(condValue, true)) {
    return true;
  }
  // (2)
  if (breaks.contains(tree)) {
    return true;
  }
  return false;
}
 
开发者ID:google,项目名称:error-prone,代码行数:17,代码来源:Reachability.java

示例7: matchWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Description matchWhileLoop(WhileLoopTree tree, VisitorState state) {
  JCWhileLoop whileLoop = (JCWhileLoop) tree;
  JCExpression whileExpression = ((JCParens) whileLoop.getCondition()).getExpression();
  if (whileExpression instanceof MethodInvocationTree) {
    MethodInvocationTree methodInvocation = (MethodInvocationTree) whileExpression;
    if (methodSelect(isDescendantOfMethod("java.util.Iterator", "hasNext()")).matches(
        methodInvocation, state)) {
      IdentifierTree identifier = getIncrementedIdentifer(extractSingleStatement(whileLoop.body));
      if (identifier != null) {
        return describeMatch(tree, new SuggestedFix());
      }
    }
  }
  return Description.NO_MATCH;
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:17,代码来源:ElementsCountedInLoop.java

示例8: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Tree visitWhileLoop(WhileLoopTree tree, Void p) {
    WhileLoopTree n = make.WhileLoop(tree.getCondition(), tree.getStatement());
    model.setType(n, model.getType(tree));
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TreeDuplicator.java

示例9: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
public Boolean visitWhileLoop(WhileLoopTree node, TreePath p) {
    if (p == null)
        return super.visitWhileLoop(node, p);

    WhileLoopTree t = (WhileLoopTree) p.getLeaf();

    if (!scan(node.getCondition(), t.getCondition(), p))
        return false;

    return scan(node.getStatement(), t.getStatement(), p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CopyFinder.java

示例10: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Object visitWhileLoop(WhileLoopTree node, Object p) {
    boolean saveFlag = switchCase;
    switchCase = false;
    complexity++;
    Object o = super.visitWhileLoop(node, p);
    this.switchCase = saveFlag;
    return o;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CyclomaticComplexityVisitor.java

示例11: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Object visitWhileLoop(WhileLoopTree node, Object p) {
    depth++;
    Object o = super.visitWhileLoop(node, p); 
    depth--;
    return o;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DepthVisitor.java

示例12: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public Void visitWhileLoop(WhileLoopTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitWhileLoop(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TreeNode.java

示例13: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public State visitWhileLoop(WhileLoopTree node, Void p) {
    State s;
    registerBreakTarget((node));
    returnIfRecurse(s = scan(node.getCondition(), p));
    return s;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:InfiniteRecursion.java

示例14: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public List<? extends TypeMirror> visitWhileLoop(WhileLoopTree node, Object p) {
    if (theExpression == null) {
        initExpression(node.getCondition());
    }
    return booleanType();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ExpectedTypeResolver.java

示例15: visitWhileLoop

import com.sun.source.tree.WhileLoopTree; //导入依赖的package包/类
@Override
public List<Tree> visitWhileLoop(WhileLoopTree node, ExpressionScanner.ExpressionsInfo p) {
    List<Tree> cond = null;
    if (acceptsTree(node.getCondition())) {
        cond = scan(node.getCondition(), p);
    }
    List<Tree> statements = scan(node.getStatement(), p);
    if (cond != null && statements != null && statements.size() > 0) {
        p.addNextExpression(statements.get(statements.size() - 1), cond.get(0));
    }
    return reduce(cond, statements);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ExpressionScanner.java


注:本文中的com.sun.source.tree.WhileLoopTree类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。