From b3762aff2b01451f758ae85b4634f7f105f7b875 Mon Sep 17 00:00:00 2001 From: "Alex Gavrilov (DEV PROD)" Date: Sun, 3 Nov 2024 13:40:53 -0800 Subject: [PATCH] Move completion resolve code to common layer --- .../Completion/AggregateCompletionItemResolver.cs | 2 +- .../Completion/CompletionItemResolver.cs | 2 +- .../Completion/RazorCompletionItemResolver.cs | 4 +--- ...pshotManagerExtensions.SolutionQueryOperations.cs | 4 +--- .../IProjectSnapshotManagerExtensions.cs | 4 +--- .../ProjectSystem/MiscFilesHostProject.cs | 4 +--- .../Tooltip/ProjectAvailabilityTests.cs | 12 ++++++------ 7 files changed, 12 insertions(+), 20 deletions(-) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/Completion/AggregateCompletionItemResolver.cs (97%) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/Completion/CompletionItemResolver.cs (90%) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/Completion/RazorCompletionItemResolver.cs (97%) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs (89%) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/ProjectSystem/IProjectSnapshotManagerExtensions.cs (96%) rename src/Razor/src/{Microsoft.AspNetCore.Razor.LanguageServer => Microsoft.CodeAnalysis.Razor.Workspaces}/ProjectSystem/MiscFilesHostProject.cs (93%) diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/AggregateCompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs similarity index 97% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/AggregateCompletionItemResolver.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs index 21075cfacc..a0a9c54a53 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/AggregateCompletionItemResolver.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/AggregateCompletionItemResolver.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.CodeAnalysis.Razor.Logging; using Microsoft.VisualStudio.LanguageServer.Protocol; -namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion; +namespace Microsoft.CodeAnalysis.Razor.Completion; internal class AggregateCompletionItemResolver { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/CompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs similarity index 90% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/CompletionItemResolver.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs index 010b53c71d..7d43af9758 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/CompletionItemResolver.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionItemResolver.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.LanguageServer.Protocol; -namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion; +namespace Microsoft.CodeAnalysis.Razor.Completion; internal abstract class CompletionItemResolver { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionItemResolver.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs similarity index 97% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionItemResolver.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs index 3e292cb856..c346277bf8 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/RazorCompletionItemResolver.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/RazorCompletionItemResolver.cs @@ -5,15 +5,13 @@ using System; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Razor.Completion; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.CodeAnalysis.Razor.Tooltip; using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text.Adornments; -namespace Microsoft.AspNetCore.Razor.LanguageServer.Completion; +namespace Microsoft.CodeAnalysis.Razor.Completion; internal class RazorCompletionItemResolver(IProjectSnapshotManager projectManager) : CompletionItemResolver { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs similarity index 89% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs index 1c1abe0619..c3e320ef4b 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.SolutionQueryOperations.cs @@ -4,10 +4,8 @@ using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.AspNetCore.Razor.PooledObjects; -using Microsoft.AspNetCore.Razor.Utilities; -using Microsoft.CodeAnalysis.Razor.ProjectSystem; -namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem; +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; internal static partial class IProjectSnapshotManagerExtensions { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.cs similarity index 96% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.cs index 67f55c3cfd..904b4db711 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/IProjectSnapshotManagerExtensions.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/IProjectSnapshotManagerExtensions.cs @@ -6,11 +6,9 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.AspNetCore.Razor.PooledObjects; using Microsoft.AspNetCore.Razor.Utilities; -using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Logging; -using Microsoft.CodeAnalysis.Razor.ProjectSystem; -namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem; +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; internal static partial class IProjectSnapshotManagerExtensions { diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/MiscFilesHostProject.cs similarity index 93% rename from src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs rename to src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/MiscFilesHostProject.cs index cb29d7e08c..cd81557a68 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/ProjectSystem/MiscFilesHostProject.cs +++ b/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/MiscFilesHostProject.cs @@ -5,11 +5,9 @@ using System; using System.IO; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Utilities; -using Microsoft.CodeAnalysis.Razor; -using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Microsoft.Extensions.Internal; -namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem; +namespace Microsoft.CodeAnalysis.Razor.ProjectSystem; internal sealed record class MiscFilesHostProject : HostProject { diff --git a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ProjectAvailabilityTests.cs b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ProjectAvailabilityTests.cs index d19a69bede..2d238011cb 100644 --- a/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ProjectAvailabilityTests.cs +++ b/src/Razor/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/Tooltip/ProjectAvailabilityTests.cs @@ -8,11 +8,11 @@ using Microsoft.AspNetCore.Razor.Language.Components; using Microsoft.AspNetCore.Razor.ProjectSystem; using Microsoft.AspNetCore.Razor.Test.Common; using Microsoft.CodeAnalysis.Razor.ProjectSystem; -using Microsoft.CodeAnalysis.Razor.Workspaces.Test; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; using static Microsoft.AspNetCore.Razor.Language.CommonMetadata; +using IProjectSnapshotManagerExtensions = Microsoft.CodeAnalysis.Razor.Workspaces.Test.IProjectSnapshotManagerExtensions; namespace Microsoft.CodeAnalysis.Razor.Tooltip; @@ -22,7 +22,7 @@ public class ProjectAvailabilityTests(ITestOutputHelper testOutput) : ToolingTes public async Task GetProjectAvailabilityText_NoProjects_ReturnsNull() { var projectManager = CreateProjectSnapshotManager(); - var solutionQueryOperations = projectManager.GetQueryOperations(); + var solutionQueryOperations = IProjectSnapshotManagerExtensions.GetQueryOperations(projectManager); var availability = await solutionQueryOperations.GetProjectAvailabilityTextAsync("file.razor", "MyTagHelper", DisposalToken); @@ -60,7 +60,7 @@ public class ProjectAvailabilityTests(ITestOutputHelper testOutput) : ToolingTes updater.DocumentAdded(hostProject.Key, hostDocument, TestMocks.CreateTextLoader(hostDocument.FilePath, text: "")); }); - var solutionQueryOperations = projectManager.GetQueryOperations(); + var solutionQueryOperations = IProjectSnapshotManagerExtensions.GetQueryOperations(projectManager); var availability = await solutionQueryOperations.GetProjectAvailabilityTextAsync(hostDocument.FilePath, tagHelperTypeName, DisposalToken); @@ -109,7 +109,7 @@ public class ProjectAvailabilityTests(ITestOutputHelper testOutput) : ToolingTes updater.DocumentAdded(hostProject2.Key, hostDocument, TestMocks.CreateTextLoader(hostDocument.FilePath, text: "")); }); - var solutionQueryOperations = projectManager.GetQueryOperations(); + var solutionQueryOperations = IProjectSnapshotManagerExtensions.GetQueryOperations(projectManager); var availability = await solutionQueryOperations.GetProjectAvailabilityTextAsync(hostDocument.FilePath, tagHelperTypeName, DisposalToken); @@ -157,7 +157,7 @@ public class ProjectAvailabilityTests(ITestOutputHelper testOutput) : ToolingTes updater.DocumentAdded(hostProject2.Key, hostDocument, TestMocks.CreateTextLoader(hostDocument.FilePath, text: "")); }); - var solutionQueryOperations = projectManager.GetQueryOperations(); + var solutionQueryOperations = IProjectSnapshotManagerExtensions.GetQueryOperations(projectManager); var availability = await solutionQueryOperations.GetProjectAvailabilityTextAsync(hostDocument.FilePath, tagHelperTypeName, DisposalToken); @@ -201,7 +201,7 @@ public class ProjectAvailabilityTests(ITestOutputHelper testOutput) : ToolingTes updater.DocumentAdded(hostProject2.Key, hostDocument, TestMocks.CreateTextLoader(hostDocument.FilePath, text: "")); }); - var solutionQueryOperations = projectManager.GetQueryOperations(); + var solutionQueryOperations = IProjectSnapshotManagerExtensions.GetQueryOperations(projectManager); var availability = await solutionQueryOperations.GetProjectAvailabilityTextAsync(hostDocument.FilePath, "MyTagHelper", DisposalToken);