Skip to content

Commit 9926887

Browse files
authored
Update sample codes on Add-ons page to fix execution errors (#2869)
1 parent 35ee5f5 commit 9926887

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

jekyll/add-ons.markdown

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ module RubyLsp
204204
"0.1.0"
205205
end
206206

207-
def create_hover_listener(response_builder, node_context, index, dispatcher)
207+
def create_hover_listener(response_builder, node_context, dispatcher)
208208
# Use the listener factory methods to instantiate listeners with parameters sent by the LSP combined with any
209209
# pre-computed information in the add-on. These factory methods are invoked on every request
210-
Hover.new(client, response_builder, @config, dispatcher)
210+
Hover.new(response_builder, @config, dispatcher)
211211
end
212212
end
213213

@@ -222,10 +222,7 @@ module RubyLsp
222222
# to this object, which will then build the Ruby LSP's response.
223223
# Additionally, listeners are instantiated with a message_queue to push notifications (not used in this example).
224224
# See "Sending notifications to the client" for more information.
225-
def initialize(client, response_builder, config, dispatcher)
226-
super(dispatcher)
227-
228-
@client = client
225+
def initialize(response_builder, config, dispatcher)
229226
@response_builder = response_builder
230227
@config = config
231228

@@ -293,18 +290,17 @@ class MyIndexingEnhancement < RubyIndexer::Enhancement
293290
# Create the array of signatures that this method will accept. Every signatures is composed of a list of
294291
# parameters. The parameter classes represent each type of parameter
295292
signatures = [
296-
Entry::Signature.new([Entry::RequiredParameter.new(name: :a)])
293+
RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: :a)])
297294
]
298295

299-
new_entry = Entry::Method.new(
296+
new_entry = RubyIndexer::Entry::Method.new(
300297
"new_method", # The name of the method that gets created via meta-programming
301298
file_path, # The file_path where the DSL call was found. This should always just be the file_path received
302299
location, # The Prism node location where the DSL call was found
303300
location, # The Prism node location for the DSL name location. May or not be the same
304301
nil, # The documentation for this DSL call. This should always be `nil` to ensure lazy fetching of docs
305-
@index.configuration.encoding, # The negotiated encoding. This should always be `indexing.configuration.encoding`
306302
signatures, # All signatures for this method (every way it can be invoked)
307-
Entry::Visibility::PUBLIC, # The method's visibility
303+
RubyIndexer::Entry::Visibility::PUBLIC, # The method's visibility
308304
owner, # The method's owner. This is almost always going to be the same owner received
309305
)
310306

@@ -326,7 +322,7 @@ module RubyLsp
326322
class Addon < ::RubyLsp::Addon
327323
def activate(global_state, message_queue)
328324
# Register the enhancement as part of the indexing process
329-
@index.register_enhancement(MyIndexingEnhancement.new(@index))
325+
global_state.index.register_enhancement(MyIndexingEnhancement.new(global_state.index))
330326
end
331327

332328
def deactivate

0 commit comments

Comments
 (0)