Class: RubyLsp::Phlex::IndexingEnhancement

Inherits:
RubyIndexer::Enhancement
  • Object
show all
Defined in:
lib/ruby_lsp/phlex/addon.rb

Instance Method Summary collapse

Instance Method Details

#on_call_node_enter(node) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ruby_lsp/phlex/addon.rb', line 24

def on_call_node_enter(node)
	name = node.name
	owner = @listener.current_owner
	location = node.location
	arguments = node.arguments&.arguments

	return unless owner
	return unless :register_element == name

	case arguments
	in [Prism::SymbolNode[unescaped: String => method_name], *]
		tag_name = method_name.tr("_", "-")
		arguments[1] in Prism::StringNode[unescaped: String => tag_name]

		@listener.add_method(method_name, location, [
			RubyIndexer::Entry::Signature.new([
				RubyIndexer::Entry::KeywordRestParameter.new(name: :attributes),
				RubyIndexer::Entry::BlockParameter.new(name: :content),
			]),
		], visibility: :public, comments: "Outputs a `<#{tag_name}>` tag.")
	end
end