Skip to content

Commit

Permalink
Fix differences after Prism upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Aug 29, 2024
1 parent 65f3702 commit 9bde671
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/ruby_lsp/listeners/folding_ranges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def add_statements_range(node)
body = statements.body
return if body.empty?

add_lines_range(node.location.start_line, T.must(body.last).location.end_line)
add_lines_range(node.location.start_line, body.last.location.end_line)
end

sig { params(node: Prism::Node).void }
Expand Down
18 changes: 14 additions & 4 deletions test/requests/show_syntax_tree_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ def test_returns_partial_tree_if_document_has_syntax_error

assert_equal(<<~AST, server.pop_response.response[:ast])
@ ProgramNode (location: (1,0)-(1,6))
├── flags: ∅
├── locals: []
└── statements:
@ StatementsNode (location: (1,0)-(1,6))
├── flags: ∅
└── body: (length: 1)
└── @ CallNode (location: (1,0)-(1,6))
├── flags: ignore_visibility
├── flags: newline, ignore_visibility
├── receiver: ∅
├── call_operator_loc: ∅
├── name: :foo
Expand All @@ -29,12 +31,15 @@ def test_returns_partial_tree_if_document_has_syntax_error
├── closing_loc: ∅
└── block:
@ BlockNode (location: (1,4)-(1,6))
├── flags: ∅
├── locals: []
├── parameters: ∅
├── body:
│ @ StatementsNode (location: (1,4)-(1,6))
│ ├── flags: ∅
│ └── body: (length: 1)
│ └── @ MissingNode (location: (1,4)-(1,6))
│ └── flags: newline
├── opening_loc: (1,4)-(1,6) = "do"
└── closing_loc: (1,6)-(1,6) = ""
AST
Expand All @@ -51,17 +56,20 @@ def test_returns_ast_if_document_is_parsed

assert_equal(<<~AST, server.pop_response.response[:ast])
@ ProgramNode (location: (1,0)-(1,9))
├── flags: ∅
├── locals: [:foo]
└── statements:
@ StatementsNode (location: (1,0)-(1,9))
├── flags: ∅
└── body: (length: 1)
└── @ LocalVariableWriteNode (location: (1,0)-(1,9))
├── flags: newline
├── name: :foo
├── depth: 0
├── name_loc: (1,0)-(1,3) = "foo"
├── value:
│ @ IntegerNode (location: (1,6)-(1,9))
│ ├── flags: decimal
│ ├── flags: static_literal, decimal
│ └── value: 123
└── operator_loc: (1,4)-(1,5) = "="
AST
Expand All @@ -87,22 +95,24 @@ def test_returns_ast_for_a_selection

assert_equal(<<~AST, server.pop_response.response[:ast])
@ LocalVariableWriteNode (location: (1,0)-(1,9))
├── flags: newline
├── name: :foo
├── depth: 0
├── name_loc: (1,0)-(1,3) = "foo"
├── value:
│ @ IntegerNode (location: (1,6)-(1,9))
│ ├── flags: decimal
│ ├── flags: static_literal, decimal
│ └── value: 123
└── operator_loc: (1,4)-(1,5) = "="
@ LocalVariableWriteNode (location: (2,0)-(2,9))
├── flags: newline
├── name: :bar
├── depth: 0
├── name_loc: (2,0)-(2,3) = "bar"
├── value:
│ @ IntegerNode (location: (2,6)-(2,9))
│ ├── flags: decimal
│ ├── flags: static_literal, decimal
│ └── value: 456
└── operator_loc: (2,4)-(2,5) = "="
AST
Expand Down
10 changes: 4 additions & 6 deletions vscode/src/test/suite/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,10 @@ suite("Client", () => {
},
);

const expectedMessage =
os.platform() === "win32"
? /Layout\/EndOfLine: Carriage return character missing/
: /Style\/FrozenStringLiteralComment: Missing magic comment/;

assert.match(response.items[0].message, expectedMessage);
assert.strictEqual(
response.items[0].message,
"mismatched indentations at 'end' with 'def' at 1",
);
}).timeout(20000);

test("folding range", async () => {
Expand Down

0 comments on commit 9bde671

Please sign in to comment.