private static boolean canMoveLocalTypeIntoSubBlock( final Statement statement, final TypeReference localType, final boolean allowPassIntoLoops) { if (!allowPassIntoLoops && AstNode.isLoop(statement)) { return false; } // // We can move the local class into a sub-block only if the local class is used only in that // sub-block (and not in expressions such as the loop condition). // for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && referencesType(child, localType)) { if (hasNestedBlocks(child)) { // // Loops, catch clauses, switch sections, and labeled statements can contain nested blocks. // for (AstNode grandChild = child.getFirstChild(); grandChild != null; grandChild = grandChild.getNextSibling()) { if (!(grandChild instanceof BlockStatement) && referencesType(grandChild, localType)) { return false; } } } else { return false; } } } return true; }
private static boolean canMoveLocalTypeIntoSubBlock( final Statement statement, final TypeReference localType, final boolean allowPassIntoLoops) { if (!allowPassIntoLoops && AstNode.isLoop(statement)) { return false; } // // We can move the local class into a sub-block only if the local class is used only in that // sub-block (and not in expressions such as the loop condition). // for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && referencesType(child, localType)) { if (hasNestedBlocks(child)) { // // Loops, catch clauses, switch sections, and labeled statements can contain nested blocks. // for (AstNode grandChild = child.getFirstChild(); grandChild != null; grandChild = grandChild.getNextSibling()) { if (!(grandChild instanceof BlockStatement) && referencesType(grandChild, localType)) { return false; } } } else { return false; } } } return true; }
private static boolean canMoveLocalTypeIntoSubBlock( final Statement statement, final TypeReference localType, final boolean allowPassIntoLoops) { if (!allowPassIntoLoops && AstNode.isLoop(statement)) { return false; } // // We can move the local class into a sub-block only if the local class is used only in that // sub-block (and not in expressions such as the loop condition). // for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && referencesType(child, localType)) { if (hasNestedBlocks(child)) { // // Loops, catch clauses, switch sections, and labeled statements can contain nested blocks. // for (AstNode grandChild = child.getFirstChild(); grandChild != null; grandChild = grandChild.getNextSibling()) { if (!(grandChild instanceof BlockStatement) && referencesType(grandChild, localType)) { return false; } } } else { return false; } } } return true; }
for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && usesVariable(child, variableName)) { if (hasNestedBlocks(child)) {
for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && usesVariable(child, variableName)) { if (hasNestedBlocks(child)) {
for (AstNode child = statement.getFirstChild(); child != null; child = child.getNextSibling()) { if (!(child instanceof BlockStatement) && usesVariable(child, variableName)) { if (hasNestedBlocks(child)) {