From 5e7eee821b3c588af595f0fe99fb44552d0416ea Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:41:25 -0400 Subject: [PATCH] wip --- lib/ruby_indexer/lib/ruby_indexer/index.rb | 3 +++ lib/ruby_indexer/test/index_test.rb | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ruby_indexer/lib/ruby_indexer/index.rb b/lib/ruby_indexer/lib/ruby_indexer/index.rb index e769d3663a..e085ea3865 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/index.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/index.rb @@ -35,6 +35,8 @@ def initialize # Holds the linearized ancestors list for every namespace @ancestors = T.let({}, T::Hash[String, T::Array[String]]) + + index_core_classes end sig { params(indexable: IndexablePath).void } @@ -430,6 +432,7 @@ def handle_change(indexable) @ancestors.clear if original_map.any? { |name, hash| updated_map[name] != hash } end + sig { void } def index_core_classes loader = RBS::EnvironmentLoader.new RBS::Environment.from_loader(loader).resolve_type_names diff --git a/lib/ruby_indexer/test/index_test.rb b/lib/ruby_indexer/test/index_test.rb index 6ddc34bedb..192429469a 100644 --- a/lib/ruby_indexer/test/index_test.rb +++ b/lib/ruby_indexer/test/index_test.rb @@ -848,9 +848,9 @@ def test_index_core_classes_using_rbs entries = @index["String"] assert_equal(1, entries.length) entry = entries.first - # TODO: should be a relative path - assert_equal("/Users/andyw8/.gem/ruby/3.3.1/gems/rbs-3.4.4/core/string.rbs", entry.file_path) + assert_match(%r{/gems/rbs-.*/core/string.rbs}, entry.file_path) assert_equal("string.rbs", entry.file_name) + # TODO: using fixed positions may be fragile assert_equal(629, entry.location.start_line) assert_equal(3575, entry.location.end_line) assert_equal(0, entry.location.start_column) @@ -858,8 +858,13 @@ def test_index_core_classes_using_rbs gsub = @index["gsub"].first # assert_nil(gsub.comments) - # assert_nil(gsub.file_path) + assert_match(%r{/gems/rbs-.*/core/string.rbs}, gsub.file_path) # assert_nil(gsub.location) + # TODO: using fixed positions may be fragile + assert_equal(2081, gsub.location.start_line) + assert_equal(2083, gsub.location.end_line) + assert_equal(2, gsub.location.start_column) + assert_equal(74, gsub.location.end_column) assert_equal("gsub", gsub.name) # assert_nil(gsub.owner) # assert_nil(gsub.parameters)