Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Aug 30, 2023
1 parent a3a6cc6 commit bff3d2a
Show file tree
Hide file tree
Showing 54 changed files with 194 additions and 197 deletions.
32 changes: 16 additions & 16 deletions lib/ruby_indexer/test/classes_and_modules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Foo
end
RUBY

assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-3")
end

def test_class_with_statements
Expand All @@ -21,7 +21,7 @@ def something; end
end
RUBY

assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:2-2")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:2-3")
end

def test_colon_colon_class
Expand All @@ -30,7 +30,7 @@ class ::Foo
end
RUBY

assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-3")
end

def test_colon_colon_class_inside_class
Expand All @@ -41,8 +41,8 @@ class ::Foo
end
RUBY

assert_entry("Bar", Index::Entry::Class, "/fake/path/foo.rb:0-0:3-2")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:1-2:2-4")
assert_entry("Bar", Index::Entry::Class, "/fake/path/foo.rb:0-0:3-3")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:1-2:2-5")
end

def test_namespaced_class
Expand All @@ -51,7 +51,7 @@ class Foo::Bar
end
RUBY

assert_entry("Foo::Bar", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo::Bar", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-3")
end

def test_dynamically_namespaced_class
Expand All @@ -69,7 +69,7 @@ module Foo
end
RUBY

assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-3")
end

def test_module_with_statements
Expand All @@ -79,7 +79,7 @@ def something; end
end
RUBY

assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:2-2")
assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:2-3")
end

def test_colon_colon_module
Expand All @@ -88,7 +88,7 @@ module ::Foo
end
RUBY

assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-3")
end

def test_namespaced_module
Expand All @@ -97,7 +97,7 @@ module Foo::Bar
end
RUBY

assert_entry("Foo::Bar", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo::Bar", Index::Entry::Module, "/fake/path/foo.rb:0-0:1-3")
end

def test_dynamically_namespaced_module
Expand All @@ -124,11 +124,11 @@ class Something
end
RUBY

assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:10-2")
assert_entry("Foo::Bar", Index::Entry::Class, "/fake/path/foo.rb:1-2:2-4")
assert_entry("Foo::Baz", Index::Entry::Module, "/fake/path/foo.rb:4-2:9-4")
assert_entry("Foo::Baz::Qux", Index::Entry::Class, "/fake/path/foo.rb:5-4:8-6")
assert_entry("Foo::Baz::Qux::Something", Index::Entry::Class, "/fake/path/foo.rb:6-6:7-8")
assert_entry("Foo", Index::Entry::Module, "/fake/path/foo.rb:0-0:10-3")
assert_entry("Foo::Bar", Index::Entry::Class, "/fake/path/foo.rb:1-2:2-5")
assert_entry("Foo::Baz", Index::Entry::Module, "/fake/path/foo.rb:4-2:9-5")
assert_entry("Foo::Baz::Qux", Index::Entry::Class, "/fake/path/foo.rb:5-4:8-7")
assert_entry("Foo::Baz::Qux::Something", Index::Entry::Class, "/fake/path/foo.rb:6-6:7-9")
end

def test_deleting_from_index_based_on_file_path
Expand All @@ -137,7 +137,7 @@ class Foo
end
RUBY

assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-2")
assert_entry("Foo", Index::Entry::Class, "/fake/path/foo.rb:0-0:1-3")

@index.delete("/fake/path/foo.rb")
refute_entry("Foo")
Expand Down
22 changes: 11 additions & 11 deletions lib/ruby_indexer/test/constant_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class ::Bar
end
RUBY

assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-6")
assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-8")
assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-7")
assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-9")
end

def test_constant_or_writes
Expand All @@ -27,8 +27,8 @@ class ::Bar
end
RUBY

assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-8")
assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-10")
assert_entry("FOO", Index::Entry::Constant, "/fake/path/foo.rb:0-0:0-9")
assert_entry("Bar::FOO", Index::Entry::Constant, "/fake/path/foo.rb:3-2:3-11")
end

def test_constant_path_writes
Expand All @@ -45,10 +45,10 @@ module B
A::BAZ = 1
RUBY

assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-8")
assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-10")
assert_entry("A::B::FOO", Index::Entry::Constant, "/fake/path/foo.rb:5-4:5-10")
assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:9-0:9-9")
assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-9")
assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-11")
assert_entry("A::B::FOO", Index::Entry::Constant, "/fake/path/foo.rb:5-4:5-11")
assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:9-0:9-10")
end

def test_constant_path_or_writes
Expand All @@ -61,9 +61,9 @@ class A
A::BAZ ||= 1
RUBY

assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-10")
assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-12")
assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:5-0:5-11")
assert_entry("A::FOO", Index::Entry::Constant, "/fake/path/foo.rb:1-2:1-11")
assert_entry("BAR", Index::Entry::Constant, "/fake/path/foo.rb:2-2:2-13")
assert_entry("A::BAZ", Index::Entry::Constant, "/fake/path/foo.rb:5-0:5-12")
end

def test_comments_for_constants
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/requests/document_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def after_module(node)
sig { params(node: YARP::InstanceVariableWriteNode).void }
def on_instance_variable_write(node)
create_document_symbol(
name: node.name,
name: node.name.to_s, # ???
kind: :variable,
range_node: node,
selection_range_node: node.name_loc,
Expand Down
2 changes: 1 addition & 1 deletion test/expectations/definition/class_reference.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"end": {
"line": 187,
"character": 4
"character": 5
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/expectations/document_symbol/attr_accessor.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"end": {
"line": 0,
"character": 13
"character": 14
}
},
"selectionRange": {
Expand All @@ -20,7 +20,7 @@
},
"end": {
"line": 0,
"character": 13
"character": 14
}
},
"children": []
Expand All @@ -35,7 +35,7 @@
},
"end": {
"line": 1,
"character": 13
"character": 14
}
},
"selectionRange": {
Expand All @@ -45,7 +45,7 @@
},
"end": {
"line": 1,
"character": 13
"character": 14
}
},
"children": []
Expand All @@ -60,7 +60,7 @@
},
"end": {
"line": 1,
"character": 17
"character": 18
}
},
"selectionRange": {
Expand All @@ -70,7 +70,7 @@
},
"end": {
"line": 1,
"character": 17
"character": 18
}
},
"children": []
Expand All @@ -85,7 +85,7 @@
},
"end": {
"line": 2,
"character": 15
"character": 16
}
},
"selectionRange": {
Expand All @@ -95,7 +95,7 @@
},
"end": {
"line": 2,
"character": 15
"character": 16
}
},
"children": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"end": {
"line": 2,
"character": 2
"character": 3
}
},
"selectionRange": {
Expand All @@ -20,7 +20,7 @@
},
"end": {
"line": 0,
"character": 8
"character": 9
}
},
"children": [
Expand All @@ -34,7 +34,7 @@
},
"end": {
"line": 1,
"character": 15
"character": 16
}
},
"selectionRange": {
Expand All @@ -44,7 +44,7 @@
},
"end": {
"line": 1,
"character": 10
"character": 11
}
},
"children": []
Expand Down
16 changes: 8 additions & 8 deletions test/expectations/document_symbol/const.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"end": {
"line": 0,
"character": 6
"character": 7
}
},
"selectionRange": {
Expand All @@ -20,7 +20,7 @@
},
"end": {
"line": 0,
"character": 1
"character": 2
}
},
"children": []
Expand All @@ -35,7 +35,7 @@
},
"end": {
"line": 1,
"character": 8
"character": 9
}
},
"selectionRange": {
Expand All @@ -45,7 +45,7 @@
},
"end": {
"line": 1,
"character": 3
"character": 4
}
},
"children": []
Expand All @@ -60,7 +60,7 @@
},
"end": {
"line": 2,
"character": 11
"character": 12
}
},
"selectionRange": {
Expand All @@ -70,7 +70,7 @@
},
"end": {
"line": 2,
"character": 6
"character": 7
}
},
"children": []
Expand All @@ -85,7 +85,7 @@
},
"end": {
"line": 3,
"character": 13
"character": 14
}
},
"selectionRange": {
Expand All @@ -95,7 +95,7 @@
},
"end": {
"line": 3,
"character": 8
"character": 9
}
},
"children": []
Expand Down
4 changes: 2 additions & 2 deletions test/expectations/document_symbol/def.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"end": {
"line": 3,
"character": 2
"character": 3
}
},
"selectionRange": {
Expand All @@ -20,7 +20,7 @@
},
"end": {
"line": 0,
"character": 6
"character": 7
}
},
"children": []
Expand Down
4 changes: 2 additions & 2 deletions test/expectations/document_symbol/def_endless.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"end": {
"line": 2,
"character": 11
"character": 12
}
},
"selectionRange": {
Expand All @@ -20,7 +20,7 @@
},
"end": {
"line": 2,
"character": 6
"character": 7
}
},
"children": []
Expand Down
Loading

0 comments on commit bff3d2a

Please sign in to comment.