private static boolean referencesType(final AstType reference, final TypeReference localType) { return reference != null && referencesType(reference.getUserData(Keys.TYPE_REFERENCE), localType); }
@Override @SuppressWarnings("ConstantConditions") public void run(final AstNode node) { if (astBuilder == null) { return; } run(node, null); }
final TypeDefinition typeDefinition = type.getUserData(Keys.TYPE_DEFINITION); final boolean canMoveVariableIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops, if (!referencesType(statement, typeDefinition)) { continue; if (declareTypeInBlock((BlockStatement) child, type, allowPassIntoLoops, typesToDeclare)) { return true; else if (hasNestedBlocks(child)) { for (final AstNode nestedChild : child.getChildren()) { if (nestedChild instanceof BlockStatement && declareTypeInBlock((BlockStatement) nestedChild, type, allowPassIntoLoops, typesToDeclare)) { final boolean canStillMoveIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops,
if (referencesType(statement, localType)) { if (declarationPoint.get() != null) { return false; if (!canMoveLocalTypeIntoSubBlock(statement, localType, allowPassIntoLoops)) { if (referencesType(nextNode, localType)) { return false;
final TypeDeclaration localType = iterator.next(); if (declareTypeInBlock(method.getBody(), localType, true, typesToDeclare)) { madeProgress = true; iterator.remove(); new DeclareLocalClassesTransform(context).run(child); run(child, analysis);
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; }
new InsertConstantReferencesTransform(context), new SimplifyArithmeticExpressionsTransform(context), new DeclareLocalClassesTransform(context), new InsertOverrideAnnotationsTransform(context), new AddReferenceQualifiersTransform(context),
final TypeDefinition typeDefinition = type.getUserData(Keys.TYPE_DEFINITION); final boolean canMoveVariableIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops, if (!referencesType(statement, typeDefinition)) { continue; if (declareTypeInBlock((BlockStatement) child, type, allowPassIntoLoops, typesToDeclare)) { return true; else if (hasNestedBlocks(child)) { for (final AstNode nestedChild : child.getChildren()) { if (nestedChild instanceof BlockStatement && declareTypeInBlock((BlockStatement) nestedChild, type, allowPassIntoLoops, typesToDeclare)) { final boolean canStillMoveIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops,
if (referencesType(statement, localType)) { if (declarationPoint.get() != null) { return false; if (!canMoveLocalTypeIntoSubBlock(statement, localType, allowPassIntoLoops)) { if (referencesType(nextNode, localType)) { return false;
final TypeDeclaration localType = iterator.next(); if (declareTypeInBlock(method.getBody(), localType, true, typesToDeclare)) { madeProgress = true; iterator.remove(); new DeclareLocalClassesTransform(context).run(child); run(child, analysis);
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; }
new InsertConstantReferencesTransform(context), new SimplifyArithmeticExpressionsTransform(context), new DeclareLocalClassesTransform(context), new InsertOverrideAnnotationsTransform(context), new AddReferenceQualifiersTransform(context),
final TypeDefinition typeDefinition = type.getUserData(Keys.TYPE_DEFINITION); final boolean canMoveVariableIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops, if (!referencesType(statement, typeDefinition)) { continue; if (declareTypeInBlock((BlockStatement) child, type, allowPassIntoLoops, typesToDeclare)) { return true; else if (hasNestedBlocks(child)) { for (final AstNode nestedChild : child.getChildren()) { if (nestedChild instanceof BlockStatement && declareTypeInBlock((BlockStatement) nestedChild, type, allowPassIntoLoops, typesToDeclare)) { final boolean canStillMoveIntoSubBlocks = findDeclarationPoint( typeDefinition, allowPassIntoLoops,
if (referencesType(statement, localType)) { if (declarationPoint.get() != null) { return false; if (!canMoveLocalTypeIntoSubBlock(statement, localType, allowPassIntoLoops)) { if (referencesType(nextNode, localType)) { return false;
final TypeDeclaration localType = iterator.next(); if (declareTypeInBlock(method.getBody(), localType, true, typesToDeclare)) { madeProgress = true; iterator.remove(); new DeclareLocalClassesTransform(context).run(child); run(child, analysis);
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 referencesType(final AstType reference, final TypeReference localType) { return reference != null && referencesType(reference.getUserData(Keys.TYPE_REFERENCE), localType); }
@Override @SuppressWarnings("ConstantConditions") public void run(final AstNode node) { if (astBuilder == null) { return; } run(node, null); }
new InsertConstantReferencesTransform(context), new SimplifyArithmeticExpressionsTransform(context), new DeclareLocalClassesTransform(context), new AddStandardAnnotationsTransform(context), new AddReferenceQualifiersTransform(context),
private static boolean referencesType(final AstType reference, final TypeReference localType) { return reference != null && referencesType(reference.getUserData(Keys.TYPE_REFERENCE), localType); }