Class ErrorProneScanner
java.lang.Object
com.sun.source.util.TreeScanner<Void,VisitorState>
com.sun.source.util.TreePathScanner<Void,VisitorState>
com.google.errorprone.scanner.Scanner
com.google.errorprone.scanner.ErrorProneScanner
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Void,
VisitorState>
Scans the parsed AST, looking for violations of any of the enabled checks.
- Author:
- Alex Eagle (alexeagle@google.com)
-
Constructor Summary
ConstructorDescriptionErrorProneScanner
(BugChecker... checkers) Create an error-prone scanner for the given checkers.ErrorProneScanner
(Iterable<BugChecker> checkers) Create an error-prone scanner for a non-hardcoded set of checkers.ErrorProneScanner
(Iterable<BugChecker> checkers, Map<String, BugPattern.SeverityLevel> severities) Create an error-prone scanner for a non-hardcoded set of checkers. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.collect.ImmutableSet
<BugChecker> protected Set
<? extends com.sun.tools.javac.util.Name> Returns a set of all the custom suppression annotation types used by theBugChecker
s in thisScanner
.protected void
handleError
(Suppressible s, Throwable t) Handles an exception thrown by an individual BugPattern.Returns a mapping between the canonical names of checks and theirBugPattern.SeverityLevel
.visitAnnotatedType
(com.sun.source.tree.AnnotatedTypeTree tree, VisitorState visitorState) visitAnnotation
(com.sun.source.tree.AnnotationTree tree, VisitorState visitorState) visitArrayAccess
(com.sun.source.tree.ArrayAccessTree tree, VisitorState visitorState) visitArrayType
(com.sun.source.tree.ArrayTypeTree tree, VisitorState visitorState) visitAssert
(com.sun.source.tree.AssertTree tree, VisitorState visitorState) visitAssignment
(com.sun.source.tree.AssignmentTree tree, VisitorState visitorState) visitBinary
(com.sun.source.tree.BinaryTree tree, VisitorState visitorState) visitBlock
(com.sun.source.tree.BlockTree tree, VisitorState visitorState) visitBreak
(com.sun.source.tree.BreakTree tree, VisitorState visitorState) visitCase
(com.sun.source.tree.CaseTree tree, VisitorState visitorState) visitCatch
(com.sun.source.tree.CatchTree tree, VisitorState visitorState) visitClass
(com.sun.source.tree.ClassTree tree, VisitorState visitorState) visitCompilationUnit
(com.sun.source.tree.CompilationUnitTree tree, VisitorState visitorState) visitCompoundAssignment
(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState visitorState) visitConditionalExpression
(com.sun.source.tree.ConditionalExpressionTree tree, VisitorState visitorState) visitContinue
(com.sun.source.tree.ContinueTree tree, VisitorState visitorState) visitDoWhileLoop
(com.sun.source.tree.DoWhileLoopTree tree, VisitorState visitorState) visitEmptyStatement
(com.sun.source.tree.EmptyStatementTree tree, VisitorState visitorState) visitEnhancedForLoop
(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState visitorState) visitExpressionStatement
(com.sun.source.tree.ExpressionStatementTree tree, VisitorState visitorState) visitForLoop
(com.sun.source.tree.ForLoopTree tree, VisitorState visitorState) visitIdentifier
(com.sun.source.tree.IdentifierTree tree, VisitorState visitorState) visitIf
(com.sun.source.tree.IfTree tree, VisitorState visitorState) visitImport
(com.sun.source.tree.ImportTree tree, VisitorState visitorState) visitInstanceOf
(com.sun.source.tree.InstanceOfTree tree, VisitorState visitorState) visitIntersectionType
(com.sun.source.tree.IntersectionTypeTree tree, VisitorState visitorState) visitLabeledStatement
(com.sun.source.tree.LabeledStatementTree tree, VisitorState visitorState) visitLambdaExpression
(com.sun.source.tree.LambdaExpressionTree tree, VisitorState visitorState) visitLiteral
(com.sun.source.tree.LiteralTree tree, VisitorState visitorState) visitMemberReference
(com.sun.source.tree.MemberReferenceTree tree, VisitorState visitorState) visitMemberSelect
(com.sun.source.tree.MemberSelectTree tree, VisitorState visitorState) visitMethod
(com.sun.source.tree.MethodTree tree, VisitorState visitorState) visitMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, VisitorState visitorState) visitModifiers
(com.sun.source.tree.ModifiersTree tree, VisitorState visitorState) visitNewArray
(com.sun.source.tree.NewArrayTree tree, VisitorState visitorState) visitNewClass
(com.sun.source.tree.NewClassTree tree, VisitorState visitorState) visitParameterizedType
(com.sun.source.tree.ParameterizedTypeTree tree, VisitorState visitorState) visitParenthesized
(com.sun.source.tree.ParenthesizedTree tree, VisitorState visitorState) visitPrimitiveType
(com.sun.source.tree.PrimitiveTypeTree tree, VisitorState visitorState) visitReturn
(com.sun.source.tree.ReturnTree tree, VisitorState visitorState) visitSwitch
(com.sun.source.tree.SwitchTree tree, VisitorState visitorState) visitSynchronized
(com.sun.source.tree.SynchronizedTree tree, VisitorState visitorState) visitThrow
(com.sun.source.tree.ThrowTree tree, VisitorState visitorState) visitTry
(com.sun.source.tree.TryTree tree, VisitorState visitorState) visitTypeCast
(com.sun.source.tree.TypeCastTree tree, VisitorState visitorState) visitTypeParameter
(com.sun.source.tree.TypeParameterTree tree, VisitorState visitorState) visitUnary
(com.sun.source.tree.UnaryTree tree, VisitorState visitorState) visitUnionType
(com.sun.source.tree.UnionTypeTree tree, VisitorState visitorState) visitVariable
(com.sun.source.tree.VariableTree tree, VisitorState visitorState) visitWhileLoop
(com.sun.source.tree.WhileLoopTree tree, VisitorState visitorState) visitWildcard
(com.sun.source.tree.WildcardTree tree, VisitorState visitorState) Methods inherited from class com.google.errorprone.scanner.Scanner
isSuppressed, reportMatch, scan, scan
Methods inherited from class com.sun.source.util.TreePathScanner
getCurrentPath
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitAnyPattern, visitBindingPattern, visitConstantCaseLabel, visitDeconstructionPattern, visitDefaultCaseLabel, visitErroneous, visitExports, visitModule, visitOpens, visitOther, visitPackage, visitPatternCaseLabel, visitProvides, visitRequires, visitSwitchExpression, visitUses, visitYield
-
Constructor Details
-
ErrorProneScanner
Create an error-prone scanner for the given checkers.- Parameters:
checkers
- The checkers that this scanner should use.
-
ErrorProneScanner
Create an error-prone scanner for a non-hardcoded set of checkers.- Parameters:
checkers
- The checkers that this scanner should use.
-
ErrorProneScanner
public ErrorProneScanner(Iterable<BugChecker> checkers, Map<String, BugPattern.SeverityLevel> severities) Create an error-prone scanner for a non-hardcoded set of checkers.- Parameters:
checkers
- The checkers that this scanner should use.severities
- The default check severities.
-
-
Method Details
-
getCustomSuppressionAnnotations
protected Set<? extends com.sun.tools.javac.util.Name> getCustomSuppressionAnnotations(VisitorState state) Description copied from class:Scanner
Returns a set of all the custom suppression annotation types used by theBugChecker
s in thisScanner
.- Overrides:
getCustomSuppressionAnnotations
in classScanner
-
visitAnnotation
- Specified by:
visitAnnotation
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitAnnotation
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitAnnotatedType
public Void visitAnnotatedType(com.sun.source.tree.AnnotatedTypeTree tree, VisitorState visitorState) - Specified by:
visitAnnotatedType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitAnnotatedType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitArrayAccess
- Specified by:
visitArrayAccess
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitArrayAccess
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitArrayType
- Specified by:
visitArrayType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitArrayType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitAssert
- Specified by:
visitAssert
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitAssert
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitAssignment
- Specified by:
visitAssignment
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitAssignment
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitBinary
- Specified by:
visitBinary
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitBinary
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitBlock
- Specified by:
visitBlock
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitBlock
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitBreak
- Specified by:
visitBreak
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitBreak
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitCase
- Specified by:
visitCase
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitCase
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitCatch
- Specified by:
visitCatch
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitCatch
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitClass
- Specified by:
visitClass
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitClass
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitCompilationUnit
public Void visitCompilationUnit(com.sun.source.tree.CompilationUnitTree tree, VisitorState visitorState) - Specified by:
visitCompilationUnit
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitCompilationUnit
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitCompoundAssignment
public Void visitCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState visitorState) - Specified by:
visitCompoundAssignment
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitCompoundAssignment
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitConditionalExpression
public Void visitConditionalExpression(com.sun.source.tree.ConditionalExpressionTree tree, VisitorState visitorState) - Specified by:
visitConditionalExpression
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitConditionalExpression
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitContinue
- Specified by:
visitContinue
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitContinue
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitDoWhileLoop
- Specified by:
visitDoWhileLoop
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitDoWhileLoop
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitEmptyStatement
public Void visitEmptyStatement(com.sun.source.tree.EmptyStatementTree tree, VisitorState visitorState) - Specified by:
visitEmptyStatement
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitEmptyStatement
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitEnhancedForLoop
public Void visitEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState visitorState) - Specified by:
visitEnhancedForLoop
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitEnhancedForLoop
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitExpressionStatement
public Void visitExpressionStatement(com.sun.source.tree.ExpressionStatementTree tree, VisitorState visitorState) - Specified by:
visitExpressionStatement
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitExpressionStatement
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitForLoop
- Specified by:
visitForLoop
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitForLoop
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitIdentifier
- Specified by:
visitIdentifier
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitIdentifier
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitIf
- Specified by:
visitIf
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitIf
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitImport
- Specified by:
visitImport
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitImport
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitInstanceOf
- Specified by:
visitInstanceOf
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitInstanceOf
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitIntersectionType
public Void visitIntersectionType(com.sun.source.tree.IntersectionTypeTree tree, VisitorState visitorState) - Specified by:
visitIntersectionType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitIntersectionType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitLabeledStatement
public Void visitLabeledStatement(com.sun.source.tree.LabeledStatementTree tree, VisitorState visitorState) - Specified by:
visitLabeledStatement
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitLabeledStatement
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitLambdaExpression
public Void visitLambdaExpression(com.sun.source.tree.LambdaExpressionTree tree, VisitorState visitorState) - Specified by:
visitLambdaExpression
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitLambdaExpression
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitLiteral
- Specified by:
visitLiteral
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitLiteral
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitMemberReference
public Void visitMemberReference(com.sun.source.tree.MemberReferenceTree tree, VisitorState visitorState) - Specified by:
visitMemberReference
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitMemberReference
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitMemberSelect
- Specified by:
visitMemberSelect
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitMemberSelect
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitMethod
- Specified by:
visitMethod
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitMethod
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitMethodInvocation
public Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, VisitorState visitorState) - Specified by:
visitMethodInvocation
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitMethodInvocation
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitModifiers
- Specified by:
visitModifiers
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitModifiers
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitNewArray
- Specified by:
visitNewArray
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitNewArray
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitNewClass
- Specified by:
visitNewClass
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitNewClass
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitParameterizedType
public Void visitParameterizedType(com.sun.source.tree.ParameterizedTypeTree tree, VisitorState visitorState) - Specified by:
visitParameterizedType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitParameterizedType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitParenthesized
public Void visitParenthesized(com.sun.source.tree.ParenthesizedTree tree, VisitorState visitorState) - Specified by:
visitParenthesized
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitParenthesized
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitPrimitiveType
public Void visitPrimitiveType(com.sun.source.tree.PrimitiveTypeTree tree, VisitorState visitorState) - Specified by:
visitPrimitiveType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitPrimitiveType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitReturn
- Specified by:
visitReturn
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitReturn
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitSwitch
- Specified by:
visitSwitch
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitSwitch
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitSynchronized
- Specified by:
visitSynchronized
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitSynchronized
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitThrow
- Specified by:
visitThrow
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitThrow
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitTry
- Specified by:
visitTry
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitTry
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitTypeCast
- Specified by:
visitTypeCast
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitTypeCast
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitTypeParameter
public Void visitTypeParameter(com.sun.source.tree.TypeParameterTree tree, VisitorState visitorState) - Specified by:
visitTypeParameter
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitTypeParameter
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitUnary
- Specified by:
visitUnary
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitUnary
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitUnionType
- Specified by:
visitUnionType
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitUnionType
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitVariable
- Specified by:
visitVariable
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitVariable
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitWhileLoop
- Specified by:
visitWhileLoop
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitWhileLoop
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
visitWildcard
- Specified by:
visitWildcard
in interfacecom.sun.source.tree.TreeVisitor<Void,
VisitorState> - Overrides:
visitWildcard
in classcom.sun.source.util.TreeScanner<Void,
VisitorState>
-
handleError
Handles an exception thrown by an individual BugPattern. By default, wraps the exception in anErrorProneError
and rethrows. May be overridden by subclasses, for example to log the error and continue.- Overrides:
handleError
in classScanner
-
severityMap
Description copied from class:Scanner
Returns a mapping between the canonical names of checks and theirBugPattern.SeverityLevel
.- Overrides:
severityMap
in classScanner
-
getBugCheckers
-