Class: Solargraph::LanguageServer::Message::Base
- Inherits:
-
Object
- Object
- Solargraph::LanguageServer::Message::Base
show all
- Defined in:
- lib/solargraph/language_server/message/base.rb
Direct Known Subclasses
CancelRequest, Client::RegisterCapability, CompletionItem::Resolve, ExitNotification, Extended::CheckGemVersion, Extended::Document, Extended::DocumentGems, Extended::DownloadCore, Extended::Environment, Extended::Search, Initialize, Initialized, MethodNotFound, MethodNotImplemented, Shutdown, TextDocument::Base, TextDocument::DocumentSymbol, Workspace::DidChangeConfiguration, Workspace::DidChangeWatchedFiles, Workspace::DidChangeWorkspaceFolders, Workspace::WorkspaceSymbol
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(host, request) ⇒ Base
Returns a new instance of Base.
30
31
32
33
34
35
36
37
|
# File 'lib/solargraph/language_server/message/base.rb', line 30
def initialize host, request
@host = host
@id = request['id'].freeze
@request = request.freeze
@method = request['method'].freeze
@params = (request['params'] || {}).freeze
post_initialize
end
|
Instance Attribute Details
#error ⇒ Hash?
26
27
28
|
# File 'lib/solargraph/language_server/message/base.rb', line 26
def error
@error
end
|
8
9
10
|
# File 'lib/solargraph/language_server/message/base.rb', line 8
def host
@host
end
|
#id ⇒ Integer
11
12
13
|
# File 'lib/solargraph/language_server/message/base.rb', line 11
def id
@id
end
|
#method ⇒ String
17
18
19
|
# File 'lib/solargraph/language_server/message/base.rb', line 17
def method
@method
end
|
#params ⇒ Hash
20
21
22
|
# File 'lib/solargraph/language_server/message/base.rb', line 20
def params
@params
end
|
#request ⇒ Hash
14
15
16
|
# File 'lib/solargraph/language_server/message/base.rb', line 14
def request
@request
end
|
#result ⇒ Hash, ...
23
24
25
|
# File 'lib/solargraph/language_server/message/base.rb', line 23
def result
@result
end
|
Instance Method Details
#post_initialize ⇒ void
This method returns an undefined value.
40
|
# File 'lib/solargraph/language_server/message/base.rb', line 40
def post_initialize; end
|
#process ⇒ void
This method returns an undefined value.
43
|
# File 'lib/solargraph/language_server/message/base.rb', line 43
def process; end
|
#send_response ⇒ void
This method returns an undefined value.
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/solargraph/language_server/message/base.rb', line 62
def send_response
return if id.nil?
if host.cancel?(id)
Solargraph::Logging.logger.info "Cancelled response to #{method}"
return
end
Solargraph::Logging.logger.info "Sending response to #{method}"
response = {
jsonrpc: "2.0",
id: id,
}
response[:result] = result unless result.nil?
response[:error] = error unless error.nil?
response[:result] = nil if result.nil? and error.nil?
json = response.to_json
envelope = "Content-Length: #{json.bytesize}\r\n\r\n#{json}"
Solargraph.logger.debug envelope
host.queue envelope
host.clear id
end
|
#set_error(code, message) ⇒ void
This method returns an undefined value.
54
55
56
57
58
59
|
# File 'lib/solargraph/language_server/message/base.rb', line 54
def set_error code, message
@error = {
code: code,
message: message
}
end
|
#set_result(data) ⇒ void
This method returns an undefined value.
47
48
49
|
# File 'lib/solargraph/language_server/message/base.rb', line 47
def set_result data
@result = data
end
|