Class TypeHierarchyResolver

java.lang.Object
io.helidon.codegen.TypeHierarchyResolver

public class TypeHierarchyResolver extends Object
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.

  • Constructor Details

    • TypeHierarchyResolver

      protected TypeHierarchyResolver(Function<TypeName, Optional<TypeInfo>> typeInfoLookup)
      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 - if typeInfoLookup is null
  • 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 - if interfaceInfo is null
    • resolveSupertype

      public final Optional<TypeName> resolveSupertype(TypeName candidate, TypeName expected)
      Resolves one requested supertype while preserving its actual type arguments.
      Parameters:
      candidate - type whose hierarchy is inspected
      expected - requested supertype
      Returns:
      the resolved supertype, or an empty optional when it is not present
      Throws:
      NullPointerException - if candidate or expected is null
    • 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 type
      useSiteType - concrete use of the enclosing type
      memberType - member type declared by the enclosing type
      Returns:
      member type with enclosing type variables substituted
      Throws:
      NullPointerException - if enclosingType, useSiteType, or memberType is null
    • resolveEnvironmentMember

      protected Optional<TypedElementInfo> resolveEnvironmentMember(TypeInfo interfaceInfo, TypedElementInfo declaration)
      Resolves a declaration as a member of the inspected interface.
      Parameters:
      interfaceInfo - inspected interface
      declaration - source declaration
      Returns:
      the compiler resolved member, or an empty optional to use the portable model
      Throws:
      NullPointerException - if interfaceInfo or declaration is null
    • environmentOverrides

      protected Optional<Boolean> environmentOverrides(TypeInfo interfaceInfo, TypedElementInfo overrider, TypedElementInfo overridden)
      Determines whether one declaration overrides another in the inspected interface.
      Parameters:
      interfaceInfo - inspected interface
      overrider - possible overriding declaration
      overridden - possible overridden declaration
      Returns:
      the compiler decision, or an empty optional to use the portable model
      Throws:
      NullPointerException - if interfaceInfo, overrider, or overridden is null
    • 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 interface
      candidate - candidate declaration
      existing - declaration that must be implemented
      Returns:
      the compiler decision, or an empty optional to use the portable model
      Throws:
      NullPointerException - if interfaceInfo, candidate, or existing is null
    • resolveEnvironmentSupertype

      protected Optional<TypeName> resolveEnvironmentSupertype(TypeName candidate, TypeName expected)
      Resolves a supertype through the environment type system.
      Parameters:
      candidate - type whose hierarchy is inspected
      expected - requested supertype
      Returns:
      the resolved supertype, or an empty optional to use the portable model
      Throws:
      NullPointerException - if candidate or expected is null