@ Override public Description matchMemberSelect ( MemberSelectTree tree , VisitorState state ) { Symbol symbol = ASTHelpers . getSymbol ( tree ) ; // Match symbol's owner to android.R.string separately because couldn't get fully qualified // "android.R.string.yes" out of symbol, just "yes" if ( symbol == null || symbol . owner == null || symbol . getKind ( ) != ElementKind . FIELD || ! symbol . isStatic ( ) || ! R_STRING_CLASSNAME . contentEquals ( symbol . owner . getQualifiedName ( ) ) ) { return Description . NO_MATCH ; } String misleading = symbol . getSimpleName ( ) . toString ( ) ; String preferred = MISLEADING . get ( misleading ) ; if ( preferred == null ) { return Description . NO_MATCH ; } return buildDescription ( tree ) . setMessage ( String . format ( "%s.%s is not \"%s\" but \"%s\"; prefer %s.%s for clarity" , R_STRING_CLASSNAME , misleading , ASSUMED_MEANINGS . get ( misleading ) , ASSUMED_MEANINGS . get ( preferred ) , R_STRING_CLASSNAME , preferred ) ) // Keep the way tree refers to android.R.string as it is but replace the identifier . addFix ( SuggestedFix . replace ( tree , state . getSourceForNode ( tree . getExpression ( ) ) + "." + preferred ) ) . build ( ) ; }
assumed and actual meaning