Skip to content

Commit

Permalink
Upgrade Ruby LSP to v0.20 (#480)
Browse files Browse the repository at this point in the history
* Upgrade Ruby LSP requirement

* Update gem RBIs

* Fix breaking change for indexing enhancements
  • Loading branch information
vinistock authored Oct 11, 2024
1 parent 6bda22d commit b212b91
Show file tree
Hide file tree
Showing 6 changed files with 7,659 additions and 3,855 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
ruby-lsp-rails (0.3.18)
ruby-lsp (>= 0.19.0, < 0.20.0)
ruby-lsp (>= 0.20.0, < 0.21.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -148,7 +148,7 @@ GEM
parser (3.3.1.0)
ast (~> 2.4.1)
racc
prism (1.1.0)
prism (1.2.0)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -197,7 +197,7 @@ GEM
rbi (0.2.0)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)
rbs (3.6.0)
rbs (3.6.1)
logger
rdoc (6.6.3.1)
psych (>= 4.0.0)
Expand Down Expand Up @@ -227,9 +227,9 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.3)
rubocop (>= 0.90.0)
ruby-lsp (0.19.0)
ruby-lsp (0.20.0)
language_server-protocol (~> 3.17.0)
prism (>= 1.1, < 2.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
Expand Down
26 changes: 17 additions & 9 deletions lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ class IndexingEnhancement
owner: T.nilable(RubyIndexer::Entry::Namespace),
node: Prism::CallNode,
file_path: String,
code_units_cache: T.any(
T.proc.params(arg0: Integer).returns(Integer),
Prism::CodeUnitsCache,
),
).void
end
def on_call_node(index, owner, node, file_path)
def on_call_node(index, owner, node, file_path, code_units_cache)
return unless owner

name = node.name
Expand All @@ -24,7 +28,7 @@ def on_call_node(index, owner, node, file_path)
when :extend
handle_concern_extend(index, owner, node)
when :has_one, :has_many, :belongs_to, :has_and_belongs_to_many
handle_association(index, owner, node, file_path)
handle_association(index, owner, node, file_path, code_units_cache)
end
end

Expand All @@ -36,9 +40,13 @@ def on_call_node(index, owner, node, file_path)
owner: RubyIndexer::Entry::Namespace,
node: Prism::CallNode,
file_path: String,
code_units_cache: T.any(
T.proc.params(arg0: Integer).returns(Integer),
Prism::CodeUnitsCache,
),
).void
end
def handle_association(index, owner, node, file_path)
def handle_association(index, owner, node, file_path, code_units_cache)
arguments = node.arguments&.arguments
return unless arguments

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

return unless name

loc = RubyIndexer::Location.from_prism_location(name_arg.location, code_units_cache)

# Reader
index.add(RubyIndexer::Entry::Method.new(
name,
file_path,
name_arg.location,
name_arg.location,
loc,
loc,
nil,
index.configuration.encoding,
[RubyIndexer::Entry::Signature.new([])],
RubyIndexer::Entry::Visibility::PUBLIC,
owner,
Expand All @@ -70,10 +79,9 @@ def handle_association(index, owner, node, file_path)
index.add(RubyIndexer::Entry::Method.new(
"#{name}=",
file_path,
name_arg.location,
name_arg.location,
loc,
loc,
nil,
index.configuration.encoding,
[RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: name.to_sym)])],
RubyIndexer::Entry::Visibility::PUBLIC,
owner,
Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
Dir["lib/**/*", "LICENSE.txt", "Rakefile", "README.md"]
end

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

0 comments on commit b212b91

Please sign in to comment.