Skip to content

Commit c7c36e2

Browse files
authored
Index attr (#3544)
1 parent 1753b02 commit c7c36e2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def on_call_node_enter(node)
254254
case message
255255
when :private_constant
256256
handle_private_constant(node)
257-
when :attr_reader
257+
when :attr_reader, :attr
258258
handle_attribute(node, reader: true, writer: false)
259259
when :attr_writer
260260
handle_attribute(node, reader: false, writer: true)

lib/ruby_indexer/test/method_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,16 @@ def qux; end
950950
assert_predicate(entry, :public?)
951951
end
952952

953+
def test_handling_attr
954+
index(<<~RUBY)
955+
class Foo
956+
attr :bar
957+
end
958+
RUBY
959+
960+
assert_entry("bar", Entry::Accessor, "/fake/path/foo.rb:1-8:1-11")
961+
end
962+
953963
private
954964

955965
#: (Entry::Method entry, String call_string) -> void

0 commit comments

Comments
 (0)