Skip to content
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

Initial cohost server implementation #9674

Merged
merged 26 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
13777bb
Create option to enable turning on and off the cohost server
davidwengier Dec 4, 2023
4c82b15
Create the basic services needed to light up the cohost server
davidwengier Dec 4, 2023
6bfa9bc
Add a wrapper to convert Roslyn client notifier to Razor
davidwengier Dec 7, 2023
e170ffe
Create a helper method to convert protocol document type to Cohost do…
davidwengier Dec 6, 2023
b4c1d84
Make sure MEF components can be found in the language server project
davidwengier Dec 6, 2023
110f341
Expose some of our services to the Cohost server
davidwengier Dec 6, 2023
d962d5c
Extract document color logic to a service for re-use
davidwengier Dec 8, 2023
d4bb930
Add a Cohost endpoint for document color requests
davidwengier Dec 8, 2023
7fe9de3
Implement didOpen and didChange for Cohost server
davidwengier Dec 10, 2023
8cddc8b
Use normalized paths as keys in project snapshots
davidwengier Dec 10, 2023
9797f66
Update packages and feeds etc.
davidwengier Nov 21, 2023
25bce1b
Add didClose handler
davidwengier Dec 12, 2023
037a324
Mark services as Shared
davidwengier Dec 12, 2023
21c1de9
Bump to "real" version of Roslyn
davidwengier Dec 13, 2023
a511a7e
Merge branch 'main' into RoslynCohost
davidwengier Dec 13, 2023
63b44f4
Merge branch 'main' into RoslynCohost
davidwengier Dec 18, 2023
f6383f8
Bump to a new Roslyn to fix a bug with code actions
davidwengier Dec 19, 2023
cdd45cb
Skip test
davidwengier Dec 19, 2023
1f2587b
Fix test
davidwengier Dec 19, 2023
6d54a59
Bump more roslyns
davidwengier Dec 19, 2023
7e8f4e5
Merge remote-tracking branch 'upstream/main' into features/cohost
davidwengier Dec 23, 2023
8d1e4f6
Updates after merge
davidwengier Dec 23, 2023
1754741
Respond to logging changes
davidwengier Dec 23, 2023
3700e72
Merge branch 'main' into RoslynCohost
davidwengier Dec 28, 2023
82356eb
Merge branch 'main' into RoslynCohost
davidwengier Jan 4, 2024
463f869
Fix merge
davidwengier Jan 4, 2024
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 Razor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{4CAC99E0-6ECE-4264-96C3-AF4EEE7BC9D1}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
NuGet.config = NuGet.config
SpellingExclusions.dic = SpellingExclusions.dic
eng\Versions.props = eng\Versions.props
EndProjectSection
Expand Down
72 changes: 36 additions & 36 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,78 @@
<Sha>2a008ae4f42c0db384db5a4864752b2ff52d720b</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.9.0-1.23530.5">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.9.0-3.23613.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>5a41731d6717929d437137c1d0373135b5af88a0</Sha>
<Sha>93677976e310e7f910f289e962566485cbabf8f3</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
36 changes: 18 additions & 18 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@
<MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>6.0.2-servicing.22064.6</MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>
<MicrosoftNETCorePlatformsPackageVersion>6.0.1</MicrosoftNETCorePlatformsPackageVersion>
<MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>9.0.0-alpha.1.23627.2</MicrosoftSourceBuildIntermediatesourcebuildreferencepackagesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.9.0-1.23530.5</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.9.0-1.23530.5</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.9.0-1.23530.5</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.9.0-1.23530.5</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.9.0-3.23613.4</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.9.0-3.23613.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.9.0-3.23613.4</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.9.0-3.23613.4</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<!--
Exception - Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages are not updated by automation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -11,7 +12,9 @@

namespace Microsoft.AspNetCore.Razor.LanguageServer.Common;

internal class DefaultRemoteTextLoaderFactory : RemoteTextLoaderFactory
[Export(typeof(RemoteTextLoaderFactory)), Shared]
[method: ImportingConstructor]
internal class DefaultRemoteTextLoaderFactory() : RemoteTextLoaderFactory
{
public override TextLoader Create(string filePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal class ConfigurableLanguageServerFeatureOptions : LanguageServerFeatureO
private readonly bool? _updateBuffersForClosedDocuments;
private readonly bool? _includeProjectKeyInGeneratedFilePath;
private readonly bool? _monitorWorkspaceFolderForConfigurationFiles;
private readonly bool? _useRazorCohostServer;

public override bool SupportsFileManipulation => _supportsFileManipulation ?? _defaults.SupportsFileManipulation;
public override string ProjectConfigurationFileName => _projectConfigurationFileName ?? _defaults.ProjectConfigurationFileName;
Expand All @@ -37,6 +38,7 @@ internal class ConfigurableLanguageServerFeatureOptions : LanguageServerFeatureO
public override bool UpdateBuffersForClosedDocuments => _updateBuffersForClosedDocuments ?? _defaults.UpdateBuffersForClosedDocuments;
public override bool IncludeProjectKeyInGeneratedFilePath => _includeProjectKeyInGeneratedFilePath ?? _defaults.IncludeProjectKeyInGeneratedFilePath;
public override bool MonitorWorkspaceFolderForConfigurationFiles => _monitorWorkspaceFolderForConfigurationFiles ?? _defaults.MonitorWorkspaceFolderForConfigurationFiles;
public override bool UseRazorCohostServer => _useRazorCohostServer ?? _defaults.UseRazorCohostServer;

public ConfigurableLanguageServerFeatureOptions(string[] args)
{
Expand All @@ -60,6 +62,7 @@ public ConfigurableLanguageServerFeatureOptions(string[] args)
TryProcessBoolOption(nameof(UpdateBuffersForClosedDocuments), ref _updateBuffersForClosedDocuments, option, args, i);
TryProcessBoolOption(nameof(IncludeProjectKeyInGeneratedFilePath), ref _includeProjectKeyInGeneratedFilePath, option, args, i);
TryProcessBoolOption(nameof(MonitorWorkspaceFolderForConfigurationFiles), ref _monitorWorkspaceFolderForConfigurationFiles, option, args, i);
TryProcessBoolOption(nameof(UseRazorCohostServer), ref _useRazorCohostServer, option, args, i);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public override bool ReturnCodeActionAndRenamePathsWithPrefixedSlash
public override bool UsePreciseSemanticTokenRanges => false;

public override bool MonitorWorkspaceFolderForConfigurationFiles => true;

public override bool UseRazorCohostServer => false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,26 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Common;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.VisualStudio.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer.DocumentColor;

[LanguageServerEndpoint(Methods.TextDocumentDocumentColorName)]
internal sealed class DocumentColorEndpoint : IRazorRequestHandler<DocumentColorParams, ColorInformation[]>, ICapabilitiesProvider
internal sealed class DocumentColorEndpoint(IDocumentColorService documentColorService, IClientConnection clientConnection) : IRazorRequestHandler<DocumentColorParams, ColorInformation[]>, ICapabilitiesProvider
{
private readonly IClientConnection _clientConnection;

public DocumentColorEndpoint(IClientConnection clientConnection)
{
_clientConnection = clientConnection ?? throw new ArgumentNullException(nameof(clientConnection));
}
private readonly IDocumentColorService _documentColorService = documentColorService ?? throw new ArgumentNullException(nameof(documentColorService));
private readonly IClientConnection _clientConnection = clientConnection ?? throw new ArgumentNullException(nameof(clientConnection));

public bool MutatesSolutionState => false;

public void ApplyCapabilities(VSInternalServerCapabilities serverCapabilities, VSInternalClientCapabilities clientCapabilities)
{
serverCapabilities.DocumentColorProvider = new DocumentColorOptions();
}
=> _documentColorService.ApplyCapabilities(serverCapabilities, clientCapabilities);

public TextDocumentIdentifier GetTextDocumentIdentifier(DocumentColorParams request)
=> request.TextDocument;

public async Task<ColorInformation[]> HandleRequestAsync(DocumentColorParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
{
// Workaround for Web Tools bug https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1743689 where they sometimes
// send requests for filenames that are stale, possibly due to adornment taggers being cached incorrectly (or caching
// filenames incorrectly)
if (requestContext.DocumentContext is null)
{
return Array.Empty<ColorInformation>();
}

var delegatedRequest = new DelegatedDocumentColorParams()
{
HostDocumentVersion = requestContext.GetRequiredDocumentContext().Version,
TextDocument = request.TextDocument
};

var documentColors = await _clientConnection.SendRequestAsync<DelegatedDocumentColorParams, ColorInformation[]>(
CustomMessageNames.RazorProvideHtmlDocumentColorEndpoint,
delegatedRequest,
cancellationToken).ConfigureAwait(false);

if (documentColors is null)
{
return Array.Empty<ColorInformation>();
}

// HTML and Razor documents have identical mapping locations. Because of this we can return the result as-is.
return documentColors;
}
public Task<ColorInformation[]> HandleRequestAsync(DocumentColorParams request, RazorRequestContext requestContext, CancellationToken cancellationToken)
=> _documentColorService.GetColorInformationAsync(_clientConnection, request, requestContext.DocumentContext, cancellationToken);
}
Loading