-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
629a067
to
9c5d892
Compare
test/test_helper.rb
Outdated
block: T.proc.params(server: RubyLsp::Server, uri: URI::Generic).returns(T.type_parameter(:T)), | ||
).returns(T.type_parameter(:T)) | ||
end | ||
def with_server(source = nil, uri = URI("file:///fake.rb"), &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinistock I copied this from ruby-lsp
, but is this how you were expecting we'd structure the tests for addons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of copying, I think we should move this in the Ruby LSP to a file that's not required by default like lib/ruby_lsp/test_case
and every addon can just require the file and inherit from a class to get our test helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I can do that. One minor niggle is that we we see the "initializing" message on each test, e.g.:
ruby-lsp-rails andyw8/update-for-ruby-lsp-refactor % be rake test
Run options: --seed 14480
# Running:
....Finished initializing Ruby LSP!
Ruby LSP detected this is a Sorbet project so will defer to Sorbet LSP for some functionality
.Finished initializing Ruby LSP!
.Finished initializing Ruby LSP!
.Finished initializing Ruby LSP!
.Finished initializing Ruby LSP!
.Finished initializing Ruby LSP!
.Finished initializing Ruby LSP!
(etc)
I'll see if there's a way to silence that during the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to capture_subprocess_io
wherever we are executing the initialized
notification.
3b081ae
to
c7b77d2
Compare
6ab9137
to
1182623
Compare
1182623
to
343a974
Compare
lib/ruby_lsp/ruby_lsp_rails/addon.rb
Outdated
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 updated
lib/ruby_lsp/ruby_lsp_rails/addon.rb
Outdated
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
e060efd
to
0c18f57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put up a PR to ensure we deactivate addons on with_server
Shopify/ruby-lsp#1872. Otherwise, we spawn a bunch of runner clients and don't shut them down gracefully.
I think we can address the stderr printing in a separate PR, given that it needs to be addressed in the base LSP too.
Nevermind what I said, I was mistaken. We're already invoking deactivate manually in |
Needed due to Shopify/ruby-lsp#1648