Package spoon.support.visitor
Class MethodTypingContext
java.lang.Object
spoon.support.visitor.MethodTypingContext
- All Implemented Interfaces:
GenericTypeAdapter
For the scope method or constructor and super type hierarchy of it's declaring type,
it is able to adapt type parameters.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.4.4
Where two methods or constructors M and N have the same type parameters
hasSameMethodFormalTypeParameters(CtFormalTypeDeclarer),
a type mentioned in N can be adapted to the type parameters of M-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadaptType(CtTypeInformation type)adapts `type` to theCtTypeReferenceof the scope of thisGenericTypeAdapterThis mapping function is able to resolveCtTypeParameterof:
A) input type or any super class or any enclosing class of input type or it's super class
B) super interfaces of input type or super interfaces of it's super classes.
The type reference is adapted recursive including all it's actual type arguments and bounds.protected @Nullable CtTypeReference<?>adaptTypeParameter(CtTypeParameter typeParam)Adapts `typeParam` to theCtTypeReferenceof scope of thisMethodTypingContextIn can beCtTypeParameterReferenceagain - depending actual type arguments of thisMethodTypingContext.booleanhasSameMethodFormalTypeParameters(CtFormalTypeDeclarer typeParamDeclarer)https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.4.4 Formal type parameters of method are same if 1) both methods have same number of formal type parameters 2) bounds of Formal type parameters are after adapting same typessetClassTypingContext(ClassTypingContext classTypingContext)setConstructor(CtConstructor<?> constructor)setExecutableReference(CtExecutableReference<?> execRef)setInvocation(CtInvocation<?> invocation)
-
Constructor Details
-
MethodTypingContext
public MethodTypingContext()
-
-
Method Details
-
getAdaptationScope
- Returns:
- the scope of this type adapter
-
setMethod
-
setConstructor
-
getEnclosingGenericTypeAdapter
- Returns:
- the
GenericTypeAdapter, which adapts generic types of enclosing type
-
setClassTypingContext
-
setInvocation
-
setExecutableReference
-
adaptTypeParameter
Adapts `typeParam` to theCtTypeReferenceof scope of thisMethodTypingContextIn can beCtTypeParameterReferenceagain - depending actual type arguments of thisMethodTypingContext.- Parameters:
typeParam- to be resolvedCtTypeParameter- Returns:
CtTypeReferenceorCtTypeParameterReferenceadapted to scope of thisMethodTypingContextor null if `typeParam` cannot be adapted to target `scope`
-
hasSameMethodFormalTypeParameters
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.4.4 Formal type parameters of method are same if 1) both methods have same number of formal type parameters 2) bounds of Formal type parameters are after adapting same types- Returns:
- true if formal type parameters of method are same
-
adaptType
Description copied from interface:GenericTypeAdapteradapts `type` to theCtTypeReferenceof the scope of thisGenericTypeAdapterThis mapping function is able to resolveCtTypeParameterof:
A) input type or any super class or any enclosing class of input type or it's super class
B) super interfaces of input type or super interfaces of it's super classes.
The type reference is adapted recursive including all it's actual type arguments and bounds.- Specified by:
adaptTypein interfaceGenericTypeAdapter- Parameters:
type- to be adapted type- Returns:
CtTypeReferenceadapted to scope of thisClassTypingContextor null if type cannot be adapted to this `scope`.
-