private JCExpression scanForAssign(final MethodSymbol sym,
                                       final JCTree tree) {
        class TS extends TreeScanner {
            JCExpression result = null;
            public void scan(JCTree t) {
                if (t != null && result == null)
                    t.accept(this);
            }
            public void visitAnnotation(JCAnnotation t) {
                if (t == tree)
                    scan(t.args);
            }
            public void visitAssign(JCAssign t) {
                if (t.lhs.hasTag(IDENT)) {
                    JCIdent ident = (JCIdent) t.lhs;
                    if (ident.sym == sym)
                        result = t.rhs;
                }
            }
        }
        TS scanner = new TS();
        tree.accept(scanner);
        return scanner.result;
    }
private JCExpression scanForAssign ( final MethodSymbol sym , final JCTree tree ) { class TS extends TreeScanner { JCExpression result = null ; public void scan ( JCTree t ) { if ( t != null && result == null ) t . accept ( this ) ; } public void visitAnnotation ( JCAnnotation t ) { if ( t == tree ) scan ( t . args ) ; } public void visitAssign ( JCAssign t ) { if ( t . lhs . hasTag ( IDENT ) ) { JCIdent ident = ( JCIdent ) t . lhs ; if ( ident . sym == sym ) result = t . rhs ; } } } TS scanner = new TS ( ) ; tree . accept ( scanner ) ; return scanner . result ; }
Scans for a JCAssign node with a LHS matching a given
symbol, and returns its RHS.  Does not scan nested JCAnnotations.