From a3ad10add75ef43fd657857d4709b1a63530114d Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Thu, 18 Apr 2024 00:51:58 -0700 Subject: [PATCH] Remove no longer used api --- ...faultUnitTestingDocumentTrackingService.cs | 31 -------- .../IUnitTestingDocumentTrackingService.cs | 30 -------- ...estingDocumentTrackingServiceExtensions.cs | 36 --------- ...or.AbstractUnitTestingPriorityProcessor.cs | 26 ------- ...UnitTestingIncrementalAnalyzerProcessor.cs | 3 - ...dinator.UnitTestingLowPriorityProcessor.cs | 7 +- ...ator.UnitTestingNormalPriorityProcessor.cs | 77 ------------------- 7 files changed, 1 insertion(+), 209 deletions(-) delete mode 100644 src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/DefaultUnitTestingDocumentTrackingService.cs delete mode 100644 src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingService.cs delete mode 100644 src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingServiceExtensions.cs diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/DefaultUnitTestingDocumentTrackingService.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/DefaultUnitTestingDocumentTrackingService.cs deleted file mode 100644 index 97e279c6cb2a2..0000000000000 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/DefaultUnitTestingDocumentTrackingService.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Immutable; -using System.Composition; -using Microsoft.CodeAnalysis.Host.Mef; - -namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler; - -[ExportWorkspaceService(typeof(IUnitTestingDocumentTrackingService), ServiceLayer.Default)] -[Shared] -internal sealed class DefaultUnitTestingDocumentTrackingService : IUnitTestingDocumentTrackingService -{ - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public DefaultUnitTestingDocumentTrackingService() - { - } - - public bool SupportsDocumentTracking => false; - - public event EventHandler NonRoslynBufferTextChanged { add { } remove { } } - - public ImmutableArray GetVisibleDocuments() - => []; - - public DocumentId? TryGetActiveDocument() - => null; -} diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingService.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingService.cs deleted file mode 100644 index bdd1f6262ce7d..0000000000000 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingService.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.Host; - -namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler; - -internal interface IUnitTestingDocumentTrackingService : IWorkspaceService -{ - bool SupportsDocumentTracking { get; } - - /// - /// Get the of the active document. May be null if there is no active document - /// or the active document is not in the workspace. - /// - DocumentId? TryGetActiveDocument(); - - /// - /// Get a read only collection of the s of all the visible documents in the workspace. - /// - ImmutableArray GetVisibleDocuments(); - - /// - /// Raised when a text buffer that's not part of a workspace is changed. - /// - event EventHandler NonRoslynBufferTextChanged; -} diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingServiceExtensions.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingServiceExtensions.cs deleted file mode 100644 index 8d5735b865092..0000000000000 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/IUnitTestingDocumentTrackingServiceExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Immutable; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Roslyn.Utilities; - -namespace Microsoft.CodeAnalysis.ExternalAccess.UnitTesting.SolutionCrawler; - -internal static class IUnitTestingDocumentTrackingServiceExtensions -{ - /// - /// Gets the active the user is currently working in. May be null if - /// there is no active document or the active document is not in this . - /// - public static Document? GetActiveDocument(this IUnitTestingDocumentTrackingService service, Solution solution) - { - // Note: GetDocument checks that the DocId is contained in the solution, and returns null if not. - return solution.GetDocument(service.TryGetActiveDocument()); - } - - /// - /// Get a read only collection of all the unique visible documents in the workspace that are - /// contained within . - /// - public static ImmutableArray GetVisibleDocuments(this IUnitTestingDocumentTrackingService service, Solution solution) - => service.GetVisibleDocuments() - .Select(solution.GetDocument) - .WhereNotNull() - .Distinct() - .ToImmutableArray(); -} diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.AbstractUnitTestingPriorityProcessor.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.AbstractUnitTestingPriorityProcessor.cs index ddaa204b9282b..826660ba0a116 100644 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.AbstractUnitTestingPriorityProcessor.cs +++ b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.AbstractUnitTestingPriorityProcessor.cs @@ -37,7 +37,6 @@ public AbstractUnitTestingPriorityProcessor( _lazyAnalyzers = lazyAnalyzers; Processor = processor; - Processor._documentTracker.NonRoslynBufferTextChanged += OnNonRoslynBufferTextChanged; } public ImmutableArray Analyzers @@ -117,31 +116,6 @@ protected async Task WaitForHigherPriorityOperationsAsync() } } } - - public override void Shutdown() - { - base.Shutdown(); - - Processor._documentTracker.NonRoslynBufferTextChanged -= OnNonRoslynBufferTextChanged; - } - - private void OnNonRoslynBufferTextChanged(object? sender, EventArgs e) - { - // There are 2 things incremental processor takes care of - // - // #1 is making sure we delay processing any work until there is enough idle (ex, typing) in host. - // #2 is managing cancellation and pending works. - // - // we used to do #1 and #2 only for Roslyn files. and that is usually fine since most of time solution contains only roslyn files. - // - // but for mixed solution (ex, Roslyn files + HTML + JS + CSS), #2 still makes sense but #1 doesn't. We want - // to pause any work while something is going on in other project types as well. - // - // we need to make sure we play nice with neighbors as well. - // - // now, we don't care where changes are coming from. if there is any change in host, we pause ourselves for a while. - UpdateLastAccessTime(); - } } } } diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingIncrementalAnalyzerProcessor.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingIncrementalAnalyzerProcessor.cs index 9f3ef2fd09d1c..7b883e0bed9fd 100644 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingIncrementalAnalyzerProcessor.cs +++ b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingIncrementalAnalyzerProcessor.cs @@ -30,7 +30,6 @@ private partial class UnitTestingIncrementalAnalyzerProcessor private readonly UnitTestingRegistration _registration; private readonly IAsynchronousOperationListener _listener; - private readonly IUnitTestingDocumentTrackingService _documentTracker; private readonly UnitTestingNormalPriorityProcessor _normalPriorityProcessor; private readonly UnitTestingLowPriorityProcessor _lowPriorityProcessor; @@ -58,8 +57,6 @@ public UnitTestingIncrementalAnalyzerProcessor( var lazyAllAnalyzers = new Lazy>(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: false)); // event and worker queues - _documentTracker = _registration.Services.GetRequiredService(); - var globalNotificationService = _registration.Services.ExportProvider.GetExports().FirstOrDefault()?.Value; _normalPriorityProcessor = new UnitTestingNormalPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, normalBackOffTimeSpan, shutdownToken); diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingLowPriorityProcessor.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingLowPriorityProcessor.cs index e7a622ffc754b..a9bf69e2f06c9 100644 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingLowPriorityProcessor.cs +++ b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingLowPriorityProcessor.cs @@ -51,13 +51,8 @@ protected override async Task ExecuteAsync() // we wait for global operation, higher and normal priority processor to finish its working await WaitForHigherPriorityOperationsAsync().ConfigureAwait(false); - // process any available project work, preferring the active project. - var preferableProjectId = Processor._documentTracker.SupportsDocumentTracking - ? Processor._documentTracker.TryGetActiveDocument()?.ProjectId - : null; - if (_workItemQueue.TryTakeAnyWork( - preferableProjectId, + preferableProjectId: null, out var workItem, out var projectCancellation)) { await ProcessProjectAsync(Analyzers, workItem, projectCancellation).ConfigureAwait(false); diff --git a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingNormalPriorityProcessor.cs b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingNormalPriorityProcessor.cs index 9c6186807918a..9c8fb46ddf534 100644 --- a/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingNormalPriorityProcessor.cs +++ b/src/Features/Core/Portable/ExternalAccess/UnitTesting/SolutionCrawler/UnitTestingWorkCoordinator.UnitTestingNormalPriorityProcessor.cs @@ -120,12 +120,6 @@ protected override async Task ExecuteAsync() // okay, there must be at least one item in the map ResetStates(); - if (await TryProcessOneHigherPriorityDocumentAsync().ConfigureAwait(false)) - { - // successfully processed a high priority document. - return; - } - // process one of documents remaining if (!_workItemQueue.TryTakeAnyWork( _currentProjectProcessing, @@ -175,77 +169,6 @@ private void SetProjectProcessing(ProjectId currentProject) _currentProjectProcessing = currentProject; } - private IEnumerable GetPrioritizedPendingDocuments() - { - // First the active document - var activeDocumentId = Processor._documentTracker.TryGetActiveDocument(); - if (activeDocumentId != null) - { - yield return activeDocumentId; - } - - // Now any visible documents - foreach (var visibleDocumentId in Processor._documentTracker.GetVisibleDocuments()) - { - yield return visibleDocumentId; - } - - // Any other high priority documents - foreach (var (documentId, _) in _higherPriorityDocumentsNotProcessed) - { - yield return documentId; - } - } - - private async Task TryProcessOneHigherPriorityDocumentAsync() - { - try - { - if (!Processor._documentTracker.SupportsDocumentTracking) - { - return false; - } - - foreach (var documentId in GetPrioritizedPendingDocuments()) - { - if (CancellationToken.IsCancellationRequested) - { - return true; - } - - // this is a best effort algorithm with some shortcomings. - // - // the most obvious issue is if there is a new work item (without a solution change - but very unlikely) - // for a opened document we already processed, the work item will be treated as a regular one rather than higher priority one - // (opened document) - // see whether we have work item for the document - if (!_workItemQueue.TryTake(documentId, out var workItem, out var documentCancellation)) - { - RemoveHigherPriorityDocument(documentId); - continue; - } - - // okay now we have work to do - await ProcessDocumentAsync(Analyzers, workItem, documentCancellation).ConfigureAwait(false); - - RemoveHigherPriorityDocument(documentId); - return true; - } - - return false; - } - catch (Exception e) when (FatalError.ReportAndPropagateUnlessCanceled(e)) - { - throw ExceptionUtilities.Unreachable(); - } - } - - private void RemoveHigherPriorityDocument(DocumentId documentId) - { - // remove opened document processed - _higherPriorityDocumentsNotProcessed.TryRemove(documentId, out _); - } - private async Task ProcessDocumentAsync(ImmutableArray analyzers, UnitTestingWorkItem workItem, CancellationToken cancellationToken) { Contract.ThrowIfNull(workItem.DocumentId);