Skip to content

Commit

Permalink
Index modules and classes starting with unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Sep 5, 2023
1 parent 44c7b1c commit d9c8245
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/ruby_indexer/lib/ruby_indexer/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ def add_constant_with_path(node)
sig { params(node: T.any(YARP::ClassNode, YARP::ModuleNode), klass: T.class_of(Index::Entry)).void }
def add_index_entry(node, klass)
name = node.constant_path.location.slice

unless /^[A-Z:]/.match?(name)
return visit_child_nodes(node)
end
return visit_child_nodes(node) unless /^[[:upper:]:]/.match?(name)

comments = collect_comments(node)
@index << klass.new(fully_qualify_name(name), @file_path, node.location, comments)
Expand Down
16 changes: 16 additions & 0 deletions lib/ruby_indexer/test/classes_and_modules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,21 @@ class Bar; end
second_foo_entry = @index["Bar"][0]
assert_equal("This is a Bar comment", second_foo_entry.comments.join("\n"))
end

def test_constants_using_unicode_names_are_properly_indexed
index(<<~RUBY)
class Árvore
end
module Ônibus
end
ÓCULOS = 1
RUBY

assert_entry("Árvore", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Ônibus", Index::Entry::Module, "/fake/path/foo.rb:3-0:4-2")
assert_entry("ÓCULOS", Index::Entry::Constant, "/fake/path/foo.rb:6-0:6-9")
end
end
end

0 comments on commit d9c8245

Please sign in to comment.