Skip to content

Commit

Permalink
Remove no longer used api
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Apr 18, 2024
1 parent 8f2659a commit a3ad10a
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 209 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public AbstractUnitTestingPriorityProcessor(
_lazyAnalyzers = lazyAnalyzers;

Processor = processor;
Processor._documentTracker.NonRoslynBufferTextChanged += OnNonRoslynBufferTextChanged;
}

public ImmutableArray<IUnitTestingIncrementalAnalyzer> Analyzers
Expand Down Expand Up @@ -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();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,8 +57,6 @@ public UnitTestingIncrementalAnalyzerProcessor(
var lazyAllAnalyzers = new Lazy<ImmutableArray<IUnitTestingIncrementalAnalyzer>>(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: false));

// event and worker queues
_documentTracker = _registration.Services.GetRequiredService<IUnitTestingDocumentTrackingService>();

var globalNotificationService = _registration.Services.ExportProvider.GetExports<IGlobalOperationNotificationService>().FirstOrDefault()?.Value;

_normalPriorityProcessor = new UnitTestingNormalPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, normalBackOffTimeSpan, shutdownToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -175,77 +169,6 @@ private void SetProjectProcessing(ProjectId currentProject)
_currentProjectProcessing = currentProject;
}

private IEnumerable<DocumentId> 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<bool> 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<IUnitTestingIncrementalAnalyzer> analyzers, UnitTestingWorkItem workItem, CancellationToken cancellationToken)
{
Contract.ThrowIfNull(workItem.DocumentId);
Expand Down

0 comments on commit a3ad10a

Please sign in to comment.