reorganize the project.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,8 +11,4 @@ struct Option {
|
||||
void parse(int argc, const char** argv);
|
||||
};
|
||||
|
||||
namespace global {
|
||||
extern struct Option option;
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
|
||||
26
include/Server/Scheduler .h
Normal file
26
include/Server/Scheduler .h
Normal 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
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <llvm/Support/FileSystem.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user