Class: TypeProf::LSP::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/typeprof/lsp/messages.rb

Defined Under Namespace

Modules: TextDocument, Workspace Classes: CancelRequest, Exit, Initialize, Initialized, Shutdown

Constant Summary collapse

Classes =
[]
Table =
Hash.new(Message)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, json) ⇒ Message

: (Server, untyped) -> void



4
5
6
7
8
9
# File 'lib/typeprof/lsp/messages.rb', line 4

def initialize(server, json)
  @server = server
  @id = json[:id]
  @method = json[:method]
  @params = json[:params]
end

Class Method Details

.build_tableObject



38
39
40
41
42
# File 'lib/typeprof/lsp/messages.rb', line 38

def self.build_table
  Classes.each do |klass|
    Table[klass::METHOD] = klass
  end
end

.find(method) ⇒ Object



44
45
46
# File 'lib/typeprof/lsp/messages.rb', line 44

def self.find(method)
  Table[method]
end

.inherited(klass) ⇒ Object



33
34
35
# File 'lib/typeprof/lsp/messages.rb', line 33

def self.inherited(klass)
  Classes << klass
end

Instance Method Details

#log(msg) ⇒ Object



15
16
# File 'lib/typeprof/lsp/messages.rb', line 15

def log(msg)
end

#notify(method, **params) ⇒ Object



28
29
30
# File 'lib/typeprof/lsp/messages.rb', line 28

def notify(method, **params)
  @server.send_notification(method, **params)
end

#respond(result) ⇒ Object



18
19
20
21
# File 'lib/typeprof/lsp/messages.rb', line 18

def respond(result)
  raise "do not respond to notification" if @id == nil
  @server.send_response(id: @id, result: result)
end

#respond_error(error) ⇒ Object



23
24
25
26
# File 'lib/typeprof/lsp/messages.rb', line 23

def respond_error(error)
  raise "do not respond to notification" if @id == nil
  @server.send_response(id: @id, error: error)
end

#runObject



11
12
13
# File 'lib/typeprof/lsp/messages.rb', line 11

def run
  p [:ignored, @method]
end