loom
29 строк · 1.2 Кб
1#include "DocDidClose.h"
2#include "simodo/lsp-server/ServerContext.h"
3
4#include "simodo/variable/json/Rpc.h"
5#include "simodo/variable/json/Serialization.h"
6#include "simodo/inout/convert/functions.h"
7
8namespace simodo::lsp
9{
10
11void DocDidClose::work()
12{
13if (_jsonrpc.is_valid() && _jsonrpc.params().type() == variable::ValueType::Object) {
14variable::Value & textDocument_value = _jsonrpc.params().getObject()->find(u"textDocument");
15if (textDocument_value.type() == variable::ValueType::Object) {
16variable::Value & uri_value = textDocument_value.getObject()->find(u"uri");
17if (uri_value.type() == variable::ValueType::String) {
18if (_server.closeDocument(inout::toU8(uri_value.getString())))
19return;
20}
21}
22}
23_server.log().error("There are wrong parameter structure of 'textDocument/didClose' notification", variable::toJson(_jsonrpc.value()));
24_server.sending().push(
25/// @todo Скорректировать коды (и тексты) ошибок
26variable::JsonRpc(-1,u"There are wrong parameter structure of 'textDocument/didClose' notification",-1));
27}
28
29}