Class: RubyLsp::FactoryBot::Addon
- Inherits:
-
Addon
- Object
- Addon
- RubyLsp::FactoryBot::Addon
- Defined in:
- lib/ruby_lsp/factory_bot/addon.rb
Overview
Ruby LSP addon that provides "Go to Definition" for FactoryBot factory references. Indexes all factories in spec/factories/**/*.rb and enables jumping to factory definitions from calls like create(:factory_name), build(:factory_name), etc.
Instance Method Summary collapse
- #activate(global_state, _outgoing_queue) ⇒ Object
- #create_definition_listener(response_builder, _uri, node_context, dispatcher) ⇒ Object
- #deactivate ⇒ Object
-
#initialize ⇒ Addon
constructor
A new instance of Addon.
- #name ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ Addon
Returns a new instance of Addon.
14 15 16 17 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 14 def initialize super @factory_index = FactoryIndex.new end |
Instance Method Details
#activate(global_state, _outgoing_queue) ⇒ Object
19 20 21 22 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 19 def activate(global_state, _outgoing_queue) workspace_root = global_state&.workspace_path || Dir.pwd @factory_index.rebuild!(workspace_root) end |
#create_definition_listener(response_builder, _uri, node_context, dispatcher) ⇒ Object
32 33 34 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 32 def create_definition_listener(response_builder, _uri, node_context, dispatcher) DefinitionListener.new(response_builder, node_context, @factory_index, dispatcher) end |
#deactivate ⇒ Object
36 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 36 def deactivate; end |
#name ⇒ Object
24 25 26 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 24 def name 'Ruby LSP FactoryBot' end |
#version ⇒ Object
28 29 30 |
# File 'lib/ruby_lsp/factory_bot/addon.rb', line 28 def version '0.1.0' end |