Skip to content

Commit 53e49ab

Browse files
committed
SImplify listener creation
1 parent 13b79c7 commit 53e49ab

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

lib/ruby_lsp/rails/factory_bot/addon.rb

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ def name
2828
end
2929

3030
def create_completion_listener(response_builder, node_context, dispatcher, uri) # rubocop:disable Lint/UnusedMethodArgument
31-
path = uri.to_standardized_path
32-
return unless path&.end_with?("_test.rb") || path&.end_with?("_spec.rb")
33-
return unless factory_bot_call_args?(node_context)
34-
35-
ensure_addon_registered!
31+
register_addon!
3632

3733
Completion.new(response_builder, node_context, dispatcher, runner_client)
3834
end
@@ -75,18 +71,6 @@ def runner_client
7571
@rails_addon.rails_runner_client
7672
end
7773

78-
FACTORY_BOT_METHODS = %i[
79-
create
80-
build
81-
build_stubbed
82-
attributes_for
83-
].flat_map { |attr| [attr, :"#{attr}_list", :"#{attr}_pair"] }.freeze
84-
85-
def factory_bot_call_args?(node_context)
86-
node_context.call_node && FACTORY_BOT_METHODS.include?(node_context.call_node.name)
87-
true
88-
end
89-
9074
def log(msg)
9175
return if !@outgoing_queue || @outgoing_queue.closed?
9276

lib/ruby_lsp/rails/factory_bot/completion.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ module RubyLsp
88
module Rails
99
module FactoryBot
1010
# The listener that is created when the user requests autocomplete at the relevant time.
11-
#
12-
# NOTE: autocompletion is only triggered on certain node types - almost exclusively call nodes
13-
# and constants IIRC, so you cannot currently receive autocomplete options for symbols (eg.
14-
# factory or trait names) :/
1511
class Completion
1612
include RubyLsp::Requests::Support::Common
1713

0 commit comments

Comments
 (0)