Successfully implemented SemanticTokens communication between the client and server.

This commit is contained in:
ykiko
2024-09-12 22:02:48 +08:00
parent 081e6d1d53
commit 783edfe709
7 changed files with 296 additions and 45 deletions

View File

@@ -1,10 +1,12 @@
#include <Server/Scheduler.h>
#include <Protocol/Protocol.h>
#include <spdlog/spdlog.h>
#include <Feature/SemanticTokens.h>
#include <Server/Server.h>
namespace clice {
void Scheduler::dispatch(std::string_view method, json::Value value) {
void Scheduler::dispatch(json::Value id, std::string_view method, json::Value value) {
if(method == "textDocument/didOpen") {
auto params = json::deserialize<protocol::DidOpenTextDocumentParams>(value);
std::vector<const char*> compileArgs = {
@@ -20,7 +22,8 @@ void Scheduler::dispatch(std::string_view method, json::Value value) {
} else if(method == "textDocument/semanticTokens/full") {
auto params = json::deserialize<protocol::SemanticTokensParams>(value);
auto AST = files[params.textDocument.uri].ast.get();
auto semanticTokens = feature::semanticTokens(*AST, "main.cpp");
Server::instance.response(std::move(id), json::serialize(semanticTokens));
} else {
spdlog::error("unknown method: {}", method);
}