Class: Rigor::LanguageServer::HoverRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/language_server/hover_renderer.rb

Overview

Builds the LSP ‘Hover.contents` markdown body. Dispatches on the hovered Prism node class so each shape (method call, constant, local, literal, …) gets the most relevant type-aware presentation.

Slice A1 (this commit) ships:

  • default body bit-for-bit matching the LSP v1 slice 5 output (‘type:` / `erased:` / `node:`),

  • ‘Prism::CallNode` specialisation surfacing the receiver type + RBS-erased method signature.

Slices A2-A4 extend the dispatch with constant / local / ivar / literal renderers per ‘docs/design/20260517-lsp-hover-completion.md`.

Instance Method Summary collapse

Instance Method Details

#render(node:, type:, node_scope_lookup:) ⇒ Object

Parameters:

  • node_scope_lookup (#[])

    node-to-scope table built by ‘ScopeIndexer.index`. The renderer indexes into it to retrieve the receiver’s narrow scope when specialising on ‘CallNode`. The lookup never returns nil (the indexer’s Hash carries ‘default_scope` as its default value), so the renderer trusts the lookup result.



33
34
35
36
37
38
# File 'lib/rigor/language_server/hover_renderer.rb', line 33

def render(node:, type:, node_scope_lookup:)
  body = render_body(node, type, node_scope_lookup)
  result = { contents: { kind: "markdown", value: body } }
  result[:range] = lsp_range_for(node) if node.respond_to?(:location) && node.location
  result
end