Class: Rigor::Plugin::TypeNodeResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/plugin/type_node_resolver.rb,
sig/rigor/plugin/type_node_resolver.rbs

Overview

Plugin-supplied resolver for custom named / generic type vocabulary in RBS::Extended payloads. ADR-13 § "Decision".

Subclasses override #resolve to return a Type::Base when the node matches the vocabulary the resolver covers, or nil to fall through to the next resolver in the chain (and finally to the built-in / RBS fallback). The base implementation returns nil so an unimplemented subclass is a safe no-op.

Resolvers are registered through their plugin's manifest under the type_node_resolvers: slot:

class RigorTypescriptUtilityTypes < Rigor::Plugin::Base
manifest(
  id: "typescript-utility-types",
  version: "0.1.0",
  type_node_resolvers: [Resolvers::Pick.new,
                        Resolvers::Omit.new]
)
end

ADR-13 — base class, manifest hook, and registry aggregation for plugin-contributed type-node resolvers. Resolvers declared via manifest(type_node_resolvers:) run for every real %a{rigor:v1:...} payload through TypeNode::ResolverChain (built by Environment#build_name_scope from Plugin::Registry#type_node_resolvers).

Resolvers SHOULD be stateless and re-entrant; the registry builds the chain once per Analysis::Runner.run and may consult any resolver multiple times for the same node.

Instance Method Summary collapse

Instance Method Details

#resolve(node, scope) ⇒ Rigor::Type::Base?

Returns resolved type, or nil to fall through.

Parameters:

Returns:

  • (Rigor::Type::Base, nil)

    resolved type, or nil to fall through.



36
37
38
# File 'lib/rigor/plugin/type_node_resolver.rb', line 36

def resolve(node, scope) # rubocop:disable Lint/UnusedMethodArgument
  nil
end