Module: Ibex::LSP::DocumentHandlers
Overview
Applies full-text LSP document notifications to the overlay-backed store.
Instance Method Summary
collapse
#hash_member, #integer_member, #params_hash, #publish, #require_running!, #require_state!, #stale_publication?, #store, #string_member, #workspace
Instance Method Details
#did_change(raw_params) ⇒ nil
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/ibex/lsp/document_handlers.rb', line 24
def did_change(raw_params)
require_running!
params = params_hash(raw_params)
document = hash_member(params, "textDocument")
changes = params["contentChanges"]
unless changes.is_a?(Array) && changes.one? && changes.first.is_a?(Hash) &&
!changes.first.key?("range") && !changes.first.key?("rangeLength")
raise ProtocolError.new("full sync requires exactly one range-free content change", code: -32_602)
end
source = string_member(changes.fetch(0), "text")
publications = store.change(
string_member(document, "uri"), integer_member(document, "version"), source
)
publish(publications)
nil
end
|
#did_close(raw_params) ⇒ nil
57
58
59
60
61
62
63
|
# File 'lib/ibex/lsp/document_handlers.rb', line 57
def did_close(raw_params)
require_running!
params = params_hash(raw_params)
document = hash_member(params, "textDocument")
publish(store.close(string_member(document, "uri")))
nil
end
|
#did_open(raw_params) ⇒ nil
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/ibex/lsp/document_handlers.rb', line 12
def did_open(raw_params)
require_running!
params = params_hash(raw_params)
document = hash_member(params, "textDocument")
publications = store.open(
string_member(document, "uri"), integer_member(document, "version"), string_member(document, "text")
)
publish(publications)
nil
end
|
#did_save(raw_params) ⇒ nil
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/ibex/lsp/document_handlers.rb', line 43
def did_save(raw_params)
require_running!
params = params_hash(raw_params)
document = hash_member(params, "textDocument")
source = params["text"]
unless source.nil? || source.is_a?(String)
raise ProtocolError.new("saved document text must be a string", code: -32_602)
end
publish(store.save(string_member(document, "uri"), source: source))
nil
end
|