public class NullnessAnnotatedTypeFactory extends BasicAnnotatedTypeFactory<NullnessSubchecker>
NonNull
annotation to a type that is:
null
literal)
DefaultQualifier
annotation and
matches its location criteria
NonNull
by flow-sensitive inference
Raw
annotation to
Additionally, the type factory will add the Nullable
annotation to a
type if the input is
AnnotatedTypeFactory.InheritedFromClassAnnotator
Modifier and Type | Field and Description |
---|---|
protected @Nullable AnnotationMirror |
LAZYNONNULL
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
NONNULL
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
NULLABLE
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
POLYALL
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
POLYNULL
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
PRIMITIVE
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
RAW
Represents the Nullness Checker qualifiers
|
protected @Nullable AnnotationMirror |
UNUSED
Represents the Nullness Checker qualifiers
|
checker, defaults, flow, FLOW_BY_DEFAULT, poly, treeAnnotator, typeAnnotator, useFlow
annotations, atypes, elements, env, fromTreeCache, qualHierarchy, root, trees, types, uid, visitorState
Constructor and Description |
---|
NullnessAnnotatedTypeFactory(NullnessSubchecker checker,
RawnessSubchecker rawnesschecker,
@Nullable CompilationUnitTree root)
Creates a
NullnessAnnotatedTypeFactory . |
Modifier and Type | Method and Description |
---|---|
protected void |
annotateImplicit(@Nullable Element elt,
@Mutable AnnotatedTypeMirror type)
Adds implicit annotations to a type obtained from a
Element . |
protected void |
annotateImplicit(@Nullable Tree tree,
@Mutable AnnotatedTypeMirror type,
boolean iUseFlow) |
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> |
constructorFromUse(NewClassTree tree)
Determines the
AnnotatedTypeMirror.AnnotatedExecutableType of a constructor
invocation. |
protected Flow |
createFlow(NullnessSubchecker checker,
@Nullable CompilationUnitTree root,
Set<@Nullable AnnotationMirror> flowQuals)
Returns a
Flow instance that performs flow sensitive analysis
to infer qualifiers on unqualified types. |
protected Set<@Nullable AnnotationMirror> |
createFlowQualifiers(NullnessSubchecker checker)
Returns the set of annotations to be inferred in flow analysis
|
protected TreeAnnotator |
createTreeAnnotator(NullnessSubchecker checker)
Returns a
TreeAnnotator that adds annotations to a type based
on the contents of a tree. |
protected TypeAnnotator |
createTypeAnnotator(NullnessSubchecker checker)
Returns a
TypeAnnotator that adds annotations to a type based
on the content of the type itself. |
AnnotatedTypeMirror.AnnotatedDeclaredType |
getEnclosingType(TypeElement element,
@Nullable Tree tree)
Determine the type of the most enclosing class of the given tree that
is a subtype of the given element.
|
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(@Nullable Tree tree)
Returns the type of
this in the current location, which can
be used if this has a special semantics (e.g. |
Set<VariableElement> |
initializedAfter(@Nullable MethodTree node) |
Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> |
methodFromUse(MethodInvocationTree tree)
Determines the type of the invoked method based on the passed method
invocation tree.
|
protected void |
postDirectSuperTypes(@Mutable AnnotatedTypeMirror type,
List<? extends @Mutable AnnotatedTypeMirror> supertypes)
A callback method for the AnnotatedTypeFactory subtypes to customize
directSuperTypes().
|
annotateImplicit, 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, getImplicitReceiverType, getPath, getQualifierHierarchy, getReceiverType, getUnboxedType, getVisitorState, isAnyEnclosingThisDeref, isMostEnclosingThisDeref, isSupportedQualifier, isWithinConstructor, postAsMemberOf, toAnnotatedType, toString, typeVariablesFromUse, unify
protected final @Nullable AnnotationMirror NONNULL
protected final @Nullable AnnotationMirror NULLABLE
protected final @Nullable AnnotationMirror LAZYNONNULL
protected final @Nullable AnnotationMirror RAW
protected final @Nullable AnnotationMirror PRIMITIVE
protected final @Nullable AnnotationMirror POLYNULL
protected final @Nullable AnnotationMirror POLYALL
protected final @Nullable AnnotationMirror UNUSED
public NullnessAnnotatedTypeFactory(NullnessSubchecker checker, RawnessSubchecker rawnesschecker, @Nullable CompilationUnitTree root)
NullnessAnnotatedTypeFactory
.protected Flow createFlow(NullnessSubchecker checker, @Nullable CompilationUnitTree root, Set<@Nullable AnnotationMirror> flowQuals)
BasicAnnotatedTypeFactory
Flow
instance that performs flow sensitive analysis
to infer qualifiers on unqualified types.createFlow
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
checker
- the checkerroot
- the compilation unit associated with this factoryflowQuals
- the qualifiers to inferprotected Set<@Nullable AnnotationMirror> createFlowQualifiers(NullnessSubchecker checker)
BasicAnnotatedTypeFactory
createFlowQualifiers
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
protected TreeAnnotator createTreeAnnotator(NullnessSubchecker 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<NullnessSubchecker>
protected TypeAnnotator createTypeAnnotator(NullnessSubchecker checker)
BasicAnnotatedTypeFactory
TypeAnnotator
that adds annotations to a type based
on the content of the type itself.createTypeAnnotator
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
protected void annotateImplicit(@Nullable Element elt, @Mutable AnnotatedTypeMirror type)
AnnotatedTypeFactory
Element
. By
default, this method does nothing. Subclasses should use this method to
implement implicit annotations specific to their type systems.annotateImplicit
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
elt
- an elementtype
- the type obtained from elt
protected void annotateImplicit(@Nullable Tree tree, @Mutable AnnotatedTypeMirror type, boolean iUseFlow)
annotateImplicit
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
public AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(@Nullable Tree tree)
AnnotatedTypeFactory
this
in the current location, which can
be used if this
has a special semantics (e.g. this
is non-null).
The parameter is an arbitrary tree and does not have to mention "this",
neither explicitly nor implicitly.
This method should be overridden for type-system specific behavior.
TODO: in 1.3, handle all receiver type annotations.
TODO: handle enclosing classes correctly.getSelfType
in class AnnotatedTypeFactory
public final AnnotatedTypeMirror.AnnotatedDeclaredType getEnclosingType(TypeElement element, @Nullable Tree tree)
AnnotatedTypeFactory
getEnclosingType
in class AnnotatedTypeFactory
protected void postDirectSuperTypes(@Mutable AnnotatedTypeMirror type, List<? extends @Mutable AnnotatedTypeMirror> supertypes)
AnnotatedTypeFactory
type
annotations to
supertypes
. This allows the type
and its supertypes
to have the qualifiers, e.g. the supertypes of an Immutable
type are also Immutable
.postDirectSuperTypes
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
type
- the type whose supertypes are desiredsupertypes
- the supertypes as specified by the base AnnotatedTypeFactorypublic Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> methodFromUse(MethodInvocationTree tree)
AnnotatedTypeFactory
AnnotatedTypes.asMemberOf(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.methodFromUse
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
tree
- the method invocation treepublic Pair<AnnotatedTypeMirror.AnnotatedExecutableType,List<@Mutable AnnotatedTypeMirror>> constructorFromUse(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?constructorFromUse
in class BasicAnnotatedTypeFactory<NullnessSubchecker>
tree
- the constructor invocation treepublic Set<VariableElement> initializedAfter(@Nullable MethodTree node)