|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.types.AnnotatedTypeFactory checkers.types.BasicAnnotatedTypeFactory<IGJChecker> checkers.igj.IGJAnnotatedTypeFactory
public class IGJAnnotatedTypeFactory
Adds implicit and default IGJ annotations, only if the user does not
annotate the type explicitly. The default annotations are designed
to minimize the number of 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).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class checkers.types.AnnotatedTypeFactory |
---|
AnnotatedTypeFactory.InheritedFromClassAnnotator |
Field Summary | |
---|---|
protected static String |
IMMUTABILITY_KEY
the I annotation value key |
Fields inherited from class checkers.types.BasicAnnotatedTypeFactory |
---|
defaults, flow, FLOW_BY_DEFAULT, poly, treeAnnotator, typeAnnotator, useFlow |
Fields inherited from class checkers.types.AnnotatedTypeFactory |
---|
annotations, atypes, elements, env, qualHierarchy, root, trees, types, visitorState |
Constructor Summary | |
---|---|
IGJAnnotatedTypeFactory(IGJChecker checker,
CompilationUnitTree root)
Constructor for IGJAnnotatedTypeFactory object. |
Method Summary | |
---|---|
protected void |
annotateInheritedFromClass(AnnotatedTypeMirror type)
Override the default behavior of implicitly adding annotations on the class type to the declared types within the passed type. |
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(Tree tree)
|
AnnotatedTypeMirror.AnnotatedDeclaredType |
getSelfType(Tree tree)
Returns the type of field this , for the scope of this tree. |
AnnotatedTypeMirror.AnnotatedExecutableType |
methodFromUse(MethodInvocationTree tree)
Resolves @I in the type of the method type base on the method
invocation tree parameters. |
void |
postAsMemberOf(AnnotatedTypeMirror elementType,
AnnotatedTypeMirror owner,
Element element)
Resolve the instances of @I in the elementType based
on owner , according to is specification. |
protected void |
postDirectSuperTypes(AnnotatedTypeMirror type,
List<? extends AnnotatedTypeMirror> supertypes)
Replace all instances of @I in the super types with the
immutability of the current type |
Methods inherited from class checkers.types.BasicAnnotatedTypeFactory |
---|
annotateImplicit, annotateImplicit, createFlow |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String IMMUTABILITY_KEY
I
annotation value key
Constructor Detail |
---|
public IGJAnnotatedTypeFactory(IGJChecker checker, CompilationUnitTree root)
checker
- the checker to which this factory belongsroot
- the compilation unit the annotation processor is
processing currentlyMethod Detail |
---|
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 void annotateInheritedFromClass(AnnotatedTypeMirror type)
annotateInheritedFromClass
in class AnnotatedTypeFactory
type
- the type for which class annotations will be inherited if
there are no annotations already presentprotected AnnotatedTypeMirror.AnnotatedDeclaredType getImplicitReceiverType(Tree tree)
getImplicitReceiverType
in class AnnotatedTypeFactory
public AnnotatedTypeMirror.AnnotatedDeclaredType getSelfType(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, List<? extends AnnotatedTypeMirror> supertypes)
@I
in the super types with the
immutability of the current type
postDirectSuperTypes
in class BasicAnnotatedTypeFactory<IGJChecker>
type
- the type whose supertypes are requestedsupertypes
- the supertypes of typepublic void postAsMemberOf(AnnotatedTypeMirror elementType, AnnotatedTypeMirror owner, 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 AnnotatedTypeMirror.AnnotatedExecutableType 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |