Skip to content

Commit 8c03055

Browse files
committed
Add the tag name to the comments
1 parent 6d194f9 commit 8c03055

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

fixtures/components/article.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
class Components::Article < Phlex::HTML
4+
register_element :react_component
5+
46
def view_template(&)
57
article(&)
68
end

lib/ruby_lsp/phlex/addon.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ def on_call_node_enter(node)
3131
return unless :register_element == name
3232

3333
case arguments
34-
in [Prism::SymbolNode[unescaped: String => element_name], *]
35-
@listener.add_method(element_name, location, [
34+
in [Prism::SymbolNode[unescaped: String => method_name], *]
35+
tag_name = method_name.tr("_", "-")
36+
arguments[1] in Prism::StringNode[unescaped: String => tag_name]
37+
38+
@listener.add_method(method_name, location, [
3639
RubyIndexer::Entry::Signature.new([
3740
RubyIndexer::Entry::KeywordRestParameter.new(name: :attributes),
3841
RubyIndexer::Entry::BlockParameter.new(name: :content),
3942
]),
40-
], visibility: :public)
43+
], visibility: :public, comments: "Outputs a `<#{tag_name}>` tag.")
4144
end
4245
end
4346
end

0 commit comments

Comments
 (0)