Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jun 5, 2024
1 parent 3a241d8 commit 5e7eee8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/ruby_indexer/lib/ruby_indexer/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions lib/ruby_indexer/test/index_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -848,18 +848,23 @@ 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)
assert_equal(3, entry.location.end_column)

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)
Expand Down

0 comments on commit 5e7eee8

Please sign in to comment.