public class LockVisitor extends BaseTypeVisitor<LockAnnotatedTypeFactory>
atypeFactory, checker, contractsUtils, positions, typeValidator, visitorState
elements, root, trees, types
Constructor and Description |
---|
LockVisitor(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,
java.lang.Void p)
Checks that an overriding method's return type, parameter types, and
receiver type are correct with respect to the annotations on the
overridden method's return type, parameter types, and receiver type.
|
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.
|
protected java.util.List<java.lang.String> |
methodHolding(javax.lang.model.element.ExecutableElement element) |
java.lang.Void |
visitIdentifier(com.sun.source.tree.IdentifierTree node,
java.lang.Void p) |
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.
|
java.lang.Void |
visitSynchronized(com.sun.source.tree.SynchronizedTree node,
java.lang.Void p) |
java.lang.Void |
visitVariable(com.sun.source.tree.VariableTree node,
java.lang.Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostconditions, checkConditionalPostconditionsConsistency, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkFlowExprParameters, checkForAnnotatedJdk, checkPostconditions, checkPostconditionsConsistency, checkPreconditions, checkPreconditionsConsistency, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createTypeFactory, createTypeValidator, enclosingMemberSelect, enclosingStatement, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, reportPurityErrors, scan, shouldSkipUses, typeCheckVectorCopyIntoArgument, validateTypeOf, visit, visitAnnotation, visitArrayAccess, visitAssignment, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitInstanceOf, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitTypeCast, visitTypeParameter, visitUnary
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitThrow, visitTry, visitUnionType, visitWhileLoop, visitWildcard
public LockVisitor(BaseTypeChecker checker)
public java.lang.Void visitVariable(com.sun.source.tree.VariableTree node, java.lang.Void p)
visitVariable
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitVariable
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitIdentifier(com.sun.source.tree.IdentifierTree node, java.lang.Void p)
visitIdentifier
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitIdentifier
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
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 java.lang.Void visitSynchronized(com.sun.source.tree.SynchronizedTree node, java.lang.Void p)
visitSynchronized
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitSynchronized
in class com.sun.source.util.TreeScanner<java.lang.Void,java.lang.Void>
public java.lang.Void visitMethod(com.sun.source.tree.MethodTree node, java.lang.Void p)
BaseTypeVisitor
visitMethod
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethod
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
public java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node, java.lang.Void p)
BaseTypeVisitor
visitMethodInvocation
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethodInvocation
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
protected boolean checkOverride(com.sun.source.tree.MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, java.lang.Void p)
BaseTypeVisitor
Furthermore, any contracts on the method must satisfy behavioral subtyping, that is, postconditions must be at least as strong as the postcondition on the superclass, and preconditions must be at most as strong as the condition on the superclass.
This method returns the result of the check, but also emits error messages as a side effect.
checkOverride
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
overriderTree
- the AST node of the overriding methodenclosingType
- the declared type enclosing the overrider methodoverridden
- the type of the overridden methodoverriddenType
- the declared type enclosing the overridden methodp
- an optional parameter (as supplied to visitor methods)protected void checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, com.sun.source.tree.MethodInvocationTree node)
BaseTypeVisitor
checkMethodInvocability
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
method
- the type of the invoked methodnode
- the method invocation nodeprotected java.util.List<java.lang.String> methodHolding(javax.lang.model.element.ExecutableElement element)
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.
For instance, in the IGJ type system, a @Mutable
is an invalid
qualifier for String
, as String
is declared as
@Immutable String
.
In most cases, useType
simply needs to be a subtype of
declarationType
, but there are exceptions. In IGJ, a variable may be
declared @ReadOnly String
, even though String
is
@Immutable String
; ReadOnly
is not a subtype of
Immutable
.
isValidUse
in class BaseTypeVisitor<LockAnnotatedTypeFactory>
declarationType
- the type of the class (TypeElement)useType
- the use of the class (instance type)tree
- the tree where the type is used