loom
45 строк · 1.9 Кб
1#include "DocHover.h"
2#include "simodo/lsp/server/ServerContext.h"
3#include "simodo/lsp/server/DocumentContext.h"
4#include "simodo/lsp/client/TextDocumentPositionParamsParsers.h"
5
6#include "simodo/variable/json/Rpc.h"
7#include "simodo/variable/json/Serialization.h"
8#include "simodo/inout/convert/functions.h"
9
10namespace simodo::lsp
11{
12
13void DocHover::work()
14{
15if (_jsonrpc.is_valid()) {
16lsp::TextDocumentPositionParams doc_position;
17if (lsp::parseTextDocumentPositionParams(_jsonrpc.params(), doc_position)) {
18DocumentContext * doc = _server.findDocument(doc_position.textDocument.uri);
19if (doc) {
20variable::Value result = doc->produceHoverResponse(doc_position.position);
21_server.sending().push(variable::JsonRpc(result, _jsonrpc.id()));
22return;
23}
24
25_server.log().error("'textDocument/hover' command: uri '"
26+ doc_position.textDocument.uri + "' don't loaded yet",
27variable::toJson(_jsonrpc.value()));
28_server.sending().push(
29/// @todo Скорректировать коды (и тексты) ошибок
30variable::JsonRpc(-1,
31u"'textDocument/hover' command: uri '"
32+ inout::toU16(doc_position.textDocument.uri) + u"' don't loaded yet",
33_jsonrpc.id()));
34return;
35}
36}
37_server.log().error("There are wrong parameter structure of 'textDocument/hover' command",
38variable::toJson(_jsonrpc.value()));
39_server.sending().push(
40/// @todo Скорректировать коды (и тексты) ошибок
41variable::JsonRpc(-1,u"There are wrong parameter structure of 'textDocument/hover' command",
42_jsonrpc.id()));
43}
44
45}