public class LockVisitor extends BaseTypeVisitor<LockChecker>
BaseTypeVisitor.TypeValidator
checker, options, typeValidator, visitorState
elements, root, trees, types
Constructor and Description |
---|
LockVisitor(LockChecker checker,
CompilationUnitTree root) |
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 boolean |
checkOverride(MethodTree overriderTree,
AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
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)
Tests that the qualifiers present on the useType are valid qualifiers,
given the qualifiers on the declaration of the type, declarationType.
|
protected List<String> |
methodHolding(ExecutableElement element) |
Void |
visitIdentifier(IdentifierTree node,
Void p) |
Void |
visitMemberSelect(MemberSelectTree node,
Void p) |
Void |
visitMethod(MethodTree node,
Void p)
Performs pseudo-assignment check: 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 |
visitSynchronized(SynchronizedTree node,
Void p) |
Void |
visitVariable(VariableTree node,
Void p) |
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConstructorInvocation, checkDefaultConstructor, checkForAnnotatedJdk, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createTypeValidator, enclosingMemberSelect, enclosingStatement, isAccessAllowed, isAssignable, isValidUse, isValidUse, isVectorCopyInto, scan, shouldSkipUses, typeCheckVectorCopyIntoArgument, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitInstanceOf, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitTypeCast, visitTypeParameter, visitUnary
getCurrentPath, scan
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(LockChecker checker, CompilationUnitTree root)
public Void visitVariable(VariableTree node, Void p)
visitVariable
in interface TreeVisitor<Void,Void>
visitVariable
in class BaseTypeVisitor<LockChecker>
public Void visitIdentifier(IdentifierTree node, Void p)
visitIdentifier
in interface TreeVisitor<Void,Void>
visitIdentifier
in class BaseTypeVisitor<LockChecker>
public Void visitMemberSelect(MemberSelectTree node, Void p)
visitMemberSelect
in interface TreeVisitor<Void,Void>
visitMemberSelect
in class TreeScanner<Void,Void>
public Void visitSynchronized(SynchronizedTree node, Void p)
visitSynchronized
in interface TreeVisitor<Void,Void>
visitSynchronized
in class TreeScanner<Void,Void>
public Void visitMethod(MethodTree node, Void p)
BaseTypeVisitor
visitMethod
in interface TreeVisitor<Void,Void>
visitMethod
in class BaseTypeVisitor<LockChecker>
public Void visitMethodInvocation(MethodInvocationTree node, Void p)
BaseTypeVisitor
visitMethodInvocation
in interface TreeVisitor<Void,Void>
visitMethodInvocation
in class BaseTypeVisitor<LockChecker>
protected boolean checkOverride(MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, Void p)
BaseTypeVisitor
This method returns the result of the check, but also emits error messages as a side effect.
checkOverride
in class BaseTypeVisitor<LockChecker>
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, MethodInvocationTree node)
BaseTypeVisitor
checkMethodInvocability
in class BaseTypeVisitor<LockChecker>
method
- the type of the invoked methodnode
- the method invocation nodeprotected List<String> methodHolding(ExecutableElement element)
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType)
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<LockChecker>
declarationType
- the type of the class (TypeElement)useType
- the use of the class (instance type)