File tree 2 files changed +13
-4
lines changed
lib/ruby_lsp/rails/factory_bot
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ module Rails
13
13
module FactoryBot
14
14
# The addon to be registered with ruby-lsp. See https://shopify.github.io/ruby-lsp/add-ons.html
15
15
class Addon < ::RubyLsp ::Addon
16
- def activate ( global_state , * )
16
+ def activate ( global_state , outgoing_queue )
17
17
runner_client . register_server_addon ( File . expand_path ( "server_addon.rb" , __dir__ ) )
18
18
19
19
@ruby_index = global_state . index
20
+
21
+ @outgoing_queue = outgoing_queue
22
+ log "Activating #{ name } add-on v#{ VERSION } "
20
23
end
21
24
22
25
def deactivate ( *) ; end
@@ -67,6 +70,12 @@ def factory_bot_call_args?(node_context)
67
70
node_context . call_node && FACTORY_BOT_METHODS . include? ( node_context . call_node . name )
68
71
true
69
72
end
73
+
74
+ def log ( msg )
75
+ return unless @outgoing_queue
76
+
77
+ @outgoing_queue << Notification . window_log_message ( msg )
78
+ end
70
79
end
71
80
end
72
81
end
Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ module Rails
10
10
module FactoryBot
11
11
# The addon for the ruby-lsp-rails server runtime
12
12
class ServerAddon < RubyLsp ::Rails ::ServerAddon
13
- def initialize ( stdout )
13
+ def initialize ( stdout , stderr , capabilities )
14
14
super
15
15
16
16
# 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
18
18
require "factory_bot"
19
19
::FactoryBot . find_definitions
20
20
::FactoryBot . factories . each ( &:compile )
@@ -33,7 +33,7 @@ def execute(request, params)
33
33
collection = AttributeHandler . new . execute ( params )
34
34
end
35
35
36
- write_response ( { result : collection } )
36
+ send_result ( collection )
37
37
end
38
38
end
39
39
end
You can’t perform that action at this time.
0 commit comments