Skip to content

Commit 3d95b97

Browse files
authored
Use field instead of variable for instance variable symbol kinds (#2898)
### Motivation Very minor thing, but I noticed that we were using the wrong symbol kind for instance variables in document symbols. We use `FIELD` everywhere else, so that it doesn't get confused with other types of variables. ### Implementation Changed to `FIELD`. ### Automated Tests Updated the tests.
1 parent 15841f6 commit 3d95b97

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/ruby_lsp/listeners/document_symbol.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def on_class_variable_write_node_enter(node)
266266
def on_instance_variable_write_node_enter(node)
267267
create_document_symbol(
268268
name: node.name.to_s,
269-
kind: Constant::SymbolKind::VARIABLE,
269+
kind: Constant::SymbolKind::FIELD,
270270
range_location: node.name_loc,
271271
selection_range_location: node.name_loc,
272272
)
@@ -276,7 +276,7 @@ def on_instance_variable_write_node_enter(node)
276276
def on_instance_variable_operator_write_node_enter(node)
277277
create_document_symbol(
278278
name: node.name.to_s,
279-
kind: Constant::SymbolKind::VARIABLE,
279+
kind: Constant::SymbolKind::FIELD,
280280
range_location: node.name_loc,
281281
selection_range_location: node.name_loc,
282282
)
@@ -286,7 +286,7 @@ def on_instance_variable_operator_write_node_enter(node)
286286
def on_instance_variable_or_write_node_enter(node)
287287
create_document_symbol(
288288
name: node.name.to_s,
289-
kind: Constant::SymbolKind::VARIABLE,
289+
kind: Constant::SymbolKind::FIELD,
290290
range_location: node.name_loc,
291291
selection_range_location: node.name_loc,
292292
)
@@ -296,7 +296,7 @@ def on_instance_variable_or_write_node_enter(node)
296296
def on_instance_variable_and_write_node_enter(node)
297297
create_document_symbol(
298298
name: node.name.to_s,
299-
kind: Constant::SymbolKind::VARIABLE,
299+
kind: Constant::SymbolKind::FIELD,
300300
range_location: node.name_loc,
301301
selection_range_location: node.name_loc,
302302
)

test/expectations/document_symbol/ivar.exp.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"result": [
33
{
44
"name": "@a",
5-
"kind": 13,
5+
"kind": 8,
66
"range": {
77
"start": {
88
"line": 0,
@@ -27,7 +27,7 @@
2727
},
2828
{
2929
"name": "@aa",
30-
"kind": 13,
30+
"kind": 8,
3131
"range": {
3232
"start": {
3333
"line": 1,
@@ -76,7 +76,7 @@
7676
"children": [
7777
{
7878
"name": "@b",
79-
"kind": 13,
79+
"kind": 8,
8080
"range": {
8181
"start": {
8282
"line": 4,
@@ -101,7 +101,7 @@
101101
},
102102
{
103103
"name": "@bb",
104-
"kind": 13,
104+
"kind": 8,
105105
"range": {
106106
"start": {
107107
"line": 5,
@@ -150,7 +150,7 @@
150150
"children": [
151151
{
152152
"name": "@c",
153-
"kind": 13,
153+
"kind": 8,
154154
"range": {
155155
"start": {
156156
"line": 8,
@@ -175,7 +175,7 @@
175175
},
176176
{
177177
"name": "@cc",
178-
"kind": 13,
178+
"kind": 8,
179179
"range": {
180180
"start": {
181181
"line": 9,

0 commit comments

Comments
 (0)