reorganize the project.

This commit is contained in:
ykiko
2024-09-08 22:14:44 +08:00
parent e18e4e7e6f
commit 536ff8c02f
8 changed files with 50 additions and 14 deletions

View File

@@ -2,8 +2,15 @@
namespace clice::protocol {
enum class TextDocumentSyncKind {
None = 0,
Full = 1,
Incremental = 2,
};
struct ServerCapabilities {
std::string_view positionEncoding = "utf-16";
TextDocumentSyncKind textDocumentSync = TextDocumentSyncKind::Full;
SemanticTokensOptions semanticTokensProvider;
};

View File

@@ -1,3 +1,5 @@
#pragma once
#include <clang/Tooling/CompilationDatabase.h>
namespace clice {
@@ -13,10 +15,4 @@ private:
std::unique_ptr<clang::tooling::CompilationDatabase> CDB;
};
namespace global {
extern CompilationDatabase CDB;
};
} // namespace clice

View File

@@ -11,8 +11,4 @@ struct Option {
void parse(int argc, const char** argv);
};
namespace global {
extern struct Option option;
};
} // namespace clice

View File

@@ -0,0 +1,26 @@
#include <llvm/ADT/StringMap.h>
#include <Support/JSON.h>
#include <AST/Preamble.h>
#include <AST/ParsedAST.h>
namespace clice {
/// responsible for file management and scheduling tasks.
class Scheduler {
private:
struct TU {
using message = llvm::unique_function<json::Object()>;
std::string content;
std::deque<message> messages;
std::unique_ptr<ParsedAST> ast;
std::unique_ptr<Preamble> preamble;
};
public:
void update(std::string_view path, std::string_view content);
private:
llvm::StringMap<TU> files;
};
} // namespace clice

View File

@@ -1,5 +1,9 @@
#pragma once
#include <Server/Option.h>
#include <Server/Command.h>
#include <Server/Scheduler .h>
namespace clice {
class Server {
@@ -7,6 +11,11 @@ public:
int run(int argc, const char** argv);
void handleMessage(std::string_view message);
private:
Option option;
Scheduler scheduler;
CompilationDatabase CDB;
};
namespace global {

View File

@@ -1,3 +1,5 @@
#pragma once
#include <llvm/Support/FileSystem.h>
namespace clice {

View File

@@ -1,3 +1,5 @@
#pragma once
#include <llvm/Support/JSON.h>
#include <Support/Reflection.h>
#include <array>
@@ -28,6 +30,8 @@ Object serialize(const T& object) {
result.try_emplace(name, std::move(array));
} else if constexpr(std::is_constructible_v<json::Value, Value&>) {
result.try_emplace(name, value);
} else if constexpr(std::is_enum_v<Value>) {
result.try_emplace(name, static_cast<std::underlying_type_t<Value>>(value));
} else {
result.try_emplace(name, serialize(value));
}