private void visitObjectIterationStatement(IterationStatementTree tree, Tree counterBlock) { currentLoopCounters = new HashSet<>(); scanCounterBlock(counterBlock); enterLoopBody(); scan(tree.statement()); leaveLoopBody(); }
private static boolean hasPredecessorInsideLoopBody( CfgBranchingBlock conditionBlock, IterationStatementTree loopTree) { for (CfgBlock loopPredecessor : conditionBlock.predecessors()) { List<Tree> predecessorElements = loopPredecessor.elements(); Tree predecessorLastElement = predecessorElements.get(predecessorElements.size() - 1); if (loopTree.is(Kind.FOR_STATEMENT)) { ForStatementTree forTree = (ForStatementTree) loopTree; if (forTree.update() != null && forTree.update().equals(predecessorLastElement)) { return !loopPredecessor.predecessors().isEmpty(); } } StatementTree loopBody = loopTree.statement(); if (isDescendant(predecessorLastElement, loopBody)) { return true; } } return false; }