Interface ViewpointAdapter
- All Known Implementing Classes:
AbstractViewpointAdapter,ViewpointTestViewpointAdapter
Viewpoint adaptation takes a type that was written from a particular viewpoint (the
declaration viewpoint) and translates it to a type from another viewpoint (the receiver
viewpoint). For example, if a field's type uses an annotation like @This, viewpoint
adaptation replaces that annotation with the actual receiver type at the use site.
Viewpoint adaptation applies to member/field accesses, constructor invocations, method invocations, and type parameter bound instantiations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidviewpointAdaptConstructor(AnnotatedTypeMirror receiverType, ExecutableElement constructorElt, AnnotatedTypeMirror.AnnotatedExecutableType constructorType) Viewpoint-adapts a constructor invocation.voidviewpointAdaptMember(AnnotatedTypeMirror receiverType, Element memberElement, AnnotatedTypeMirror memberType) Viewpoint-adapts a member or field access.voidviewpointAdaptMethod(AnnotatedTypeMirror receiverType, ExecutableElement methodElt, AnnotatedTypeMirror.AnnotatedExecutableType methodType) Viewpoint-adapts a method invocation.viewpointAdaptType(AnnotatedTypeMirror receiverType, AnnotatedTypeMirror declaredType) Viewpoint-adapts a type written from the receiver's declaration viewpoint.viewpointAdaptTypeDeclarationBounds(AnnotationMirrorSet viewpointBounds, AnnotatedTypeMirror declarationBoundType) Viewpoint-adapts the primary qualifiers ofdeclarationBoundTypefrom the viewpoint ofviewpointBounds.voidviewpointAdaptTypeParameterBounds(AnnotatedTypeMirror receiverType, List<AnnotatedTypeParameterBounds> typeParameterBounds) Viewpoint-adapts a type parameter bound when being instantiated.
-
Method Details
-
viewpointAdaptMember
void viewpointAdaptMember(AnnotatedTypeMirror receiverType, Element memberElement, AnnotatedTypeMirror memberType) Viewpoint-adapts a member or field access.Developer notes: When this method is invoked on a member/field with a type given by a type parameter, the type arguments are correctly substituted, and
memberTypeis already in a good shape. Only annotations onmemberTypeshould be replaced by the viewpoint-adapted ones.- Parameters:
receiverType- the receiver type through which the member or field is accessedmemberElement- the element of the accessed member or fieldmemberType- the accessed type of the member or field. After the method returns, it will be mutated to the viewpoint-adapted result.
-
viewpointAdaptConstructor
void viewpointAdaptConstructor(AnnotatedTypeMirror receiverType, ExecutableElement constructorElt, AnnotatedTypeMirror.AnnotatedExecutableType constructorType) Viewpoint-adapts a constructor invocation. Takes an unsubstituted method invocation type and performs the viewpoint adaptation in place, modifying the parameter. The type variables of the class stay in place:AnnotatedTypes#asMemberOfsubstitutes the type arguments for them afterwards.- Parameters:
receiverType- the receiver type through which a constructor is invokedconstructorElt- the element of the invoked constructorconstructorType- the invoked type of the constructor with type variables not substituted. After the method returns, it will be mutated to the viewpoint-adapted constructor type.
-
viewpointAdaptMethod
void viewpointAdaptMethod(AnnotatedTypeMirror receiverType, ExecutableElement methodElt, AnnotatedTypeMirror.AnnotatedExecutableType methodType) Viewpoint-adapts a method invocation. Takes an unsubstituted method invocation type and performs the viewpoint adaptation in place, modifying the parameter. The type variables of the class stay in place:AnnotatedTypes#asMemberOfsubstitutes the receiver's type arguments for them afterwards.- Parameters:
receiverType- the receiver type through which a method is invokedmethodElt- the element of the invoked method. Only used to determine whether this type should be viewpoint-adapted.methodType- the invoked type of the method with type variables not substituted. After the method returns, it will be mutated to the viewpoint-adapted method type.
-
viewpointAdaptTypeParameterBounds
void viewpointAdaptTypeParameterBounds(AnnotatedTypeMirror receiverType, List<AnnotatedTypeParameterBounds> typeParameterBounds) Viewpoint-adapts a type parameter bound when being instantiated.- Parameters:
receiverType- the receiver type through which the type parameter is instantiatedtypeParameterBounds- a list of type parameter bounds. After the method returns, it will be mutated to the viewpoint-adapted type parameter bounds.
-
viewpointAdaptTypeDeclarationBounds
AnnotationMirrorSet viewpointAdaptTypeDeclarationBounds(AnnotationMirrorSet viewpointBounds, AnnotatedTypeMirror declarationBoundType) Viewpoint-adapts the primary qualifiers ofdeclarationBoundTypefrom the viewpoint ofviewpointBounds. This is how a supertype declared with a receiver-dependent bound takes on the bound of the subtype that extends or implements it.- Parameters:
viewpointBounds- the type-declaration bounds that provide the viewpointdeclarationBoundType- the type whose declaration bounds to adapt- Returns:
- the adapted declaration bounds
-
viewpointAdaptType
AnnotatedTypeMirror viewpointAdaptType(AnnotatedTypeMirror receiverType, AnnotatedTypeMirror declaredType) Viewpoint-adapts a type written from the receiver's declaration viewpoint.- Parameters:
receiverType- the receiver type through whichdeclaredTypeis vieweddeclaredType- the type to viewpoint-adapt- Returns:
- the viewpoint-adapted type
-