Skip to content

Commit

Permalink
Provide nesting and the index for hover extensions (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Sep 19, 2023
1 parent 78a1876 commit 2d54c58
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion SERVER_EXTENSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ module RubyLsp

sig do
override.params(
nesting: T::Array[String],
index: RubyIndexer::Index,
emitter: EventEmitter,
message_queue: Thread::Queue,
).returns(T.nilable(Listener[T.nilable(Interface::Hover)]))
end
def create_hover_listener(emitter, message_queue)
def create_hover_listener(nesting, index emitter, message_queue)
# Use the listener factory methods to instantiate listeners with parameters sent by the LSP combined with any
# pre-computed information in the extension. These factory methods are invoked on every request
Hover.new(@config, emitter, message_queue)
Expand Down
4 changes: 3 additions & 1 deletion lib/ruby_lsp/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,13 @@ def create_code_lens_listener(uri, emitter, message_queue); end
# Creates a new Hover listener. This method is invoked on every Hover request
sig do
overridable.params(
nesting: T::Array[String],
index: RubyIndexer::Index,
emitter: EventEmitter,
message_queue: Thread::Queue,
).returns(T.nilable(Listener[T.nilable(Interface::Hover)]))
end
def create_hover_listener(emitter, message_queue); end
def create_hover_listener(nesting, index, emitter, message_queue); end

# Creates a new DocumentSymbol listener. This method is invoked on every DocumentSymbol request
sig do
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/requests/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def initialize(index, nesting, emitter, message_queue)

sig { override.params(extension: RubyLsp::Extension).returns(T.nilable(Listener[ResponseType])) }
def initialize_external_listener(extension)
extension.create_hover_listener(@emitter, @message_queue)
extension.create_hover_listener(@nesting, @index, @emitter, @message_queue)
end

# Merges responses from other hover listeners
Expand Down
2 changes: 1 addition & 1 deletion test/requests/hover_expectations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def name
"HoverExtension"
end

def create_hover_listener(emitter, message_queue)
def create_hover_listener(nesting, index, emitter, message_queue)
klass = Class.new(RubyLsp::Listener) do
attr_reader :_response

Expand Down

0 comments on commit 2d54c58

Please sign in to comment.