public class GuiEffectVisitor extends BaseTypeVisitor<GuiEffectTypeFactory>
Modifier and Type | Class and Description |
---|---|
protected class |
GuiEffectVisitor.GuiEffectOverrideChecker |
BaseTypeVisitor.OverrideChecker
Modifier and Type | Field and Description |
---|---|
protected ArrayDeque<MethodTree> |
currentMethods |
protected boolean |
debugSpew
Whether or not to display debugging information.
|
protected ArrayDeque<Effect> |
effStack |
atypeFactory, checker, DETERMINISTIC, inferPurity, methodTree, positions, PURE, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeValidator, unusedWhenElement
elements, root, trees, treesWithSuppressWarnings, types
Constructor and Description |
---|
GuiEffectVisitor(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType,
ExecutableElement constructorElement)
Issue a warning if the result type of the constructor is not top.
|
protected void |
checkExtendsImplements(ClassTree classTree)
If "@B class Y extends @A X {}", then enforce that @B must be a subtype of @A.
|
protected void |
checkForPolymorphicQualifiers(ClassTree classTree)
Issues an "invalid.polymorphic.qualifier" error for all polymorphic annotations written on the
class declaration.
|
protected void |
checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method,
MethodInvocationTree node)
Tests whether the method can be invoked using the receiver of the 'node' method invocation, and
issues a "method.invocation" if the invocation is invalid.
|
protected BaseTypeVisitor.OverrideChecker |
createOverrideChecker(Tree overriderTree,
AnnotatedTypeMirror.AnnotatedExecutableType overrider,
AnnotatedTypeMirror overridingType,
AnnotatedTypeMirror overridingReturnType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
AnnotatedTypeMirror overriddenReturnType)
Create an OverrideChecker.
|
protected GuiEffectTypeFactory |
createTypeFactory()
Constructs an instance of the appropriate type factory for the implemented type system.
|
protected Set<? extends AnnotationMirror> |
getExceptionParameterLowerBoundAnnotations()
Returns a set of AnnotationMirrors that is a lower bound for exception parameters.
|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
AnnotatedTypeMirror.AnnotatedDeclaredType useType,
Tree tree)
Tests that the qualifiers present on
useType are valid qualifiers, given the qualifiers
on the declaration of the type, declarationType . |
void |
processClassTree(ClassTree classTree)
Type-check classTree.
|
Void |
visitLambdaExpression(LambdaExpressionTree node,
Void p) |
Void |
visitMethod(MethodTree node,
Void p)
Checks that the method obeys override and subtype rules to all overridden methods.
|
Void |
visitMethodInvocation(MethodInvocationTree node,
Void p)
Performs a method invocation check.
|
Void |
visitNewClass(NewClassTree node,
Void p)
Performs a new class invocation check.
|
checkAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkFieldInvariantDeclarations, checkForPolymorphicQualifiers, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurity, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isTypeCastSafe, isValidUse, isValidUse, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotatedType, visitAnnotatedType, visitAnnotation, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitMemberReference, visitNewArray, visitReturn, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypes
visit
getCurrentPath, scan
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
protected final boolean debugSpew
protected final ArrayDeque<Effect> effStack
protected final ArrayDeque<MethodTree> currentMethods
public GuiEffectVisitor(BaseTypeChecker checker)
protected GuiEffectTypeFactory createTypeFactory()
BaseTypeVisitor
The default implementation uses the checker naming convention to create the appropriate type
factory. If no factory is found, it returns BaseAnnotatedTypeFactory
. It reflectively
invokes the constructor that accepts this checker and compilation unit tree (in that order) as
arguments.
Subclasses have to override this method to create the appropriate visitor if they do not follow the checker naming convention.
createTypeFactory
in class BaseTypeVisitor<GuiEffectTypeFactory>
protected void checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, MethodInvocationTree node)
BaseTypeVisitor
This implementation tests whether the receiver in the method invocation is a subtype of the method receiver type. This behavior can be specialized by overriding skipReceiverSubtypeCheck.
checkMethodInvocability
in class BaseTypeVisitor<GuiEffectTypeFactory>
method
- the type of the invoked methodnode
- the method invocation nodeprotected BaseTypeVisitor.OverrideChecker createOverrideChecker(Tree overriderTree, AnnotatedTypeMirror.AnnotatedExecutableType overrider, AnnotatedTypeMirror overridingType, AnnotatedTypeMirror overridingReturnType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, AnnotatedTypeMirror overriddenReturnType)
BaseTypeVisitor
This exists so that subclasses can subclass OverrideChecker and use their subclass instead of using OverrideChecker itself.
createOverrideChecker
in class BaseTypeVisitor<GuiEffectTypeFactory>
overriderTree
- the AST node of the overriding method or method referenceoverrider
- the type of the overriding methodoverridingType
- the type enclosing the overrider method, usually an AnnotatedDeclaredType;
for Method References may be something elseoverridingReturnType
- the return type of the overriding methodoverridden
- the type of the overridden methodoverriddenType
- the declared type enclosing the overridden methodoverriddenReturnType
- the return type of the overridden methodprotected Set<? extends AnnotationMirror> getExceptionParameterLowerBoundAnnotations()
BaseTypeVisitor
This implementation returns top; subclasses can change this behavior.
Note: by default this method is called by BaseTypeVisitor.getThrowUpperBoundAnnotations()
, so that
this annotation is enforced.
getExceptionParameterLowerBoundAnnotations
in class BaseTypeVisitor<GuiEffectTypeFactory>
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, Tree tree)
BaseTypeVisitor
useType
are valid qualifiers, given the qualifiers
on the declaration of the type, declarationType
.
The check is shallow, as it does not descend into generic or array types (i.e. only
performing the validity check on the raw type or outermost array dimension). BaseTypeVisitor.validateTypeOf(Tree)
would call this for each type argument or array dimension
separately.
In most cases, useType
simply needs to be a subtype of declarationType
. If a
type system makes exceptions to this rule, its implementation should override this method.
This method is not called if BaseTypeValidator.shouldCheckTopLevelDeclaredOrPrimitiveType(AnnotatedTypeMirror, Tree)
returns false -- by default, it is not called on the top level for locals and expressions. To
enforce a type validity property everywhere, override methods such as BaseTypeValidator.visitDeclared(org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType, com.sun.source.tree.Tree)
rather than this method.
isValidUse
in class BaseTypeVisitor<GuiEffectTypeFactory>
declarationType
- the type of the class (TypeElement)useType
- the use of the class (instance type)tree
- the tree where the type is usedpublic Void visitLambdaExpression(LambdaExpressionTree node, Void p)
visitLambdaExpression
in interface TreeVisitor<Void,Void>
visitLambdaExpression
in class BaseTypeVisitor<GuiEffectTypeFactory>
protected void checkExtendsImplements(ClassTree classTree)
BaseTypeVisitor
Also validate the types of the extends and implements clauses.
checkExtendsImplements
in class BaseTypeVisitor<GuiEffectTypeFactory>
classTree
- class tree to checkprotected void checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement)
BaseTypeVisitor
BaseTypeVisitor.isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType,AnnotatedTypeMirror.AnnotatedDeclaredType,Tree)
.checkConstructorResult
in class BaseTypeVisitor<GuiEffectTypeFactory>
constructorType
- AnnotatedExecutableType for the constructorconstructorElement
- element that declares the constructorprotected void checkForPolymorphicQualifiers(ClassTree classTree)
BaseTypeVisitor
checkForPolymorphicQualifiers
in class BaseTypeVisitor<GuiEffectTypeFactory>
classTree
- the class to checkpublic Void visitMethodInvocation(MethodInvocationTree node, Void p)
BaseTypeVisitor
An invocation of a method, m, on the receiver, r is valid only if:
visitMethodInvocation
in interface TreeVisitor<Void,Void>
visitMethodInvocation
in class BaseTypeVisitor<GuiEffectTypeFactory>
public Void visitMethod(MethodTree node, Void p)
BaseTypeVisitor
The override rule specifies that a method, m1, may override a method m2 only if:
visitMethod
in interface TreeVisitor<Void,Void>
visitMethod
in class BaseTypeVisitor<GuiEffectTypeFactory>
public Void visitNewClass(NewClassTree node, Void p)
BaseTypeVisitor
An invocation of a constructor, c, is valid only if:
visitNewClass
in interface TreeVisitor<Void,Void>
visitNewClass
in class BaseTypeVisitor<GuiEffectTypeFactory>
public void processClassTree(ClassTree classTree)
BaseTypeVisitor
BaseTypeVisitor.visitClass(ClassTree, Void)
.processClassTree
in class BaseTypeVisitor<GuiEffectTypeFactory>
classTree
- class to check