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 sample codes on Add-ons page to fix execution errors #2869

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
18 changes: 7 additions & 11 deletions jekyll/add-ons.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ module RubyLsp
"0.1.0"
end

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

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

@client = client
def initialize(response_builder, config, dispatcher)
@response_builder = response_builder
@config = config

Expand Down Expand Up @@ -293,18 +290,17 @@ class MyIndexingEnhancement < RubyIndexer::Enhancement
# Create the array of signatures that this method will accept. Every signatures is composed of a list of
# parameters. The parameter classes represent each type of parameter
signatures = [
Entry::Signature.new([Entry::RequiredParameter.new(name: :a)])
RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: :a)])
andyw8 marked this conversation as resolved.
Show resolved Hide resolved
]

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

Expand All @@ -326,7 +322,7 @@ module RubyLsp
class Addon < ::RubyLsp::Addon
def activate(global_state, message_queue)
# Register the enhancement as part of the indexing process
@index.register_enhancement(MyIndexingEnhancement.new(@index))
global_state.index.register_enhancement(MyIndexingEnhancement.new(global_state.index))
end

def deactivate
Expand Down
Loading