Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Ruby LSP v0.10.0 #149

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
vinistock marked this conversation as resolved.
Show resolved Hide resolved

- 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")
vinistock marked this conversation as resolved.
Show resolved Hide resolved
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
Loading