-
Notifications
You must be signed in to change notification settings - Fork 5
· 补充遗漏的协议 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WCKYWCKF
wants to merge
8
commits into
CppCXY:main
Choose a base branch
from
WCKYWCKF:languageclient-help
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
· 补充遗漏的协议 #12
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6489e10
· 补充遗漏的协议
WCKYWCKF beba7ba
· 处理代码风格问题。
WCKYWCKF 5bcd035
· 修改补充协议内容的命名空间。如果需要将由仓库主理人将这些补充类移动到对应的文件夹并再次修改命名空间。
WCKYWCKF fe498be
· 为MarkedStringsOrMarkupContentJsonConverter添加序列化功能。
WCKYWCKF fff672c
· 使用一些奇技淫巧模拟Union让MarkedStringsOrMarkupContent的设计更加严谨。
WCKYWCKF ae5ddd2
· 补充JsonProtocolContext的JsonSerializable装饰。
WCKYWCKF 694b8d6
· 修复MarkedStringsOrMarkupContentJsonConverter反序列化时未使用传入的options。
WCKYWCKF e2eaa14
为LSPCommunicationBase类中的SendNotification、SendRequest和SendRequestNoWai…
WCKYWCKF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
LanguageServer.Framework/Protocol/Model/Kind/MonikerKind.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EmmyLua.LanguageServer.Framework.Protocol.Model.Kind; | ||
|
||
[JsonConverter(typeof(MonikerKindJsonConverter))] | ||
public readonly record struct MonikerKind | ||
{ | ||
public static readonly MonikerKind Import = new() { Kind = "import" }; | ||
WCKYWCKF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static readonly MonikerKind Export = new() { Kind = "export" }; | ||
public static readonly MonikerKind Local = new() { Kind = "local" }; | ||
public required string Kind { get; init; } | ||
} | ||
|
||
public class MonikerKindJsonConverter : JsonConverter<MonikerKind> | ||
{ | ||
public override MonikerKind Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var value = reader.GetString(); | ||
return new MonikerKind { Kind = value! }; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, MonikerKind value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Kind); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
LanguageServer.Framework/Protocol/Model/Kind/UniquenessLevel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace EmmyLua.LanguageServer.Framework.Protocol.Model.Kind; | ||
|
||
[JsonConverter(typeof(UniquenessLevelJsonConverter))] | ||
public readonly record struct UniquenessLevel | ||
{ | ||
public static readonly UniquenessLevel Document = new() { Level = "document" }; | ||
WCKYWCKF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static readonly UniquenessLevel Project = new() { Level = "project" }; | ||
public static readonly UniquenessLevel Group = new() { Level = "group" }; | ||
public static readonly UniquenessLevel Scheme = new() { Level = "scheme" }; | ||
public static readonly UniquenessLevel Global = new() { Level = "global" }; | ||
public required string Level { get; init; } | ||
} | ||
|
||
public class UniquenessLevelJsonConverter : JsonConverter<UniquenessLevel> | ||
{ | ||
public override UniquenessLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var value = reader.GetString(); | ||
return new UniquenessLevel { Level = value! }; | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, UniquenessLevel value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.Level); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
LanguageServer.Framework/Protocol/Model/Union/MarkedStringsOrMarkupContent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model.Markup; | ||
using WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
namespace EmmyLua.LanguageServer.Framework.Protocol.Union; | ||
|
||
[JsonConverter(typeof(MarkedStringsOrMarkupContentJsonConverter))] | ||
public record MarkedStringsOrMarkupContent | ||
{ | ||
public List<MarkedString>? MarkedStrings { get; init; } | ||
WCKYWCKF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public MarkupContent? MarkupContent { get; init; } | ||
} | ||
|
||
public class MarkedStringsOrMarkupContentJsonConverter : JsonConverter<MarkedStringsOrMarkupContent> | ||
{ | ||
public override MarkedStringsOrMarkupContent? Read(ref Utf8JsonReader reader, Type typeToConvert, | ||
JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType == JsonTokenType.StartObject) | ||
{ | ||
var jsonObj = JsonObject.Parse(ref reader); | ||
if (jsonObj?["language"] is not null) | ||
{ | ||
var obj = jsonObj.Deserialize<MarkedString>(options); | ||
return new() | ||
{ | ||
MarkedStrings = obj is not null ? [obj] : null | ||
}; | ||
} | ||
|
||
return new() | ||
{ | ||
MarkupContent = jsonObj.Deserialize<MarkupContent>(options) | ||
}; | ||
} | ||
|
||
if (reader.TokenType == JsonTokenType.StartArray) | ||
{ | ||
var jsonArray = JsonArray.Parse(ref reader); | ||
return new MarkedStringsOrMarkupContent() | ||
{ | ||
MarkedStrings = jsonArray.Deserialize<List<MarkedString>>(options) | ||
}; | ||
} | ||
|
||
if (reader.TokenType == JsonTokenType.String) | ||
{ | ||
return new() | ||
{ | ||
MarkedStrings = [new MarkedString() { Value = reader.GetString() ?? string.Empty }] | ||
}; | ||
} | ||
|
||
return new(); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, MarkedStringsOrMarkupContent value, JsonSerializerOptions options) | ||
{ | ||
throw new NotSupportedException("It only use Deserialize."); | ||
WCKYWCKF marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
LanguageServer.Framework/Protocol/Supplement/DidChangeConfigurationParams.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Serialization; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public record DidChangeConfigurationParams | ||
{ | ||
/// <summary> | ||
/// The actual changed settings | ||
/// </summary> | ||
/// | ||
[JsonPropertyName("settings")] | ||
public LSPAny? Settings { get; init; } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model.Markup; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Union; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public record Hover | ||
{ | ||
[JsonPropertyName("contents")] public required MarkedStringsOrMarkupContent Contents { get; init; } | ||
[JsonPropertyName("range")] public DocumentRange? Range { get; init; } | ||
} |
18 changes: 18 additions & 0 deletions
18
LanguageServer.Framework/Protocol/Supplement/LogMessageParams.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public record LogMessageParams | ||
{ | ||
/// <summary> | ||
/// The message type. See {@link MessageType} | ||
/// </summary> | ||
[JsonPropertyName("type")] | ||
public MessageType Type { get; init; } | ||
|
||
/// <summary> | ||
/// The actual message | ||
/// </summary> | ||
[JsonPropertyName("message")] | ||
public required string Message { get; init; } | ||
} |
9 changes: 9 additions & 0 deletions
9
LanguageServer.Framework/Protocol/Supplement/LogTraceParams.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public class LogTraceParams | ||
{ | ||
[JsonPropertyName("message")] public required string Message { get; init; } | ||
[JsonPropertyName("verbose")] public string? Verbose { get; init; } | ||
} |
72 changes: 72 additions & 0 deletions
72
LanguageServer.Framework/Protocol/Supplement/MarkedString.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
[JsonConverter(typeof(MarkedStringJsonConverter))] | ||
public class MarkedString | ||
{ | ||
[JsonPropertyName("language")] public string? Language { get; init; } | ||
|
||
[JsonPropertyName("value")] public required string Value { get; init; } | ||
} | ||
|
||
public class MarkedStringJsonConverter : JsonConverter<MarkedString> | ||
{ | ||
public override MarkedString? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
switch (reader.TokenType) | ||
{ | ||
case JsonTokenType.String: | ||
return new MarkedString { Value = reader.GetString() ?? string.Empty }; | ||
|
||
case JsonTokenType.StartObject: | ||
string? language = null; | ||
string? value = null; | ||
|
||
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) | ||
{ | ||
if (reader.TokenType == JsonTokenType.PropertyName) | ||
{ | ||
var propName = reader.GetString(); | ||
reader.Read(); // Move to value | ||
|
||
switch (propName) | ||
{ | ||
case "language": | ||
language = reader.GetString(); | ||
break; | ||
case "value": | ||
value = reader.GetString(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return new MarkedString | ||
{ | ||
Language = language, | ||
Value = value ?? string.Empty | ||
}; | ||
|
||
default: | ||
return new MarkedString { Value = string.Empty }; | ||
} | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, MarkedString value, JsonSerializerOptions options) | ||
{ | ||
if (string.IsNullOrWhiteSpace(value.Language)) | ||
{ | ||
writer.WriteStringValue(value.Value); | ||
} | ||
else | ||
{ | ||
writer.WriteStartObject(); | ||
writer.WriteString("language", value.Language); | ||
writer.WriteString("value", value.Value); | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
LanguageServer.Framework/Protocol/Supplement/MessageActionItem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public record MessageActionItem | ||
{ | ||
[JsonPropertyName("title")] public required string Title { get; init; } | ||
} |
24 changes: 24 additions & 0 deletions
24
LanguageServer.Framework/Protocol/Supplement/MessageType.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public enum MessageType | ||
{ | ||
/// <summary> | ||
/// An error message. | ||
/// </summary> | ||
Error = 1, | ||
|
||
/// <summary> | ||
/// A warning message. | ||
/// </summary> | ||
Warning = 2, | ||
|
||
/// <summary> | ||
/// An information message. | ||
/// </summary> | ||
Info = 3, | ||
|
||
/// <summary> | ||
/// A log message. | ||
/// </summary> | ||
Log = 4, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model.Kind; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public class Moniker | ||
{ | ||
/// <summary> | ||
/// The scheme of the moniker. For example tsc or .Net | ||
/// </summary> | ||
[JsonPropertyName("scheme")] | ||
public required string Scheme { get; init; } | ||
|
||
/// <summary> | ||
/// The identifier of the moniker. The value is opaque in LSIF however | ||
/// schema owners are allowed to define the structure if they want. | ||
/// </summary> | ||
[JsonPropertyName("identifier")] | ||
public required string Identifier { get; init; } | ||
|
||
/// <summary> | ||
/// The scope in which the moniker is unique | ||
/// </summary> | ||
[JsonPropertyName("unique")] | ||
public required UniquenessLevel Unique { get; init; } | ||
|
||
/// <summary> | ||
/// The moniker kind if known. | ||
/// </summary> | ||
[JsonPropertyName("kind")] | ||
public MonikerKind Kind { get; init; } | ||
} |
10 changes: 10 additions & 0 deletions
10
LanguageServer.Framework/Protocol/Supplement/MonikerParams.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using EmmyLua.LanguageServer.Framework.Protocol.Message.Interface; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model.TextDocument; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
public sealed class MonikerParams : TextDocumentPositionParams, IWorkDoneProgressParams, IPartialResultParams | ||
{ | ||
public string? WorkDoneToken { get; set; } | ||
public string? PartialResultToken { get; set; } | ||
} |
42 changes: 42 additions & 0 deletions
42
LanguageServer.Framework/Protocol/Supplement/ProgressToken.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using EmmyLua.LanguageServer.Framework.Protocol.Model.Union; | ||
|
||
namespace WCKYWCKF.EmmyLua.LanguageServer.Framework.ClientEx.Protocol; | ||
|
||
[JsonConverter(typeof(ProgressTokenJsonConverter))] | ||
public sealed class ProgressToken : StringOrInt | ||
{ | ||
public ProgressToken(string value) : base(value) | ||
{ | ||
} | ||
|
||
public ProgressToken(int value) : base(value) | ||
{ | ||
} | ||
} | ||
|
||
public class ProgressTokenJsonConverter : JsonConverter<ProgressToken> | ||
{ | ||
public override ProgressToken Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType == JsonTokenType.Number) | ||
{ | ||
return new ProgressToken(reader.GetInt32()); | ||
} | ||
|
||
return new ProgressToken(reader.GetString()!); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, ProgressToken value, JsonSerializerOptions options) | ||
{ | ||
if (value.StringValue != null) | ||
{ | ||
writer.WriteStringValue(value.StringValue); | ||
} | ||
else | ||
{ | ||
writer.WriteNumberValue(value.IntValue); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.