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 java.util.ArrayDeque<MethodTree> |
currentMethods |
protected boolean |
debugSpew |
protected java.util.ArrayDeque<Effect> |
effStack |
atypeFactory, checker, contractsUtils, positions, typeValidator, visitorStateelements, root, trees, types| Constructor and Description |
|---|
GuiEffectVisitor(BaseTypeChecker checker) |
| Modifier and Type | Method and Description |
|---|---|
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.invalid" 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 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,
Tree tree)
Tests that the qualifiers present on the useType are valid qualifiers, given the qualifiers
on the declaration of the type, declarationType.
|
java.lang.Void |
visitAssignment(AssignmentTree node,
java.lang.Void p)
Performs two checks: subtyping and assignability checks, using
BaseTypeVisitor.commonAssignmentCheck(Tree, ExpressionTree, String). |
java.lang.Void |
visitMethod(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(MethodInvocationTree node,
java.lang.Void p)
Performs a method invocation check.
|
java.lang.Void |
visitReturn(ReturnTree node,
java.lang.Void p)
Checks that the type of the return expression is a subtype of the enclosing method required
return type.
|
java.lang.Void |
visitVariable(VariableTree node,
java.lang.Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createTypeValidator, enclosingMemberSelect, enclosingStatement, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, processClassTree, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitNewArray, visitNewClass, visitParameterizedType, visitThrow, visitTypeCast, visitTypeParameter, visitUnaryvisitgetCurrentPath, scanreduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitTry, visitUnionType, visitWhileLoop, visitWildcardprotected final boolean debugSpew
protected final java.util.ArrayDeque<Effect> effStack
protected final java.util.ArrayDeque<MethodTree> currentMethods
public GuiEffectVisitor(BaseTypeChecker checker)
protected GuiEffectTypeFactory createTypeFactory()
BaseTypeVisitorThe 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)
BaseTypeVisitorThis 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)
BaseTypeVisitorThis exists so that subclasses can subclass OverrideChecker and use their subclass instead of using OverrideChecker itself.
createOverrideChecker in class BaseTypeVisitor<GuiEffectTypeFactory>protected java.util.Set<? extends javax.lang.model.element.AnnotationMirror> getExceptionParameterLowerBoundAnnotations()
BaseTypeVisitorNote: 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, Tree tree)
BaseTypeVisitorThe 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.
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 visitVariable(VariableTree node, java.lang.Void p)
visitVariable in interface TreeVisitor<java.lang.Void,java.lang.Void>visitVariable in class BaseTypeVisitor<GuiEffectTypeFactory>public java.lang.Void visitAssignment(AssignmentTree node, java.lang.Void p)
BaseTypeVisitorBaseTypeVisitor.commonAssignmentCheck(Tree, ExpressionTree, String).
If the subtype check fails, it issues a "assignment.type.incompatible" error.
visitAssignment in interface TreeVisitor<java.lang.Void,java.lang.Void>visitAssignment in class BaseTypeVisitor<GuiEffectTypeFactory>public java.lang.Void visitReturn(ReturnTree node, java.lang.Void p)
BaseTypeVisitorvisitReturn in interface TreeVisitor<java.lang.Void,java.lang.Void>visitReturn in class BaseTypeVisitor<GuiEffectTypeFactory>public java.lang.Void visitMethodInvocation(MethodInvocationTree node, java.lang.Void p)
BaseTypeVisitorAn invocation of a method, m, on the receiver, r is valid only if:
visitMethodInvocation in interface TreeVisitor<java.lang.Void,java.lang.Void>visitMethodInvocation in class BaseTypeVisitor<GuiEffectTypeFactory>public java.lang.Void visitMethod(MethodTree node, java.lang.Void p)
BaseTypeVisitorThe override rule specifies that a method, m1, may override a method m2 only if:
visitMethod in interface TreeVisitor<java.lang.Void,java.lang.Void>visitMethod in class BaseTypeVisitor<GuiEffectTypeFactory>