|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.types.AnnotatedTypeFactory checkers.javari.JavariAnnotatedTypeFactory
public class JavariAnnotatedTypeFactory extends AnnotatedTypeFactory
Generates a AnnotatedTypeMirror with Javari annotations from a Tree or a Element parameter.
Implicit annotations are added as follows:
@Mutable
annotation.
@ReadOnly
,
@Mutable
or @PolyRead
, according to the qualified type
of this
.
Modifier and Type | Class and Description |
---|
Nested classes/interfaces inherited from class checkers.types.AnnotatedTypeFactory |
---|
AnnotatedTypeFactory.InheritedFromClassAnnotator |
Modifier and Type | Field and Description |
---|
Fields inherited from class checkers.types.AnnotatedTypeFactory |
---|
annotations, atypes, elements, env, qualHierarchy, root, trees, types, visitorState |
Constructor and Description |
---|
JavariAnnotatedTypeFactory(JavariChecker checker,
CompilationUnitTree root)
Creates a new JavariAnnotatedTypeFactory that operates on a
particular AST. |
Modifier and Type | Method and Description |
---|---|
protected void |
annotateImplicit(Element element,
AnnotatedTypeMirror type)
Adds annotations to qualified types according to their provided element, as follows: 1. |
protected void |
annotateImplicit(Iterable<? extends Tree> trees,
Iterable<? extends AnnotatedTypeMirror> types)
Convenience method for annotating two corresponding iterables. |
protected void |
annotateImplicit(Tree tree,
AnnotatedTypeMirror type)
Adds implicit annotations to a qualified type, based on its tree, as follows: 1. |
AnnotatedTypeMirror.AnnotatedExecutableType |
constructorFromUse(NewClassTree tree)
Determines the type of the constructed object based on the parameters passed to the constructor. |
boolean |
hasImmutabilityAnnotation(AnnotatedTypeMirror type)
|
AnnotatedTypeMirror.AnnotatedExecutableType |
methodFromUse(MethodInvocationTree tree)
Determines the type of the invoked method based on the passed method invocation tree. |
void |
postAsMemberOf(AnnotatedTypeMirror type,
AnnotatedTypeMirror owner,
Element element)
We modify this callback method to replace @ThisMutable
implicit annotations with the qualified supertype annotation,
if the owner doesn't have a @ReadOnly annotation. |
protected void |
postDirectSuperTypes(AnnotatedTypeMirror type,
List<? extends AnnotatedTypeMirror> supertypes)
A callback method for the AnnotatedTypeFactory subtypes to customize directSuperTypes(). |
Collection<AnnotationMirror> |
unify(Collection<AnnotationMirror> c1,
Collection<AnnotationMirror> c2)
Returns a singleton collection with the most restrictive immutability annotation that is a supertype of the annotations on both collections. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavariAnnotatedTypeFactory(JavariChecker checker, CompilationUnitTree root)
JavariAnnotatedTypeFactory
that operates on a
particular AST.
checker
- the checker to which this factory belongsroot
- the AST on which this type factory operatesMethod Detail |
---|
public boolean hasImmutabilityAnnotation(@ReadOnly AnnotatedTypeMirror type)
type
- an annotated type mirrorprotected void annotateImplicit(Tree tree, @Mutable AnnotatedTypeMirror type)
@ThisMutable
.
@Mutable
annotation.
@Mutable
.
@ReadOnly
,
@Mutable
or @PolyRead
, according to the
qualified type of this
.
annotateImplicit
in class AnnotatedTypeFactory
tree
- an AST nodetype
- the type obtained from tree
protected void annotateImplicit(Iterable<? extends Tree> trees, Iterable<? extends AnnotatedTypeMirror> types)
protected void annotateImplicit(Element element, @Mutable AnnotatedTypeMirror type)
@Mutable
annotation.
@ReadOnly
or
@ThisMutable
, according to the supertype.
annotateImplicit
in class AnnotatedTypeFactory
element
- an elementtype
- the type obtained from elt
protected void postDirectSuperTypes(AnnotatedTypeMirror type, List<? extends 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 AnnotatedTypeFactory
type
- the type whose supertypes are desiredsupertypes
- the supertypes as specified by the base AnnotatedTypeFactorypublic Collection<AnnotationMirror> unify(Collection<AnnotationMirror> c1, Collection<AnnotationMirror> c2)
unify
in class AnnotatedTypeFactory
c1
- type qualifiers for the first typec2
- tyep qualifiers for the second typepublic AnnotatedTypeMirror.AnnotatedExecutableType constructorFromUse(NewClassTree tree)
@PolyRead
receiver values are resolved by looking at
the mutability of any parameters marked as @PolyRead
. The rules
are similar to the ones applicable to
method invocation resolution, but without looking at this
.
@PolyRead
receive
@Mutable
arguments, the receiver value is resolved as
@Mutable
.
@PolyRead
receive
@Mutable
or @ThisMutable
arguments and the
condition above is not satisfied, the receiver value is
resolved as @ThisMutable
.
@PolyRead
receive
@Mutable
or @PolyRead
arguments and none of
the condition above is satisfied, the receiver value is
resolved as @PolyRead
.
@ReadOnly
.
constructorFromUse
in class AnnotatedTypeFactory
tree
- the new class treepublic AnnotatedTypeMirror.AnnotatedExecutableType methodFromUse(MethodInvocationTree tree)
@PolyRead
at the raw level on return values by looking at the
mutability of any parameters marked as @PolyRead
. For
this purpose, a @PolyRead
annotation on the receiver
counts as if this
were being passed as an argument to a
parameter marked as @PolyRead
.
@PolyRead
receive
@Mutable
arguments, the return value is resolved as
@Mutable
.
@PolyRead
receive
@Mutable
or @ThisMutable
arguments and the
condition above is not satisfied, the return value is resolved
as @ThisMutable
.
@PolyRead
receive
@Mutable
or @PolyRead
arguments and none of
the condition above is satisfied, the return value is resolved
as @PolyRead
.
@ReadOnly
.
methodFromUse
in class AnnotatedTypeFactory
tree
- the method invocation treepublic void postAsMemberOf(AnnotatedTypeMirror type, AnnotatedTypeMirror owner, Element element)
@ThisMutable
implicit annotations with the qualified supertype annotation,
if the owner doesn't have a @ReadOnly
annotation.
Note on the given example that, if @ThisMutable tmObject
were resolved as @ReadOnly tmObject
, the code snippet
would be legal. Such a class could then be created to obtain
@Mutable
access to tmObject
from a @ReadOnly
reference to it, without typechecker errors.
@PolyRead Object breakJavari(@PolyRead Object s) @ReadOnly { tmObject = s; return null; }
postAsMemberOf
in class AnnotatedTypeFactory
type
- the annotated type of the elementowner
- the annotated type of the receiver of the accessing treeelement
- the element of the field or method
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |