Class: Diakonos::Lsp::Server
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(command:, working_directory:) ⇒ Server
constructor
A new instance of Server.
- #next_request_id ⇒ Object
- #stop ⇒ Object
- #write(message:) ⇒ Object
Constructor Details
#initialize(command:, working_directory:) ⇒ Server
Returns a new instance of Server.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/diakonos/lsp/server.rb', line 8 def initialize(command:, working_directory:) @capabilities = nil @command = command @pid = nil @queue = Thread::Queue.new @reader_thread = nil @request_id = 0 @stderr_io = nil @stopping = false @transport = nil @working_directory = working_directory @write_queue = Thread::Queue.new @writer_thread = nil spawn_process handshake start_reader_thread start_writer_thread end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
6 7 8 |
# File 'lib/diakonos/lsp/server.rb', line 6 def capabilities @capabilities end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/diakonos/lsp/server.rb', line 6 def queue @queue end |
Instance Method Details
#next_request_id ⇒ Object
103 104 105 |
# File 'lib/diakonos/lsp/server.rb', line 103 def next_request_id @request_id += 1 end |
#stop ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/diakonos/lsp/server.rb', line 28 def stop @stopping = true @write_queue.push(nil) @writer_thread&.join @reader_thread&.kill @reader_thread&.join if alive? shut_down end end |
#write(message:) ⇒ Object
39 40 41 |
# File 'lib/diakonos/lsp/server.rb', line 39 def write(message:) @write_queue.push() end |