loom
73 строки · 3.4 Кб
1#include "TaskDistribute.h"2#include "simodo/lsp/server/ServerContext.h"3#include "parsers/Initialize.h"4#include "parsers/Initialized.h"5#include "parsers/Shutdown.h"6#include "parsers/DocDidOpen.h"7#include "parsers/DocDidChange.h"8#include "parsers/DocDidClose.h"9#include "parsers/DocHover.h"10#include "parsers/DocumentSymbol.h"11#include "parsers/SemanticTokens.h"12#include "parsers/GotoDeclaration.h"13#include "parsers/GotoDefinition.h"14#include "parsers/Completion.h"15#include "parsers/SegmentationFault.h"16#include "parsers/SimodoCommand.h"17
18#include "simodo/variable/json/Serialization.h"19#include "simodo/variable/json/Rpc.h"20#include "simodo/inout/convert/functions.h"21
22namespace simodo::lsp23{
24
25void TaskDistribute::work()26{
27variable::JsonRpc json_rpc(_jsonrpc_content);28
29/// @note Метод может быть пустым только когда сделаем отправку запросов с сервера на клиент30if (!json_rpc.is_valid() || json_rpc.method().empty()) {31_server.log().error("Unrecognized JSON-RPC structure", _jsonrpc_content);32_server.sending().push(33/// @todo Скорректировать коды (и тексты) ошибок34simodo::variable::JsonRpc(-1, u"Unrecognized JSON-RPC structure", json_rpc.id()));35}36
37if (json_rpc.method() == u"initialize")38_server.tp().submit(new Initialize(_server,_jsonrpc_content));39else if (json_rpc.method() == u"initialized")40_server.tp().submit(new Initialized(_server,_jsonrpc_content));41else if (json_rpc.method() == u"shutdown")42_server.tp().submit(new Shutdown(_server,_jsonrpc_content));43else if (json_rpc.method() == u"textDocument/didOpen")44_server.tp().submit(new DocDidOpen(_server,_jsonrpc_content));45else if (json_rpc.method() == u"textDocument/didChange")46_server.tp().submit(new DocDidChange(_server,_jsonrpc_content));47else if (json_rpc.method() == u"textDocument/didClose")48_server.tp().submit(new DocDidClose(_server,_jsonrpc_content));49else if (json_rpc.method() == u"textDocument/hover")50_server.tp().submit(new DocHover(_server,_jsonrpc_content));51else if (json_rpc.method() == u"textDocument/documentSymbol")52_server.tp().submit(new DocumentSymbol(_server,_jsonrpc_content));53else if (json_rpc.method().starts_with(u"textDocument/semanticTokens"))54_server.tp().submit(new SemanticTokens(_server,_jsonrpc_content));55else if (json_rpc.method() == u"textDocument/declaration")56_server.tp().submit(new GotoDeclaration(_server,_jsonrpc_content));57else if (json_rpc.method() == u"textDocument/definition")58_server.tp().submit(new GotoDefinition(_server,_jsonrpc_content));59else if (json_rpc.method() == u"textDocument/completion")60_server.tp().submit(new Completion(_server,_jsonrpc_content));61else if (json_rpc.method() == u"simodo/command")62_server.tp().submit(new SimodoCommand(_server,_jsonrpc_content));63else if (json_rpc.method() == u"SegmentationFault")64_server.tp().submit(new SegmentationFault(_server,_jsonrpc_content));65else {66_server.log().warning("Unsupported method '" + inout::toU8(json_rpc.method()) + "'", _jsonrpc_content);67_server.sending().push(68/// @todo Скорректировать коды (и тексты) ошибок69simodo::variable::JsonRpc(-1, u"Unsupported method '" + json_rpc.method() + u"'", json_rpc.id()));70}71}
72
73}