Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LanguageServer.Framework/Protocol/JsonProtocolContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace EmmyLua.LanguageServer.Framework.Protocol;
[JsonSerializable(typeof(MethodMessage))]
[JsonSerializable(typeof(RequestMessage))]
[JsonSerializable(typeof(ResponseMessage))]
[JsonSerializable(typeof(ShutdownResponseMessage))]
[JsonSerializable(typeof(NotificationMessage))]
[JsonSerializable(typeof(ResponseError))]
[JsonSerializable(typeof(InitializeParams))]
Expand Down
13 changes: 13 additions & 0 deletions LanguageServer.Framework/Protocol/JsonRpc/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ public record ResponseMessage(
[JsonPropertyName("error")] public ResponseError? Error { get; } = Error;
}

public record ShutdownResponseMessage(
StringOrInt Id
) : Message("2.0")
{
[JsonPropertyName("id")] public StringOrInt Id { get; } = Id;

[JsonPropertyName("result")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public JsonDocument? Result { get; } = null;
// - When responding to a "shutdown" message, the result must always be null.
// - The JsonIgnoreCondition.Never attribute is explicitly set to serialize the JSON as null
}

public record NotificationMessage(
string Method,
JsonDocument? Params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public void WriteResponse(StringOrInt id, JsonDocument? document, ResponseError?
WriteMessage(response);
}

public void WriteShutdownResponse(StringOrInt id)
{
var response = new ShutdownResponseMessage(id);
WriteMessage(response);
}

public void WriteNotification(NotificationMessage message)
{
WriteMessage(message);
Expand Down
2 changes: 1 addition & 1 deletion LanguageServer.Framework/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected override bool BaseHandle(Message message)
}

ShutdownEventDelegate?.Invoke();
Writer.WriteResponse(requestMessage.Id, null);
Writer.WriteShutdownResponse(requestMessage.Id);
return true;
}
}
Expand Down
Loading