implement basic communication between the server and the client.

This commit is contained in:
ykiko
2024-09-08 17:10:57 +08:00
parent 8b48f9d9e8
commit e18e4e7e6f
7 changed files with 167 additions and 22 deletions

View File

@@ -43,4 +43,8 @@ struct TextDocumentItem {
string text;
};
struct TextDocumentIdentifier {
DocumentUri uri;
};
} // namespace clice::protocol

View File

@@ -12,7 +12,7 @@ enum class SemanticTokenType : uint8_t {
/// Represents a character literal.
Char,
/// Represents a string literal.
String,
string,
/// Represents a C/C++ keyword (e.g., `int`, `class`, `struct`).
Keyword,
/// Represents a compiler built-in macro, function, or keyword (e.g., `__stdcall`,
@@ -126,10 +126,10 @@ struct SemanticTokensClientCapabilities {
};
/// The token types that the client supports.
std::vector<String> tokenTypes;
std::vector<string> tokenTypes;
/// The token modifiers that the client supports.
std::vector<String> tokenModifiers;
std::vector<string> tokenModifiers;
/// The formats the client supports.
/// formats: TokenFormat[];
@@ -149,10 +149,10 @@ struct SemanticTokensClientCapabilities {
struct SemanticTokensLegend {
/// The token types a server uses.
std::vector<String> tokenTypes;
std::vector<string> tokenTypes;
/// The token modifiers a server uses.
std::vector<String> tokenModifiers;
std::vector<string> tokenModifiers;
};
/// Server Capability:
@@ -172,24 +172,20 @@ struct SemanticTokensOptions {
/// Request:
/// - method: `textDocument/semanticTokens/full`
/// - params: `SemanticTokensParams` defined as follows:
struct SemanticTokensParamsBody {
struct SemanticTokensParams {
/// The text document.
TextDocumentIdentifier textDocument;
};
using SemanticTokensParams = Combine<
// WorkDoneProgressParams,
// PartialResultParams,
SemanticTokensParamsBody>;
/// Response:
/// - result: `SemanticTokens` defined as follows:
struct SemanticTokens {
/// An optional result id.
String resultId;
string resultId;
/// The actual tokens.
std::vector<Integer> data;
std::vector<integer> data;
};
} // namespace clice::protocol

View File

@@ -1,7 +1,19 @@
#include "../Basic.h"
#include "../Language/SemanticToken.h"
namespace clice::protocol {
struct ServerCapabilities {
std::string_view positionEncoding = "utf-16";
SemanticTokensOptions semanticTokensProvider;
};
}
struct InitializeResult {
ServerCapabilities capabilities;
struct {
std::string_view name = "clice";
std::string_view version = "0.0.1";
} serverInfo;
};
} // namespace clice::protocol