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


19
20
21
# File 'lib/solargraph/language_server/transport/adapter.rb', line 19

def closing
  @host.stop
end

#openingObject


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

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 Also known as: sending

Parameters:

  • data (String)

24
25
26
# File 'lib/solargraph/language_server/transport/adapter.rb', line 24

def receiving data
  @data_reader.receive data
end

#updateObject


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

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