Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -87,12 +87,6 @@ Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
Task<ImmutableArray<DiagnosticDescriptor>> GetDiagnosticDescriptorsAsync(
Solution solution, ProjectId projectId, AnalyzerReference analyzerReference, string language, CancellationToken cancellationToken);

/// <summary>
/// Given a list of errors ids (like CS1234), attempts to find an associated descriptor for each id.
/// </summary>
Task<ImmutableDictionary<string, DiagnosticDescriptor>> TryGetDiagnosticDescriptorsAsync(
Solution solution, ImmutableArray<string> diagnosticIds, CancellationToken cancellationToken);

/// <inheritdoc cref="HostDiagnosticAnalyzers.GetDiagnosticDescriptorsPerReference(DiagnosticAnalyzerInfoCache)"/>
Task<ImmutableDictionary<string, ImmutableArray<DiagnosticDescriptor>>> GetDiagnosticDescriptorsPerReferenceAsync(
Solution solution, CancellationToken cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,6 @@ public async Task<ImmutableArray<DiagnosticDescriptor>> GetDiagnosticDescriptors
.SelectManyAsArray(this._analyzerInfoCache.GetDiagnosticDescriptors);
}

public async Task<ImmutableDictionary<string, DiagnosticDescriptor>> TryGetDiagnosticDescriptorsAsync(
Solution solution, ImmutableArray<string> diagnosticIds, CancellationToken cancellationToken)
{
var client = await RemoteHostClient.TryGetClientAsync(solution.Services, cancellationToken).ConfigureAwait(false);
if (client is not null)
{
var map = await client.TryInvokeAsync<IRemoteDiagnosticAnalyzerService, ImmutableDictionary<string, DiagnosticDescriptorData>>(
solution,
(service, solution, cancellationToken) => service.TryGetDiagnosticDescriptorsAsync(solution, diagnosticIds, cancellationToken),
cancellationToken).ConfigureAwait(false);

if (!map.HasValue)
return ImmutableDictionary<string, DiagnosticDescriptor>.Empty;

return map.Value.ToImmutableDictionary(
kvp => kvp.Key,
kvp => kvp.Value.ToDiagnosticDescriptor());
}

var builder = ImmutableDictionary.CreateBuilder<string, DiagnosticDescriptor>();
foreach (var diagnosticId in diagnosticIds)
{
if (this._analyzerInfoCache.TryGetDescriptorForDiagnosticId(diagnosticId, out var descriptor))
builder[diagnosticId] = descriptor;
}

return builder.ToImmutable();
}

public async Task<ImmutableDictionary<string, ImmutableArray<DiagnosticDescriptor>>> GetDiagnosticDescriptorsPerReferenceAsync(Solution solution, CancellationToken cancellationToken)
{
var client = await RemoteHostClient.TryGetClientAsync(solution.Services, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
internal sealed class ExternalErrorDiagnosticUpdateSource : IDisposable
{
private readonly Workspace _workspace;
public readonly IAsynchronousOperationListener Listener;
public readonly CancellationToken DisposalToken;
private readonly IServiceBroker _serviceBroker;

/// <summary>
Expand Down Expand Up @@ -70,17 +68,14 @@ public ExternalErrorDiagnosticUpdateSource(
[Import(typeof(SVsFullAccessServiceBroker))] IServiceBroker serviceBroker,
IThreadingContext threadingContext)
{
DisposalToken = threadingContext.DisposalToken;
_workspace = workspace;
Listener = listenerProvider.GetListener(FeatureAttribute.ErrorList);

_serviceBroker = serviceBroker;
_taskQueue = new AsyncBatchingWorkQueue<Func<CancellationToken, Task>>(
TimeSpan.Zero,
processBatchAsync: ProcessTaskQueueItemsAsync,
Listener,
DisposalToken
);
listenerProvider.GetListener(FeatureAttribute.ErrorList),
threadingContext.DisposalToken);

// This pattern ensures that we are called whenever the build starts/completes even if it is already in progress.
KnownUIContexts.SolutionBuildingContext.WhenActivated(() =>
Expand Down
Loading
Loading