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
-
Method Summary
Modifier and TypeMethodDescriptionadaptType(CtTypeInformation type)
adapts `type` to theCtTypeReference
of the scope of thisGenericTypeAdapter
This mapping function is able to resolveCtTypeParameter
of:
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 theCtTypeReference
of scope of thisMethodTypingContext
In can beCtTypeParameterReference
again - depending actual type arguments of thisMethodTypingContext
.boolean
hasSameMethodFormalTypeParameters(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 theCtTypeReference
of scope of thisMethodTypingContext
In can beCtTypeParameterReference
again - depending actual type arguments of thisMethodTypingContext
.- Parameters:
typeParam
- to be resolvedCtTypeParameter
- Returns:
CtTypeReference
orCtTypeParameterReference
adapted to scope of thisMethodTypingContext
or 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:GenericTypeAdapter
adapts `type` to theCtTypeReference
of the scope of thisGenericTypeAdapter
This mapping function is able to resolveCtTypeParameter
of:
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:
adaptType
in interfaceGenericTypeAdapter
- Parameters:
type
- to be adapted type- Returns:
CtTypeReference
adapted to scope of thisClassTypingContext
or null if type cannot be adapted to this `scope`.
-