public class LockVisitor extends BaseTypeVisitor<LockChecker>
BaseTypeVisitor.TypeValidatorannoFactory, annoTypes, checker, options, typeValidator, visitorStateelements, root, trees, types| Constructor and Description |
|---|
LockVisitor(LockChecker checker,
@Nullable CompilationUnitTree root) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
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(@Nullable MethodTree overriderTree,
AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType,
AnnotatedTypeMirror.AnnotatedExecutableType overridden,
AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType,
@Nullable 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.
|
protected static boolean |
hasGuardedBy(@Mutable AnnotatedTypeMirror t) |
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<@ReadOnly String> |
methodHolding(@NonNull ExecutableElement element) |
@Nullable Void |
visitIdentifier(IdentifierTree node,
@Nullable Void p) |
@Nullable Void |
visitMemberSelect(MemberSelectTree node,
@Nullable Void p) |
@Nullable Void |
visitMethod(@Nullable MethodTree node,
@Nullable Void p)
Performs pseudo-assignment check: checks that the method obeys override
and subtype rules to all overridden methods.
|
@Nullable Void |
visitMethodInvocation(MethodInvocationTree node,
@Nullable Void p)
Performs a method invocation check.
|
@Nullable Void |
visitSynchronized(SynchronizedTree node,
@Nullable 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, visitVariablegetCurrentPath, scanreduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitThrow, visitTry, visitUnionType, visitWhileLoop, visitWildcardpublic LockVisitor(LockChecker checker, @Nullable CompilationUnitTree root)
public @Nullable Void visitIdentifier(IdentifierTree node, @Nullable Void p)
visitIdentifier in interface TreeVisitor<@Nullable Void,@Nullable Void>visitIdentifier in class BaseTypeVisitor<LockChecker>public @Nullable Void visitMemberSelect(MemberSelectTree node, @Nullable Void p)
visitMemberSelect in interface TreeVisitor<@Nullable Void,@Nullable Void>visitMemberSelect in class TreeScanner<@Nullable Void,@Nullable Void>protected static boolean hasGuardedBy(@Mutable AnnotatedTypeMirror t)
public @Nullable Void visitSynchronized(SynchronizedTree node, @Nullable Void p)
visitSynchronized in interface TreeVisitor<@Nullable Void,@Nullable Void>visitSynchronized in class TreeScanner<@Nullable Void,@Nullable Void>public @Nullable Void visitMethod(@Nullable MethodTree node, @Nullable Void p)
BaseTypeVisitorvisitMethod in interface TreeVisitor<@Nullable Void,@Nullable Void>visitMethod in class BaseTypeVisitor<LockChecker>public @Nullable Void visitMethodInvocation(MethodInvocationTree node, @Nullable Void p)
BaseTypeVisitorvisitMethodInvocation in interface TreeVisitor<@Nullable Void,@Nullable Void>visitMethodInvocation in class BaseTypeVisitor<LockChecker>protected boolean checkOverride(@Nullable MethodTree overriderTree, AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType, AnnotatedTypeMirror.AnnotatedExecutableType overridden, AnnotatedTypeMirror.AnnotatedDeclaredType overriddenType, @Nullable Void p)
BaseTypeVisitorThis 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 boolean checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, MethodInvocationTree node)
BaseTypeVisitorcheckMethodInvocability in class BaseTypeVisitor<LockChecker>method - the type of the invoked methodnode - the method invocation nodeprotected List<@ReadOnly String> methodHolding(@NonNull 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)