Class ReplacementVariableFinder
java.lang.Object
com.google.errorprone.bugpatterns.ReplacementVariableFinder
Utility methods to find replacement variables with similar names.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList
<Fix> fixesByReplacingExpressionWithLocallyDeclaredField
(com.sun.source.tree.ExpressionTree input, Predicate<com.sun.tools.javac.tree.JCTree.JCVariableDecl> validFieldPredicate, VisitorState state) Suggest replacinginput
with a qualified reference to a locally declared field with a similar or the same name as theinput
expression.static com.google.common.collect.ImmutableList
<Fix> fixesByReplacingExpressionWithMethodParameter
(com.sun.source.tree.ExpressionTree input, Predicate<com.sun.tools.javac.tree.JCTree.JCVariableDecl> validParameterPredicate, VisitorState state) Suggest replacinginput
with a reference to a method parameter in the nearest enclosing method declaration with a similar or the same name as theinput
expression.
-
Method Details
-
fixesByReplacingExpressionWithLocallyDeclaredField
public static com.google.common.collect.ImmutableList<Fix> fixesByReplacingExpressionWithLocallyDeclaredField(com.sun.source.tree.ExpressionTree input, Predicate<com.sun.tools.javac.tree.JCTree.JCVariableDecl> validFieldPredicate, VisitorState state) Suggest replacinginput
with a qualified reference to a locally declared field with a similar or the same name as theinput
expression.- Parameters:
input
- a MEMBER_SELECT or IDENTIFIER expression which should be replaced.validFieldPredicate
- Predicate used to decide which locally declared fields are appropriate candidates for replacement (e.g.: is the appropriate type)
-
fixesByReplacingExpressionWithMethodParameter
public static com.google.common.collect.ImmutableList<Fix> fixesByReplacingExpressionWithMethodParameter(com.sun.source.tree.ExpressionTree input, Predicate<com.sun.tools.javac.tree.JCTree.JCVariableDecl> validParameterPredicate, VisitorState state) Suggest replacinginput
with a reference to a method parameter in the nearest enclosing method declaration with a similar or the same name as theinput
expression.- Parameters:
input
- a MEMBER_SELECT or IDENTIFIER expression which should be replaced.validParameterPredicate
- Predicate used to decide which method parameters are appropriate candidates for replacement (e.g.: is the appropriate type)
-