-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding client capabilities to OOP client initialization data (#11129)
* Add RemoteClientCapabilities service The service gets initialized once during initial connection / init and provides client capabilities to other remote services. * Add RemoteClientCapabilitiesService - Adding client capabilities to RemoteClientLSPInitializationOptions - Converting IRemoteClientIntializationService to be a JSON service for simplicity of data serialization - Converting client initialization code to use JSON client to call IRemoteClientIntializationService * Fixing tests * Removing unneeded class * Fixing tests * Export IClientCapabilitiesService and consume it when appropriate Only consumers that are initializing capabiilities service by calling SetCapabilities should be importing it via RemoteClientCapabilitiesService. All other consumers should be using IClientCapabilitiesService. * Simplifying code, moving and correcting comment * Test fixup per PR feedback * Service rename per PR feedback * More PR feedback - Renaming a variable - Made UpdateClientLSPInitializationOptions mode complete (so it updates RemoteSemanticTokensLegendService now with initialization data) - Removed limitation of single update on RemoteSemanticTokensLegendService - Use UpdateClientLSPInitializationOptions in cohost semantic tokens test * Removed unused service
- Loading branch information
Showing
14 changed files
with
111 additions
and
70 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...src/Microsoft.CodeAnalysis.Razor.Workspaces/Protocol/AbstractClientCapabilitiesService.cs
This file contains 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,21 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
|
||
namespace Microsoft.CodeAnalysis.Razor.Protocol; | ||
|
||
internal abstract class AbstractClientCapabilitiesService : IClientCapabilitiesService | ||
{ | ||
private VSInternalClientCapabilities? _clientCapabilities; | ||
|
||
public bool CanGetClientCapabilities => _clientCapabilities is not null; | ||
|
||
public VSInternalClientCapabilities ClientCapabilities => _clientCapabilities ?? throw new InvalidOperationException("Client capabilities requested before initialized."); | ||
|
||
public void SetCapabilities(VSInternalClientCapabilities clientCapabilities) | ||
{ | ||
_clientCapabilities = clientCapabilities; | ||
} | ||
} |
This file contains 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
This file contains 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
31 changes: 15 additions & 16 deletions
31
...r/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientInitializationOptions.cs
This file contains 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 |
---|---|---|
@@ -1,31 +1,30 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.CodeAnalysis.Razor.Remote; | ||
|
||
[DataContract] | ||
internal struct RemoteClientInitializationOptions | ||
{ | ||
[DataMember(Order = 0)] | ||
internal required bool UseRazorCohostServer; | ||
[JsonPropertyName("useRazorCohostServer")] | ||
public required bool UseRazorCohostServer { get; set; } | ||
|
||
[DataMember(Order = 1)] | ||
internal required bool UsePreciseSemanticTokenRanges; | ||
[JsonPropertyName("usePreciseSemanticTokenRanges")] | ||
public required bool UsePreciseSemanticTokenRanges { get; set; } | ||
|
||
[DataMember(Order = 2)] | ||
internal required string CSharpVirtualDocumentSuffix; | ||
[JsonPropertyName("csharpVirtualDocumentSuffix")] | ||
public required string CSharpVirtualDocumentSuffix { get; set; } | ||
|
||
[DataMember(Order = 3)] | ||
internal required string HtmlVirtualDocumentSuffix; | ||
[JsonPropertyName("htmlVirtualDocumentSuffix")] | ||
public required string HtmlVirtualDocumentSuffix { get; set; } | ||
|
||
[DataMember(Order = 4)] | ||
internal required bool IncludeProjectKeyInGeneratedFilePath; | ||
[JsonPropertyName("includeProjectKeyInGeneratedFilePath")] | ||
public required bool IncludeProjectKeyInGeneratedFilePath { get; set; } | ||
|
||
[DataMember(Order = 5)] | ||
internal required bool ReturnCodeActionAndRenamePathsWithPrefixedSlash; | ||
[JsonPropertyName("returnCodeActionAndRenamePathsWithPrefixedSlash")] | ||
public required bool ReturnCodeActionAndRenamePathsWithPrefixedSlash { get; set; } | ||
|
||
[DataMember(Order = 6)] | ||
internal required bool ForceRuntimeCodeGeneration; | ||
[JsonPropertyName("forceRuntimeCodeGeneration")] | ||
public required bool ForceRuntimeCodeGeneration { get; set; } | ||
} |
15 changes: 9 additions & 6 deletions
15
...rc/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteClientLSPInitializationOptions.cs
This file contains 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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.Serialization; | ||
using System.Text.Json.Serialization; | ||
using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
|
||
namespace Microsoft.CodeAnalysis.Razor.Remote; | ||
|
||
[DataContract] | ||
internal struct RemoteClientLSPInitializationOptions | ||
{ | ||
[DataMember(Order = 0)] | ||
internal required string[] TokenTypes; | ||
[JsonPropertyName("tokenTypes")] | ||
public required string[] TokenTypes { get; set; } | ||
|
||
[DataMember(Order = 1)] | ||
internal required string[] TokenModifiers; | ||
[JsonPropertyName("tokenModifiers")] | ||
public required string[] TokenModifiers { get; set; } | ||
|
||
[JsonPropertyName("clientCapabilities")] | ||
public required VSInternalClientCapabilities ClientCapabilities { get; set; } | ||
} |
This file contains 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
12 changes: 12 additions & 0 deletions
12
...src/Microsoft.CodeAnalysis.Remote.Razor/Initialization/RemoteClientCapabilitiesService.cs
This file contains 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,12 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Composition; | ||
using Microsoft.CodeAnalysis.Razor.Protocol; | ||
|
||
namespace Microsoft.CodeAnalysis.Remote.Razor; | ||
|
||
[Shared] | ||
[Export(typeof(IClientCapabilitiesService))] | ||
[Export(typeof(RemoteClientCapabilitiesService))] | ||
internal sealed class RemoteClientCapabilitiesService : AbstractClientCapabilitiesService; |
This file contains 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
This file contains 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
16 changes: 1 addition & 15 deletions
16
...udio.LanguageServices.Razor/LanguageClient/Cohost/RazorCohostClientCapabilitiesService.cs
This file contains 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 |
---|---|---|
@@ -1,25 +1,11 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.ComponentModel.Composition; | ||
using Microsoft.CodeAnalysis.Razor.Protocol; | ||
using Microsoft.VisualStudio.LanguageServer.Protocol; | ||
|
||
namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost; | ||
|
||
[Export(typeof(RazorCohostClientCapabilitiesService))] | ||
[Export(typeof(IClientCapabilitiesService))] | ||
internal class RazorCohostClientCapabilitiesService : IClientCapabilitiesService | ||
{ | ||
private VSInternalClientCapabilities? _clientCapabilities; | ||
|
||
public bool CanGetClientCapabilities => _clientCapabilities is not null; | ||
|
||
public VSInternalClientCapabilities ClientCapabilities => _clientCapabilities ?? throw new InvalidOperationException("Client capabilities requested before initialized."); | ||
|
||
public void SetCapabilities(VSInternalClientCapabilities clientCapabilities) | ||
{ | ||
_clientCapabilities = clientCapabilities; | ||
} | ||
} | ||
internal sealed class RazorCohostClientCapabilitiesService : AbstractClientCapabilitiesService; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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