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

Update for latest ruby-lsp changes #301

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
actionpack (>= 6.0)
activerecord (>= 6.0)
railties (>= 6.0)
ruby-lsp (>= 0.14.2, < 0.15.0)
ruby-lsp (>= 0.16.0, < 0.17.0)
sorbet-runtime (>= 0.5.9897)

GEM
Expand Down Expand Up @@ -227,7 +227,7 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.0)
rubocop (>= 0.90.0)
ruby-lsp (0.14.6)
ruby-lsp (0.16.0)
language_server-protocol (~> 3.17.0)
prism (>= 0.22.0, < 0.25)
sorbet-runtime (>= 0.5.10782)
Expand Down
15 changes: 8 additions & 7 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def initialize
@client = T.let(NullClient.new, RunnerClient)
end

sig { override.params(message_queue: Thread::Queue).void }
def activate(message_queue)
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}")
sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
def activate(global_state, message_queue)
@global_state = T.let(global_state, T.nilable(RubyLsp::GlobalState))
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}") unless ENV["RAILS_ENV"] == "test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these stderr silencing changes are not required for bumping Ruby LSP? I also remember @vinistock proposed a better way to handle these messages. Should we handle these in a more sophisticated way in a separate PR instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a bit tricky, I've removed the conditionals for now and we can address in a separate PR.

# Start booting the real client in a background thread. Until this completes, the client will be a NullClient
Thread.new { @client = RunnerClient.create_client }
end
Expand All @@ -53,11 +54,11 @@ def create_code_lens_listener(response_builder, uri, dispatcher)
override.params(
response_builder: ResponseBuilders::Hover,
nesting: T::Array[String],
index: RubyIndexer::Index,
dispatcher: Prism::Dispatcher,
).void
end
def create_hover_listener(response_builder, nesting, index, dispatcher)
def create_hover_listener(response_builder, nesting, dispatcher)
index = T.must(@global_state).index
Hover.new(@client, response_builder, nesting, index, dispatcher)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can follow Ruby LSP on passing the global state into listeners instead of index? FWIW, I'll need to do it for CodeLens in order to fix the duplicated test code lens issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 updated

end

Expand All @@ -76,11 +77,11 @@ def create_document_symbol_listener(response_builder, dispatcher)
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::Location],
uri: URI::Generic,
nesting: T::Array[String],
index: RubyIndexer::Index,
dispatcher: Prism::Dispatcher,
).void
end
def create_definition_listener(response_builder, uri, nesting, index, dispatcher)
def create_definition_listener(response_builder, uri, nesting, dispatcher)
index = T.must(@global_state).index
Definition.new(response_builder, nesting, index, dispatcher)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def initialize
@stdin.binmode # for Windows compatibility
@stdout.binmode # for Windows compatibility

$stderr.puts("Ruby LSP Rails booting server")
$stderr.puts("Ruby LSP Rails booting server") unless ENV["RAILS_ENV"] == "test"
count = 0

begin
Expand All @@ -72,7 +72,7 @@ def initialize
retry if count < MAX_RETRIES
end

$stderr.puts("Finished booting Ruby LSP Rails server")
$stderr.puts("Finished booting Ruby LSP Rails server") unless ENV["RAILS_ENV"] == "test"

unless ENV["RAILS_ENV"] == "test"
at_exit do
Expand All @@ -97,7 +97,7 @@ def model(name)

sig { void }
def trigger_reload
$stderr.puts("Reloading Rails application")
$stderr.puts("Reloading Rails application") unless ENV["RAILS_ENV"] == "test"
send_notification("reload")
rescue IncompleteMessageError
$stderr.puts("Ruby LSP Rails failed to trigger reload")
Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
spec.add_dependency("actionpack", ">= 6.0")
spec.add_dependency("activerecord", ">= 6.0")
spec.add_dependency("railties", ">= 6.0")
spec.add_dependency("ruby-lsp", ">= 0.14.2", "< 0.15.0")
spec.add_dependency("ruby-lsp", ">= 0.16.0", "< 0.17.0")
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
end
Loading
Loading