<s> package org . eclipse . jdt . internal . core . search . matching ; import org . eclipse . jdt . internal . compiler . ast . * ; public class VariableLocator extends PatternLocator { protected VariablePattern pattern ; public VariableLocator ( VariablePattern pattern ) { super ( pattern ) ; this . pattern = pattern ; } public int match ( Expression node , MatchingNodeSet nodeSet ) { if ( this . pattern . writeAccess ) { if ( this . pattern . readAccess ) return IMPOSSIBLE_MATCH ; if ( node instanceof Assignment ) { Expression lhs = ( ( Assignment ) node ) . lhs ; if ( lhs instanceof Reference ) return matchReference ( ( Reference ) lhs , nodeSet , true ) ; } } else if ( this . pattern . readAccess || this . pattern . fineGrain != 0 ) { if ( node instanceof Assignment && ! ( node instanceof CompoundAssignment ) ) { char [ ] lastToken = null ; Expression lhs = ( ( Assignment ) node ) . lhs ; if ( lhs instanceof QualifiedNameReference ) { char [ ] [ ] tokens = ( ( QualifiedNameReference ) lhs ) . tokens ; lastToken = tokens [ tokens . length - 1 ] ; } if ( lastToken == null || matchesName ( this . pattern . name , lastToken ) ) { nodeSet . removePossibleMatch ( lhs ) ; nodeSet . removeTrustedMatch ( lhs ) ; } } } return IMPOSSIBLE_MATCH ; } public int match ( Reference node , MatchingNodeSet nodeSet ) { return ( this . pattern . readAccess || this . pattern . fineGrain != 0 ) ? matchReference ( node , nodeSet , false ) : IMPOSSIBLE_MATCH ; } protected int matchReference ( Reference node , MatchingNodeSet nodeSet , boolean writeOnlyAccess ) { if ( node instanceof NameReference ) { if ( this . pattern . name == null ) { return nodeSet . addMatch ( node , this . pattern . mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH ) ; } else if ( node instanceof SingleNameReference ) { if ( matchesName ( this . pattern . name , ( ( SingleNameReference ) node ) . token ) ) return nodeSet . addMatch ( node , POSSIBLE_MATCH ) ; } else { QualifiedNameReference qNameRef = ( QualifiedNameReference ) node ; char [ ] [ ] tokens = qNameRef . tokens ; if ( writeOnlyAccess ) { if ( matchesName ( this . pattern . name , tokens [ tokens . length - 1 ] ) ) return nodeSet . addMatch ( node , POSSIBLE_MATCH ) ; } else { for ( int i = 0 , max = tokens . length ; i < max ; i ++ ) if ( matchesName ( this . pattern . name , tokens [ i ] ) ) return nodeSet . addMatch ( node , POSSIBLE_MATCH ) ; } } } return IMPOSSIBLE_MATCH ; } public String toString ( ) { return "Locator for " + this . pattern . toString ( ) ; } } </s>