7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/milk_tea/lsp/server/debug_info.rb', line 7
def handle_debug_info(params)
uri = params.dig('textDocument', 'uri')
return { text: 'error: no textDocument.uri' } unless uri
content = @workspace.get_content(uri)
path = uri_to_path(uri) || uri
tokens = @workspace.get_tokens(uri)
ast = @workspace.get_ast(uri)
facts = @workspace.get_facts(uri)
snapshot = @workspace.get_tooling_snapshot(uri)
parse_errors = begin
result = MilkTea::Parser.parse_collecting_errors(content, path: uri)
result.errors
rescue StandardError
[]
end
text = DebugInfoFormatter.format_all(
content: content,
tokens: tokens,
ast: ast,
parse_errors: parse_errors,
facts: facts,
snapshot: snapshot,
path: path,
semantic_entries: facts ? build_semantic_token_entries(tokens, facts) : nil,
)
{ text: text }
rescue StandardError => e
{ text: "error generating debug info: #{e.message}\n#{e.backtrace.first(5).join("\n")}" }
end
|