Skip to content

Commit

Permalink
Cohost inlay hint support (#10672)
Browse files Browse the repository at this point in the history
Part of #9519
Needs dotnet/roslyn#74548 before it will compile
Needs
https://devdiv.visualstudio.com/DevDiv/_git/VSLanguageServerClient/pullrequest/567229
before it will work in VS

There were a few side quests on this one:
* Roslyn OOP, at least the way we access it, doesn't have any options
set, so took a few tries to get the Roslyn side of this right for our
needs
* I wrote this feature test-first so only discovered the lack of options
after I modified Roslyn and our test infra to allow us to set global
options, so ended up removing most of that code, Kept the bit about
isolated workspaces because it just makes sense.
* Had to re-write one of the `DocumentMappingService` methods to use
`TextChange` instead of `TextEdit` so I could use Roslyn LSP types
* The hacky, and fortunately temporary, way we were doing generated C#
content was causing cache misses in Roslyn in tests, so fixed that up
* When I finally got up to manual testing I found a bug in the platform
that meant inlay hints just don't work with dynamic registration, so
filed the above linked PR to fix that

If reviewing commit-at-a-time please note that the first commit was
written before the reworking of extension methods and LSP types, and the
fixes for that are in the last commit.
  • Loading branch information
davidwengier authored Jul 31, 2024
2 parents 3f7545b + 788988b commit c78f5f2
Show file tree
Hide file tree
Showing 46 changed files with 835 additions and 235 deletions.
76 changes: 38 additions & 38 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,82 @@
<Sha>9ae78a4e6412926d19ba97cfed159bf9de70b538</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-1.24366.6">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-1.24379.11">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<Sha>cf82d399c36008e7936d545cde24141f8d3790fa</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
38 changes: 19 additions & 19 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@
<MicrosoftSourceBuildIntermediatearcadePackageVersion>9.0.0-beta.24352.2</MicrosoftSourceBuildIntermediatearcadePackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.12.0-1.24366.6</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.12.0-1.24366.6</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.12.0-1.24366.6</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.12.0-1.24366.6</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.12.0-1.24379.11</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.12.0-1.24379.11</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.12.0-1.24379.11</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.12.0-1.24379.11</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.12.0-1.24379.11</MicrosoftVisualStudioLanguageServicesPackageVersion>
<!--
Exception - Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages are not updated by automation,
but are present in Version.Details.xml for source-build PVP flow. See the comment in Version.Details.xml for more information.
Expand Down
1 change: 1 addition & 0 deletions eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<ServiceHubService Include="Microsoft.VisualStudio.Razor.FoldingRange" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteFoldingRangeService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.SignatureHelp" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteSignatureHelpService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.DocumentHighlight" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteDocumentHighlightService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.InlayHint" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteInlayHintService+Factory" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.AspNetCore.Razor.Threading;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer.InlayHints;

[RazorLanguageServerEndpoint(Methods.TextDocumentInlayHintName)]
internal sealed class InlayHintEndpoint(LanguageServerFeatureOptions featureOptions, IInlayHintService inlayHintService, IClientConnection clientConnection)
internal sealed class InlayHintEndpoint(IInlayHintService inlayHintService, IClientConnection clientConnection)
: IRazorRequestHandler<InlayHintParams, InlayHint[]?>, ICapabilitiesProvider
{
private readonly LanguageServerFeatureOptions _featureOptions = featureOptions;
private readonly IInlayHintService _inlayHintService = inlayHintService;
private readonly IClientConnection _clientConnection = clientConnection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ static void AddHandlers(IServiceCollection services, LanguageServerFeatureOption
services.AddHandlerWithCapabilities<SignatureHelpEndpoint>();
services.AddHandlerWithCapabilities<LinkedEditingRangeEndpoint>();
services.AddHandlerWithCapabilities<FoldingRangeEndpoint>();

services.AddSingleton<IInlayHintService, InlayHintService>();
services.AddHandlerWithCapabilities<InlayHintEndpoint>();
services.AddHandler<InlayHintResolveEndpoint>();
}

services.AddHandler<WrapWithTagEndpoint>();
Expand All @@ -204,11 +208,6 @@ static void AddHandlers(IServiceCollection services, LanguageServerFeatureOption
services.AddHandlerWithCapabilities<ProjectContextsEndpoint>();
services.AddHandlerWithCapabilities<DocumentSymbolEndpoint>();
services.AddHandlerWithCapabilities<MapCodeEndpoint>();

services.AddSingleton<IInlayHintService, InlayHintService>();

services.AddHandlerWithCapabilities<InlayHintEndpoint>();
services.AddHandler<InlayHintResolveEndpoint>();
}
}
}
Loading

0 comments on commit c78f5f2

Please sign in to comment.