Class ReplacementVariableFinder
- java.lang.Object
-
- com.google.errorprone.bugpatterns.ReplacementVariableFinder
-
public final class ReplacementVariableFinder extends Object
Utility methods to find replacement variables with similar names.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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 Detail
-
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)
-
-