public class NullnessAnnotatedTypeFactory extends InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
Modifier and Type | Class and Description |
---|---|
protected class |
NullnessAnnotatedTypeFactory.NullnessQualifierHierarchy |
protected class |
NullnessAnnotatedTypeFactory.NullnessTreeAnnotator |
protected class |
NullnessAnnotatedTypeFactory.NullnessTypeAnnotator |
InitializationAnnotatedTypeFactory.CommitmentTreeAnnotator, InitializationAnnotatedTypeFactory.CommitmentTypeAnnotator, InitializationAnnotatedTypeFactory.InitializationQualifierHierarchy
GenericAnnotatedTypeFactory.ScanState
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected CollectionToArrayHeuristics |
collectionToArrayHeuristics |
protected DependentTypes |
dependentTypes
Dependent types instance.
|
protected GeneralAnnotatedTypeFactory |
generalFactory
Factory for arbitrary qualifiers, used for declarations and "unused"
qualifier.
|
protected org.checkerframework.checker.nullness.MapGetHeuristics |
mapGetHeuristics |
protected javax.lang.model.element.AnnotationMirror |
MONOTONIC_NONNULL
Annotation constants
|
protected javax.lang.model.element.AnnotationMirror |
NONNULL
Annotation constants
|
protected javax.lang.model.element.AnnotationMirror |
NULLABLE
Annotation constants
|
protected java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
nullnessAnnos |
protected javax.lang.model.element.AnnotationMirror |
POLYNULL
Annotation constants
|
protected SystemGetPropertyHandler |
systemGetPropertyHandler |
COMMITTED, FBCBOTTOM, FREE, HACK_DONT_CALL_POST_AS_MEMBER, initAnnos, NOT_ONLY_COMMITTED, UNCLASSIFIED, useFbc
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 |
---|
NullnessAnnotatedTypeFactory(BaseTypeChecker checker,
boolean useFbc) |
Modifier and Type | Method and Description |
---|---|
protected void |
annotateImplicit(com.sun.source.tree.Tree tree,
AnnotatedTypeMirror type,
boolean useFlow) |
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> |
constructorFromUse(com.sun.source.tree.NewClassTree tree)
Determines the
AnnotatedTypeMirror.AnnotatedExecutableType of a constructor
invocation. |
protected NullnessAnalysis |
createFlowAnalysis(java.util.List<Pair<javax.lang.model.element.VariableElement,NullnessValue>> fieldValues)
Returns the appropriate flow analysis class that is used for the org.checkerframework.dataflow
analysis.
|
NullnessTransfer |
createFlowTransferFunction(CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer> analysis)
Returns the appropriate transfer function that is used for the org.checkerframework.dataflow
analysis.
|
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 AnnotatedTypeMirror |
getDeclaredAndDefaultedAnnotatedType(com.sun.source.tree.Tree tree) |
AnnotatedTypeMirror |
getDefaultedAnnotatedType(com.sun.source.tree.Tree varTree,
com.sun.source.tree.ExpressionTree valueTree)
Get the defaulted type of a variable, without considering
flow inference from the initializer expression.
|
javax.lang.model.element.AnnotationMirror |
getFieldInvariantAnnotation()
Returns the annotation that makes up the invariant of this commitment
type system.
|
java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
getInvalidConstructorReturnTypeAnnotations() |
AnnotatedTypeMirror |
getMethodReturnType(com.sun.source.tree.MethodTree m,
com.sun.source.tree.ReturnTree r)
Returns the return type of the method
m at the return statement r . |
java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> |
getNullnessAnnotations() |
java.util.List<com.sun.source.tree.VariableTree> |
getUninitializedInvariantFields(NullnessStore store,
com.sun.source.util.TreePath path,
boolean isStatic,
java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
Returns the (non-static) fields that have the invariant annotation
and are not yet initialized in a given store.
|
protected AnnotatedTypeMirror |
handlePolyNull(AnnotatedTypeMirror type,
com.sun.source.tree.Tree context)
|
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> |
methodFromUse(com.sun.source.tree.MethodInvocationTree tree)
Determines the type of the invoked method based on the passed method
invocation tree.
|
void |
setRoot(com.sun.source.tree.CompilationUnitTree root) |
areAllFieldsCommittedOnly, createFreeAnnotation, createFreeAnnotation, createQualifierHierarchyFactory, createUnclassifiedAnnotation, createUnclassifiedAnnotation, getFreeOrRawAnnotationOfSuperType, getInitializationAnnotations, getInitializedInvariantFields, getSelfType, getTypeFrameFromAnnotation, isCommitted, isCommitted, isFbcBottom, isFbcBottom, isFree, isFree, isInitializationAnnotation, isInitializedForFrame, isUnclassified, isUnclassified, postAsMemberOf, setSelfTypeInInitializationCode
analyze, annotateImplicit, annotateImplicit, annotateImplicitWithFlow, applyInferredAnnotations, createQualifierDefaults, createQualifierPolymorphism, dotOutputFileName, getEmptyStore, getFinalLocalValues, getInferredValueFor, getNodeForTree, getRegularExitStore, getReturnStatementStores, getStoreAfter, getStoreBefore, getSupportedMonotonicTypeQualifiers, getUseFlow, performFlowAnalysis, postDirectSuperTypes, postInit, setUseFlow
addAliasedAnnotation, addAliasedDeclAnnotation, aliasedAnnotation, annotateInheritedFromClass, annotateInheritedFromClass, buildIndexTypes, createLRUCache, createQualifierHierarchy, createQualifierHierarchy, createSupportedTypeQualifiers, createTypeHierarchy, 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, getImplicitReceiverType, getMethodReturnType, getPath, getProcessingEnv, getQualifierHierarchy, getReceiverType, getSupportedTypeQualifiers, getTreeUtils, getTypeHierarchy, getUnboxedType, getUninferredWildcardType, getVisitorState, getWildcardBoundedBy, isAnyEnclosingThisDeref, isFromByteCode, isFromStubFile, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, postProcessClassTree, setPathHack, toAnnotatedType, toString, type, typeVariablesFromUse
protected final javax.lang.model.element.AnnotationMirror NONNULL
protected final javax.lang.model.element.AnnotationMirror NULLABLE
protected final javax.lang.model.element.AnnotationMirror POLYNULL
protected final javax.lang.model.element.AnnotationMirror MONOTONIC_NONNULL
protected final DependentTypes dependentTypes
protected final org.checkerframework.checker.nullness.MapGetHeuristics mapGetHeuristics
protected final SystemGetPropertyHandler systemGetPropertyHandler
protected final CollectionToArrayHeuristics collectionToArrayHeuristics
protected final GeneralAnnotatedTypeFactory generalFactory
protected final java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> nullnessAnnos
public NullnessAnnotatedTypeFactory(BaseTypeChecker checker, boolean useFbc)
public void setRoot(com.sun.source.tree.CompilationUnitTree root)
setRoot
in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
protected void annotateImplicit(com.sun.source.tree.Tree tree, AnnotatedTypeMirror type, boolean useFlow)
annotateImplicit
in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
public AnnotatedTypeMirror getDefaultedAnnotatedType(com.sun.source.tree.Tree varTree, com.sun.source.tree.ExpressionTree valueTree)
GenericAnnotatedTypeFactory
protected AnnotatedTypeMirror handlePolyNull(AnnotatedTypeMirror type, com.sun.source.tree.Tree context)
public Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> constructorFromUse(com.sun.source.tree.NewClassTree tree)
AnnotatedTypeFactory
AnnotatedTypeMirror.AnnotatedExecutableType
of a constructor
invocation. Note that this is different than calling
AnnotatedTypeFactory.getAnnotatedType(Tree)
or
AnnotatedTypeFactory.fromExpression(ExpressionTree)
on the constructor invocation;
those determine the type of the result of invoking the
constructor, which is probably an AnnotatedTypeMirror.AnnotatedDeclaredType
.
TODO: Should the result of getAnnotatedType be the return type
from the AnnotatedExecutableType computed here?
Note that "this" and "super" constructor invocations are handled by
method AnnotatedTypeFactory.methodFromUse(com.sun.source.tree.MethodInvocationTree)
. This method only handles constructor invocations
in a "new" expression.constructorFromUse
in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
tree
- the constructor invocation treepublic java.util.List<com.sun.source.tree.VariableTree> getUninitializedInvariantFields(NullnessStore store, com.sun.source.util.TreePath path, boolean isStatic, java.util.List<? extends javax.lang.model.element.AnnotationMirror> receiverAnnotations)
InitializationAnnotatedTypeFactory
protected NullnessAnalysis createFlowAnalysis(java.util.List<Pair<javax.lang.model.element.VariableElement,NullnessValue>> fieldValues)
GenericAnnotatedTypeFactory
This implementation uses the checker naming convention to create the
appropriate analysis. If no transfer function is found, it returns an
instance of CFAnalysis
.
Subclasses have to override this method to create the appropriate analysis if they do not follow the checker naming convention.
createFlowAnalysis
in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
public NullnessTransfer createFlowTransferFunction(CFAbstractAnalysis<NullnessValue,NullnessStore,NullnessTransfer> analysis)
GenericAnnotatedTypeFactory
This implementation uses the checker naming convention to create the
appropriate transfer function. If no transfer function is found, it
returns an instance of CFTransfer
.
Subclasses have to override this method to create the appropriate transfer function if they do not follow the checker naming convention.
public Pair<AnnotatedTypeMirror.AnnotatedExecutableType,java.util.List<AnnotatedTypeMirror>> methodFromUse(com.sun.source.tree.MethodInvocationTree tree)
AnnotatedTypeFactory
AnnotatedTypes.asMemberOf(Types, AnnotatedTypeFactory, AnnotatedTypeMirror, Element)
,
and customization based on receiver type should be in accordance to its
specification.
The return type is a pair of the type of the invoked method and
the (inferred) type arguments.
Note that neither the explicitly passed nor the inferred type arguments
are guaranteed to be subtypes of the corresponding upper bounds.
See method
BaseTypeVisitor.checkTypeArguments(Tree, List, List, List)
for the checks of type argument well-formedness.
Note that "this" and "super" constructor invocations are also handled by this
method. Method AnnotatedTypeFactory.constructorFromUse(NewClassTree)
is only used for a constructor
invocation in a "new" expression.methodFromUse
in class GenericAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
tree
- the method invocation treepublic AnnotatedTypeMirror getMethodReturnType(com.sun.source.tree.MethodTree m, com.sun.source.tree.ReturnTree r)
AnnotatedTypeFactory
m
at the return statement r
.getMethodReturnType
in class AnnotatedTypeFactory
protected AnnotatedTypeMirror getDeclaredAndDefaultedAnnotatedType(com.sun.source.tree.Tree tree)
protected TypeAnnotator createTypeAnnotator()
GenericAnnotatedTypeFactory
TypeAnnotator
that adds annotations to a type based
on the content of the type itself.createTypeAnnotator
in class InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
protected 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 InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
public java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getNullnessAnnotations()
public java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> getInvalidConstructorReturnTypeAnnotations()
getInvalidConstructorReturnTypeAnnotations
in class InitializationAnnotatedTypeFactory<NullnessValue,NullnessStore,NullnessTransfer,NullnessAnalysis>
public javax.lang.model.element.AnnotationMirror getFieldInvariantAnnotation()
InitializationAnnotatedTypeFactory
public QualifierHierarchy createQualifierHierarchy(MultiGraphQualifierHierarchy.MultiGraphFactory factory)
AnnotatedTypeFactory
createQualifierHierarchy
in class AnnotatedTypeFactory