diff --git a/include/Protocol/Lifecycle/Initialize.h b/include/Protocol/Lifecycle/Initialize.h index 041eec2c..3a1d81a7 100644 --- a/include/Protocol/Lifecycle/Initialize.h +++ b/include/Protocol/Lifecycle/Initialize.h @@ -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; }; diff --git a/include/Server/Command.h b/include/Server/Command.h index 47e7288d..0d9d9028 100644 --- a/include/Server/Command.h +++ b/include/Server/Command.h @@ -1,3 +1,5 @@ +#pragma once + #include namespace clice { @@ -13,10 +15,4 @@ private: std::unique_ptr CDB; }; -namespace global { - -extern CompilationDatabase CDB; - -}; - } // namespace clice diff --git a/include/Server/Option.h b/include/Server/Option.h index fcc2f0f4..b18c3c59 100644 --- a/include/Server/Option.h +++ b/include/Server/Option.h @@ -11,8 +11,4 @@ struct Option { void parse(int argc, const char** argv); }; -namespace global { -extern struct Option option; -}; - } // namespace clice diff --git a/include/Server/Scheduler .h b/include/Server/Scheduler .h new file mode 100644 index 00000000..eb33f2c6 --- /dev/null +++ b/include/Server/Scheduler .h @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +namespace clice { + +/// responsible for file management and scheduling tasks. +class Scheduler { +private: + struct TU { + using message = llvm::unique_function; + std::string content; + std::deque messages; + std::unique_ptr ast; + std::unique_ptr preamble; + }; + +public: + void update(std::string_view path, std::string_view content); + +private: + llvm::StringMap files; +}; + +} // namespace clice diff --git a/include/Server/Server.h b/include/Server/Server.h index 58197faa..8be75c66 100644 --- a/include/Server/Server.h +++ b/include/Server/Server.h @@ -1,5 +1,9 @@ #pragma once +#include +#include +#include + 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 { diff --git a/include/Support/FileSystem.h b/include/Support/FileSystem.h index 2bd55824..9dd17dbc 100644 --- a/include/Support/FileSystem.h +++ b/include/Support/FileSystem.h @@ -1,3 +1,5 @@ +#pragma once + #include namespace clice { diff --git a/include/Support/JSON.h b/include/Support/JSON.h index 2ab59ad5..836cb9f0 100644 --- a/include/Support/JSON.h +++ b/include/Support/JSON.h @@ -1,3 +1,5 @@ +#pragma once + #include #include #include @@ -28,6 +30,8 @@ Object serialize(const T& object) { result.try_emplace(name, std::move(array)); } else if constexpr(std::is_constructible_v) { result.try_emplace(name, value); + } else if constexpr(std::is_enum_v) { + result.try_emplace(name, static_cast>(value)); } else { result.try_emplace(name, serialize(value)); } diff --git a/src/Server/Command.cpp b/src/Server/Command.cpp index 0ff0da5a..b336bc91 100644 --- a/src/Server/Command.cpp +++ b/src/Server/Command.cpp @@ -25,8 +25,4 @@ void CompilationDatabase::load(clang::StringRef path) { } } -namespace global { -CompilationDatabase CDB; -} - } // namespace clice