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

Use Roslyn LSP library instead of Visual Studio #10682

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
95c37af
Rename VsLsp files to just Lsp
davidwengier Jul 30, 2024
a9ab067
Remote RoslynLsp files
davidwengier Jul 30, 2024
b0dcedb
Rename VsLsp* and RoslynLsp* to just Lsp*
davidwengier Jul 30, 2024
27c038c
Change all Range aliases to LspRange aliases
davidwengier Jul 30, 2024
4c649b2
Reference Roslyn protocol library, and deal with the extern alias bits
davidwengier Jul 30, 2024
eb3565c
Remove unused usings
davidwengier Jul 30, 2024
9792de5
More Range -> LspRange
davidwengier Jul 30, 2024
8d45e98
Introduce extern alias where necessary to reference Roslyn types
davidwengier Jul 30, 2024
bbb5adb
Move Lsp helpers into the right namespace
davidwengier Jul 30, 2024
e4537e0
Adjust namespaces and factory method names
davidwengier Jul 30, 2024
6067779
Adjust visibility on a couple of things
davidwengier Jul 30, 2024
be5f735
Fix issues with ContainedLanguage being dependent on VS types
davidwengier Jul 30, 2024
a21fd27
Roslyn types are immutable
davidwengier Jul 30, 2024
8725bba
Cohost signature help now only has to return a single type
davidwengier Jul 30, 2024
bd720ba
Project file tweaks
davidwengier Jul 30, 2024
7caf726
PR feedback
davidwengier Jul 31, 2024
ccd76da
Use extension method as extension method
davidwengier Jul 31, 2024
f505e9c
Move test code back to the test where it belongs
davidwengier Jul 31, 2024
1d5a102
Merge remote-tracking branch 'upstream/main' into LspTypes
davidwengier Jul 31, 2024
e572122
Fixes after merge
davidwengier Jul 31, 2024
4ca0fbe
Merge remote-tracking branch 'upstream/main' into LspTypes
davidwengier Aug 14, 2024
ef3b749
Merge remote-tracking branch 'upstream/main' into LspTypes
davidwengier Sep 17, 2024
dd43a04
Fixes after merge
davidwengier Sep 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
using LSP = Microsoft.VisualStudio.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer.MapCode.Mappers;

Expand All @@ -13,7 +12,7 @@ internal static class InsertMapper
public static int? GetInsertionPoint(
SyntaxNode documentRoot,
SourceText sourceText,
LSP.Location focusArea)
Location focusArea)
{
// If there's an specific focus area, or caret provided, we should try to insert as close as possible.
// As long as the focused area is not empty.
Expand All @@ -34,7 +33,7 @@ internal static class InsertMapper
private static bool TryGetFocusedInsertionPoint(
SyntaxNode documentRoot,
SourceText sourceText,
LSP.Location focusArea,
Location focusArea,
out int insertionPoint)
{
// If there's an specific focus area, or caret provided, we should try to insert as close as possible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Microsoft.CodeAnalysis.Razor.Protocol;

using Location = Roslyn.LanguageServer.Protocol.Location;
davidwengier marked this conversation as resolved.
Show resolved Hide resolved

internal record DelegatedSpellCheckParams(
[property: JsonPropertyName("identifier")] TextDocumentIdentifierAndVersion Identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

using System.Runtime.Serialization;
using Microsoft.CodeAnalysis.Text;
using static Roslyn.LanguageServer.Protocol.LspExtensions;
using RoslynDocumentHighlight = Roslyn.LanguageServer.Protocol.DocumentHighlight;
using VsDocumentHighlight = Microsoft.VisualStudio.LanguageServer.Protocol.DocumentHighlight;
using LspDocumentHighlight = Roslyn.LanguageServer.Protocol.DocumentHighlight;

namespace Microsoft.CodeAnalysis.Razor.Protocol.DocumentHighlight;

Expand All @@ -14,10 +12,10 @@ internal readonly record struct RemoteDocumentHighlight(
[property: DataMember(Order = 0)] LinePositionSpan Span,
[property: DataMember(Order = 1)] DocumentHighlightKind Kind)
{
public static RemoteDocumentHighlight FromRoslynDocumentHighlight(RoslynDocumentHighlight highlight)
=> new(highlight.Range.ToLinePositionSpan(), (DocumentHighlightKind)highlight.Kind);
public static RemoteDocumentHighlight FromLspDocumentHighlight(LspDocumentHighlight highlight)
=> new(highlight.Range.ToLinePositionSpan(), highlight.Kind);

public static VsDocumentHighlight ToVsDocumentHighlight(RemoteDocumentHighlight highlight)
public static LspDocumentHighlight ToLspDocumentHighlight(RemoteDocumentHighlight highlight)
=> new()
{
Range = LspExtensions.ToRange(highlight.Span),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Roslyn.LanguageServer.Protocol;
using LspSignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp;

namespace Microsoft.CodeAnalysis.Razor.Remote;

using SignatureHelp = Roslyn.LanguageServer.Protocol.SignatureHelp;

internal interface IRemoteSignatureHelpService : IRemoteJsonService
{
ValueTask<SignatureHelp?> GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position linePosition, CancellationToken cancellationToken);
ValueTask<LspSignatureHelp?> GetSignatureHelpAsync(JsonSerializableRazorPinnedSolutionInfoWrapper solutionInfo, JsonSerializableDocumentId documentId, Position linePosition, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Text;
using static Microsoft.VisualStudio.LanguageServer.Protocol.LspExtensions;
using static Roslyn.LanguageServer.Protocol.LspExtensions;
using Roslyn.LanguageServer.Protocol;
using Response = Microsoft.CodeAnalysis.Razor.Remote.RemoteResponse<Microsoft.CodeAnalysis.Razor.Protocol.DocumentHighlight.RemoteDocumentHighlight[]?>;

namespace Microsoft.CodeAnalysis.Remote.Razor;
Expand Down Expand Up @@ -80,8 +79,8 @@ private async ValueTask<Response> GetHighlightsAsync(
{
if (_documentMappingService.TryMapToHostDocumentRange(csharpDocument, highlight.Range.ToLinePositionSpan(), out var mappedRange))
{
highlight.Range = Roslyn.LanguageServer.Protocol.LspExtensions.ToRange(mappedRange);
results.Add(RemoteDocumentHighlight.FromRoslynDocumentHighlight(highlight));
highlight.Range = mappedRange.ToRange();
results.Add(RemoteDocumentHighlight.FromLspDocumentHighlight(highlight));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using ExternalHandlers = Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers;

namespace Microsoft.CodeAnalysis.Remote.Razor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal class CohostDocumentHighlightEndpoint(
// If we got a response back, then either Razor or C# wants to do something with this, so we're good to go
if (csharpResult.Result is { } highlights)
{
return highlights.Select(RemoteDocumentHighlight.ToVsDocumentHighlight).ToArray();
return highlights.Select(RemoteDocumentHighlight.ToLspDocumentHighlight).ToArray();
}

if (csharpResult.StopHandling)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Api;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.VisualStudio.Razor.Settings;
using FormattingOptions = Microsoft.CodeAnalysis.Formatting.FormattingOptions;

namespace Microsoft.VisualStudio.Razor.LanguageClient;

Expand Down
2 changes: 1 addition & 1 deletion src/Razor/src/rzls/LspLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Threading;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Threading;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ await _projectManager.UpdateAsync(updater =>
});

// Act
Assert.True(factory.TryCreate(uri, new VisualStudio.LanguageServer.Protocol.VSProjectContext { Id = hostProject.Key.Id }, out var documentContext));
Assert.True(factory.TryCreate(uri, new VSProjectContext { Id = hostProject.Key.Id }, out var documentContext));

// Assert
Assert.Equal(uri, documentContext.Uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class RazorSemanticTokensLegendServiceTest(ITestOutputHelper testOutput)
[Fact]
public void RazorModifiers_MustStartAfterRoslyn()
{
var clientCapabilitiesService = new TestClientCapabilitiesService(new VisualStudio.LanguageServer.Protocol.VSInternalClientCapabilities());
var clientCapabilitiesService = new TestClientCapabilitiesService(new VSInternalClientCapabilities());
var service = new RazorSemanticTokensLegendService(clientCapabilitiesService);

var expected = Math.Pow(2, RazorSemanticTokensAccessor.GetTokenModifiers().Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
using Diagnostic = Microsoft.CodeAnalysis.Diagnostic;

namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests;

Expand Down Expand Up @@ -280,7 +281,7 @@ protected static CompileToAssemblyResult CompileToAssembly(CompileToCSharpResult

var diagnostics = compilation
.GetDiagnostics()
.Where(d => d.Severity != DiagnosticSeverity.Hidden);
.Where(d => d.Severity != CodeAnalysis.DiagnosticSeverity.Hidden);

if (diagnostics.Any() && throwOnFailure)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Composition;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CommonLanguageServerProtocol.Framework;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Xunit.Abstractions;

namespace Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Razor.LanguageServer.Test;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;

namespace Microsoft.AspNetCore.Razor.LanguageServer.Semantic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.CodeAnalysis.Razor.LinkedEditingRange;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Xunit;
using Xunit.Abstractions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.CodeAnalysis.Razor.Settings;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.LanguageServices.Razor.LanguageClient.Cohost;
using Microsoft.VisualStudio.Razor.Settings;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Xunit;
using Xunit.Abstractions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.Debugging;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
using Xunit.Abstractions;
using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
using LspRange = Roslyn.LanguageServer.Protocol.Range;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Debugging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.AspNetCore.Razor.Threading;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.Debugging;
using Microsoft.VisualStudio.Text;
using Moq;
using Roslyn.LanguageServer.Protocol;
using Xunit;
using Xunit.Abstractions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Threading;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
using Roslyn.LanguageServer.Protocol;
using LspRange = Roslyn.LanguageServer.Protocol.Range;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Debugging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Text;
using Moq;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Razor.Workspaces.Protocol.SemanticTokens;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
using Microsoft.VisualStudio.Razor.Settings;
using Microsoft.VisualStudio.Razor.Snippets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
using Microsoft.CodeAnalysis.Razor.Protocol.DocumentMapping;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.LanguageClient.DocumentMapping;
using Moq;
using Xunit;
using Xunit.Abstractions;
using LspRange = Microsoft.VisualStudio.LanguageServer.Protocol.Range;
using LspRange = Roslyn.LanguageServer.Protocol.Range;

namespace Microsoft.VisualStudio.Razor.LanguageClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Text;

namespace Microsoft.VisualStudio.Razor.LanguageClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.LanguageClient.DocumentMapping;

namespace Microsoft.VisualStudio.Razor.LanguageClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Microsoft.AspNetCore.Razor.Test.Common;
using Microsoft.AspNetCore.Razor.Test.Common.Editor;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Roslyn.LanguageServer.Protocol;
using Microsoft.VisualStudio.Razor.Debugging;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.TextManager.Interop;
Expand Down