Skip to content

Commit b212b91

Browse files
authored
Upgrade Ruby LSP to v0.20 (#480)
* Upgrade Ruby LSP requirement * Update gem RBIs * Fix breaking change for indexing enhancements
1 parent 6bda22d commit b212b91

File tree

6 files changed

+7659
-3855
lines changed

6 files changed

+7659
-3855
lines changed

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
ruby-lsp-rails (0.3.18)
5-
ruby-lsp (>= 0.19.0, < 0.20.0)
5+
ruby-lsp (>= 0.20.0, < 0.21.0)
66

77
GEM
88
remote: https://rubygems.org/
@@ -148,7 +148,7 @@ GEM
148148
parser (3.3.1.0)
149149
ast (~> 2.4.1)
150150
racc
151-
prism (1.1.0)
151+
prism (1.2.0)
152152
psych (5.1.2)
153153
stringio
154154
public_suffix (5.0.5)
@@ -197,7 +197,7 @@ GEM
197197
rbi (0.2.0)
198198
prism (~> 1.0)
199199
sorbet-runtime (>= 0.5.9204)
200-
rbs (3.6.0)
200+
rbs (3.6.1)
201201
logger
202202
rdoc (6.6.3.1)
203203
psych (>= 4.0.0)
@@ -227,9 +227,9 @@ GEM
227227
rubocop (~> 1.51)
228228
rubocop-sorbet (0.8.3)
229229
rubocop (>= 0.90.0)
230-
ruby-lsp (0.19.0)
230+
ruby-lsp (0.20.0)
231231
language_server-protocol (~> 3.17.0)
232-
prism (>= 1.1, < 2.0)
232+
prism (>= 1.2, < 2.0)
233233
rbs (>= 3, < 4)
234234
sorbet-runtime (>= 0.5.10782)
235235
ruby-progressbar (1.13.0)

lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ class IndexingEnhancement
1313
owner: T.nilable(RubyIndexer::Entry::Namespace),
1414
node: Prism::CallNode,
1515
file_path: String,
16+
code_units_cache: T.any(
17+
T.proc.params(arg0: Integer).returns(Integer),
18+
Prism::CodeUnitsCache,
19+
),
1620
).void
1721
end
18-
def on_call_node(index, owner, node, file_path)
22+
def on_call_node(index, owner, node, file_path, code_units_cache)
1923
return unless owner
2024

2125
name = node.name
@@ -24,7 +28,7 @@ def on_call_node(index, owner, node, file_path)
2428
when :extend
2529
handle_concern_extend(index, owner, node)
2630
when :has_one, :has_many, :belongs_to, :has_and_belongs_to_many
27-
handle_association(index, owner, node, file_path)
31+
handle_association(index, owner, node, file_path, code_units_cache)
2832
end
2933
end
3034

@@ -36,9 +40,13 @@ def on_call_node(index, owner, node, file_path)
3640
owner: RubyIndexer::Entry::Namespace,
3741
node: Prism::CallNode,
3842
file_path: String,
43+
code_units_cache: T.any(
44+
T.proc.params(arg0: Integer).returns(Integer),
45+
Prism::CodeUnitsCache,
46+
),
3947
).void
4048
end
41-
def handle_association(index, owner, node, file_path)
49+
def handle_association(index, owner, node, file_path, code_units_cache)
4250
arguments = node.arguments&.arguments
4351
return unless arguments
4452

@@ -53,14 +61,15 @@ def handle_association(index, owner, node, file_path)
5361

5462
return unless name
5563

64+
loc = RubyIndexer::Location.from_prism_location(name_arg.location, code_units_cache)
65+
5666
# Reader
5767
index.add(RubyIndexer::Entry::Method.new(
5868
name,
5969
file_path,
60-
name_arg.location,
61-
name_arg.location,
70+
loc,
71+
loc,
6272
nil,
63-
index.configuration.encoding,
6473
[RubyIndexer::Entry::Signature.new([])],
6574
RubyIndexer::Entry::Visibility::PUBLIC,
6675
owner,
@@ -70,10 +79,9 @@ def handle_association(index, owner, node, file_path)
7079
index.add(RubyIndexer::Entry::Method.new(
7180
"#{name}=",
7281
file_path,
73-
name_arg.location,
74-
name_arg.location,
82+
loc,
83+
loc,
7584
nil,
76-
index.configuration.encoding,
7785
[RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: name.to_sym)])],
7886
RubyIndexer::Entry::Visibility::PUBLIC,
7987
owner,

ruby-lsp-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
2424
Dir["lib/**/*", "LICENSE.txt", "Rakefile", "README.md"]
2525
end
2626

27-
spec.add_dependency("ruby-lsp", ">= 0.19.0", "< 0.20.0")
27+
spec.add_dependency("ruby-lsp", ">= 0.20.0", "< 0.21.0")
2828
end

0 commit comments

Comments
 (0)