Class MustBeClosedChecker
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.AbstractMustBeClosedChecker
com.google.errorprone.bugpatterns.MustBeClosedChecker
- All Implemented Interfaces:
BugChecker.ClassTreeMatcher
,BugChecker.MethodInvocationTreeMatcher
,BugChecker.MethodTreeMatcher
,BugChecker.NewClassTreeMatcher
,Suppressible
,Serializable
public class MustBeClosedChecker extends AbstractMustBeClosedChecker implements BugChecker.MethodTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ClassTreeMatcher
Checks if a constructor or method annotated with
MustBeClosed
is called within the
resource variable initializer of a try-with-resources statement.- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.AbstractMustBeClosedChecker
AbstractMustBeClosedChecker.FixAggregator
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.BlockTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.CaseTreeMatcher, BugChecker.CatchTreeMatcher, BugChecker.ClassTreeMatcher, BugChecker.CompilationUnitTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.ConditionalExpressionTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.DoWhileLoopTreeMatcher, BugChecker.EmptyStatementTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.ExpressionStatementTreeMatcher, BugChecker.ForLoopTreeMatcher, BugChecker.IdentifierTreeMatcher, BugChecker.IfTreeMatcher, BugChecker.ImportTreeMatcher, BugChecker.InstanceOfTreeMatcher, BugChecker.IntersectionTypeTreeMatcher, BugChecker.LabeledStatementTreeMatcher, BugChecker.LambdaExpressionTreeMatcher, BugChecker.LiteralTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MemberSelectTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ModifiersTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<A,B>, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher
-
Field Summary
Fields inherited from class com.google.errorprone.bugpatterns.AbstractMustBeClosedChecker
HAS_MUST_BE_CLOSED_ANNOTATION
-
Constructor Summary
Constructors Constructor Description MustBeClosedChecker()
MustBeClosedChecker(ErrorProneFlags flags)
-
Method Summary
Modifier and Type Method Description Description
matchClass(com.sun.source.tree.ClassTree tree, VisitorState state)
Description
matchMethod(com.sun.source.tree.MethodTree tree, VisitorState state)
Check that theMustBeClosed
annotation is only used for constructors of AutoCloseables and methods that return an AutoCloseable.Description
matchMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, VisitorState state)
Check that invocations of methods annotated withMustBeClosed
are called within the resource variable initializer of a try-with-resources statement.Description
matchNewClass(com.sun.source.tree.NewClassTree tree, VisitorState state)
Check that construction of constructors annotated withMustBeClosed
occurs within the resource variable initializer of a try-with-resources statement.protected Description
matchNewClassOrMethodInvocation(com.sun.source.tree.ExpressionTree tree, VisitorState state, AbstractMustBeClosedChecker.FixAggregator aggregator)
Check that the expressiontree
occurs within the resource variable initializer of a try-with-resources statement.Methods inherited from class com.google.errorprone.bugpatterns.AbstractMustBeClosedChecker
addFix, findingPerMethod, findingPerSite, scanEntireMethodFor
Methods inherited from class com.google.errorprone.bugpatterns.BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegions
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.errorprone.matchers.Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
Constructor Details
-
MustBeClosedChecker
public MustBeClosedChecker() -
MustBeClosedChecker
-
-
Method Details
-
matchMethod
Check that theMustBeClosed
annotation is only used for constructors of AutoCloseables and methods that return an AutoCloseable.- Specified by:
matchMethod
in interfaceBugChecker.MethodTreeMatcher
-
matchMethodInvocation
public Description matchMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, VisitorState state)Check that invocations of methods annotated withMustBeClosed
are called within the resource variable initializer of a try-with-resources statement.- Specified by:
matchMethodInvocation
in interfaceBugChecker.MethodInvocationTreeMatcher
-
matchNewClass
Check that construction of constructors annotated withMustBeClosed
occurs within the resource variable initializer of a try-with-resources statement.- Specified by:
matchNewClass
in interfaceBugChecker.NewClassTreeMatcher
-
matchNewClassOrMethodInvocation
protected Description matchNewClassOrMethodInvocation(com.sun.source.tree.ExpressionTree tree, VisitorState state, AbstractMustBeClosedChecker.FixAggregator aggregator)Description copied from class:AbstractMustBeClosedChecker
Check that the expressiontree
occurs within the resource variable initializer of a try-with-resources statement.- Overrides:
matchNewClassOrMethodInvocation
in classAbstractMustBeClosedChecker
-
matchClass
- Specified by:
matchClass
in interfaceBugChecker.ClassTreeMatcher
-