Class: RubyLsp::Tapioca::ServerAddon

Inherits:
Rails::ServerAddon
  • Object
show all
Defined in:
lib/ruby_lsp/tapioca/server_addon.rb

Instance Method Summary collapse

Instance Method Details

#execute(request, params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ruby_lsp/tapioca/server_addon.rb', line 13

def execute(request, params)
  case request
  when "reload_workspace_compilers"
    with_notification_wrapper("reload_workspace_compilers", "Reloading DSL compilers") do
      @loader&.reload_custom_compilers
    end
  when "load_compilers_and_extensions"
    # Load DSL extensions and compilers ahead of time, so that we don't have to pay the price of invoking
    # `Gem.find_files` on every execution, which is quite expensive
    with_notification_wrapper("load_compilers_and_extensions", "Loading DSL compilers") do
      ::Tapioca::Dsl::Compiler.extend(T::Generic)
      @loader = ::Tapioca::Loaders::Dsl.new(
        tapioca_path: ::Tapioca::TAPIOCA_DIR,
        eager_load: false,
        app_root: params[:workspace_path],
        halt_upon_load_error: false,
      )
      @loader.load_dsl_extensions_and_compilers
    end
  when "dsl"
    fork do
      with_notification_wrapper("dsl", "Generating DSL RBIs") do
        dsl(params[:constants])
      end
    end
  when "route_dsl"
    fork do
      with_notification_wrapper("route_dsl", "Generating route DSL RBIs") do
        constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
        dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::UrlHelpers", "ActiveSupportConcern")
      end
    end
  when "fixtures_dsl"
    fork do
      with_notification_wrapper("fixture_dsl", "Generating fixture DSL RBIs") do
        constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
        dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::ActiveRecordFixtures")
      end
    end
  end
end

#nameObject



9
10
11
# File 'lib/ruby_lsp/tapioca/server_addon.rb', line 9

def name
  "Tapioca"
end