Uses of Class
com.google.errorprone.VisitorState
Packages that use VisitorState
Package
Description
Support code for providing automated corrections for defects we find.
A predicate DSL for matching javac AST nodes.
Supports matchers, but rather than giving Matcher implementations which are predicates on
individual AST nodes, a supplier gives contextual information from the traversal of the AST.
Utility code.
-
Uses of VisitorState in com.google.errorprone
Methods in com.google.errorprone that return VisitorStateModifier and TypeMethodDescriptionstatic VisitorState
VisitorState.createConfiguredForCompilation
(com.sun.tools.javac.util.Context context, DescriptionListener listener, Map<String, BugPattern.SeverityLevel> severityMap, ErrorProneOptions errorProneOptions) Return a VisitorState configured for a new compilation, including Error Prone configuration.static VisitorState
VisitorState.createForCustomFindingCollection
(com.sun.tools.javac.util.Context context, DescriptionListener listener) Return a VisitorState that has no Error Prone configuration, but can report findings tolistener
.static VisitorState
VisitorState.createForUtilityPurposes
(com.sun.tools.javac.util.Context context) Return a VisitorState that has no Error Prone configuration, and can't report results.VisitorState.withPath
(com.sun.source.util.TreePath path) VisitorState.withSuppression
(SuppressionInfo.SuppressedState suppressedState) Methods in com.google.errorprone with parameters of type VisitorStateModifier and TypeMethodDescriptionSuppressionInfo.forCompilationUnit
(com.sun.source.tree.CompilationUnitTree tree, VisitorState state) Generates theSuppressionInfo
for aCompilationUnitTree
.SuppressionInfo.suppressedState
(Suppressible suppressible, boolean suppressedInGeneratedCode, VisitorState state) Returns true if this checker should be considered suppressed given the signals present in this object.SuppressionInfo.withExtendedSuppressions
(com.sun.tools.javac.code.Symbol sym, VisitorState state, Set<? extends com.sun.tools.javac.util.Name> customSuppressionAnnosToLookFor) Returns an instance ofSuppressionInfo
that takes into account any suppression signals present onsym
as well as those already stored inthis
. -
Uses of VisitorState in com.google.errorprone.bugpatterns
Fields in com.google.errorprone.bugpatterns declared as VisitorStateModifier and TypeFieldDescriptionprotected final VisitorState
BugChecker.SuppressibleTreePathScanner.state
Methods in com.google.errorprone.bugpatterns with parameters of type VisitorStateModifier and TypeMethodDescriptionboolean
BugChecker.isSuppressed
(com.sun.source.tree.Tree tree, VisitorState state) Returns true if the given tree is annotated with a@SuppressWarnings
that disables this bug checker.boolean
BugChecker.isSuppressed
(com.sun.tools.javac.code.Symbol sym, VisitorState state) Returns true if the given symbol is annotated with a@SuppressWarnings
or other annotation that disables this bug checker.BugChecker.AnnotatedTypeTreeMatcher.matchAnnotatedType
(com.sun.source.tree.AnnotatedTypeTree tree, VisitorState state) BugChecker.AnnotationTreeMatcher.matchAnnotation
(com.sun.source.tree.AnnotationTree tree, VisitorState state) BugChecker.ArrayAccessTreeMatcher.matchArrayAccess
(com.sun.source.tree.ArrayAccessTree tree, VisitorState state) BugChecker.ArrayTypeTreeMatcher.matchArrayType
(com.sun.source.tree.ArrayTypeTree tree, VisitorState state) BugChecker.AssertTreeMatcher.matchAssert
(com.sun.source.tree.AssertTree tree, VisitorState state) BugChecker.AssignmentTreeMatcher.matchAssignment
(com.sun.source.tree.AssignmentTree tree, VisitorState state) BugChecker.BinaryTreeMatcher.matchBinary
(com.sun.source.tree.BinaryTree tree, VisitorState state) BugChecker.BlockTreeMatcher.matchBlock
(com.sun.source.tree.BlockTree tree, VisitorState state) BugChecker.BreakTreeMatcher.matchBreak
(com.sun.source.tree.BreakTree tree, VisitorState state) BugChecker.CaseTreeMatcher.matchCase
(com.sun.source.tree.CaseTree tree, VisitorState state) BugChecker.CatchTreeMatcher.matchCatch
(com.sun.source.tree.CatchTree tree, VisitorState state) BugChecker.ClassTreeMatcher.matchClass
(com.sun.source.tree.ClassTree tree, VisitorState state) BugChecker.CompilationUnitTreeMatcher.matchCompilationUnit
(com.sun.source.tree.CompilationUnitTree tree, VisitorState state) BugChecker.CompoundAssignmentTreeMatcher.matchCompoundAssignment
(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState state) BugChecker.ConditionalExpressionTreeMatcher.matchConditionalExpression
(com.sun.source.tree.ConditionalExpressionTree tree, VisitorState state) BugChecker.ContinueTreeMatcher.matchContinue
(com.sun.source.tree.ContinueTree tree, VisitorState state) BugChecker.DoWhileLoopTreeMatcher.matchDoWhileLoop
(com.sun.source.tree.DoWhileLoopTree tree, VisitorState state) BugChecker.EmptyStatementTreeMatcher.matchEmptyStatement
(com.sun.source.tree.EmptyStatementTree tree, VisitorState state) BugChecker.EnhancedForLoopTreeMatcher.matchEnhancedForLoop
(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState state) BugChecker.ExpressionStatementTreeMatcher.matchExpressionStatement
(com.sun.source.tree.ExpressionStatementTree tree, VisitorState state) BugChecker.ForLoopTreeMatcher.matchForLoop
(com.sun.source.tree.ForLoopTree tree, VisitorState state) BugChecker.IdentifierTreeMatcher.matchIdentifier
(com.sun.source.tree.IdentifierTree tree, VisitorState state) BugChecker.IfTreeMatcher.matchIf
(com.sun.source.tree.IfTree tree, VisitorState state) BugChecker.ImportTreeMatcher.matchImport
(com.sun.source.tree.ImportTree tree, VisitorState state) BugChecker.InstanceOfTreeMatcher.matchInstanceOf
(com.sun.source.tree.InstanceOfTree tree, VisitorState state) BugChecker.IntersectionTypeTreeMatcher.matchIntersectionType
(com.sun.source.tree.IntersectionTypeTree tree, VisitorState state) BugChecker.LabeledStatementTreeMatcher.matchLabeledStatement
(com.sun.source.tree.LabeledStatementTree tree, VisitorState state) BugChecker.LambdaExpressionTreeMatcher.matchLambdaExpression
(com.sun.source.tree.LambdaExpressionTree tree, VisitorState state) BugChecker.LiteralTreeMatcher.matchLiteral
(com.sun.source.tree.LiteralTree tree, VisitorState state) BugChecker.MemberReferenceTreeMatcher.matchMemberReference
(com.sun.source.tree.MemberReferenceTree tree, VisitorState state) BugChecker.MemberSelectTreeMatcher.matchMemberSelect
(com.sun.source.tree.MemberSelectTree tree, VisitorState state) BugChecker.MethodTreeMatcher.matchMethod
(com.sun.source.tree.MethodTree tree, VisitorState state) BugChecker.MethodInvocationTreeMatcher.matchMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, VisitorState state) BugChecker.ModifiersTreeMatcher.matchModifiers
(com.sun.source.tree.ModifiersTree tree, VisitorState state) BugChecker.NewArrayTreeMatcher.matchNewArray
(com.sun.source.tree.NewArrayTree tree, VisitorState state) BugChecker.NewClassTreeMatcher.matchNewClass
(com.sun.source.tree.NewClassTree tree, VisitorState state) BugChecker.ParameterizedTypeTreeMatcher.matchParameterizedType
(com.sun.source.tree.ParameterizedTypeTree tree, VisitorState state) BugChecker.ParenthesizedTreeMatcher.matchParenthesized
(com.sun.source.tree.ParenthesizedTree tree, VisitorState state) BugChecker.PrimitiveTypeTreeMatcher.matchPrimitiveType
(com.sun.source.tree.PrimitiveTypeTree tree, VisitorState state) BugChecker.ReturnTreeMatcher.matchReturn
(com.sun.source.tree.ReturnTree tree, VisitorState state) BugChecker.SwitchTreeMatcher.matchSwitch
(com.sun.source.tree.SwitchTree tree, VisitorState state) BugChecker.SynchronizedTreeMatcher.matchSynchronized
(com.sun.source.tree.SynchronizedTree tree, VisitorState state) BugChecker.ThrowTreeMatcher.matchThrow
(com.sun.source.tree.ThrowTree tree, VisitorState state) BugChecker.TryTreeMatcher.matchTry
(com.sun.source.tree.TryTree tree, VisitorState state) BugChecker.TypeCastTreeMatcher.matchTypeCast
(com.sun.source.tree.TypeCastTree tree, VisitorState state) BugChecker.TypeParameterTreeMatcher.matchTypeParameter
(com.sun.source.tree.TypeParameterTree tree, VisitorState state) BugChecker.UnaryTreeMatcher.matchUnary
(com.sun.source.tree.UnaryTree tree, VisitorState state) BugChecker.UnionTypeTreeMatcher.matchUnionType
(com.sun.source.tree.UnionTypeTree tree, VisitorState state) BugChecker.VariableTreeMatcher.matchVariable
(com.sun.source.tree.VariableTree tree, VisitorState state) BugChecker.WhileLoopTreeMatcher.matchWhileLoop
(com.sun.source.tree.WhileLoopTree tree, VisitorState state) BugChecker.WildcardTreeMatcher.matchWildcard
(com.sun.source.tree.WildcardTree tree, VisitorState state) boolean
BugChecker.suppressedByAnyOf
(Set<com.sun.tools.javac.util.Name> annotations, VisitorState s) com.google.common.collect.ImmutableRangeSet<Integer>
BugChecker.suppressedRegions
(VisitorState state) Computes a RangeSet of code regions which are suppressed by this bug checker.Constructors in com.google.errorprone.bugpatterns with parameters of type VisitorState -
Uses of VisitorState in com.google.errorprone.fixes
Methods in com.google.errorprone.fixes with parameters of type VisitorStateModifier and TypeMethodDescriptionstatic Optional<SuggestedFix>
SuggestedFixes.addMembers
(com.sun.source.tree.ClassTree classTree, VisitorState state, SuggestedFixes.AdditionPosition where, Iterable<String> members) static SuggestedFix
SuggestedFixes.addMembers
(com.sun.source.tree.ClassTree classTree, VisitorState state, SuggestedFixes.AdditionPosition where, String firstMember, String... otherMembers) Returns aFix
that adds members defined byfirstMember
(and optionallyotherMembers
) to the class referenced byclassTree
.static SuggestedFix
SuggestedFixes.addMembers
(com.sun.source.tree.ClassTree classTree, VisitorState state, String firstMember, String... otherMembers) Returns aFix
that adds members defined byfirstMember
(and optionallyotherMembers
) to the end of the class referenced byclassTree
.static Optional<SuggestedFix>
SuggestedFixes.addModifiers
(com.sun.source.tree.Tree tree, VisitorState state, Modifier... modifiers) Adds modifiers to the given class, method, or field declaration.static Optional<SuggestedFix>
SuggestedFixes.addModifiers
(com.sun.source.tree.Tree tree, com.sun.source.tree.ModifiersTree originalModifiers, VisitorState state, Set<Modifier> modifiers) Adds modifiers to the given declaration and corresponding modifiers tree.static void
SuggestedFixes.addSuppressWarnings
(SuggestedFix.Builder fixBuilder, VisitorState state, String warningToSuppress) ModifiesfixBuilder
to either create a new@SuppressWarnings
element on the closest suppressible node, or addwarningToSuppress
to that node if there's already aSuppressWarnings
annotation there.static void
SuggestedFixes.addSuppressWarnings
(SuggestedFix.Builder fixBuilder, VisitorState state, String warningToSuppress, String lineComment) ModifiesfixBuilder
to either create a new@SuppressWarnings
element on the closest suppressible node, or addwarningToSuppress
to that node if there's already aSuppressWarnings
annotation there.static void
SuggestedFixes.addSuppressWarnings
(SuggestedFix.Builder fixBuilder, VisitorState state, String warningToSuppress, String lineComment, boolean commentOnNewLine) ModifiesfixBuilder
to either create a new@SuppressWarnings
element on the closest suppressible node, or addwarningToSuppress
to that node if there's already aSuppressWarnings
annotation there.static SuggestedFix
SuggestedFixes.addSuppressWarnings
(VisitorState state, String warningToSuppress) Returns a fix that adds a@SuppressWarnings(warningToSuppress)
to the closest suppressible element to the node pointed at bystate.getPath()
.static SuggestedFix
SuggestedFixes.addSuppressWarnings
(VisitorState state, String warningToSuppress, String lineComment) Returns a fix that adds a@SuppressWarnings(warningToSuppress)
to the closest suppressible element to the node pointed at bystate.getPath()
, optionally suffixing the suppression with a comment suffix (e.g.static SuggestedFix.Builder
SuggestedFixes.addValuesToAnnotationArgument
(com.sun.source.tree.AnnotationTree annotation, String parameterName, Collection<String> newValues, VisitorState state) Returns a fix that appendsnewValues
to theparameterName
argument forannotation
, regardless of whether there is already an argument.static String
SuggestedFixes.castTree
(com.sun.source.tree.ExpressionTree expressionTree, String toType, VisitorState state) Casts the givenexpressionTree
totoType
, adding parentheses if necessary.static boolean
SuggestedFixes.compilesWithFix
(Fix fix, VisitorState state) Returns true if the current compilation would succeed with the given fix applied.static boolean
SuggestedFixes.compilesWithFix
(Fix fix, VisitorState state, com.google.common.collect.ImmutableList<String> extraOptions, boolean onlyInSameCompilationUnit) Returns true if the current compilation would succeed with the given fix applied, using the given additional compiler options, optionally limiting the checking of compilation failures to the compilation unit in which the fix is applied.static SuggestedFixes.FixCompiler
SuggestedFixes.FixCompiler.create
(Fix fix, VisitorState state) static Fix
SuggestedFixes.deleteExceptions
(com.sun.source.tree.MethodTree tree, VisitorState state, List<com.sun.source.tree.ExpressionTree> toDelete) Deletes the given exceptions from a method's throws clause.static URI
SuggestedFixes.FixCompiler.getModifiedFileUri
(VisitorState state) static String
SuggestedFixes.prettyType
(VisitorState state, SuggestedFix.Builder existingFix, com.sun.tools.javac.code.Type type) Pretty-prints a Type for use in fixes, qualifying any enclosed type names usingSuggestedFixes.qualifyType(com.google.errorprone.VisitorState, com.google.errorprone.fixes.SuggestedFix.Builder, com.sun.tools.javac.code.Symbol)
}.static String
SuggestedFixes.prettyType
(com.sun.tools.javac.code.Type type, VisitorState state) Pretty-prints a Type for use in diagnostic messages, qualifying any enclosed type names usingSuggestedFixes.qualifyType(com.google.errorprone.VisitorState, com.google.errorprone.fixes.SuggestedFix.Builder, com.sun.tools.javac.code.Symbol)
}.static void
SuggestedFixes.qualifyDocReference
(SuggestedFix.Builder fix, com.sun.source.util.DocTreePath docPath, VisitorState state) Fully qualifies a javadoc reference, e.g.static String
SuggestedFixes.qualifyStaticImport
(String qualifiedName, SuggestedFix.Builder fix, VisitorState state) Provides a name to use for the (fully qualified) method provided inqualifiedName
, trying to static import it if possible.static String
SuggestedFixes.qualifyType
(VisitorState state, SuggestedFix.Builder fix, com.sun.tools.javac.code.Symbol sym) Returns a human-friendly name of the givenSymbol
for use in fixes.static String
SuggestedFixes.qualifyType
(VisitorState state, SuggestedFix.Builder fix, String typeName) Returns a human-friendly name of the giventypeName
for use in fixes.static String
SuggestedFixes.qualifyType
(VisitorState state, SuggestedFix.Builder fix, TypeMirror type) Returns a human-friendly name of the given type for use in fixes.static SuggestedFix
SuggestedFixes.removeElement
(com.sun.source.tree.Tree tree, List<? extends com.sun.source.tree.Tree> trees, VisitorState state) Removestree
fromtrees
, assuming thattrees
represents a comma-separated list of expressions containingtree
.static Optional<SuggestedFix>
SuggestedFixes.removeModifiers
(com.sun.source.tree.ModifiersTree originalModifiers, VisitorState state, Set<Modifier> toRemove) Removes modifiers to the given declaration and corresponding modifiers tree.static Optional<SuggestedFix>
SuggestedFixes.removeModifiers
(com.sun.source.tree.Tree tree, VisitorState state, Modifier... modifiers) Removes modifiers from the given class, method, or field declaration.static void
SuggestedFixes.removeSuppressWarnings
(SuggestedFix.Builder fixBuilder, VisitorState state, String warningToRemove) ModifiesfixBuilder
to either remove awarningToRemove
warning from the closestSuppressWarning
node or remove the entireSuppressWarning
node ifwarningToRemove
is the only warning in that node.static SuggestedFix
SuggestedFixes.renameMethod
(com.sun.source.tree.MethodTree tree, String replacement, VisitorState state) Be warned, only changes method name at the declaration.static SuggestedFix
SuggestedFixes.renameMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, String replacement, VisitorState state) Replaces the name of the method being invoked intree
withreplacement
.static SuggestedFix
SuggestedFixes.renameMethodWithInvocations
(com.sun.source.tree.MethodTree tree, String replacement, VisitorState state) Renames the givenMethodTree
and its usages in the current compilation unit toreplacement
.static SuggestedFix
SuggestedFixes.renameTypeParameter
(com.sun.source.tree.TypeParameterTree typeParameter, com.sun.source.tree.Tree owningTree, String typeVarReplacement, VisitorState state) Renames a type parametertypeParameter
owned byowningTree
totypeVarReplacement
.static SuggestedFix
SuggestedFixes.renameVariable
(com.sun.source.tree.VariableTree tree, String replacement, VisitorState state) Renames the givenVariableTree
and its usages in the current compilation unit toreplacement
.static SuggestedFix
SuggestedFixes.renameVariableUsages
(com.sun.source.tree.VariableTree tree, String replacement, VisitorState state) Renames usage of the givenVariableTree
in the current compilation unit toreplacement
.static SuggestedFix
SuggestedFixes.replaceIncludingComments
(com.sun.source.util.TreePath path, String replacement, VisitorState state) Replaces the tree atpath
along with any Javadocs/associated single-line comments.static Optional<SuggestedFix>
SuggestedFixes.suggestExemptingAnnotation
(String exemptingAnnotation, com.sun.source.util.TreePath where, VisitorState state) Create a fix to add a suppression annotation on the surrounding class.static SuggestedFix.Builder
SuggestedFixes.updateAnnotationArgumentValues
(com.sun.source.tree.AnnotationTree annotation, VisitorState state, String parameterName, Collection<String> newValues) Returns a fix that updatesnewValues
to theparameterName
argument forannotation
, regardless of whether there is already an argument. -
Uses of VisitorState in com.google.errorprone.matchers
Methods in com.google.errorprone.matchers with parameters of type VisitorStateModifier and TypeMethodDescriptionstatic boolean
UnusedReturnValueMatcher.expectedExceptionTest
(VisitorState state) Allow return values to be ignored in tests that expect an exception to be thrown.UnusedReturnValueMatcher.getAllowReasons
(com.sun.source.tree.ExpressionTree tree, VisitorState state) Returns a stream of reasons the given expression is allowed to have an unused return value based on its context.protected Iterable<? extends com.sun.source.tree.AnnotationTree>
AnnotationMatcher.getChildNodes
(T tree, VisitorState state) ChildMultiMatcher.getChildNodes
(T tree, VisitorState state) Returns the set of child nodes to match.protected Iterable<? extends com.sun.source.tree.MethodTree>
ConstructorOfClass.getChildNodes
(com.sun.source.tree.ClassTree classTree, VisitorState state) protected Iterable<? extends com.sun.source.tree.ExpressionTree>
HasArguments.getChildNodes
(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state) protected Iterable<? extends com.sun.source.tree.VariableTree>
MethodHasParameters.getChildNodes
(com.sun.source.tree.MethodTree methodTree, VisitorState state) static boolean
CompileTimeConstantExpressionMatcher.hasCompileTimeConstantAnnotation
(VisitorState state, com.sun.tools.javac.code.Symbol symbol) static boolean
JUnitMatchers.hasJUnitAnnotation
(com.sun.source.tree.MethodTree tree, VisitorState state) Checks if a method, or any overridden method, is annotated with any annotation from the org.junit package.static boolean
TestNgMatchers.hasTestNgAnnotation
(com.sun.source.tree.MethodTree tree, VisitorState state) Checks if a method, or any overridden method, is annotated with any annotation from the org.testng package.boolean
UnusedReturnValueMatcher.isAllowed
(com.sun.source.tree.ExpressionTree tree, VisitorState state) Returnstrue
if the given expression is allowed to have an unused return value based on its context.static boolean
UnusedReturnValueMatcher.isReturnValueUnused
(com.sun.source.tree.ExpressionTree tree, VisitorState state) Returnstrue
if and only if the giventree
is an invocation of or reference to a constructor or non-void
method for which the return value is considered unused.static boolean
Matchers.isThrowingFunctionalInterface
(com.sun.tools.javac.code.Type clazzType, VisitorState state) abstract boolean
AbstractTypeMatcher.matches
(T tree, VisitorState state) boolean
AnnotationDoesNotHaveArgument.matches
(com.sun.source.tree.AnnotationTree annotationTree, VisitorState state) boolean
AnnotationHasArgumentWithValue.matches
(com.sun.source.tree.AnnotationTree annotationTree, VisitorState state) boolean
AnnotationType.matches
(com.sun.source.tree.AnnotationTree annotationTree, VisitorState state) boolean
Asserts.matches
(com.sun.source.tree.StatementTree statementTree, VisitorState state) boolean
ChildMultiMatcher.matches
(T tree, VisitorState state) boolean
CompileTimeConstantExpressionMatcher.matches
(com.sun.source.tree.ExpressionTree t, VisitorState state) boolean
CompoundAssignment.matches
(com.sun.source.tree.CompoundAssignmentTree compoundAssignmentTree, VisitorState state) boolean
Contains.matches
(com.sun.source.tree.Tree tree, VisitorState state) boolean
Enclosing.BlockOrCase.matches
(T unused, VisitorState state) boolean
HasIdentifier.matches
(com.sun.source.tree.Tree tree, VisitorState state) boolean
IsNonNullMatcher.matches
(com.sun.source.tree.ExpressionTree tree, VisitorState state) boolean
IsSameType.matches
(T tree, VisitorState state) boolean
IsSubtypeOf.matches
(T tree, VisitorState state) boolean
Matcher.matches
(T t, VisitorState state) boolean
MethodInvocation.matches
(com.sun.source.tree.ExpressionTree expressionTree, VisitorState state) boolean
MethodInvocationArgument.matches
(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state) boolean
MethodVisibility.matches
(com.sun.source.tree.MethodTree t, VisitorState state) boolean
NullnessMatcher.matches
(com.sun.source.tree.ExpressionTree expr, VisitorState state) boolean
Returns.matches
(com.sun.source.tree.StatementTree expressionTree, VisitorState state) boolean
StringLiteral.matches
(com.sun.source.tree.ExpressionTree expressionTree, VisitorState state) boolean
Throws.matches
(com.sun.source.tree.StatementTree expressionTree, VisitorState state) boolean
UnusedReturnValueMatcher.matches
(com.sun.source.tree.ExpressionTree tree, VisitorState state) static boolean
Matchers.methodCallInDeclarationOfThrowingRunnable
(VisitorState state) static boolean
UnusedReturnValueMatcher.mockitoInvocation
(com.sun.source.tree.Tree tree, VisitorState state) Don't match the method that is invoked throughMockito.verify(t)
ordoReturn(val).when(t)
.ChildMultiMatcher.multiMatchResult
(T tree, VisitorState state) MultiMatcher.multiMatchResult
(T tree, VisitorState vs) Attempt to match the given node, and return the associated subnodes that matched.boolean
Suppressible.suppressedByAnyOf
(Set<com.sun.tools.javac.util.Name> annotations, VisitorState s) Method parameters in com.google.errorprone.matchers with type arguments of type VisitorStateModifier and TypeMethodDescriptionstatic <T extends com.sun.source.tree.Tree>
Matcher<T>Matchers.symbolMatcher
(BiPredicate<com.sun.tools.javac.code.Symbol, VisitorState> pred) Match a Tree based solely on the Symbol produced byASTHelpers.getSymbol(Tree)
. -
Uses of VisitorState in com.google.errorprone.predicates
Methods in com.google.errorprone.predicates with parameters of type VisitorStateModifier and TypeMethodDescriptionboolean
TypePredicate.apply
(com.sun.tools.javac.code.Type type, VisitorState state) -
Uses of VisitorState in com.google.errorprone.predicates.type
Methods in com.google.errorprone.predicates.type with parameters of type VisitorStateModifier and TypeMethodDescriptionboolean
DescendantOf.apply
(com.sun.tools.javac.code.Type type, VisitorState state) boolean
DescendantOfAny.apply
(com.sun.tools.javac.code.Type type, VisitorState state) boolean
Exact.apply
(com.sun.tools.javac.code.Type type, VisitorState state) boolean
ExactAny.apply
(com.sun.tools.javac.code.Type type, VisitorState state) -
Uses of VisitorState in com.google.errorprone.scanner
Methods in com.google.errorprone.scanner with parameters of type VisitorStateModifier and TypeMethodDescriptionprotected Set<? extends com.sun.tools.javac.util.Name>
ErrorProneScanner.getCustomSuppressionAnnotations
(VisitorState state) protected Set<? extends com.sun.tools.javac.util.Name>
Scanner.getCustomSuppressionAnnotations
(VisitorState state) Returns a set of all the custom suppression annotation types used by theBugChecker
s in thisScanner
.protected SuppressionInfo.SuppressedState
Scanner.isSuppressed
(Suppressible suppressible, ErrorProneOptions errorProneOptions, VisitorState state) Returns if this checker should be suppressed on the current tree path.protected void
Scanner.reportMatch
(Description description, VisitorState state) Scanner.scan
(com.sun.source.tree.Tree tree, VisitorState state) Scan a single node.Scanner.scan
(com.sun.source.util.TreePath path, VisitorState state) Scan a tree from a position identified by a TreePath.ErrorProneScanner.visitAnnotatedType
(com.sun.source.tree.AnnotatedTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitAnnotation
(com.sun.source.tree.AnnotationTree tree, VisitorState visitorState) ErrorProneScanner.visitArrayAccess
(com.sun.source.tree.ArrayAccessTree tree, VisitorState visitorState) ErrorProneScanner.visitArrayType
(com.sun.source.tree.ArrayTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitAssert
(com.sun.source.tree.AssertTree tree, VisitorState visitorState) ErrorProneScanner.visitAssignment
(com.sun.source.tree.AssignmentTree tree, VisitorState visitorState) ErrorProneScanner.visitBinary
(com.sun.source.tree.BinaryTree tree, VisitorState visitorState) ErrorProneScanner.visitBlock
(com.sun.source.tree.BlockTree tree, VisitorState visitorState) ErrorProneScanner.visitBreak
(com.sun.source.tree.BreakTree tree, VisitorState visitorState) ErrorProneScanner.visitCase
(com.sun.source.tree.CaseTree tree, VisitorState visitorState) ErrorProneScanner.visitCatch
(com.sun.source.tree.CatchTree tree, VisitorState visitorState) ErrorProneScanner.visitClass
(com.sun.source.tree.ClassTree tree, VisitorState visitorState) ErrorProneScanner.visitCompilationUnit
(com.sun.source.tree.CompilationUnitTree tree, VisitorState visitorState) ErrorProneScanner.visitCompoundAssignment
(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState visitorState) ErrorProneScanner.visitConditionalExpression
(com.sun.source.tree.ConditionalExpressionTree tree, VisitorState visitorState) ErrorProneScanner.visitContinue
(com.sun.source.tree.ContinueTree tree, VisitorState visitorState) ErrorProneScanner.visitDoWhileLoop
(com.sun.source.tree.DoWhileLoopTree tree, VisitorState visitorState) ErrorProneScanner.visitEmptyStatement
(com.sun.source.tree.EmptyStatementTree tree, VisitorState visitorState) ErrorProneScanner.visitEnhancedForLoop
(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState visitorState) ErrorProneScanner.visitExpressionStatement
(com.sun.source.tree.ExpressionStatementTree tree, VisitorState visitorState) ErrorProneScanner.visitForLoop
(com.sun.source.tree.ForLoopTree tree, VisitorState visitorState) ErrorProneScanner.visitIdentifier
(com.sun.source.tree.IdentifierTree tree, VisitorState visitorState) ErrorProneScanner.visitIf
(com.sun.source.tree.IfTree tree, VisitorState visitorState) ErrorProneScanner.visitImport
(com.sun.source.tree.ImportTree tree, VisitorState visitorState) ErrorProneScanner.visitInstanceOf
(com.sun.source.tree.InstanceOfTree tree, VisitorState visitorState) ErrorProneScanner.visitIntersectionType
(com.sun.source.tree.IntersectionTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitLabeledStatement
(com.sun.source.tree.LabeledStatementTree tree, VisitorState visitorState) ErrorProneScanner.visitLambdaExpression
(com.sun.source.tree.LambdaExpressionTree tree, VisitorState visitorState) ErrorProneScanner.visitLiteral
(com.sun.source.tree.LiteralTree tree, VisitorState visitorState) ErrorProneScanner.visitMemberReference
(com.sun.source.tree.MemberReferenceTree tree, VisitorState visitorState) ErrorProneScanner.visitMemberSelect
(com.sun.source.tree.MemberSelectTree tree, VisitorState visitorState) ErrorProneScanner.visitMethod
(com.sun.source.tree.MethodTree tree, VisitorState visitorState) ErrorProneScanner.visitMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, VisitorState visitorState) ErrorProneScanner.visitModifiers
(com.sun.source.tree.ModifiersTree tree, VisitorState visitorState) ErrorProneScanner.visitNewArray
(com.sun.source.tree.NewArrayTree tree, VisitorState visitorState) ErrorProneScanner.visitNewClass
(com.sun.source.tree.NewClassTree tree, VisitorState visitorState) ErrorProneScanner.visitParameterizedType
(com.sun.source.tree.ParameterizedTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitParenthesized
(com.sun.source.tree.ParenthesizedTree tree, VisitorState visitorState) ErrorProneScanner.visitPrimitiveType
(com.sun.source.tree.PrimitiveTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitReturn
(com.sun.source.tree.ReturnTree tree, VisitorState visitorState) ErrorProneScanner.visitSwitch
(com.sun.source.tree.SwitchTree tree, VisitorState visitorState) ErrorProneScanner.visitSynchronized
(com.sun.source.tree.SynchronizedTree tree, VisitorState visitorState) ErrorProneScanner.visitThrow
(com.sun.source.tree.ThrowTree tree, VisitorState visitorState) ErrorProneScanner.visitTry
(com.sun.source.tree.TryTree tree, VisitorState visitorState) ErrorProneScanner.visitTypeCast
(com.sun.source.tree.TypeCastTree tree, VisitorState visitorState) ErrorProneScanner.visitTypeParameter
(com.sun.source.tree.TypeParameterTree tree, VisitorState visitorState) ErrorProneScanner.visitUnary
(com.sun.source.tree.UnaryTree tree, VisitorState visitorState) ErrorProneScanner.visitUnionType
(com.sun.source.tree.UnionTypeTree tree, VisitorState visitorState) ErrorProneScanner.visitVariable
(com.sun.source.tree.VariableTree tree, VisitorState visitorState) ErrorProneScanner.visitWhileLoop
(com.sun.source.tree.WhileLoopTree tree, VisitorState visitorState) ErrorProneScanner.visitWildcard
(com.sun.source.tree.WildcardTree tree, VisitorState visitorState) -
Uses of VisitorState in com.google.errorprone.suppliers
Methods in com.google.errorprone.suppliers with parameters of type VisitorState -
Uses of VisitorState in com.google.errorprone.util
Methods in com.google.errorprone.util with parameters of type VisitorStateModifier and TypeMethodDescriptionstatic Set<com.sun.tools.javac.util.Name>
ASTHelpers.annotationsAmong
(com.sun.tools.javac.code.Symbol sym, Set<? extends com.sun.tools.javac.util.Name> annotationClasses, VisitorState state) Determines which of a set of annotations are present on a symbol.static boolean
ASTHelpers.canBeRemoved
(com.sun.tools.javac.code.Symbol symbol, VisitorState state) Returns whether this symbol is safe to remove.static boolean
ASTHelpers.containsComments
(com.sun.source.tree.Tree tree, VisitorState state) Returns whether the giventree
contains any comments in its source.static com.google.common.collect.ImmutableList<com.sun.tools.javac.code.Symbol.VarSymbol>
FindIdentifiers.findAllFields
(com.sun.tools.javac.code.Type classType, VisitorState state) Finds all the visible fields declared or inherited in the target classstatic com.google.common.collect.ImmutableSet<com.sun.tools.javac.code.Symbol.VarSymbol>
FindIdentifiers.findAllIdents
(VisitorState state) Finds the set of all bare variable identifiers in scope at the current location.static com.sun.source.tree.ClassTree
ASTHelpers.findClass
(com.sun.tools.javac.code.Symbol.ClassSymbol symbol, VisitorState state) Returns the class tree that matches the given symbol within the compilation unit, or null if none was found.static com.google.common.collect.ImmutableList<Commented<com.sun.source.tree.ExpressionTree>>
Comments.findCommentsForArguments
(com.sun.source.tree.MethodInvocationTree methodInvocationTree, VisitorState state) Attach comments to nodes on arguments of method calls.static com.google.common.collect.ImmutableList<Commented<com.sun.source.tree.ExpressionTree>>
Comments.findCommentsForArguments
(com.sun.source.tree.NewClassTree newClassTree, VisitorState state) Attach comments to nodes on arguments of constructor calls.static com.sun.source.tree.MethodTree
ASTHelpers.findEnclosingMethod
(VisitorState state) Finds the enclosingMethodTree
.static com.sun.tools.javac.code.Symbol
FindIdentifiers.findIdent
(String name, VisitorState state) Finds a variable declaration with the given name that is in scope at the current location.static com.sun.tools.javac.code.Symbol
FindIdentifiers.findIdent
(String name, VisitorState state, com.sun.tools.javac.code.Kinds.KindSelector kind) Finds a declaration with the given name and type that is in scope at the current location.static com.sun.source.tree.MethodTree
ASTHelpers.findMethod
(com.sun.tools.javac.code.Symbol.MethodSymbol symbol, VisitorState state) Returns the method tree that matches the given symbol within the compilation unit, or null if none was found.static com.google.common.collect.ImmutableSet<com.sun.tools.javac.code.Symbol.VarSymbol>
FindIdentifiers.findUnusedIdentifiers
(VisitorState state) Finds all variable declarations which are unused at this point in the AST (i.e.static com.sun.tools.javac.code.TypeAnnotations.AnnotationType
ASTHelpers.getAnnotationType
(com.sun.source.tree.AnnotationTree anno, com.sun.tools.javac.code.Symbol target, VisitorState state) Returns whetheranno
corresponds to a type annotation, ornull
if it could not be determined.static com.google.common.collect.ImmutableSet<String>
ASTHelpers.getGeneratedBy
(VisitorState state) Returns the value of the@Generated
annotation on enclosing classes, if present.static com.google.common.collect.ImmutableSet<String>
ASTHelpers.getGeneratedBy
(com.sun.tools.javac.code.Symbol symbol, VisitorState state) Returns the values of the given symbol'sGenerated
annotations, if present.static Nullness
ASTHelpers.getNullnessValue
(com.sun.source.tree.ExpressionTree expr, VisitorState state, NullnessAnalysis nullnessAnalysis) Returns theNullness
for an expression as determined by the nullness dataflow analysis.static com.google.common.collect.ImmutableSet<com.sun.tools.javac.code.Type>
ASTHelpers.getThrownExceptions
(com.sun.source.tree.Tree tree, VisitorState state) Returns the exceptions thrown bytree
.static boolean
ASTHelpers.hasAnnotation
(com.sun.source.tree.Tree tree, Class<? extends Annotation> annotationClass, VisitorState state) Deprecated.static boolean
ASTHelpers.hasAnnotation
(com.sun.source.tree.Tree tree, String annotationClass, VisitorState state) Check for the presence of an annotation, considering annotation inheritance.static boolean
ASTHelpers.hasAnnotation
(com.sun.tools.javac.code.Symbol sym, Class<? extends Annotation> annotationClass, VisitorState state) Deprecated.preferASTHelpers.hasAnnotation(Symbol, String, VisitorState)
to avoid needing a runtime dependency on the annotation class, and to prevent issues if there is skew between the definition of the annotation on the runtime and compile-time classpathsstatic boolean
ASTHelpers.hasAnnotation
(com.sun.tools.javac.code.Symbol sym, String annotationClass, VisitorState state) Determines whether a symbol has an annotation of the given type.static boolean
ASTHelpers.hasNoExplicitType
(com.sun.source.tree.VariableTree tree, VisitorState state) Returnstrue
if this is a `var` or a lambda parameter that has no explicit type.static boolean
ASTHelpers.hasOverloadWithOnlyOneParameter
(com.sun.tools.javac.code.Symbol.MethodSymbol existingMethod, com.sun.tools.javac.util.Name targetMethodName, com.sun.tools.javac.code.Type onlyParameterType, VisitorState state) Returns whetherexistingMethod
has an overload (or "nearly" an overload) with the giventargetMethodName
, and only a single parameter of typeonlyParameterType
.static boolean
ASTHelpers.inSamePackage
(com.sun.tools.javac.code.Symbol targetSymbol, VisitorState state) Return true if the given symbol is defined in the current package.static boolean
ASTHelpers.isBugCheckerCode
(VisitorState state) Returnstrue
if the code is in a BugChecker class.static boolean
ASTHelpers.isCastable
(com.sun.tools.javac.code.Type s, com.sun.tools.javac.code.Type t, VisitorState state) Returns true iferasure(s)
is castable toerasure(t)
.static boolean
ASTHelpers.isCheckedExceptionType
(com.sun.tools.javac.code.Type t, VisitorState state) Returns true ift
is a subtype of Throwable but not a subtype of RuntimeException or Error.static boolean
ASTHelpers.isInStaticInitializer
(VisitorState state) Attempts to detect whether we're in a static-initializer-like context: that includes direct assignments to static fields, assignments to enum fields, being contained within an expression which is ultimately assigned to a static field.static boolean
ASTHelpers.isJUnitTestCode
(VisitorState state) Returns true if the leaf node in theTreePath
fromstate
sits somewhere underneath a class or method that is marked as JUnit 3 or 4 test code.static boolean
ASTHelpers.isKotlin
(com.sun.tools.javac.code.Symbol symbol, VisitorState state) Returnstrue
if this symbol was declared in Kotlin source.static boolean
ASTHelpers.isSameType
(com.sun.tools.javac.code.Type s, com.sun.tools.javac.code.Type t, VisitorState state) Returns true iferasure(s) == erasure(t)
.static boolean
ASTHelpers.isSubtype
(com.sun.tools.javac.code.Type s, com.sun.tools.javac.code.Type t, VisitorState state) Returns true iferasure(s) <: erasure(t)
.static boolean
ASTHelpers.isTestNgTestCode
(VisitorState state) Returns true if the leaf node in theTreePath
fromstate
sits somewhere underneath a class or method that is marked as TestNG test code.static boolean
ASTHelpers.isVoidType
(com.sun.tools.javac.code.Type type, VisitorState state) Return true if the given type is 'void' or 'Void'.static List<com.sun.source.tree.ExpressionTree>
ASTHelpers.matchBinaryTree
(com.sun.source.tree.BinaryTree tree, List<Matcher<com.sun.source.tree.ExpressionTree>> matchers, VisitorState state) Given a BinaryTree to match against and a list of two matchers, applies the matchers to the operands in both orders.static boolean
ASTHelpers.methodIsPublicAndNotAnOverride
(com.sun.tools.javac.code.Symbol.MethodSymbol method, VisitorState state) Returns true if the given method symbol is public (both the method and the enclosing class) and does not have a super-method (i.e., it is not an@Override
).static boolean
ASTHelpers.requiresParentheses
(com.sun.source.tree.ExpressionTree expression, VisitorState state) Checks whether an expression requires parentheses.static com.sun.tools.javac.code.Symbol.MethodSymbol
ASTHelpers.resolveExistingMethod
(VisitorState state, com.sun.tools.javac.code.Symbol.TypeSymbol base, com.sun.tools.javac.util.Name name, Iterable<com.sun.tools.javac.code.Type> argTypes, Iterable<com.sun.tools.javac.code.Type> tyargTypes) Given a Type (base
), find the method namedname
, with the appropriateargTypes
andtyargTypes
and return its MethodSymbol.abstract boolean
Visibility.shouldBeVisible
(com.sun.source.tree.Tree tree, VisitorState state) Whethertree
should be visible from the path instate
assuming we're in prod code.abstract boolean
Visibility.shouldBeVisible
(com.sun.tools.javac.code.Symbol symbol, VisitorState state) Whethersymbol
should be visible from the path instate
assuming we're in prod code.static ASTHelpers.TargetType
ASTHelpers.targetType
(VisitorState state) Returns the target type of the tree at the givenVisitorState
's path, or elsenull
.Constructors in com.google.errorprone.util with parameters of type VisitorState
ASTHelpers.hasAnnotation(Symbol, String, VisitorState)
to avoid needing a runtime dependency on the annotation class, and to prevent issues if there is skew between the definition of the annotation on the runtime and compile-time classpaths