lsp协议的枚举不使用google风格
This commit is contained in:
parent
1f7045140e
commit
4deb0b6d87
|
|
@ -196,8 +196,8 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class ApplyKind
|
enum class ApplyKind
|
||||||
{
|
{
|
||||||
kReplace = 1,
|
Replace = 1,
|
||||||
kMerge = 2
|
Merge = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
using MarkupKind = std::string_view;
|
using MarkupKind = std::string_view;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class CodeActionTag
|
enum class CodeActionTag
|
||||||
{
|
{
|
||||||
kLLMGenerated = 1
|
LLMGenerated = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CodeActionClientCapabilities
|
struct CodeActionClientCapabilities
|
||||||
|
|
|
||||||
|
|
@ -7,55 +7,55 @@ namespace lsp::protocol
|
||||||
{
|
{
|
||||||
enum class CompletionItemTag
|
enum class CompletionItemTag
|
||||||
{
|
{
|
||||||
kDeprecated = 1
|
Deprecated = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class InsertTextMode
|
enum class InsertTextMode
|
||||||
{
|
{
|
||||||
kAsIs = 1,
|
AsIs = 1,
|
||||||
kAdjustIndentation = 2
|
AdjustIndentation = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CompletionItemKind
|
enum class CompletionItemKind
|
||||||
{
|
{
|
||||||
kText = 1,
|
Text = 1,
|
||||||
kMethod = 2,
|
Method = 2,
|
||||||
kFunction = 3,
|
Function = 3,
|
||||||
kConstructor = 4,
|
Constructor = 4,
|
||||||
kField = 5,
|
Field = 5,
|
||||||
kVariable = 6,
|
Variable = 6,
|
||||||
kClass = 7,
|
Class = 7,
|
||||||
kInterface = 8,
|
Interface = 8,
|
||||||
kModule = 9,
|
Module = 9,
|
||||||
kProperty = 10,
|
Property = 10,
|
||||||
kUnit = 11,
|
Unit = 11,
|
||||||
kValue = 12,
|
Value = 12,
|
||||||
kEnum = 13,
|
Enum = 13,
|
||||||
kKeyword = 14,
|
Keyword = 14,
|
||||||
kSnippet = 15,
|
Snippet = 15,
|
||||||
kColor = 16,
|
Color = 16,
|
||||||
kFile = 17,
|
File = 17,
|
||||||
kReference = 18,
|
Reference = 18,
|
||||||
kFolder = 19,
|
Folder = 19,
|
||||||
kEnumMember = 20,
|
EnumMember = 20,
|
||||||
kConstant = 21,
|
Constant = 21,
|
||||||
kStruct = 22,
|
Struct = 22,
|
||||||
kEvent = 23,
|
Event = 23,
|
||||||
kOperator = 24,
|
Operator = 24,
|
||||||
kTypeParameter = 25
|
TypeParameter = 25
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class InsertTextFormat
|
enum class InsertTextFormat
|
||||||
{
|
{
|
||||||
kPlainText = 1,
|
PlainText = 1,
|
||||||
kSnippet = 2
|
Snippet = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CompletionTriggerKind
|
enum CompletionTriggerKind
|
||||||
{
|
{
|
||||||
kInvoked = 1,
|
Invoked = 1,
|
||||||
kTriggerCharacter = 2,
|
TriggerCharacter = 2,
|
||||||
kTriggerForIncompleteCompletions = 3
|
TriggerForIncompleteCompletions = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompletionContext
|
struct CompletionContext
|
||||||
|
|
@ -200,8 +200,8 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class InlineCompletionTriggerKind
|
enum class InlineCompletionTriggerKind
|
||||||
{
|
{
|
||||||
kInvoked = 1,
|
Invoked = 1,
|
||||||
kAutomatic = 2
|
Automatic = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SelectedCompletionInfo
|
struct SelectedCompletionInfo
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@ namespace lsp::protocol
|
||||||
// Message
|
// Message
|
||||||
enum class MessageType
|
enum class MessageType
|
||||||
{
|
{
|
||||||
kError = 1,
|
Error = 1,
|
||||||
kWarning = 2,
|
Warning = 2,
|
||||||
kInfo = 3,
|
Info = 3,
|
||||||
kLog = 4,
|
Log = 4,
|
||||||
kDebug = 5
|
Debug = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShowMessageParams
|
struct ShowMessageParams
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ namespace lsp::protocol
|
||||||
{
|
{
|
||||||
enum class DiagnosticSeverity
|
enum class DiagnosticSeverity
|
||||||
{
|
{
|
||||||
kError = 1,
|
Error = 1,
|
||||||
kWarning = 2,
|
Warning = 2,
|
||||||
kInformation = 3,
|
Information = 3,
|
||||||
kHint = 4
|
Hint = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DiagnosticTag
|
enum class DiagnosticTag
|
||||||
{
|
{
|
||||||
kUnnecessary = 1,
|
Unnecessary = 1,
|
||||||
kDeprecated = 2
|
Deprecated = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DiagnosticRelatedInformation
|
struct DiagnosticRelatedInformation
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class TextDocumentSyncKind
|
enum class TextDocumentSyncKind
|
||||||
{
|
{
|
||||||
kNone = 0,
|
None = 0,
|
||||||
kFull = 1,
|
Full = 1,
|
||||||
kIncremental = 2
|
Incremental = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TextDocumentSyncOptions
|
struct TextDocumentSyncOptions
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,9 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class WatchKind
|
enum class WatchKind
|
||||||
{
|
{
|
||||||
kCreate = 1,
|
Create = 1,
|
||||||
kChange = 2,
|
Change = 2,
|
||||||
kDelete = 4
|
Delete = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FileSystemWatcher
|
struct FileSystemWatcher
|
||||||
|
|
@ -103,9 +103,9 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class FileChangeType
|
enum class FileChangeType
|
||||||
{
|
{
|
||||||
kCreated = 1,
|
Created = 1,
|
||||||
kChanged = 2,
|
Changed = 2,
|
||||||
kDeleted = 3
|
Deleted = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FileEvent
|
struct FileEvent
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class InlayHintKind
|
enum class InlayHintKind
|
||||||
{
|
{
|
||||||
kType = 1,
|
Type = 1,
|
||||||
kParameter = 2
|
Parameter = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InlayHint
|
struct InlayHint
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,22 @@ namespace lsp::protocol
|
||||||
{
|
{
|
||||||
enum class ErrorCodes : int
|
enum class ErrorCodes : int
|
||||||
{
|
{
|
||||||
kParseError = -32700,
|
ParseError = -32700,
|
||||||
kInvalidRequest = -32600,
|
InvalidRequest = -32600,
|
||||||
kMethodNotFound = -32601,
|
MethodNotFound = -32601,
|
||||||
kInvalidParams = -32602,
|
InvalidParams = -32602,
|
||||||
kInternalError = -32603,
|
InternalError = -32603,
|
||||||
|
|
||||||
kJsonrpcReservedErrorRangeStart = -32099,
|
JsonrpcReservedErrorRangeStart = -32099,
|
||||||
kServerNotInitialized = -32002,
|
ServerNotInitialized = -32002,
|
||||||
kUnknownErrorCode = -32001,
|
UnknownErrorCode = -32001,
|
||||||
kJsonrpcReservedErrorRangeEnd = -32000,
|
JsonrpcReservedErrorRangeEnd = -32000,
|
||||||
kLspReservedErrorRangeStart = -32899,
|
LspReservedErrorRangeStart = -32899,
|
||||||
kRequestFailed = -32803,
|
RequestFailed = -32803,
|
||||||
kServerCancelled = -32802,
|
ServerCancelled = -32802,
|
||||||
kContentModified = -32801,
|
ContentModified = -32801,
|
||||||
kRequestCancelled = -32800,
|
RequestCancelled = -32800,
|
||||||
kLspReservedErrorRangeEnd = -32800
|
LspReservedErrorRangeEnd = -32800
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message
|
struct Message
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace lsp::protocol
|
||||||
{
|
{
|
||||||
enum class PrepareSupportDefaultBehavior
|
enum class PrepareSupportDefaultBehavior
|
||||||
{
|
{
|
||||||
kIdentifier = 1
|
Identifier = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
// Rename
|
// Rename
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@ namespace lsp::protocol
|
||||||
|
|
||||||
enum class SignatureHelpTriggerKind
|
enum class SignatureHelpTriggerKind
|
||||||
{
|
{
|
||||||
kInvoked = 1,
|
Invoked = 1,
|
||||||
kTriggerCharacter = 2,
|
TriggerCharacter = 2,
|
||||||
kContentChange = 3
|
ContentChange = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ParammeterInformation
|
struct ParammeterInformation
|
||||||
|
|
|
||||||
|
|
@ -8,32 +8,32 @@ namespace lsp::protocol
|
||||||
{
|
{
|
||||||
enum class SymbolKind
|
enum class SymbolKind
|
||||||
{
|
{
|
||||||
kFile = 1,
|
File = 1,
|
||||||
kModule = 2,
|
Module = 2,
|
||||||
kNamespace = 3,
|
Namespace = 3,
|
||||||
kPackage = 4,
|
Package = 4,
|
||||||
kClass = 5,
|
Class = 5,
|
||||||
kMethod = 6,
|
Method = 6,
|
||||||
kProperty = 7,
|
Property = 7,
|
||||||
kField = 8,
|
Field = 8,
|
||||||
kConstructor = 9,
|
Constructor = 9,
|
||||||
kEnum = 10,
|
Enum = 10,
|
||||||
kInterface = 11,
|
Interface = 11,
|
||||||
kFunction = 12,
|
Function = 12,
|
||||||
kVariable = 13,
|
Variable = 13,
|
||||||
kConstant = 14,
|
Constant = 14,
|
||||||
kString = 15,
|
String = 15,
|
||||||
kNumber = 16,
|
Number = 16,
|
||||||
kBoolean = 17,
|
Boolean = 17,
|
||||||
kArray = 18,
|
Array = 18,
|
||||||
kObject = 19,
|
Object = 19,
|
||||||
kKey = 20,
|
Key = 20,
|
||||||
kNull = 21,
|
Null = 21,
|
||||||
kEnumMember = 22,
|
EnumMember = 22,
|
||||||
kStruct = 23,
|
Struct = 23,
|
||||||
kEvent = 24,
|
Event = 24,
|
||||||
kOperator = 25,
|
Operator = 25,
|
||||||
kTypeParameter = 26
|
TypeParameter = 26
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SymbolTag
|
enum class SymbolTag
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace lsp::provider::client
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace lsp::provider::client
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace lsp::provider::completion_item
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::CompletionItem item = transform::As<protocol::CompletionItem>(request.params.value());
|
protocol::CompletionItem item = transform::As<protocol::CompletionItem>(request.params.value());
|
||||||
|
|
@ -35,7 +35,7 @@ namespace lsp::provider::completion_item
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,21 +48,21 @@ namespace lsp::provider::completion_item
|
||||||
// 根据补全项类型进行解析
|
// 根据补全项类型进行解析
|
||||||
switch (item.kind.value())
|
switch (item.kind.value())
|
||||||
{
|
{
|
||||||
case protocol::CompletionItemKind::kKeyword:
|
case protocol::CompletionItemKind::Keyword:
|
||||||
ResolveKeyword(resolved);
|
ResolveKeyword(resolved);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case protocol::CompletionItemKind::kFunction:
|
case protocol::CompletionItemKind::Function:
|
||||||
case protocol::CompletionItemKind::kMethod:
|
case protocol::CompletionItemKind::Method:
|
||||||
ResolveFunction(resolved, execution_context);
|
ResolveFunction(resolved, execution_context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case protocol::CompletionItemKind::kClass:
|
case protocol::CompletionItemKind::Class:
|
||||||
ResolveClass(resolved, execution_context);
|
ResolveClass(resolved, execution_context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case protocol::CompletionItemKind::kVariable:
|
case protocol::CompletionItemKind::Variable:
|
||||||
case protocol::CompletionItemKind::kProperty:
|
case protocol::CompletionItemKind::Property:
|
||||||
ResolveVariable(resolved, execution_context);
|
ResolveVariable(resolved, execution_context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -138,7 +138,7 @@ namespace lsp::provider::completion_item
|
||||||
|
|
||||||
item.documentation = documentation::BuildFunctionDocumentation(*sig, source_file);
|
item.documentation = documentation::BuildFunctionDocumentation(*sig, source_file);
|
||||||
item.insertText = snippet::BuildFunctionCallSnippet(*sig);
|
item.insertText = snippet::BuildFunctionCallSnippet(*sig);
|
||||||
item.insertTextFormat = protocol::InsertTextFormat::kSnippet;
|
item.insertTextFormat = protocol::InsertTextFormat::Snippet;
|
||||||
|
|
||||||
spdlog::trace("{}: Resolved function '{}' from '{}'", GetProviderName(), item.label, source_file);
|
spdlog::trace("{}: Resolved function '{}' from '{}'", GetProviderName(), item.label, source_file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ namespace lsp::provider
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
{
|
{
|
||||||
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitializeFailed);
|
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitializeFailed);
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
}
|
}
|
||||||
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitialized);
|
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitialized);
|
||||||
return json.value();
|
return json.value();
|
||||||
|
|
@ -52,7 +52,7 @@ namespace lsp::provider
|
||||||
{
|
{
|
||||||
protocol::TextDocumentSyncOptions options;
|
protocol::TextDocumentSyncOptions options;
|
||||||
options.openClose = true;
|
options.openClose = true;
|
||||||
options.change = protocol::TextDocumentSyncKind::kIncremental;
|
options.change = protocol::TextDocumentSyncKind::Incremental;
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace lsp::provider
|
||||||
response.id = request.id;
|
response.id = request.id;
|
||||||
auto json = transform::Serialize(response);
|
auto json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
spdlog::info("Shutdown request processed successfully");
|
spdlog::info("Shutdown request processed successfully");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ namespace lsp::provider::text_document
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::CompletionParams completion_params = transform::As<protocol::CompletionParams>(request.params.value());
|
protocol::CompletionParams completion_params = transform::As<protocol::CompletionParams>(request.params.value());
|
||||||
|
|
@ -263,7 +263,7 @@ namespace lsp::provider::text_document
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
{
|
{
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.value();
|
return json.value();
|
||||||
|
|
@ -344,7 +344,7 @@ namespace lsp::provider::text_document
|
||||||
{
|
{
|
||||||
protocol::CompletionItem item;
|
protocol::CompletionItem item;
|
||||||
item.label = keyword.keyword;
|
item.label = keyword.keyword;
|
||||||
item.kind = protocol::CompletionItemKind::kKeyword;
|
item.kind = protocol::CompletionItemKind::Keyword;
|
||||||
item.labelDetails = protocol::CompletionItemLabelDetails{
|
item.labelDetails = protocol::CompletionItemLabelDetails{
|
||||||
.detail = "",
|
.detail = "",
|
||||||
.description = "[K]"
|
.description = "[K]"
|
||||||
|
|
@ -512,7 +512,7 @@ namespace lsp::provider::text_document
|
||||||
{
|
{
|
||||||
protocol::CompletionItem item;
|
protocol::CompletionItem item;
|
||||||
item.label = file_index.primary_symbol;
|
item.label = file_index.primary_symbol;
|
||||||
item.kind = protocol::CompletionItemKind::kClass;
|
item.kind = protocol::CompletionItemKind::Class;
|
||||||
item.labelDetails = protocol::CompletionItemLabelDetails{
|
item.labelDetails = protocol::CompletionItemLabelDetails{
|
||||||
.detail = "",
|
.detail = "",
|
||||||
.description = "[W]"
|
.description = "[W]"
|
||||||
|
|
@ -532,7 +532,7 @@ namespace lsp::provider::text_document
|
||||||
{
|
{
|
||||||
protocol::CompletionItem item;
|
protocol::CompletionItem item;
|
||||||
item.label = sys_index.primary_symbol;
|
item.label = sys_index.primary_symbol;
|
||||||
item.kind = protocol::CompletionItemKind::kClass;
|
item.kind = protocol::CompletionItemKind::Class;
|
||||||
item.labelDetails = protocol::CompletionItemLabelDetails{
|
item.labelDetails = protocol::CompletionItemLabelDetails{
|
||||||
.detail = "",
|
.detail = "",
|
||||||
.description = "[S]"
|
.description = "[S]"
|
||||||
|
|
@ -686,23 +686,23 @@ namespace lsp::provider::text_document
|
||||||
switch (symbol->kind)
|
switch (symbol->kind)
|
||||||
{
|
{
|
||||||
case Kind::kFunction:
|
case Kind::kFunction:
|
||||||
return protocol::CompletionItemKind::kFunction;
|
return protocol::CompletionItemKind::Function;
|
||||||
case Kind::kMethod:
|
case Kind::kMethod:
|
||||||
case Kind::kConstructor:
|
case Kind::kConstructor:
|
||||||
return protocol::CompletionItemKind::kMethod;
|
return protocol::CompletionItemKind::Method;
|
||||||
case Kind::kClass:
|
case Kind::kClass:
|
||||||
return protocol::CompletionItemKind::kClass;
|
return protocol::CompletionItemKind::Class;
|
||||||
case Kind::kProperty:
|
case Kind::kProperty:
|
||||||
return protocol::CompletionItemKind::kProperty;
|
return protocol::CompletionItemKind::Property;
|
||||||
case Kind::kVariable:
|
case Kind::kVariable:
|
||||||
case Kind::kParameter:
|
case Kind::kParameter:
|
||||||
return protocol::CompletionItemKind::kVariable;
|
return protocol::CompletionItemKind::Variable;
|
||||||
case Kind::kConstant:
|
case Kind::kConstant:
|
||||||
return protocol::CompletionItemKind::kConstant;
|
return protocol::CompletionItemKind::Constant;
|
||||||
case Kind::kUnit:
|
case Kind::kUnit:
|
||||||
return protocol::CompletionItemKind::kModule;
|
return protocol::CompletionItemKind::Module;
|
||||||
default:
|
default:
|
||||||
return protocol::CompletionItemKind::kText;
|
return protocol::CompletionItemKind::Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -714,22 +714,22 @@ namespace lsp::provider::text_document
|
||||||
{
|
{
|
||||||
case SymbolKind::kFunction:
|
case SymbolKind::kFunction:
|
||||||
case SymbolKind::kMethod:
|
case SymbolKind::kMethod:
|
||||||
return protocol::CompletionItemKind::kFunction;
|
return protocol::CompletionItemKind::Function;
|
||||||
case SymbolKind::kConstructor:
|
case SymbolKind::kConstructor:
|
||||||
return protocol::CompletionItemKind::kConstructor;
|
return protocol::CompletionItemKind::Constructor;
|
||||||
case SymbolKind::kClass:
|
case SymbolKind::kClass:
|
||||||
return protocol::CompletionItemKind::kClass;
|
return protocol::CompletionItemKind::Class;
|
||||||
case SymbolKind::kProperty:
|
case SymbolKind::kProperty:
|
||||||
return protocol::CompletionItemKind::kProperty;
|
return protocol::CompletionItemKind::Property;
|
||||||
case SymbolKind::kVariable:
|
case SymbolKind::kVariable:
|
||||||
case SymbolKind::kParameter:
|
case SymbolKind::kParameter:
|
||||||
return protocol::CompletionItemKind::kVariable;
|
return protocol::CompletionItemKind::Variable;
|
||||||
case SymbolKind::kConstant:
|
case SymbolKind::kConstant:
|
||||||
return protocol::CompletionItemKind::kConstant;
|
return protocol::CompletionItemKind::Constant;
|
||||||
case SymbolKind::kUnit:
|
case SymbolKind::kUnit:
|
||||||
return protocol::CompletionItemKind::kModule;
|
return protocol::CompletionItemKind::Module;
|
||||||
default:
|
default:
|
||||||
return protocol::CompletionItemKind::kText;
|
return protocol::CompletionItemKind::Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace lsp::provider::text_document
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::DefinitionParams params = transform::As<protocol::DefinitionParams>(request.params.value());
|
protocol::DefinitionParams params = transform::As<protocol::DefinitionParams>(request.params.value());
|
||||||
|
|
@ -43,7 +43,7 @@ namespace lsp::provider::text_document
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace lsp::provider::text_document
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::ReferenceParams params =
|
protocol::ReferenceParams params =
|
||||||
|
|
@ -41,7 +41,7 @@ namespace lsp::provider::text_document
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace lsp::provider::text_document
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::RenameParams params =
|
protocol::RenameParams params =
|
||||||
|
|
@ -37,7 +37,7 @@ namespace lsp::provider::text_document
|
||||||
if (!IsValidIdentifier(params.newName))
|
if (!IsValidIdentifier(params.newName))
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Invalid new name: '{}'", GetProviderName(), params.newName);
|
spdlog::warn("{}: Invalid new name: '{}'", GetProviderName(), params.newName);
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "'" + params.newName + "' is not a valid identifier");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "'" + params.newName + "' is not a valid identifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto workspace_edit_opt = BuildRenameResponse(params, context);
|
auto workspace_edit_opt = BuildRenameResponse(params, context);
|
||||||
|
|
@ -57,7 +57,7 @@ namespace lsp::provider::text_document
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ namespace lsp::provider::text_document
|
||||||
auto content = doc_service.GetContent(params.textDocument.uri);
|
auto content = doc_service.GetContent(params.textDocument.uri);
|
||||||
|
|
||||||
if (!tree || !content)
|
if (!tree || !content)
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Document not available");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Document not available");
|
||||||
|
|
||||||
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value(), ¶ms.range);
|
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value(), ¶ms.range);
|
||||||
auto encoded = EncodeTokens(tokens);
|
auto encoded = EncodeTokens(tokens);
|
||||||
|
|
@ -568,7 +568,7 @@ namespace lsp::provider::text_document
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -582,7 +582,7 @@ namespace lsp::provider::text_document
|
||||||
auto content = doc_service.GetContent(params.textDocument.uri);
|
auto content = doc_service.GetContent(params.textDocument.uri);
|
||||||
|
|
||||||
if (!tree || !content)
|
if (!tree || !content)
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Document not available");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Document not available");
|
||||||
|
|
||||||
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value());
|
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value());
|
||||||
auto encoded = EncodeTokens(tokens);
|
auto encoded = EncodeTokens(tokens);
|
||||||
|
|
@ -606,7 +606,7 @@ namespace lsp::provider::text_document
|
||||||
spdlog::debug("SemanticTokens Full: Generated {} tokens for document: {}", encoded.size() / 5, params.textDocument.uri);
|
spdlog::debug("SemanticTokens Full: Generated {} tokens for document: {}", encoded.size() / 5, params.textDocument.uri);
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -648,7 +648,7 @@ namespace lsp::provider::text_document
|
||||||
auto content = doc_service.GetContent(params.textDocument.uri);
|
auto content = doc_service.GetContent(params.textDocument.uri);
|
||||||
|
|
||||||
if (!tree || !content)
|
if (!tree || !content)
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Document not available");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Document not available");
|
||||||
|
|
||||||
// Get new tokens
|
// Get new tokens
|
||||||
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value());
|
auto tokens = CollectTokensInRange(ts_tree_root_node(tree), content.value());
|
||||||
|
|
@ -675,7 +675,7 @@ namespace lsp::provider::text_document
|
||||||
spdlog::debug("SemanticTokens Delta: Generated {} edits for document: {}", edits.size(), params.textDocument.uri);
|
spdlog::debug("SemanticTokens Delta: Generated {} edits for document: {}", edits.size(), params.textDocument.uri);
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Internal error");
|
||||||
return json.value();
|
return json.value();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace lsp::provider::workspace
|
||||||
if (!request.params.has_value())
|
if (!request.params.has_value())
|
||||||
{
|
{
|
||||||
spdlog::warn("{}: Missing params in request", GetProviderName());
|
spdlog::warn("{}: Missing params in request", GetProviderName());
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInvalidParams, "Missing params");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InvalidParams, "Missing params");
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol::WorkspaceSymbolParams params =
|
protocol::WorkspaceSymbolParams params =
|
||||||
|
|
@ -39,7 +39,7 @@ namespace lsp::provider::workspace
|
||||||
|
|
||||||
std::optional<std::string> json = transform::Serialize(response);
|
std::optional<std::string> json = transform::Serialize(response);
|
||||||
if (!json.has_value())
|
if (!json.has_value())
|
||||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
|
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||||
return json.value();
|
return json.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,24 +66,24 @@ namespace lsp::service
|
||||||
switch (kind)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case SymbolKind::kUnit:
|
case SymbolKind::kUnit:
|
||||||
return protocol::CompletionItemKind::kModule;
|
return protocol::CompletionItemKind::Module;
|
||||||
case SymbolKind::kClass:
|
case SymbolKind::kClass:
|
||||||
return protocol::CompletionItemKind::kClass;
|
return protocol::CompletionItemKind::Class;
|
||||||
case SymbolKind::kFunction:
|
case SymbolKind::kFunction:
|
||||||
case SymbolKind::kMethod:
|
case SymbolKind::kMethod:
|
||||||
return protocol::CompletionItemKind::kFunction;
|
return protocol::CompletionItemKind::Function;
|
||||||
case SymbolKind::kConstructor:
|
case SymbolKind::kConstructor:
|
||||||
return protocol::CompletionItemKind::kConstructor;
|
return protocol::CompletionItemKind::Constructor;
|
||||||
case SymbolKind::kProperty:
|
case SymbolKind::kProperty:
|
||||||
return protocol::CompletionItemKind::kProperty;
|
return protocol::CompletionItemKind::Property;
|
||||||
case SymbolKind::kVariable:
|
case SymbolKind::kVariable:
|
||||||
return protocol::CompletionItemKind::kVariable;
|
return protocol::CompletionItemKind::Variable;
|
||||||
case SymbolKind::kConstant:
|
case SymbolKind::kConstant:
|
||||||
return protocol::CompletionItemKind::kConstant;
|
return protocol::CompletionItemKind::Constant;
|
||||||
case SymbolKind::kParameter:
|
case SymbolKind::kParameter:
|
||||||
return protocol::CompletionItemKind::kVariable;
|
return protocol::CompletionItemKind::Variable;
|
||||||
default:
|
default:
|
||||||
return protocol::CompletionItemKind::kText;
|
return protocol::CompletionItemKind::Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,24 +92,24 @@ namespace lsp::service
|
||||||
switch (kind)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case SymbolKind::kUnit:
|
case SymbolKind::kUnit:
|
||||||
return protocol::SymbolKind::kModule;
|
return protocol::SymbolKind::Module;
|
||||||
case SymbolKind::kClass:
|
case SymbolKind::kClass:
|
||||||
return protocol::SymbolKind::kClass;
|
return protocol::SymbolKind::Class;
|
||||||
case SymbolKind::kFunction:
|
case SymbolKind::kFunction:
|
||||||
case SymbolKind::kMethod:
|
case SymbolKind::kMethod:
|
||||||
return protocol::SymbolKind::kFunction;
|
return protocol::SymbolKind::Function;
|
||||||
case SymbolKind::kConstructor:
|
case SymbolKind::kConstructor:
|
||||||
return protocol::SymbolKind::kConstructor;
|
return protocol::SymbolKind::Constructor;
|
||||||
case SymbolKind::kProperty:
|
case SymbolKind::kProperty:
|
||||||
return protocol::SymbolKind::kProperty;
|
return protocol::SymbolKind::Property;
|
||||||
case SymbolKind::kVariable:
|
case SymbolKind::kVariable:
|
||||||
return protocol::SymbolKind::kVariable;
|
return protocol::SymbolKind::Variable;
|
||||||
case SymbolKind::kConstant:
|
case SymbolKind::kConstant:
|
||||||
return protocol::SymbolKind::kConstant;
|
return protocol::SymbolKind::Constant;
|
||||||
case SymbolKind::kParameter:
|
case SymbolKind::kParameter:
|
||||||
return protocol::SymbolKind::kVariable;
|
return protocol::SymbolKind::Variable;
|
||||||
default:
|
default:
|
||||||
return protocol::SymbolKind::kVariable;
|
return protocol::SymbolKind::Variable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,9 +207,10 @@ namespace lsp::service
|
||||||
table.deserializer = std::make_unique<language::ast::Deserializer>();
|
table.deserializer = std::make_unique<language::ast::Deserializer>();
|
||||||
|
|
||||||
auto ast_result = table.deserializer->Parse(ts_tree_root_node(tree), content);
|
auto ast_result = table.deserializer->Parse(ts_tree_root_node(tree), content);
|
||||||
if (!ast_result.IsSuccess())
|
if (ast_result.HasErrors())
|
||||||
{
|
{
|
||||||
spdlog::error("Failed to deserialize AST: {}", ast_result.HasErrors());
|
for (const auto& it : ast_result.errors)
|
||||||
|
spdlog::warn("Parse Error = {}", it.message);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
table.ast_nodes = std::move(ast_result.nodes);
|
table.ast_nodes = std::move(ast_result.nodes);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue