loom
45 строк · 1.9 Кб
1#include "GotoDeclaration.h"2#include "simodo/lsp/server/ServerContext.h"3#include "simodo/lsp/server/DocumentContext.h"4
5#include "simodo/variable/json/Rpc.h"6#include "simodo/variable/json/Serialization.h"7#include "simodo/inout/convert/functions.h"8#include "simodo/lsp/client/TextDocumentPositionParamsParsers.h"9
10namespace simodo::lsp11{
12
13void GotoDeclaration::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->produceGotoDeclarationResponse(doc_position.position);21_server.sending().push(variable::JsonRpc(result, _jsonrpc.id()));22return;23}24
25_server.log().error("'textDocument/declaration' 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/declaration' 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/declaration' command",38variable::toJson(_jsonrpc.value()));39_server.sending().push(40/// @todo Скорректировать коды (и тексты) ошибок41variable::JsonRpc(-1,u"There are wrong parameter structure of 'textDocument/declaration' command",42_jsonrpc.id()));43}
44
45}