Skip to content

Commit

Permalink
Upgrade to Ruby LSP v0.10.0 (#149)
Browse files Browse the repository at this point in the history
* Upgrade ruby-lsp requirement to v0.10.0

* Re-generate ruby-lsp and yarp RBIs

* Use _response for listeners

* Bump cache version
  • Loading branch information
vinistock authored Sep 12, 2023
1 parent 06c170a commit 424bcf9
Show file tree
Hide file tree
Showing 9 changed files with 14,128 additions and 595 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cache-version: 3
cache-version: 4

- name: Check if documentation is up to date
run: bundle exec rake ruby_lsp:check_docs
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ PATH
specs:
ruby-lsp-rails (0.2.4)
rails (>= 6.0)
ruby-lsp (>= 0.9.1, < 0.11.0)
ruby-lsp (>= 0.10.0, < 0.11.0)
sorbet-runtime (>= 0.5.9897)

GEM
Expand Down
10 changes: 5 additions & 5 deletions lib/ruby_lsp/ruby_lsp_rails/code_lens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ class CodeLens < ::RubyLsp::Listener
BASE_COMMAND = "bin/rails test"

sig { override.returns(ResponseType) }
attr_reader :response
attr_reader :_response

sig { params(uri: URI::Generic, emitter: EventEmitter, message_queue: Thread::Queue).void }
def initialize(uri, emitter, message_queue)
@response = T.let([], ResponseType)
@_response = T.let([], ResponseType)
@path = T.let(uri.to_standardized_path, T.nilable(String))
emitter.register(self, :on_command, :on_class, :on_def)

Expand Down Expand Up @@ -121,23 +121,23 @@ def add_test_code_lens(node, name:, command:, kind:)
},
]

@response << create_code_lens(
@_response << create_code_lens(
node,
title: "Run",
command_name: "rubyLsp.runTest",
arguments: arguments,
data: { type: "test", kind: kind },
)

@response << create_code_lens(
@_response << create_code_lens(
node,
title: "Run In Terminal",
command_name: "rubyLsp.runTestInTerminal",
arguments: arguments,
data: { type: "test_in_terminal", kind: kind },
)

@response << create_code_lens(
@_response << create_code_lens(
node,
title: "Debug",
command_name: "rubyLsp.debugTest",
Expand Down
12 changes: 6 additions & 6 deletions lib/ruby_lsp/ruby_lsp_rails/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class Hover < ::RubyLsp::Listener
ResponseType = type_member { { fixed: T.nilable(::RubyLsp::Interface::Hover) } }

sig { override.returns(ResponseType) }
attr_reader :response
attr_reader :_response

sig { params(client: RailsClient, emitter: RubyLsp::EventEmitter, message_queue: Thread::Queue).void }
def initialize(client, emitter, message_queue)
super(emitter, message_queue)

@response = T.let(nil, ResponseType)
@_response = T.let(nil, ResponseType)
@client = client
emitter.register(self, :on_const, :on_command, :on_const_path_ref, :on_call)
end
Expand All @@ -46,26 +46,26 @@ def on_const(node)
end
content << model[:columns].map { |name, type| "**#{name}**: #{type}\n" }.join("\n")
contents = RubyLsp::Interface::MarkupContent.new(kind: "markdown", value: content)
@response = RubyLsp::Interface::Hover.new(range: range_from_syntax_tree_node(node), contents: contents)
@_response = RubyLsp::Interface::Hover.new(range: range_from_syntax_tree_node(node), contents: contents)
end

sig { params(node: SyntaxTree::Command).void }
def on_command(node)
message = node.message
@response = generate_rails_document_link_hover(message.value, message)
@_response = generate_rails_document_link_hover(message.value, message)
end

sig { params(node: SyntaxTree::ConstPathRef).void }
def on_const_path_ref(node)
@response = generate_rails_document_link_hover(full_constant_name(node), node)
@_response = generate_rails_document_link_hover(full_constant_name(node), node)
end

sig { params(node: SyntaxTree::CallNode).void }
def on_call(node)
message = node.message
return if message.is_a?(Symbol)

@response = generate_rails_document_link_hover(message.value, message)
@_response = generate_rails_document_link_hover(message.value, message)
end

private
Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
end

spec.add_dependency("rails", ">= 6.0")
spec.add_dependency("ruby-lsp", ">= 0.9.1", "< 0.11.0")
spec.add_dependency("ruby-lsp", ">= 0.10.0", "< 0.11.0")
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
end
272 changes: 0 additions & 272 deletions sorbet/rbi/gems/[email protected]

This file was deleted.

Loading

0 comments on commit 424bcf9

Please sign in to comment.