Class: RubyLsp::Executor

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/executor.rb

Overview

This class dispatches a request execution to the right request class. No IO should happen anywhere here!

Instance Method Summary collapse

Constructor Details

#initialize(store, message_queue) ⇒ Executor

Returns a new instance of Executor.

[View source]

12
13
14
15
16
17
18
# File 'lib/ruby_lsp/executor.rb', line 12

def initialize(store, message_queue)
  # Requests that mutate the store must be run sequentially! Parallel requests only receive a temporary copy of the
  # store
  @store = store
  @test_library = T.let(DependencyDetector.detected_test_library, String)
  @message_queue = message_queue
end

Instance Method Details

#execute(request) ⇒ Object

[View source]

21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby_lsp/executor.rb', line 21

def execute(request)
  response = T.let(nil, T.untyped)
  error = T.let(nil, T.nilable(Exception))

  request_time = Benchmark.realtime do
    response = run(request)
  rescue StandardError, LoadError => e
    error = e
  end

  Result.new(response: response, error: error, request_time: request_time)
end