Skip to content

Commit 79c9765

Browse files
committed
Merge branch 'main' of github.com:joeldrapper/literal
2 parents de2e76e + 417b16c commit 79c9765

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/ruby_lsp/literal/addon.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ def on_call_node_enter(node)
3939
end
4040

4141
case args
42-
in [Prism::SymbolNode[unescaped: String => prop_name], *]
42+
in [Prism::SymbolNode[unescaped: String => prop_name], Prism::Node => prop_type, *]
43+
prop_type_location = prop_type.location
44+
prop_type_indentation = prop_type_location.source_lines[prop_type_location.start_line - 1][/\A\s*/]
45+
46+
prop_signature = prop_type_location.slice.lines.map { |line| line.delete_prefix(prop_type_indentation) }.join
47+
4348
@listener.instance_exec do
4449
@index.add(RubyIndexer::Entry::InstanceVariable.new(
4550
"@#{prop_name}",
4651
@uri,
4752
RubyIndexer::Location.from_prism_location(node.location, @code_units_cache),
48-
collect_comments(node),
53+
[collect_comments(node), "**Type:**\n```ruby\n#{prop_signature}\n```"].join("\n\n"),
4954
owner,
5055
))
5156
end

0 commit comments

Comments
 (0)