public class IGJAnnotatedTypeFactory extends BasicAnnotatedTypeFactory<IGJChecker>
Immutable
or ReadOnly
appearing in the source code.
Implicit Annotations for literals:
Immutable - any primitive literal (e.g. integer, long, boolean, etc.)
IGJBottom - a null literal
However, due to the default setting being similar to the implicit annotations, there is no significant distinction between the two in implementation.
Default Annotations:
This factory will add the Immutable
annotation to a type if the
input is
Immutable
ReadOnly
annotation to a type if the input is
IGJBottom
, a special bottom annotation to a type if
the input can be assigned to anything, like the following cases:
null
literal
ReadOnly
or AssignsFields
receiver type
Mutable
annotation to a type if
Furthermore, it resolves I
annotation to the proper annotation,
according to its specification (described in I
javadoc).
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected static @ReadOnly String |
IMMUTABILITY_KEY
the
I annotation value key |
checker, defaults, flow, FLOW_BY_DEFAULT, poly, treeAnnotator, typeAnnotator, useFlow
annotations, atypes, elements, env, fromTreeCache, qualHierarchy, root, trees, types, uid, visitorState
Constructor and Description |
---|
IGJAnnotatedTypeFactory(IGJChecker checker,
@Nullable CompilationUnitTree root)
Constructor for IGJAnnotatedTypeFactory object.
|
Modifier and Type | Method and Description |
---|---|
protected Set<@Nullable AnnotationMirror> |
createFlowQualifiers(IGJChecker checker)
Returns the set of annotations to be inferred in flow analysis
|
protected TreeAnnotator |
createTreeAnnotator(IGJChecker checker)
Returns a
TreeAnnotator that adds annotations to a type based
on the contents of a tree. |
protected TypeAnnotator |
createTypeAnnotator(IGJChecker checker)
Returns a
TypeAnnotator that adds annotations to a type based
on the content of the type itself. |
protected AnnotatedTypeMirror.AnnotatedDeclaredType |
getImplicitReceiverType(ExpressionTree tree)
Return the implicit receiver type of an expression tree.
|
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(@Nullable Tree tree)
Returns the type of field
this , for the scope of this tree. |
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> |
methodFromUse(MethodInvocationTree tree)
Resolves
@I in the type of the method type base on the method
invocation tree parameters. |
void |
postAsMemberOf(@Mutable AnnotatedTypeMirror elementType,
@Mutable AnnotatedTypeMirror owner,
@Nullable Element element)
Resolve the instances of
@I in the elementType based
on owner , according to is specification. |
protected void |
postDirectSuperTypes(@Mutable AnnotatedTypeMirror type,
List<? extends @Mutable AnnotatedTypeMirror> supertypes)
Replace all instances of
@I in the super types with the
immutability of the current type |
annotateImplicit, annotateImplicit, annotateImplicit, constructorFromUse, createFlow, getDefaultedAnnotatedType, postInit
addAliasedAnnotation, aliasedAnnotation, annotateInheritedFromClass, canHaveAnnotatedTypeParameters, createLRUCache, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromNewClass, fromTypeTree, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getBoxedType, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getEnclosingType, getPath, getQualifierHierarchy, getReceiverType, getUnboxedType, getVisitorState, isAnyEnclosingThisDeref, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, toAnnotatedType, toString, typeVariablesFromUse, unify
protected static final @ReadOnly String IMMUTABILITY_KEY
I
annotation value keypublic IGJAnnotatedTypeFactory(IGJChecker checker, @Nullable CompilationUnitTree root)
checker
- the checker to which this factory belongsroot
- the compilation unit the annotation processor is
processing currentlyprotected Set<@Nullable AnnotationMirror> createFlowQualifiers(IGJChecker checker)
BasicAnnotatedTypeFactory
createFlowQualifiers
in class BasicAnnotatedTypeFactory<IGJChecker>
protected TreeAnnotator createTreeAnnotator(IGJChecker checker)
BasicAnnotatedTypeFactory
TreeAnnotator
that adds annotations to a type based
on the contents of a tree.
Subclasses may override this method to specify more appriopriate
TreeAnnotator
createTreeAnnotator
in class BasicAnnotatedTypeFactory<IGJChecker>
protected TypeAnnotator createTypeAnnotator(IGJChecker checker)
BasicAnnotatedTypeFactory
TypeAnnotator
that adds annotations to a type based
on the content of the type itself.createTypeAnnotator
in class BasicAnnotatedTypeFactory<IGJChecker>
protected AnnotatedTypeMirror.AnnotatedDeclaredType getImplicitReceiverType(ExpressionTree tree)
AnnotatedTypeFactory
getImplicitReceiverType
in class AnnotatedTypeFactory
tree
- The expression that might have an implicit receiver.public AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(@Nullable Tree tree)
this
, for the scope of this tree.
In IGJ, the self type is the method receiver in this scope.getSelfType
in class AnnotatedTypeFactory
protected void postDirectSuperTypes(@Mutable AnnotatedTypeMirror type, List<? extends @Mutable AnnotatedTypeMirror> supertypes)
@I
in the super types with the
immutability of the current typepostDirectSuperTypes
in class BasicAnnotatedTypeFactory<IGJChecker>
type
- the type whose supertypes are requestedsupertypes
- the supertypes of typepublic void postAsMemberOf(@Mutable AnnotatedTypeMirror elementType, @Mutable AnnotatedTypeMirror owner, @Nullable Element element)
@I
in the elementType
based
on owner
, according to is specification.postAsMemberOf
in class AnnotatedTypeFactory
elementType
- the annotated type of the elementowner
- the annotated type of the receiver of the accessing treeelement
- the element of the field or methodpublic Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> methodFromUse(MethodInvocationTree tree)
@I
in the type of the method type base on the method
invocation tree parameters. Any unresolved @I
s is resolved to a
place holder type.
It resolves @I
annotation in the following way:
AnnotatedTypes.asMemberOf(AnnotatedTypeMirror, Element)
methodFromUse
in class BasicAnnotatedTypeFactory<IGJChecker>
tree
- the method invocation tree