From 909807814181fa6383711efa1ed10d7ed7dfe716 Mon Sep 17 00:00:00 2001 From: Mikayla Hutchinson Date: Sun, 9 Jun 2024 13:03:36 -0400 Subject: [PATCH] LSP Protocol: Update several interface types --- .../Protocol/IStaticRegistrationOptions.cs | 11 ++++++-- .../Protocol/Protocol/ITextDocumentParams.cs | 13 +++++---- .../Protocol/ITextDocumentPositionParams.cs | 28 +++++++------------ .../ITextDocumentRegistrationOptions.cs | 14 +++++++--- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs b/src/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs index 52fab2aad3cbd..8a6efa81edca5 100644 --- a/src/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs +++ b/src/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs @@ -2,17 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Text.Json.Serialization; + namespace Roslyn.LanguageServer.Protocol; /// /// Interface representing the static registration options for options returned in the initialize request. -/// -/// See the Language Server Protocol specification for additional information. +/// +/// See the Language Server Protocol specification for additional information. +/// /// internal interface IStaticRegistrationOptions { /// - /// Gets or sets the id used to register the request. The id can be used to deregister the request again. + /// Gets or sets the id used to register the request. The id can be used to deregister the request again. /// + [JsonPropertyName("id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Id { get; set; } } diff --git a/src/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs b/src/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs index 4fa13027b0903..072b1297de8b2 100644 --- a/src/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs +++ b/src/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs @@ -2,19 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Text.Json.Serialization; + namespace Roslyn.LanguageServer.Protocol { /// - /// Interface to identify a text document. + /// Interface for request/notification params that apply to a document /// internal interface ITextDocumentParams { /// - /// Gets or sets the value which identifies the document. + /// The identifier of the document. /// - public TextDocumentIdentifier TextDocument - { - get; - } + [JsonPropertyName("textDocument")] + [JsonRequired] + public TextDocumentIdentifier TextDocument { get; } } } diff --git a/src/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs b/src/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs index 22901df807aa9..5d4cb0509cd47 100644 --- a/src/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs +++ b/src/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs @@ -2,31 +2,23 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Text.Json.Serialization; + namespace Roslyn.LanguageServer.Protocol { /// - /// Interface to identify a text document and a position inside that document. - /// - /// See the Language Server Protocol specification for additional information. + /// Interface for request/notification params that apply to a a position inside a document + /// + /// See the Language Server Protocol specification for additional information. + /// /// internal interface ITextDocumentPositionParams : ITextDocumentParams { /// - /// Gets or sets the value which identifies the document. - /// - public new TextDocumentIdentifier TextDocument - { - get; - set; - } - - /// - /// Gets or sets the value which indicates the position within the document. + /// The position within the document. /// - public Position Position - { - get; - set; - } + [JsonPropertyName("position")] + [JsonRequired] + public Position Position { get; set; } } } diff --git a/src/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs b/src/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs index b919469dfb16f..d3a6424880b63 100644 --- a/src/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs +++ b/src/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs @@ -2,17 +2,23 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Text.Json.Serialization; + namespace Roslyn.LanguageServer.Protocol; /// -/// Interface representing the text document registration options. -/// -/// See the Language Server Protocol specification for additional information. +/// Interface for registration options that can be scoped to particular text documents. +/// +/// See the Language Server Protocol specification for additional information. +/// /// internal interface ITextDocumentRegistrationOptions { /// - /// Gets or sets the document filters for this registration option. + /// A document selector to identify the scope of the registration. If set to + /// the document selector provided on the client side will be used. /// + [JsonPropertyName("documentSelector")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public DocumentFilter[]? DocumentSelector { get; set; } }