Skip to content

Commit 72c2c97

Browse files
committed
Fix breaking changes from ruby-lsp-rails upgrade pt2
1 parent 66f8254 commit 72c2c97

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/ruby_lsp/rails/factory_bot/addon.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ module Rails
1313
module FactoryBot
1414
# The addon to be registered with ruby-lsp. See https://shopify.github.io/ruby-lsp/add-ons.html
1515
class Addon < ::RubyLsp::Addon
16-
def activate(global_state, *)
16+
def activate(global_state, outgoing_queue)
1717
runner_client.register_server_addon(File.expand_path("server_addon.rb", __dir__))
1818

1919
@ruby_index = global_state.index
20+
21+
@outgoing_queue = outgoing_queue
22+
log "Activating #{name} add-on v#{VERSION}"
2023
end
2124

2225
def deactivate(*); end
@@ -67,6 +70,12 @@ def factory_bot_call_args?(node_context)
6770
node_context.call_node && FACTORY_BOT_METHODS.include?(node_context.call_node.name)
6871
true
6972
end
73+
74+
def log(msg)
75+
return unless @outgoing_queue
76+
77+
@outgoing_queue << Notification.window_log_message(msg)
78+
end
7079
end
7180
end
7281
end

lib/ruby_lsp/rails/factory_bot/server_addon.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ module Rails
1010
module FactoryBot
1111
# The addon for the ruby-lsp-rails server runtime
1212
class ServerAddon < RubyLsp::Rails::ServerAddon
13-
def initialize(stdout)
13+
def initialize(stdout, stderr, capabilities)
1414
super
1515

1616
# TODO: move to before_start hook
17-
with_progress "ruby-lsp-rails-factory-bot-initialisation" do
17+
with_progress "ruby-lsp-rails-factory-bot-1", "initialisation" do
1818
require "factory_bot"
1919
::FactoryBot.find_definitions
2020
::FactoryBot.factories.each(&:compile)
@@ -33,7 +33,7 @@ def execute(request, params)
3333
collection = AttributeHandler.new.execute(params)
3434
end
3535

36-
write_response({ result: collection })
36+
send_result(collection)
3737
end
3838
end
3939
end

0 commit comments

Comments
 (0)