Class: Ibex::LSP::Server

Inherits:
Object
  • Object
show all
Includes:
RequestHandlers
Defined in:
lib/ibex/lsp/server.rb

Overview

Coordinates JSON-RPC lifecycle, request responses, and protocol-safe logging.

Constant Summary collapse

REQUEST_METHODS =
%w[
  initialize shutdown textDocument/definition textDocument/references textDocument/prepareRename
  textDocument/rename textDocument/hover
].freeze
NOTIFICATION_METHODS =

: Array

%w[
  initialized exit textDocument/didOpen textDocument/didChange textDocument/didSave textDocument/didClose
  $/cancelRequest
].freeze

Constants included from RequestHandlers

RequestHandlers::HANDLERS

Instance Method Summary collapse

Constructor Details

#initialize(stdin:, stdout:, stderr:) ⇒ Server

Returns a new instance of Server.



19
20
21
22
23
24
25
# File 'lib/ibex/lsp/server.rb', line 19

def initialize(stdin:, stdout:, stderr:)
  @transport = Transport.new(stdin, stdout)
  @stderr = stderr
  @state = :uninitialized
  @exit_requested = false
  @exit_status = nil #: Integer?
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
# File 'lib/ibex/lsp/server.rb', line 28

def run
  until @exit_requested
    message = read_message
    break unless message

    process_message(message)
  end
  @exit_status || 1
end