Skip to content

Commit

Permalink
Use field instead of variable for instance variable symbol kinds (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
vinistock authored Nov 21, 2024
1 parent 15841f6 commit 3d95b97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/ruby_lsp/listeners/document_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def on_class_variable_write_node_enter(node)
def on_instance_variable_write_node_enter(node)
create_document_symbol(
name: node.name.to_s,
kind: Constant::SymbolKind::VARIABLE,
kind: Constant::SymbolKind::FIELD,
range_location: node.name_loc,
selection_range_location: node.name_loc,
)
Expand All @@ -276,7 +276,7 @@ def on_instance_variable_write_node_enter(node)
def on_instance_variable_operator_write_node_enter(node)
create_document_symbol(
name: node.name.to_s,
kind: Constant::SymbolKind::VARIABLE,
kind: Constant::SymbolKind::FIELD,
range_location: node.name_loc,
selection_range_location: node.name_loc,
)
Expand All @@ -286,7 +286,7 @@ def on_instance_variable_operator_write_node_enter(node)
def on_instance_variable_or_write_node_enter(node)
create_document_symbol(
name: node.name.to_s,
kind: Constant::SymbolKind::VARIABLE,
kind: Constant::SymbolKind::FIELD,
range_location: node.name_loc,
selection_range_location: node.name_loc,
)
Expand All @@ -296,7 +296,7 @@ def on_instance_variable_or_write_node_enter(node)
def on_instance_variable_and_write_node_enter(node)
create_document_symbol(
name: node.name.to_s,
kind: Constant::SymbolKind::VARIABLE,
kind: Constant::SymbolKind::FIELD,
range_location: node.name_loc,
selection_range_location: node.name_loc,
)
Expand Down
12 changes: 6 additions & 6 deletions test/expectations/document_symbol/ivar.exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"result": [
{
"name": "@a",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 0,
Expand All @@ -27,7 +27,7 @@
},
{
"name": "@aa",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 1,
Expand Down Expand Up @@ -76,7 +76,7 @@
"children": [
{
"name": "@b",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 4,
Expand All @@ -101,7 +101,7 @@
},
{
"name": "@bb",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 5,
Expand Down Expand Up @@ -150,7 +150,7 @@
"children": [
{
"name": "@c",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 8,
Expand All @@ -175,7 +175,7 @@
},
{
"name": "@cc",
"kind": 13,
"kind": 8,
"range": {
"start": {
"line": 9,
Expand Down

0 comments on commit 3d95b97

Please sign in to comment.