Module: Solargraph::LanguageServer::Transport::Adapter

Defined in:
lib/solargraph/language_server/transport/adapter.rb

Overview

A common module for running language servers in Backport.

Instance Method Summary collapse

Instance Method Details

#closingObject



21
22
23
# File 'lib/solargraph/language_server/transport/adapter.rb', line 21

def closing
  @host.stop
end

#openingObject



11
12
13
14
15
16
17
18
19
# File 'lib/solargraph/language_server/transport/adapter.rb', line 11

def opening
  @host = Solargraph::LanguageServer::Host.new
  @host.add_observer self
  @host.start
  @data_reader = Solargraph::LanguageServer::Transport::DataReader.new
  @data_reader.set_message_handler do |message|
    process message
  end
end

#receiving(data) ⇒ Object

Parameters:

  • data (String)


26
27
28
# File 'lib/solargraph/language_server/transport/adapter.rb', line 26

def receiving data
  @data_reader.receive data
end

#updateObject



30
31
32
33
34
35
36
37
# File 'lib/solargraph/language_server/transport/adapter.rb', line 30

def update
  if @host.stopped?
    shutdown
  else
    tmp = @host.flush
    write tmp unless tmp.empty?
  end
end