Class TypeHierarchyResolver
java.lang.Object
io.helidon.codegen.TypeHierarchyResolver
Resolves Java methods and generic types across a type hierarchy.
The resolver uses the code generation type model as its portable baseline. An environment may override the protected operations when it has an authoritative Java type system. Annotation processing uses this extension point to delegate member substitution, overriding, and assignability to the compiler whenever the relevant elements are available.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne effective method and the maximally specific declarations that define it. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTypeHierarchyResolver(Function<TypeName, Optional<TypeInfo>> typeInfoLookup) Creates a resolver for an environment specific type information lookup. -
Method Summary
Modifier and TypeMethodDescriptioneffectiveInterfaceMethods(TypeInfo interfaceInfo) Returns effective interface methods with interface type variables resolved.environmentOverrides(TypeInfo interfaceInfo, TypedElementInfo overrider, TypedElementInfo overridden) Determines whether one declaration overrides another in the inspected interface.environmentReturnTypeAssignable(TypeInfo interfaceInfo, TypedElementInfo candidate, TypedElementInfo existing) Determines whether a candidate method has a return type that can implement another declaration.protected Optional<TypedElementInfo> resolveEnvironmentMember(TypeInfo interfaceInfo, TypedElementInfo declaration) Resolves a declaration as a member of the inspected interface.resolveEnvironmentSupertype(TypeName candidate, TypeName expected) Resolves a supertype through the environment type system.final TypeNameresolveMemberType(TypeInfo enclosingType, TypeName useSiteType, TypeName memberType) Resolves a member type in the context of one concrete enclosing type.resolveSupertype(TypeName candidate, TypeName expected) Resolves one requested supertype while preserving its actual type arguments.
-
Constructor Details
-
TypeHierarchyResolver
Creates a resolver for an environment specific type information lookup.- Parameters:
typeInfoLookup- lookup used for types that are not already present in a hierarchy- Throws:
NullPointerException- iftypeInfoLookupisnull
-
-
Method Details
-
effectiveInterfaceMethods
public final List<TypeHierarchyResolver.ResolvedMethod> effectiveInterfaceMethods(TypeInfo interfaceInfo) Returns effective interface methods with interface type variables resolved.Each result retains every maximally specific declaration that contributed to the method. A provider can therefore apply annotation and parameter policy without asking the common resolver to understand provider annotations.
- Parameters:
interfaceInfo- interface to inspect- Returns:
- resolved methods in declaration order
- Throws:
NullPointerException- ifinterfaceInfoisnull
-
resolveSupertype
Resolves one requested supertype while preserving its actual type arguments.- Parameters:
candidate- type whose hierarchy is inspectedexpected- requested supertype- Returns:
- the resolved supertype, or an empty optional when it is not present
- Throws:
NullPointerException- ifcandidateorexpectedisnull
-
resolveMemberType
public final TypeName resolveMemberType(TypeInfo enclosingType, TypeName useSiteType, TypeName memberType) Resolves a member type in the context of one concrete enclosing type.- Parameters:
enclosingType- declaration of the enclosing typeuseSiteType- concrete use of the enclosing typememberType- member type declared by the enclosing type- Returns:
- member type with enclosing type variables substituted
- Throws:
NullPointerException- ifenclosingType,useSiteType, ormemberTypeisnull
-
resolveEnvironmentMember
protected Optional<TypedElementInfo> resolveEnvironmentMember(TypeInfo interfaceInfo, TypedElementInfo declaration) Resolves a declaration as a member of the inspected interface.- Parameters:
interfaceInfo- inspected interfacedeclaration- source declaration- Returns:
- the compiler resolved member, or an empty optional to use the portable model
- Throws:
NullPointerException- ifinterfaceInfoordeclarationisnull
-
environmentOverrides
protected Optional<Boolean> environmentOverrides(TypeInfo interfaceInfo, TypedElementInfo overrider, TypedElementInfo overridden) Determines whether one declaration overrides another in the inspected interface.- Parameters:
interfaceInfo- inspected interfaceoverrider- possible overriding declarationoverridden- possible overridden declaration- Returns:
- the compiler decision, or an empty optional to use the portable model
- Throws:
NullPointerException- ifinterfaceInfo,overrider, oroverriddenisnull
-
environmentReturnTypeAssignable
protected Optional<Boolean> environmentReturnTypeAssignable(TypeInfo interfaceInfo, TypedElementInfo candidate, TypedElementInfo existing) Determines whether a candidate method has a return type that can implement another declaration.- Parameters:
interfaceInfo- inspected interfacecandidate- candidate declarationexisting- declaration that must be implemented- Returns:
- the compiler decision, or an empty optional to use the portable model
- Throws:
NullPointerException- ifinterfaceInfo,candidate, orexistingisnull
-
resolveEnvironmentSupertype
Resolves a supertype through the environment type system.- Parameters:
candidate- type whose hierarchy is inspectedexpected- requested supertype- Returns:
- the resolved supertype, or an empty optional to use the portable model
- Throws:
NullPointerException- ifcandidateorexpectedisnull
-