Class: RubyLsp::FactoryBot::Definition
- Inherits:
-
Object
- Object
- RubyLsp::FactoryBot::Definition
- Includes:
- Requests::Support::Common
- Defined in:
- lib/ruby_lsp/factory_bot/definition.rb
Constant Summary collapse
- FACTORY_BOT_STRATEGIES =
%i[ create build build_stubbed attributes_for ].flat_map { |attr| [attr, :"#{attr}_list", :"#{attr}_pair"] }.freeze
Instance Method Summary collapse
-
#initialize(response_builder, uri, node_context, index, dispatcher) ⇒ Definition
constructor
A new instance of Definition.
- #on_call_node_enter(node) ⇒ Object
- #on_symbol_node_enter(node) ⇒ Object
Constructor Details
#initialize(response_builder, uri, node_context, index, dispatcher) ⇒ Definition
Returns a new instance of Definition.
17 18 19 20 21 22 23 |
# File 'lib/ruby_lsp/factory_bot/definition.rb', line 17 def initialize(response_builder, uri, node_context, index, dispatcher) @response_builder = response_builder @uri = uri @node_context = node_context @index = index dispatcher.register(self, :on_symbol_node_enter, :on_call_node_enter) end |
Instance Method Details
#on_call_node_enter(node) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/ruby_lsp/factory_bot/definition.rb', line 34 def on_call_node_enter(node) return unless @node_context&.call_node&. == "factory" return if node.arguments || node.block factory_location_for(node.) end |
#on_symbol_node_enter(node) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ruby_lsp/factory_bot/definition.rb', line 25 def on_symbol_node_enter(node) return unless (call_node = @node_context&.call_node) case call_node.name when *FACTORY_BOT_STRATEGIES then factory_or_trait_location_for(call_node, node) when :generate then sequence_location_for(node.value) end end |