Sha256: dcec45cf8e5072daf3f59371fabfb73d516ee4a4b951d30a6d538e0f075a43aa

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# typed: false
# frozen_string_literal: true

require "tapioca/internal"

module RubyLsp
  module Tapioca
    class ServerAddon < ::RubyLsp::Rails::ServerAddon
      def name
        "Tapioca"
      end

      def execute(request, params)
        case request
        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
          ::Tapioca::Loaders::Dsl.new(
            tapioca_path: ::Tapioca::TAPIOCA_DIR,
            eager_load: false,
            app_root: params[:workspace_path],
            halt_upon_load_error: false,
          ).load_dsl_extensions_and_compilers
        when "dsl"
          fork do
            dsl(params)
          end
        end
      end

      private

      def dsl(params)
        load("tapioca/cli.rb") # Reload the CLI to reset thor defaults between requests
        ::Tapioca::Cli.start(["dsl", "--lsp_addon", "--workers=1"] + params[:constants])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tapioca-0.16.8 lib/ruby_lsp/tapioca/server_addon.rb