private void correctAccessedVariable(final InnerClassNode closureClass, ClosureExpression ce) { CodeVisitorSupport visitor = new CodeVisitorSupport() { @Override public void visitVariableExpression(VariableExpression expression) { Variable v = expression.getAccessedVariable(); if (v == null) return; if (!(v instanceof FieldNode)) return; String name = expression.getName(); FieldNode fn = closureClass.getDeclaredField(name); if (fn != null) { // only overwrite if we find something more specific expression.setAccessedVariable(fn); } } }; visitor.visitClosureExpression(ce); }
public void visitWhileLoop(WhileStatement loop) { visitStatement(loop); super.visitWhileLoop(loop); }
public void visitTryCatchFinally(TryCatchStatement statement) { visitStatement(statement); super.visitTryCatchFinally(statement); }
public void visitThrowStatement(ThrowStatement statement) { visitStatement(statement); super.visitThrowStatement(statement); }
public void visitSynchronizedStatement(SynchronizedStatement statement) { visitStatement(statement); super.visitSynchronizedStatement(statement); }
public void visitSwitch(SwitchStatement statement) { visitStatement(statement); super.visitSwitch(statement); }
public void visitReturnStatement(ReturnStatement statement) { visitStatement(statement); super.visitReturnStatement(statement); }
public void visitIfElse(IfStatement ifElse) { visitStatement(ifElse); super.visitIfElse(ifElse); }
public void visitForLoop(ForStatement forLoop) { visitStatement(forLoop); super.visitForLoop(forLoop); }
public void visitExpressionStatement(ExpressionStatement statement) { visitStatement(statement); super.visitExpressionStatement(statement); }
public void visitContinueStatement(ContinueStatement statement) { visitStatement(statement); super.visitContinueStatement(statement); }
public void visitCatchStatement(CatchStatement statement) { visitStatement(statement); super.visitCatchStatement(statement); }
public void visitBreakStatement(BreakStatement statement) { visitStatement(statement); super.visitBreakStatement(statement); }
public void visitBlockStatement(BlockStatement block) { visitStatement(block); super.visitBlockStatement(block); }
public void visitAssertStatement(AssertStatement statement) { visitStatement(statement); super.visitAssertStatement(statement); }
@Override public void visitDeclarationExpression(DeclarationExpression expression) { visitAnnotations(expression); super.visitDeclarationExpression(expression); }