From 501f7ee3fb801b90bb20bf3f3314d84664289716 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Wed, 10 Jun 2020 12:26:13 -0700 Subject: [PATCH] address more feedback --- .../LanguageServer/AbstractLanguageServerProtocolTests.cs | 2 -- .../LanguageServer/Protocol/Extensions/Extensions.cs | 4 ++-- ...itionHandlerBase.cs => AbstractGoToDefinitionHandler.cs} | 4 ++-- .../Protocol/Handler/Definitions/GoToDefinitionHandler.cs | 2 +- .../Handler/Definitions/GoToTypeDefinitionHandler.cs | 2 +- .../ProjectContext/GetTextDocumentWithContextHandler.cs | 2 +- .../ProjectSystem/MiscellaneousFilesWorkspace.cs | 6 +++++- 7 files changed, 12 insertions(+), 10 deletions(-) rename src/Features/LanguageServer/Protocol/Handler/Definitions/{AbstractGoToDefinitionHandlerBase.cs => AbstractGoToDefinitionHandler.cs} (94%) diff --git a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs index 6d7eaf52603..c009625468b 100644 --- a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs +++ b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs @@ -72,8 +72,6 @@ protected virtual ExportProvider GetExportProvider() typeof(IRequestHandler).Assembly, typeof(IRequestHandler)); var executeCommandHandlerTypes = DesktopTestHelpers.GetAllTypesImplementingGivenInterface( typeof(IExecuteWorkspaceCommandHandler).Assembly, typeof(IExecuteWorkspaceCommandHandler)); - var solutionProviderTypes = DesktopTestHelpers.GetAllTypesImplementingGivenInterface( - typeof(TestLspSolutionProvider).Assembly, typeof(ILspSolutionProvider)); var exportProviderFactory = ExportProviderCache.GetOrCreateExportProviderFactory( TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic .WithPart(typeof(LanguageServerProtocol)) diff --git a/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs b/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs index aebc78b35b0..ceebed1cf78 100644 --- a/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs +++ b/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs @@ -40,7 +40,7 @@ public static ImmutableArray GetDocuments(this Solution solution, Uri return documentIds.SelectAsArray(id => solution.GetRequiredDocument(id)); } - public static ImmutableArray GetDocumentsFromProvider(this ILspSolutionProvider solutionProvider, Uri uri, string? clientName = null) + public static ImmutableArray GetDocuments(this ILspSolutionProvider solutionProvider, Uri uri, string? clientName) { var documents = solutionProvider.GetDocuments(uri); @@ -65,7 +65,7 @@ public static ImmutableArray GetDocumentsFromProvider(this ILspSolutio public static Document? GetDocument(this ILspSolutionProvider solutionProvider, TextDocumentIdentifier documentIdentifier, string? clientName = null) { - var documents = solutionProvider.GetDocumentsFromProvider(documentIdentifier.Uri, clientName); + var documents = solutionProvider.GetDocuments(documentIdentifier.Uri, clientName); if (documents.Length == 0) { diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs similarity index 94% rename from src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs rename to src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs index 3e73353da9f..e114016ba8d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandlerBase.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs @@ -17,11 +17,11 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler { - internal abstract class AbstractGoToDefinitionHandlerBase : AbstractRequestHandler + internal abstract class AbstractGoToDefinitionHandler : AbstractRequestHandler { private readonly IMetadataAsSourceFileService _metadataAsSourceFileService; - public AbstractGoToDefinitionHandlerBase(IMetadataAsSourceFileService metadataAsSourceFileService, ILspSolutionProvider solutionProvider) : base(solutionProvider) + public AbstractGoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService, ILspSolutionProvider solutionProvider) : base(solutionProvider) => _metadataAsSourceFileService = metadataAsSourceFileService; protected async Task GetDefinitionAsync(LSP.TextDocumentPositionParams request, bool typeOnly, string? clientName, CancellationToken cancellationToken) diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs index ebf59a95476..abf730c37a6 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler { [Shared] [ExportLspMethod(LSP.Methods.TextDocumentDefinitionName)] - internal class GoToDefinitionHandler : AbstractGoToDefinitionHandlerBase + internal class GoToDefinitionHandler : AbstractGoToDefinitionHandler { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs index 2d6775a9e94..f653a0b1105 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler { [Shared] [ExportLspMethod(LSP.Methods.TextDocumentTypeDefinitionName)] - internal class GoToTypeDefinitionHandler : AbstractGoToDefinitionHandlerBase + internal class GoToTypeDefinitionHandler : AbstractGoToDefinitionHandler { [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] diff --git a/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs b/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs index b272bfa407d..122fdd0809b 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs @@ -32,7 +32,7 @@ public GetTextDocumentWithContextHandler(ILspSolutionProvider solutionProvider) string? clientName, CancellationToken cancellationToken) { - var documents = SolutionProvider.GetDocumentsFromProvider(request.TextDocument.Uri, clientName); + var documents = SolutionProvider.GetDocuments(request.TextDocument.Uri, clientName); if (!documents.Any()) { diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs index 5170677d68e..2f88c7aa62c 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MiscellaneousFilesWorkspace.cs @@ -63,7 +63,11 @@ internal sealed partial class MiscellaneousFilesWorkspace : Workspace, IRunningD _foregroundThreadAffinitization = new ForegroundThreadAffinitizedObject(threadingContext, assertIsForeground: false); _fileTrackingMetadataAsSourceService = fileTrackingMetadataAsSourceService; - _lazyTextManager = new Lazy(() => (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager))); + _lazyTextManager = new Lazy(() => + { + _foregroundThreadAffinitization.AssertIsForeground(); + return (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); + }); var runningDocumentTable = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); _runningDocumentTableEventTracker = new RunningDocumentTableEventTracker(threadingContext, editorAdaptersFactoryService, runningDocumentTable, this); -- GitLab