Skip to content

Commit

Permalink
Merge pull request #74068 from dibarbet/add_lsp_types
Browse files Browse the repository at this point in the history
Add some missing LSP protocol definitions
  • Loading branch information
dibarbet authored Jun 20, 2024
2 parents 8bdf5c4 + 30a1dda commit adce315
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for code action support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#codeActionRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class CodeActionRegistrationOptions : CodeActionOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for completion support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#completionRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class CompletionRegistrationOptions : CompletionOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for go to definition support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#definitionRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class DefinitionRegistrationOptions : DefinitionOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for document formatting support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#documentFormattingRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class DocumentFormattingRegistrationOptions : DocumentFormattingOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for document on type formatting support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#documentOnTypeFormattingRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class DocumentOnTypeFormattingRegistrationOptions : DocumentOnTypeFormattingOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for document range formatting support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#documentRangeFormattingRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class DocumentRangeFormattingRegistrationOptions : DocumentRangeFormattingOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for folding range support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#foldingRangeRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class FoldingRangeRegistrationOptions : FoldingRangeOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
25 changes: 25 additions & 0 deletions src/LanguageServer/Protocol/Protocol/HoverRegistrationOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for hover support.
///
/// See the <see href="https://microsoft.github.io/language-server-protocol/specifications/specification-current/#hoverRegistrationOptions">Language Server Protocol specification</see> for additional information.
/// </summary>
internal class HoverRegistrationOptions : HoverOptions, ITextDocumentRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;

/// <summary>
/// Class representing the registration options for on auto insert support.
/// </summary>
internal class VSInternalDocumentOnAutoInsertRegistrationOptions : VSInternalDocumentOnAutoInsertOptions, ITextDocumentRegistrationOptions, IStaticRegistrationOptions
{
/// <summary>
/// Gets or sets the document filters for this registration option.
/// </summary>
[JsonPropertyName("documentSelector")]
public DocumentFilter[]? DocumentSelector
{
get;
set;
}

/// <summary>
/// Gets or sets the id used to register the request. The id can be used to deregister the request again.
/// </summary>
[JsonPropertyName("id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Id
{
get;
set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ public TextEdit TextEdit
get;
set;
}

/// <summary>
/// Gets or sets any optional command that will be executed after insertion.
/// </summary>
[JsonPropertyName("command")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Command? Command { get; set; }
}
}

0 comments on commit adce315

Please sign in to comment.