checkers.nullness
Class NullnessAnnotatedTypeFactory

java.lang.Object
  extended by checkers.types.AnnotatedTypeFactory
      extended by checkers.nullness.NullnessAnnotatedTypeFactory

public class NullnessAnnotatedTypeFactory
extends AnnotatedTypeFactory

Adds the NonNull annotation to a type that is: 1. in the scope of a DefaultQualifier annotation and matches its location criteria 2. determined to be NonNull by flow-sensitive inference 3. the class in a static member access (e.g., "System" in "System.out") 4. an array-creation expression (with new) 5. an object-creation expression (with new) 6. a string literal 7. a package declaration 8. an exception parameter 9. the receiver type of a non-static (and non-constructor) method Adds the Raw annotation to 10. the receiver type of constructors.

Additionally, the type factory will add the Nullable annotation to a type if the input is 11. the null literal 12. of type Void, 13. may resolve the types of some NonNull fields as Nullable depending on the presence of a Raw annotation on a constructor or method receiver. Please review the Checker Framework for Raw semantics.


Field Summary
protected  AnnotationMirror NONNULL
          Represents the Nullness Checker qualifiers
protected  AnnotationMirror NULLABLE
          Represents the Nullness Checker qualifiers
protected  AnnotationMirror RAW
          Represents the Nullness Checker qualifiers
 
Fields inherited from class checkers.types.AnnotatedTypeFactory
annotations, atypes, elements, eltsToArrays, env, JSR308_ELTS_ARRAY_CONVENTION, qualHierarchy, root, trees, types, visitorState
 
Constructor Summary
NullnessAnnotatedTypeFactory(NullnessChecker checker, CompilationUnitTree root)
          Creates a NullnessAnnotatedTypeFactory.
 
Method Summary
protected  void annotateImplicit(Element elt, AnnotatedTypeMirror type)
          Adds implicit annotations to a type obtained from a Element.
protected  void annotateImplicit(Tree tree, AnnotatedTypeMirror type)
          Adds implicit annotations to a type obtained from a Tree.
 AnnotatedTypeMirror.AnnotatedExecutableType methodFromUse(MethodInvocationTree tree)
          Determines the type of the invoked method based on the passed method invocation tree.
protected  void postDirectSuperTypes(AnnotatedTypeMirror type, List<? extends AnnotatedTypeMirror> supertypes)
          A callback method for the AnnotatedTypeFactory subtypes to customize directSuperTypes().
 
Methods inherited from class checkers.types.AnnotatedTypeFactory
annotateInheritedFromClass, constructorFromUse, createLRUCache, declarationFromElement, fromClass, fromElement, fromElement, fromElement, fromExpression, fromMember, fromTypeTree, fromTypeTreeInternal, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedType, getAnnotatedTypeFromTypeTree, getBoxedType, getCurrentClassType, getCurrentMethodReceiver, getPath, getReceiver, getSelfType, getUnboxedType, getVisitorState, postAsMemberOf, unify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONNULL

protected final AnnotationMirror NONNULL
Represents the Nullness Checker qualifiers


RAW

protected final AnnotationMirror RAW
Represents the Nullness Checker qualifiers


NULLABLE

protected final AnnotationMirror NULLABLE
Represents the Nullness Checker qualifiers

Constructor Detail

NullnessAnnotatedTypeFactory

public NullnessAnnotatedTypeFactory(NullnessChecker checker,
                                    CompilationUnitTree root)
Creates a NullnessAnnotatedTypeFactory.

Method Detail

annotateImplicit

protected void annotateImplicit(Element elt,
                                AnnotatedTypeMirror type)
Description copied from class: AnnotatedTypeFactory
Adds implicit annotations to a type obtained from a Element. By default, this method does nothing. Subclasses should use this method to implement implicit annotations specific to their type systems.

Overrides:
annotateImplicit in class AnnotatedTypeFactory
Parameters:
elt - an element
type - the type obtained from elt

annotateImplicit

protected void annotateImplicit(Tree tree,
                                AnnotatedTypeMirror type)
Description copied from class: AnnotatedTypeFactory
Adds implicit annotations to a type obtained from a Tree. By default, this method does nothing. Subclasses should use this method to implement implicit annotations specific to their type systems.

Overrides:
annotateImplicit in class AnnotatedTypeFactory
Parameters:
tree - an AST node
type - the type obtained from tree

postDirectSuperTypes

protected void postDirectSuperTypes(AnnotatedTypeMirror type,
                                    List<? extends AnnotatedTypeMirror> supertypes)
Description copied from class: AnnotatedTypeFactory
A callback method for the AnnotatedTypeFactory subtypes to customize directSuperTypes(). Overriding methods should merely change the annotations on the supertypes, without adding or removing new types

Overrides:
postDirectSuperTypes in class AnnotatedTypeFactory
Parameters:
type - the type whose supertypes are desired
supertypes - the supertypes as specified by the base AnnotatedTypeFactory

methodFromUse

public AnnotatedTypeMirror.AnnotatedExecutableType methodFromUse(MethodInvocationTree tree)
Description copied from class: AnnotatedTypeFactory
Determines the type of the invoked method based on the passed method invocation tree. The returned method type has all type variables resolved, whether based on receiver type, passed type parameters if any, and method invocation parameter. Subclasses may override this method to customize inference of types or qualifiers based on method invocation parameters. As an implementation detail, this method depends on AnnotatedTypes.asMemberOf(AnnotatedTypeMirror, Element), and customization based on receiver type should be in accordance to its specification.

Overrides:
methodFromUse in class AnnotatedTypeFactory
Parameters:
tree - the method invocation tree
Returns:
the method type being invoked with tree