clear the project.
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Support/Async.h>
|
||||
#include <Clang/ParsedAST.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
struct TranslationUnit {
|
||||
std::string path;
|
||||
std::deque<std::string> messages;
|
||||
std::unique_ptr<ParsedAST> ast;
|
||||
};
|
||||
|
||||
/// a class used to manage all resources for the LSP server
|
||||
class Scheduler {
|
||||
private:
|
||||
llvm::StringMap<std::unique_ptr<ParsedAST>> parsedASTs;
|
||||
|
||||
public:
|
||||
// update the AST for a given file
|
||||
Task<void> update(std::string_view path, std::string_view content);
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
@@ -1,68 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <Protocol/Protocol.h>
|
||||
#include "Scheduler.h"
|
||||
#include "Transport.h"
|
||||
|
||||
namespace clice {
|
||||
|
||||
// global server instance
|
||||
extern class Server server;
|
||||
|
||||
/// core class responsible for starting the server
|
||||
class Server {
|
||||
std::unique_ptr<Transport> transport;
|
||||
std::unique_ptr<Scheduler> scheduler;
|
||||
std::map<std::string_view, void (*)(std::string_view)> methods;
|
||||
|
||||
public:
|
||||
int run(int argc, char** argv);
|
||||
int exit();
|
||||
void handle_message(std::string_view message);
|
||||
|
||||
template <auto ptr>
|
||||
void register_method(std::string_view name) {
|
||||
methods[name] = []<typename R, typename... Args>(R (*)(Args...)) {
|
||||
return [](std::string_view message) {
|
||||
// auto input = json::parse(message);
|
||||
// auto params = deserialize<Args>(input["params"]);
|
||||
// ptr(params);
|
||||
};
|
||||
}(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
/*===================================================/
|
||||
/ /
|
||||
/==================== LSP methods ===================/
|
||||
/ /
|
||||
/===================================================*/
|
||||
|
||||
// Server lifecycle
|
||||
void initialize(const InitializeParams& params);
|
||||
|
||||
// Text Document Synchronization
|
||||
Task<void> didOpen(const DidOpenTextDocumentParams& params);
|
||||
Task<void> didChange(const DidChangeTextDocumentParams& params);
|
||||
Task<void> didClose(const DidCloseTextDocumentParams& params);
|
||||
Task<void> didSave(const DidSaveTextDocumentParams& params);
|
||||
|
||||
// Language Features
|
||||
Task<void> declaration();
|
||||
Task<void> definition();
|
||||
Task<void> typeDefinition();
|
||||
Task<void> implementation();
|
||||
Task<void> references();
|
||||
Task<void> callHierarchy();
|
||||
/* ... */
|
||||
Task<void> hover();
|
||||
Task<void> codeLens();
|
||||
/* ... */
|
||||
Task<void> foldingRange();
|
||||
Task<void> selectionRange();
|
||||
Task<void> documentSymbol();
|
||||
Task<void> semanticTokens();
|
||||
Task<void> inlineValue();
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
@@ -1,16 +0,0 @@
|
||||
#include <string_view>
|
||||
|
||||
namespace clice {
|
||||
|
||||
/// Settings for the LSP server
|
||||
struct Setting {
|
||||
/// compile_commands.json file path
|
||||
std::string compile_commands_dictionary = "/build";
|
||||
/// mode of the server: ["pipe", "socket", "index"]
|
||||
std::string mode = "pipe";
|
||||
};
|
||||
|
||||
/// global setting instance
|
||||
inline Setting setting = {};
|
||||
|
||||
} // namespace clice
|
||||
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
class Transport {
|
||||
public:
|
||||
virtual void send(std::string_view) = 0;
|
||||
virtual ~Transport() = default;
|
||||
};
|
||||
|
||||
class Pipe : public Transport {
|
||||
private:
|
||||
uv_pipe_t stdin_pipe;
|
||||
uv_pipe_t stdout_pipe;
|
||||
|
||||
private:
|
||||
static void alloc_buffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
|
||||
static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
|
||||
|
||||
public:
|
||||
Pipe() {
|
||||
// initialize the pipe
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
uv_pipe_init(loop, &stdin_pipe, 0);
|
||||
uv_pipe_init(loop, &stdout_pipe, 0);
|
||||
|
||||
// bind to stdin and stdout
|
||||
uv_pipe_open(&stdin_pipe, 0);
|
||||
uv_pipe_open(&stdout_pipe, 1);
|
||||
|
||||
// set callback for reading from stdin
|
||||
uv_read_start((uv_stream_t*)&stdin_pipe, alloc_buffer, on_read);
|
||||
}
|
||||
|
||||
void send(std::string_view message) override;
|
||||
|
||||
~Pipe() override {
|
||||
uv_close((uv_handle_t*)&stdin_pipe, nullptr);
|
||||
uv_close((uv_handle_t*)&stdout_pipe, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
class Socket : public Transport {
|
||||
private:
|
||||
uv_tcp_t socket;
|
||||
|
||||
public:
|
||||
Socket(std::string_view address, int port);
|
||||
|
||||
void send(std::string_view message) override;
|
||||
|
||||
~Socket() override { uv_close((uv_handle_t*)&socket, nullptr); }
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
Reference in New Issue
Block a user