public class GuiEffectVisitor extends BaseTypeVisitor<GuiEffectTypeFactory>
BaseTypeVisitor.OverrideChecker
Modifier and Type | Field and Description |
---|---|
protected java.util.Stack<com.sun.source.tree.MethodTree> |
currentMethods |
protected boolean |
debugSpew |
protected java.util.Stack<Effect> |
effStack |
atypeFactory, checker, contractsUtils, positions, typeValidator, visitorState
elements, root, trees, types
Constructor and Description |
---|
GuiEffectVisitor(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method,
com.sun.source.tree.MethodInvocationTree node)
Tests whether the method can be invoked using the receiver of the 'node' method invocation,
and issues a "method.invocation.invalid" if the invocation is invalid.
|
protected boolean |
checkOverride(com.sun.source.tree.MethodTree overriderTree,
AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
Type checks that a method may override another method.
|
protected GuiEffectTypeFactory |
createTypeFactory()
Constructs an instance of the appropriate type factory for the implemented type system.
|
protected java.util.Set<? extends javax.lang.model.element.AnnotationMirror> |
getExceptionParameterLowerBoundAnnotations()
Returns a set of AnnotationMirrors that is a lower bound for exception parameters.
|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
AnnotatedTypeMirror.AnnotatedDeclaredType useType,
com.sun.source.tree.Tree tree)
Tests that the qualifiers present on the useType are valid qualifiers, given the qualifiers
on the declaration of the type, declarationType.
|
void |
processClassTree(com.sun.source.tree.ClassTree node)
Type-check classTree.
|
java.lang.Void |
visitMemberSelect(com.sun.source.tree.MemberSelectTree node,
java.lang.Void p) |
java.lang.Void |
visitMethod(com.sun.source.tree.MethodTree node,
java.lang.Void p)
Performs pseudo-assignment check: checks that the method obeys override and subtype rules to
all overridden methods.
|
java.lang.Void |
visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node,
java.lang.Void p)
Performs a method invocation check.
|
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodReferenceAsOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createOverrideChecker, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitVariable
visit
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitUnionType, visitWhileLoop, visitWildcard
protected final boolean debugSpew
protected final java.util.Stack<Effect> effStack
protected final java.util.Stack<com.sun.source.tree.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, com.sun.source.tree.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 boolean checkOverride(com.sun.source.tree.MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType)
BaseTypeVisitor
checkOverride
in class BaseTypeVisitor<GuiEffectTypeFactory>
overriderTree
- declaration tree of overriding methodenclosingType
- type of overriding classoverridden
- type of overridden methodoverriddenType
- type of overridden classBaseTypeVisitor.checkOverride(MethodTree, AnnotatedTypeMirror.AnnotatedExecutableType,
AnnotatedTypeMirror.AnnotatedDeclaredType, AnnotatedTypeMirror.AnnotatedExecutableType,
AnnotatedTypeMirror.AnnotatedDeclaredType)
protected java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getExceptionParameterLowerBoundAnnotations()
BaseTypeVisitor
Note: by default this method is called by getThrowUpperBoundAnnotations(), so that this annotation is enforced.
(Default is top)
getExceptionParameterLowerBoundAnnotations
in class BaseTypeVisitor<GuiEffectTypeFactory>
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, com.sun.source.tree.Tree tree)
BaseTypeVisitor
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
,
but there are exceptions.
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 java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node, java.lang.Void p)
BaseTypeVisitor
An invocation of a method, m, on the receiver, r is valid only if:
visitMethodInvocation
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethodInvocation
in class BaseTypeVisitor<GuiEffectTypeFactory>
public java.lang.Void visitMethod(com.sun.source.tree.MethodTree node, java.lang.Void p)
BaseTypeVisitor
The override rule specifies that a method, m1, may override a method m2 only if:
visitMethod
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethod
in class BaseTypeVisitor<GuiEffectTypeFactory>
public java.lang.Void visitMemberSelect(com.sun.source.tree.MemberSelectTree node, java.lang.Void p)
visitMemberSelect
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMemberSelect
in class com.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
public void processClassTree(com.sun.source.tree.ClassTree node)
BaseTypeVisitor
BaseTypeVisitor.visitClass(ClassTree, Void)
.processClassTree
in class BaseTypeVisitor<GuiEffectTypeFactory>
node
- class to check