class Yoda::Server

Constants

NO_RESPONSE

Use this value as return value for notification handling

Attributes

reader[R]

@return [::LanguageServer::Protocol::Transport::Stdio::Reader]

root_handler[R]

@return [RootHandler]

writer[R]

@return [ConcurrentWriter]

Public Class Methods

new( reader: LanguageServer::Protocol::Transport::Stdio::Reader.new, writer: LanguageServer::Protocol::Transport::Stdio::Writer.new, root_handler_class: RootHandler ) click to toggle source
# File lib/yoda/server.rb, line 27
def initialize(
  reader: LanguageServer::Protocol::Transport::Stdio::Reader.new,
  writer: LanguageServer::Protocol::Transport::Stdio::Writer.new,
  root_handler_class: RootHandler
)
  @reader = reader
  @writer = ConcurrentWriter.new(writer)
  @root_handler = RootHandler.new(writer: @writer)
end

Public Instance Methods

deserialize(hash) click to toggle source
# File lib/yoda/server.rb, line 48
def deserialize(hash)
  Deserializer.new.deserialize(hash || {})
end
run() click to toggle source
# File lib/yoda/server.rb, line 37
def run
  reader.read do |request|
    begin
      root_handler.handle(id: request[:id], method: request[:method].to_sym, params: deserialize(request[:params]))
    rescue StandardError => ex
      Logger.warn ex
      Logger.warn ex.backtrace
    end
  end
end