Support socket to transport.

This commit is contained in:
ykiko
2024-09-13 18:59:07 +08:00
parent 783edfe709
commit cfcb3f488b
6 changed files with 184 additions and 81 deletions

View File

@@ -7,18 +7,21 @@
namespace clice {
void Scheduler::dispatch(json::Value id, std::string_view method, json::Value value) {
std::vector<const char*> compileArgs = {
"clang++",
"-std=c++20",
"main.cpp",
"-resource-dir=/home/ykiko/C++/clice2/build/lib/clang/20",
};
if(method == "textDocument/didOpen") {
auto params = json::deserialize<protocol::DidOpenTextDocumentParams>(value);
std::vector<const char*> compileArgs = {
"clang++",
"-std=c++20",
"main.cpp",
"-resource-dir=/home/ykiko/C++/clice2/build/lib/clang/20",
};
auto AST = ParsedAST::build("main.cpp", params.textDocument.text, compileArgs);
spdlog::info("read file: {}", params.textDocument.text);
files[params.textDocument.uri].ast = std::move(AST);
} else if(method == "textDocument/didChange") {
auto params = json::deserialize<protocol::DidChangeTextDocumentParams>(value);
auto AST = ParsedAST::build("main.cpp", params.contentChanges.back().text, compileArgs);
files[params.textDocument.uri].ast = std::move(AST);
} else if(method == "textDocument/semanticTokens/full") {
auto params = json::deserialize<protocol::SemanticTokensParams>(value);
auto AST = files[params.textDocument.uri].ast.get();