Module: Holistic::LanguageServer::Router

Extended by:
Router
Included in:
Router
Defined in:
lib/holistic/language_server/router.rb

Constant Summary collapse

ROUTES =
{
  "initialize"              => Requests::Lifecycle::Initialize,
  "initialized"             => Requests::Lifecycle::Initialized,
  "shutdown"                => Requests::Lifecycle::Shutdown,
  "exit"                    => Requests::Lifecycle::Exit,
  "textDocument/didOpen"    => Requests::TextDocument::DidOpen,
  "textDocument/didChange"  => Requests::TextDocument::DidChange,
  "textDocument/didSave"    => Requests::TextDocument::DidSave,
  "textDocument/didClose"   => Requests::TextDocument::DidClose,
  "textDocument/definition" => Requests::TextDocument::GoToDefinition,
  "textDocument/references" => Requests::TextDocument::FindReferences,
  "textDocument/completion" => Requests::TextDocument::Completion
}.freeze

Instance Method Summary collapse

Instance Method Details

#dispatch(message) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/holistic/language_server/router.rb', line 21

def dispatch(message)
  request = Request.new(message:, application: Current.application)

  ::ActiveSupport::Notifications.instrument("holistic.language_server.request", request:) do
    return respond_with_rejection(request) if Current.lifecycle.reject?(message.method)

    handler = ROUTES[message.method]

    return Response::NotFound.new if handler.nil?

    handler.call(request)
  end
end