public class IGJAnnotatedTypeFactory extends BaseAnnotatedTypeFactory
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).
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected javax.lang.model.element.AnnotationMirror |
ASSIGNS_FIELDS
Supported annotations for IGJ.
|
protected javax.lang.model.element.AnnotationMirror |
BOTTOM_QUAL
Supported annotations for IGJ.
|
protected javax.lang.model.element.AnnotationMirror |
I
Supported annotations for IGJ.
|
protected static java.lang.String |
IMMUTABILITY_KEY
the
I annotation value key |
protected javax.lang.model.element.AnnotationMirror |
IMMUTABLE
Supported annotations for IGJ.
|
protected javax.lang.model.element.AnnotationMirror |
MUTABLE
Supported annotations for IGJ.
|
protected javax.lang.model.element.AnnotationMirror |
READONLY
Supported annotations for IGJ.
|
analyses, defaults, FLOW_BY_DEFAULT, flowResult, initializationStaticStore, initializationStore, methodInvocationStores, poly, regularExitStores, returnStatementStores, scannedClasses, treeAnnotator, typeAnnotator, useFlow
checker, elements, fromTreeCache, processingEnv, qualHierarchy, root, SHOULD_CACHE, SHOULD_READ_CACHE, shouldCache, shouldReadCache, trees, typeHierarchy, types, uid, visitorState
Constructor and Description |
---|
IGJAnnotatedTypeFactory(BaseTypeChecker checker)
Constructor for IGJAnnotatedTypeFactory object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
annotateInheritedFromClass(@Mutable AnnotatedTypeMirror type,
java.util.Set<javax.lang.model.element.AnnotationMirror> fromClass)
Callback to determine what to do with the annotations from a class declaration.
|
QualifierHierarchy |
createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
Factory method to easily change what QualifierHierarchy is
created.
|
protected TreeAnnotator |
createTreeAnnotator()
Returns a
TreeAnnotator that adds annotations to a type based
on the contents of a tree. |
protected TypeAnnotator |
createTypeAnnotator()
Returns a
TypeAnnotator that adds annotations to a type based
on the content of the type itself. |
protected TypeHierarchy |
createTypeHierarchy()
Creates the type subtyping checker using the current type qualifier
hierarchy.
|
protected AnnotatedTypeMirror.AnnotatedDeclaredType |
getImplicitReceiverType(com.sun.source.tree.ExpressionTree tree)
Return the implicit receiver type of an expression tree.
|
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(com.sun.source.tree.Tree tree)
Returns the type of field
this , for the scope of this tree. |
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> |
methodFromUse(com.sun.source.tree.MethodInvocationTree tree)
Resolves
@I in the type of the method type base on the method
invocation tree parameters. |
void |
postAsMemberOf(AnnotatedTypeMirror elementType,
AnnotatedTypeMirror owner,
javax.lang.model.element.Element element)
Resolve the instances of
@I in the elementType based
on owner , according to is specification. |
protected void |
postDirectSuperTypes(AnnotatedTypeMirror type,
java.util.List<? extends AnnotatedTypeMirror> supertypes)
Replace all instances of
@I in the super types with the
immutability of the current type |
void |
postProcessClassTree(com.sun.source.tree.ClassTree tree)
Called by getAnnotatedType(Tree) for each ClassTree after determining the type.
|
createFlowAnalysis
analyze, annotateImplicit, annotateImplicit, annotateImplicit, annotateImplicitWithFlow, applyInferredAnnotations, constructorFromUse, createFlowTransferFunction, createQualifierDefaults, createQualifierPolymorphism, dotOutputFileName, getDefaultedAnnotatedType, getEmptyStore, getFinalLocalValues, getInferredValueFor, getNodeForTree, getRegularExitStore, getReturnStatementStores, getStoreAfter, getStoreBefore, getSupportedMonotonicTypeQualifiers, getUseFlow, performFlowAnalysis, postInit, setRoot, setUseFlow
addAliasedAnnotation, addAliasedDeclAnnotation, aliasedAnnotation, annotateInheritedFromClass, buildIndexTypes, createLRUCache, createQualifierHierarchy, createQualifierHierarchy, createQualifierHierarchyFactory, createSupportedTypeQualifiers, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromNewClass, fromTypeTree, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getAnnotationMirror, getAnnotationWithMetaAnnotation, getBoxedType, getCurrentClassTree, getCurrentClassType, getCurrentMethodReceiver, getDeclAnnotation, getDeclAnnotations, getDeclAnnotationWithMetaAnnotation, getElementUtils, getEnclosingMethod, getEnclosingType, getMethodReturnType, getMethodReturnType, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSupportedTypeQualifiers, getTreeUtils, getTypeHierarchy, getUnboxedType, getUninferredWildcardType, getVisitorState, getWildcardBoundedBy, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, setPathHack, toAnnotatedType, toString, type, typeVariablesFromUse
protected final javax.lang.model.element.AnnotationMirror READONLY
protected final javax.lang.model.element.AnnotationMirror MUTABLE
protected final javax.lang.model.element.AnnotationMirror IMMUTABLE
protected final javax.lang.model.element.AnnotationMirror I
protected final javax.lang.model.element.AnnotationMirror ASSIGNS_FIELDS
protected final javax.lang.model.element.AnnotationMirror BOTTOM_QUAL
protected static final java.lang.String IMMUTABILITY_KEY
I
annotation value keypublic IGJAnnotatedTypeFactory(BaseTypeChecker checker)
checker
- the checker to which this factory belongsprotected TreeAnnotator createTreeAnnotator()
GenericAnnotatedTypeFactory
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 GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
protected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
TypeAnnotator
that adds annotations to a type based
on the content of the type itself.createTypeAnnotator
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
public void postProcessClassTree(com.sun.source.tree.ClassTree tree)
AnnotatedTypeFactory
postProcessClassTree
in class AnnotatedTypeFactory
protected AnnotatedTypeMirror.AnnotatedDeclaredType getImplicitReceiverType(com.sun.source.tree.ExpressionTree tree)
AnnotatedTypeFactory
getImplicitReceiverType
in class AnnotatedTypeFactory
tree
- The expression that might have an implicit receiver.public AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(com.sun.source.tree.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(AnnotatedTypeMirror type, java.util.List<? extends AnnotatedTypeMirror> supertypes)
@I
in the super types with the
immutability of the current typepostDirectSuperTypes
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
type
- the type whose supertypes are requestedsupertypes
- the supertypes of typepublic void postAsMemberOf(AnnotatedTypeMirror elementType, AnnotatedTypeMirror owner, javax.lang.model.element.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 methodprotected void annotateInheritedFromClass(@Mutable AnnotatedTypeMirror type, java.util.Set<javax.lang.model.element.AnnotationMirror> fromClass)
AnnotatedTypeFactory
annotateInheritedFromClass
in class AnnotatedTypeFactory
public Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> methodFromUse(com.sun.source.tree.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(Types, AnnotatedTypeFactory, AnnotatedTypeMirror, Element)
methodFromUse
in class GenericAnnotatedTypeFactory<CFValue,CFStore,CFTransfer,CFAnalysis>
tree
- the method invocation treepublic QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactory
createQualifierHierarchy
in class AnnotatedTypeFactory
protected TypeHierarchy createTypeHierarchy()
AnnotatedTypeFactory
createTypeHierarchy
in class AnnotatedTypeFactory