Class AnnotatedTypeMirror.AnnotatedDeclaredType
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeMirror
-
- org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedDeclaredType
-
- All Implemented Interfaces:
org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Enclosing class:
- AnnotatedTypeMirror
public static class AnnotatedTypeMirror.AnnotatedDeclaredType extends AnnotatedTypeMirror
Represents a declared type (whether class or interface).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
AnnotatedTypeMirror.AnnotatedArrayType, AnnotatedTypeMirror.AnnotatedDeclaredType, AnnotatedTypeMirror.AnnotatedExecutableType, AnnotatedTypeMirror.AnnotatedIntersectionType, AnnotatedTypeMirror.AnnotatedNoType, AnnotatedTypeMirror.AnnotatedNullType, AnnotatedTypeMirror.AnnotatedPrimitiveType, AnnotatedTypeMirror.AnnotatedTypeVariable, AnnotatedTypeMirror.AnnotatedUnionType, AnnotatedTypeMirror.AnnotatedWildcardType
-
-
Field Summary
Fields Modifier and Type Field Description protected @Nullable AnnotatedTypeMirror.AnnotatedDeclaredType
enclosingType
The enclosing type.protected java.util.List<AnnotatedTypeMirror>
typeArgs
Parametrized Type Arguments.-
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
atypeFactory, EQUALITY_COMPARER, HASHCODE_VISITOR, primaryAnnotations, underlyingType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <R,P>
Raccept(AnnotatedTypeVisitor<R,P> v, P p)
Applies a visitor to this type.AnnotatedTypeMirror.AnnotatedDeclaredType
asUse()
AnnotatedTypeMirror.AnnotatedDeclaredType
deepCopy()
Returns a deep copy of this type with annotations.AnnotatedTypeMirror.AnnotatedDeclaredType
deepCopy(boolean copyAnnotations)
Returns a deep copy of this type.java.util.List<AnnotatedTypeMirror.AnnotatedDeclaredType>
directSupertypes()
This method returns a list of AnnotatedTypeMirrors where the Java type of each ATM is an immediate supertype (class or interface) of the Java type of this.@Nullable AnnotatedTypeMirror.AnnotatedDeclaredType
getEnclosingType()
Returns the enclosing type, as in the type ofA
in the typeA.B
.AnnotatedTypeMirror.AnnotatedDeclaredType
getErased()
Return the declared type with its type arguments removed.java.util.List<AnnotatedTypeMirror>
getTypeArguments()
Returns the type argument for this type.javax.lang.model.type.DeclaredType
getUnderlyingType()
Returns the underlying unannotated Java type, which this wraps.boolean
isDeclaration()
Returns true if this type mirror represents a declaration, rather than a use, of a type.boolean
isUnderlyingTypeRaw()
Returns true if the underlying type is raw.void
setEnclosingType(@Nullable AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType)
Sets the enclosing type.protected void
setIsUnderlyingTypeRaw()
Set the isUnderlyingTypeRaw flag to true.void
setTypeArguments(java.util.List<? extends AnnotatedTypeMirror> ts)
Sets the type arguments on this type.protected void
setWasRaw()
Deprecated.UsesetIsUnderlyingTypeRaw()
insteadAnnotatedTypeMirror.AnnotatedDeclaredType
shallowCopy()
Returns a shallow copy of this type with annotations.AnnotatedTypeMirror.AnnotatedDeclaredType
shallowCopy(boolean copyAnnotations)
Returns a shallow copy of this type.boolean
wasRaw()
Deprecated.UseisUnderlyingTypeRaw()
instead-
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
addAnnotation, addAnnotation, addAnnotations, addMissingAnnotation, addMissingAnnotations, clearAnnotations, containsUninferredTypeArguments, createType, createTypeOfObject, createTypeOfRecord, equals, getAnnotation, getAnnotation, getAnnotationInHierarchy, getAnnotations, getAnnotationsField, getEffectiveAnnotation, getEffectiveAnnotationInHierarchy, getEffectiveAnnotations, getExplicitAnnotations, getKind, getPrimitiveKind, getUnderlyingTypeHashCode, hasAnnotation, hasAnnotation, hasAnnotationInHierarchy, hasAnnotationRelaxed, hasEffectiveAnnotation, hasEffectiveAnnotation, hasEffectiveAnnotationRelaxed, hasExplicitAnnotation, hasExplicitAnnotation, hasExplicitAnnotationRelaxed, hashCode, isAnnotatedInHierarchy, removeAnnotation, removeAnnotationByClass, removeAnnotationInHierarchy, removeAnnotations, removeNonTopAnnotationInHierarchy, replaceAnnotation, replaceAnnotations, toString, toString
-
-
-
-
Field Detail
-
typeArgs
protected java.util.List<AnnotatedTypeMirror> typeArgs
Parametrized Type Arguments.
-
enclosingType
protected @Nullable AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType
The enclosing type. May be null. May be changed.
-
-
Method Detail
-
isDeclaration
public boolean isDeclaration()
Description copied from class:AnnotatedTypeMirror
Returns true if this type mirror represents a declaration, rather than a use, of a type.For example,
class List<T> { ... }
declares a new typeList<T>
, whileList<Integer>
is a use of the type.- Overrides:
isDeclaration
in classAnnotatedTypeMirror
- Returns:
- true if this represents a declaration
-
deepCopy
public AnnotatedTypeMirror.AnnotatedDeclaredType deepCopy(boolean copyAnnotations)
Description copied from class:AnnotatedTypeMirror
Returns a deep copy of this type. A deep copy implies that each component type is copied recursively and the returned type refers to those copies in its component locations.Note: deepCopy provides two important properties in the returned copy:
- Structure preservation -- The exact structure of the original AnnotatedTypeMirror is preserved in the copy including all component types.
- Annotation preservation -- All of the annotations from the original AnnotatedTypeMirror and its components have been copied to the new type.
- Specified by:
deepCopy
in classAnnotatedTypeMirror
- Returns:
- a deep copy
-
deepCopy
public AnnotatedTypeMirror.AnnotatedDeclaredType deepCopy()
Description copied from class:AnnotatedTypeMirror
Returns a deep copy of this type with annotations.Each subclass implements this method with the subclass return type. The method body must always be a call to deepCopy(true).
- Specified by:
deepCopy
in interfaceorg.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Specified by:
deepCopy
in classAnnotatedTypeMirror
- Returns:
- a deep copy of this type with annotations
- See Also:
AnnotatedTypeMirror.deepCopy(boolean)
-
asUse
public AnnotatedTypeMirror.AnnotatedDeclaredType asUse()
- Overrides:
asUse
in classAnnotatedTypeMirror
-
accept
public <R,P> R accept(AnnotatedTypeVisitor<R,P> v, P p)
Description copied from class:AnnotatedTypeMirror
Applies a visitor to this type.- Specified by:
accept
in classAnnotatedTypeMirror
- Type Parameters:
R
- the return type of the visitor's methodsP
- the type of the additional parameter to the visitor's methods- Parameters:
v
- the visitor operating on this typep
- additional parameter to the visitor- Returns:
- a visitor-specified result
-
setTypeArguments
public void setTypeArguments(java.util.List<? extends AnnotatedTypeMirror> ts)
Sets the type arguments on this type.- Parameters:
ts
- a list of type arguments to be captured by this method
-
getTypeArguments
public java.util.List<AnnotatedTypeMirror> getTypeArguments()
Returns the type argument for this type.- Returns:
- the type argument for this type
-
isUnderlyingTypeRaw
public boolean isUnderlyingTypeRaw()
Returns true if the underlying type is raw. The receiver of this method is not raw, however; its annotated type arguments have been inferred.- Returns:
- true iff the type was raw
-
wasRaw
@Deprecated public boolean wasRaw()
Deprecated.UseisUnderlyingTypeRaw()
insteadReturns true if the underlying type is raw. The receiver of this method is not raw, however; its annotated type arguments have been inferred.- Returns:
- true iff the type was raw
-
setIsUnderlyingTypeRaw
protected void setIsUnderlyingTypeRaw()
Set the isUnderlyingTypeRaw flag to true. This should only be necessary when determining the supertypes of a raw type.
-
setWasRaw
@Deprecated protected void setWasRaw()
Deprecated.UsesetIsUnderlyingTypeRaw()
insteadSet the isUnderlyingTypeRaw flag to true. This should only be necessary when determining the supertypes of a raw type.
-
getUnderlyingType
public javax.lang.model.type.DeclaredType getUnderlyingType()
Description copied from class:AnnotatedTypeMirror
Returns the underlying unannotated Java type, which this wraps.- Overrides:
getUnderlyingType
in classAnnotatedTypeMirror
- Returns:
- the underlying type
-
directSupertypes
public java.util.List<AnnotatedTypeMirror.AnnotatedDeclaredType> directSupertypes()
Description copied from class:AnnotatedTypeMirror
This method returns a list of AnnotatedTypeMirrors where the Java type of each ATM is an immediate supertype (class or interface) of the Java type of this. The interface types, if any, appear at the end of the list. If the directSuperType has type arguments, then the annotations on those type arguments are taken with proper translation from the declaration of the Java type of this.For example,
class B<T> { ... }
class A extends B<@NonNull String> { ... }
@Nullable A a;
@Nullable A
is@Nullable B<@NonNull String>
.An example with more complex type arguments:
class D<Q,R> { ... }
class A<T,S> extends D<S,T> { ... }
@Nullable A<@NonNull String, @NonNull Object> a;
@Nullable A<@NonNull String, @NonNull Object>
is@Nullable B<@NonNull Object, @NonNull String>
.An example with more than one direct supertype:
class B<T> implements List<Integer> { ... }
class A extends B<@NonNull String> implements List<Integer> { ... }
@Nullable A a;
@Nullable A
are@Nullable B <@NonNull String>
and@Nullable List<@NonNull Integer>
.- Overrides:
directSupertypes
in classAnnotatedTypeMirror
- Returns:
- the immediate supertypes of this
- See Also:
Types.directSupertypes(TypeMirror)
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedDeclaredType shallowCopy()
Description copied from class:AnnotatedTypeMirror
Returns a shallow copy of this type with annotations.Each subclass implements this method with the subclass return type. The method body must always be a call to shallowCopy(true).
- Specified by:
shallowCopy
in classAnnotatedTypeMirror
- Returns:
- a shallow copy of this type with annotations
- See Also:
AnnotatedTypeMirror.shallowCopy(boolean)
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedDeclaredType shallowCopy(boolean copyAnnotations)
Description copied from class:AnnotatedTypeMirror
Returns a shallow copy of this type. A shallow copy implies that each component type in the output copy refers to the same object as the object being copied.- Specified by:
shallowCopy
in classAnnotatedTypeMirror
- Parameters:
copyAnnotations
- whether copy should have annotations, i.e. whether fieldannotations
should be copied.
-
getErased
public AnnotatedTypeMirror.AnnotatedDeclaredType getErased()
Return the declared type with its type arguments removed. This also replaces the underlying type with its erasure.- Overrides:
getErased
in classAnnotatedTypeMirror
- Returns:
- a fresh copy of the declared type with no type arguments
- See Also:
- https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html#jls-4.6
-
setEnclosingType
public void setEnclosingType(@Nullable AnnotatedTypeMirror.AnnotatedDeclaredType enclosingType)
Sets the enclosing type.- Parameters:
enclosingType
- the new enclosing type
-
getEnclosingType
public @Nullable AnnotatedTypeMirror.AnnotatedDeclaredType getEnclosingType()
Returns the enclosing type, as in the type ofA
in the typeA.B
. May return null.- Returns:
- enclosingType the enclosing type, or null if this is a top-level type
-
-