public class ImmutabilityVisitor extends BaseTypeVisitor<ImmutabilitySubchecker>
BaseTypeVisitor.TypeValidatorannoFactory, annoTypes, checker, options, typeValidator, visitorStateatypeFactory, elements, root, trees, types| Constructor and Description |
|---|
ImmutabilityVisitor(ImmutabilitySubchecker checker,
@Nullable CompilationUnitTree root) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isAssignable(@Mutable AnnotatedTypeMirror varType,
@Mutable AnnotatedTypeMirror receiverType,
@Nullable Tree varTree)
Tests whether the variable accessed is an assignable variable or not,
given the current scope
TODO: document which parameters are nullable; e.g.
|
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.
|
boolean |
validateTypeOf(@Nullable Tree tree)
Tests whether the tree expressed by the passed type tree is a valid type,
and emits an error if that is not the case (e.g.
|
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConstructorInvocation, checkDefaultConstructor, checkForAnnotatedJdk, checkMethodInvocability, checkOverride, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createTypeValidator, enclosingMemberSelect, enclosingStatement, isAccessAllowed, isValidUse, isValidUse, isVectorCopyInto, scan, shouldSkipUses, typeCheckVectorCopyIntoArgument, visitAnnotation, visitArrayAccess, visitAssignment, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitMethod, visitMethodInvocation, 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, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitThrow, visitTry, visitUnionType, visitWhileLoop, visitWildcardpublic ImmutabilityVisitor(ImmutabilitySubchecker checker, @Nullable CompilationUnitTree root)
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<ImmutabilitySubchecker>declarationType - the type of the class (TypeElement)useType - the use of the class (instance type)public boolean validateTypeOf(@Nullable Tree tree)
BaseTypeVisitorvalidateTypeOf in class BaseTypeVisitor<ImmutabilitySubchecker>tree - the AST type supplied by the userpublic boolean isAssignable(@Mutable AnnotatedTypeMirror varType, @Mutable AnnotatedTypeMirror receiverType, @Nullable Tree varTree)
BaseTypeVisitorisAssignable in class BaseTypeVisitor<ImmutabilitySubchecker>varType - the annotated variable typevarTree - tree used to access the variable