class TypeProf::LSP::Server
Attributes
open_texts[R]
root_uri[RW]
running_requests_from_client[R]
signature_enabled[RW]
sigs[R]
typeprof_config[R]
Public Class Methods
new(config, reader, writer)
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 831 def initialize(config, reader, writer) @typeprof_config = config @reader = reader @writer = writer @tx_mutex = Mutex.new @request_id = 0 @running_requests_from_client = {} @running_requests_from_server = {} @open_texts = {} @sigs = {} # tmp @signature_enabled = true end
Public Instance Methods
exclusive_write(**json)
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 877 def exclusive_write(**json) @tx_mutex.synchronize do @writer.write(**json) end end
run()
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 847 def run @reader.read do |json| if json[:method] # request or notification msg = Message.find(json[:method]).new(self, json) @running_requests_from_client[json[:id]] = msg if json[:id] msg.run else callback = @running_requests_from_server.delete(json[:id]) callback&.call(json[:params]) end end rescue Exit end
send_notification(method, params = nil)
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 867 def send_notification(method, params = nil) exclusive_write(method: method, params: params) end
send_request(method, **params, &blk)
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 871 def send_request(method, **params, &blk) id = @request_id += 1 @running_requests_from_server[id] = blk exclusive_write(id: id, method: method, params: params) end
send_response(**msg)
click to toggle source
# File typeprof-0.21.2/lib/typeprof/lsp.rb, line 862 def send_response(**msg) @running_requests_from_client.delete(msg[:id]) exclusive_write(**msg) end