Class CalledMethodsVisitor
- java.lang.Object
-
- com.sun.source.util.TreeScanner<R,P>
-
- com.sun.source.util.TreePathScanner<R,P>
-
- org.checkerframework.framework.source.SourceVisitor<java.lang.Void,java.lang.Void>
-
- org.checkerframework.common.basetype.BaseTypeVisitor<AccumulationAnnotatedTypeFactory>
-
- org.checkerframework.common.accumulation.AccumulationVisitor
-
- org.checkerframework.checker.calledmethods.CalledMethodsVisitor
-
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
- Direct Known Subclasses:
ResourceLeakVisitor
public class CalledMethodsVisitor extends AccumulationVisitor
This visitor implements the custom error message "finalizer.invocation.invalid". It also supports counting the number of framework build calls.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
BaseTypeVisitor.FoundRequired, BaseTypeVisitor.OverrideChecker
-
-
Field Summary
-
Fields inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
atypeFactory, checker, DETERMINISTIC, ignoreTargetLocations, IMPURE, methodTree, positions, PURE, qualAllowedLocations, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElement
-
Fields inherited from class org.checkerframework.framework.source.SourceVisitor
elements, root, trees, treesWithSuppressWarnings, types
-
-
Constructor Summary
Constructors Constructor Description CalledMethodsVisitor(BaseTypeChecker checker)Creates a new CalledMethodsVisitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidreportMethodInvocabilityError(com.sun.source.tree.MethodInvocationTree tree, AnnotatedTypeMirror found, AnnotatedTypeMirror expected)Turns some "method.invocation.invalid" errors into "finalizer.invocation.invalid" errors.java.lang.VoidvisitAnnotation(com.sun.source.tree.AnnotationTree tree, java.lang.Void p)Issue an error at every EnsuresCalledMethodsVarArgs annotation, because using it is unsound.java.lang.VoidvisitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)Checks that the method obeys override and subtype rules to all overridden methods.java.lang.VoidvisitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, java.lang.Void p)Performs a method invocation check.-
Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitor
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkEnclosingExpr, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkForPolymorphicQualifiers, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createOverrideChecker, createQualAllowedLocations, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, isValidUse, processClassTree, reportCommonAssignmentError, reportPurityErrors, scan, setRoot, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateTargetLocation, validateType, validateTypeOf, validateVariablesTargetLocation, visitAnnotatedType, visitAnnotatedType, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypes, warnRedundantAnnotations
-
Methods inherited from class org.checkerframework.framework.source.SourceVisitor
visit
-
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard
-
-
-
-
Constructor Detail
-
CalledMethodsVisitor
public CalledMethodsVisitor(BaseTypeChecker checker)
Creates a new CalledMethodsVisitor.- Parameters:
checker- the type-checker associated with this visitor
-
-
Method Detail
-
visitAnnotation
public java.lang.Void visitAnnotation(com.sun.source.tree.AnnotationTree tree, java.lang.Void p)Issue an error at every EnsuresCalledMethodsVarArgs annotation, because using it is unsound.- Specified by:
visitAnnotationin interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>- Overrides:
visitAnnotationin classAccumulationVisitor
-
visitMethod
public java.lang.Void visitMethod(com.sun.source.tree.MethodTree tree, java.lang.Void p)Description copied from class:BaseTypeVisitorChecks that the method obeys override and subtype rules to all overridden methods. (Uses the pseudo-assignment logic to do so.)The override rule specifies that a method, m1, may override a method m2 only if:
- m1 return type is a subtype of m2
- m1 receiver type is a supertype of m2
- m1 parameters are supertypes of corresponding m2 parameters
- Specified by:
visitMethodin interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>- Overrides:
visitMethodin classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>
-
visitMethodInvocation
public java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, java.lang.Void p)Description copied from class:BaseTypeVisitorPerforms a method invocation check.An invocation of a method, m, on the receiver, r is valid only if:
- passed arguments are subtypes of corresponding m parameters
- r is a subtype of m receiver type
- if m is generic, passed type arguments are subtypes of m type variables
- Specified by:
visitMethodInvocationin interfacecom.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>- Overrides:
visitMethodInvocationin classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>
-
reportMethodInvocabilityError
protected void reportMethodInvocabilityError(com.sun.source.tree.MethodInvocationTree tree, AnnotatedTypeMirror found, AnnotatedTypeMirror expected)Turns some "method.invocation.invalid" errors into "finalizer.invocation.invalid" errors.- Overrides:
reportMethodInvocabilityErrorin classBaseTypeVisitor<AccumulationAnnotatedTypeFactory>- Parameters:
tree- the AST node at which to report the errorfound- the actual type of the receiverexpected- the expected type of the receiver
-
-