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 @@ -693,7 +693,7 @@ internal async Task TestOnlyRequiredAnalyzerExecutedDuringDiagnosticComputation(
var diagnosticsMapResults = await DiagnosticComputer.GetDiagnosticsAsync(
document, project, Checksum.Null, span: null, projectAnalyzerIds: [], analyzerIdsToRequestDiagnostics,
AnalysisKind.Semantic, new DiagnosticAnalyzerInfoCache(), workspace.Services,
isExplicit: false, logPerformanceInfo: false, getTelemetryInfo: false,
logPerformanceInfo: false, getTelemetryInfo: false,
cancellationToken: CancellationToken.None);
Assert.False(analyzer2.ReceivedSymbolCallback);

Expand Down Expand Up @@ -762,7 +762,7 @@ async Task VerifyCallbackSpanAsync(TextSpan? filterSpan)
_ = await DiagnosticComputer.GetDiagnosticsAsync(
documentToAnalyze, project, Checksum.Null, filterSpan, analyzerIdsToRequestDiagnostics, hostAnalyzerIds: [],
analysisKind, new DiagnosticAnalyzerInfoCache(), workspace.Services,
isExplicit: false, logPerformanceInfo: false, getTelemetryInfo: false,
logPerformanceInfo: false, getTelemetryInfo: false,
CancellationToken.None);
Assert.Equal(filterSpan, analyzer.CallbackFilterSpan);
if (kind == FilterSpanTestAnalyzer.AnalysisKind.AdditionalFile)
Expand Down Expand Up @@ -817,7 +817,7 @@ void M()
try
{
_ = await DiagnosticComputer.GetDiagnosticsAsync(document, project, Checksum.Null, span: null,
projectAnalyzerIds: [], analyzerIds, kind, diagnosticAnalyzerInfoCache, workspace.Services, isExplicit: false,
projectAnalyzerIds: [], analyzerIds, kind, diagnosticAnalyzerInfoCache, workspace.Services,
logPerformanceInfo: false, getTelemetryInfo: false, cancellationToken: analyzer.CancellationToken);

throw ExceptionUtilities.Unreachable();
Expand All @@ -830,7 +830,7 @@ void M()

// Then invoke analysis without cancellation token, and verify non-cancelled diagnostic.
var diagnosticsMap = await DiagnosticComputer.GetDiagnosticsAsync(document, project, Checksum.Null, span: null,
projectAnalyzerIds: [], analyzerIds, kind, diagnosticAnalyzerInfoCache, workspace.Services, isExplicit: false,
projectAnalyzerIds: [], analyzerIds, kind, diagnosticAnalyzerInfoCache, workspace.Services,
logPerformanceInfo: false, getTelemetryInfo: false, cancellationToken: CancellationToken.None);
var builder = diagnosticsMap.Diagnostics.Single().diagnosticMap;
var diagnostic = kind == AnalysisKind.Syntax ? builder.Syntax.Single().Item2.Single() : builder.Semantic.Single().Item2.Single();
Expand Down
11 changes: 1 addition & 10 deletions src/Features/Core/Portable/Diagnostics/DiagnosticArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ internal sealed class DiagnosticArguments
[DataMember(Order = 7)]
public ImmutableArray<string> HostAnalyzerIds;

/// <summary>
/// Indicates diagnostic computation for an explicit user-invoked request,
/// such as a user-invoked Ctrl + Dot operation to bring up the light bulb.
/// </summary>
[DataMember(Order = 8)]
public bool IsExplicit;

public DiagnosticArguments(
bool logPerformanceInfo,
bool getTelemetryInfo,
Expand All @@ -84,8 +77,7 @@ public DiagnosticArguments(
AnalysisKind? documentAnalysisKind,
ProjectId projectId,
ImmutableArray<string> projectAnalyzerIds,
ImmutableArray<string> hostAnalyzerIds,
bool isExplicit)
ImmutableArray<string> hostAnalyzerIds)
{
Debug.Assert(documentId != null || documentSpan == null);
Debug.Assert(documentId != null || documentAnalysisKind == null);
Expand All @@ -101,6 +93,5 @@ public DiagnosticArguments(
ProjectId = projectId;
ProjectAnalyzerIds = projectAnalyzerIds;
HostAnalyzerIds = hostAnalyzerIds;
IsExplicit = isExplicit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
TextDocument document, TextSpan? range, Func<string, bool>? shouldIncludeDiagnostic,
ICodeActionRequestPriorityProvider priorityProvider,
DiagnosticKind diagnosticKind,
bool isExplicit,
CancellationToken cancellationToken);
}

Expand All @@ -99,7 +98,8 @@ public static Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(th
document, range,
diagnosticId: null,
priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
diagnosticKind, isExplicit: false, cancellationToken);
diagnosticKind,
cancellationToken);

/// <summary>
/// Return up to date diagnostics for the given <paramref name="range"/> and parameters for the given <paramref name="document"/>.
Expand All @@ -113,11 +113,10 @@ public static Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(th
TextDocument document, TextSpan? range, string? diagnosticId,
ICodeActionRequestPriorityProvider priorityProvider,
DiagnosticKind diagnosticKind,
bool isExplicit,
CancellationToken cancellationToken)
{
Func<string, bool>? shouldIncludeDiagnostic = diagnosticId != null ? id => id == diagnosticId : null;
return service.GetDiagnosticsForSpanAsync(document, range, shouldIncludeDiagnostic,
priorityProvider, diagnosticKind, isExplicit, cancellationToken);
priorityProvider, diagnosticKind, cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private async Task<Document> ApplyCodeFixesForSpecificDiagnosticIdAsync(
var diagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(document, range,
shouldIncludeDiagnostic: static diagnosticId => !(IDEDiagnosticIdToOptionMappingHelper.IsKnownIDEDiagnosticId(diagnosticId)),
priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
DiagnosticKind.All, isExplicit: false,
DiagnosticKind.All,
cancellationToken).ConfigureAwait(false);

// We don't want code cleanup automatically cleaning suppressed diagnostics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task<IEnumerable<Diagnostic>> GetDocumentSpanDiagnosticsAs
var diagnostics = Filter(await _diagnosticService.GetDiagnosticsForSpanAsync(
document, fixAllSpan, shouldIncludeDiagnostic,
priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false));
DiagnosticKind.All, cancellationToken).ConfigureAwait(false));
Contract.ThrowIfFalse(diagnostics.All(d => d.DocumentId != null));
return await diagnostics.ToDiagnosticsAsync(document.Project, cancellationToken).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public CodeFixService(
{
allDiagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(
document, range, GetShouldIncludeDiagnosticPredicate(document, priorityProvider),
priorityProvider, DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false);
priorityProvider, DiagnosticKind.All, cancellationToken).ConfigureAwait(false);

// NOTE(cyrusn): We do not include suppressed diagnostics here as they are effectively hidden from the
// user in the editor. As far as the user is concerned, there is no squiggle for it and no lightbulb
Expand Down Expand Up @@ -199,7 +199,7 @@ public async IAsyncEnumerable<CodeFixCollection> StreamFixesAsync(
{
diagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(
document, range, GetShouldIncludeDiagnosticPredicate(document, priorityProvider),
priorityProvider, DiagnosticKind.All, isExplicit: true, cancellationToken).ConfigureAwait(false);
priorityProvider, DiagnosticKind.All, cancellationToken).ConfigureAwait(false);
if (!includeSuppressionFixes)
diagnostics = diagnostics.WhereAsArray(d => !d.IsSuppressed);
}
Expand Down Expand Up @@ -299,7 +299,7 @@ private static SortedDictionary<TextSpan, List<DiagnosticData>> ConvertToMap(
{
diagnostics = await _diagnosticService.GetDiagnosticsForSpanAsync(
document, range, diagnosticId, priorityProvider: new DefaultCodeActionRequestPriorityProvider(),
DiagnosticKind.All, isExplicit: false, cancellationToken).ConfigureAwait(false);
DiagnosticKind.All, cancellationToken).ConfigureAwait(false);

// NOTE(cyrusn): We do not include suppressed diagnostics here as they are effectively hidden from the
// user in the editor. As far as the user is concerned, there is no squiggle for it and no lightbulb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
Func<string, bool>? shouldIncludeDiagnostic,
ICodeActionRequestPriorityProvider priorityProvider,
DiagnosticKind diagnosticKinds,
bool isExplicit,
CancellationToken cancellationToken)
{
var analyzer = CreateIncrementalAnalyzer(document.Project.Solution.Workspace);
Expand All @@ -93,7 +92,7 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
priorityProvider ??= new DefaultCodeActionRequestPriorityProvider();

return await analyzer.GetDiagnosticsForSpanAsync(
document, range, shouldIncludeDiagnostic, priorityProvider, diagnosticKinds, isExplicit, cancellationToken).ConfigureAwait(false);
document, range, shouldIncludeDiagnostic, priorityProvider, diagnosticKinds, cancellationToken).ConfigureAwait(false);
}

public async Task<ImmutableArray<DiagnosticData>> ForceAnalyzeProjectAsync(Project project, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal sealed partial class DocumentAnalysisExecutor
{
private readonly CompilationWithAnalyzersPair? _compilationWithAnalyzers;
private readonly InProcOrRemoteHostAnalyzerRunner _diagnosticAnalyzerRunner;
private readonly bool _isExplicit;
private readonly bool _logPerformanceInfo;
private readonly Action? _onAnalysisException;

Expand All @@ -41,14 +40,12 @@ public DocumentAnalysisExecutor(
DocumentAnalysisScope analysisScope,
CompilationWithAnalyzersPair? compilationWithAnalyzers,
InProcOrRemoteHostAnalyzerRunner diagnosticAnalyzerRunner,
bool isExplicit,
bool logPerformanceInfo,
Action? onAnalysisException = null)
{
AnalysisScope = analysisScope;
_compilationWithAnalyzers = compilationWithAnalyzers;
_diagnosticAnalyzerRunner = diagnosticAnalyzerRunner;
_isExplicit = isExplicit;
_logPerformanceInfo = logPerformanceInfo;
_onAnalysisException = onAnalysisException;

Expand All @@ -66,7 +63,7 @@ public DocumentAnalysisExecutor(
public DocumentAnalysisScope AnalysisScope { get; }

public DocumentAnalysisExecutor With(DocumentAnalysisScope analysisScope)
=> new(analysisScope, _compilationWithAnalyzers, _diagnosticAnalyzerRunner, _isExplicit, _logPerformanceInfo, _onAnalysisException);
=> new(analysisScope, _compilationWithAnalyzers, _diagnosticAnalyzerRunner, _logPerformanceInfo, _onAnalysisException);

/// <summary>
/// Return all local diagnostics (syntax, semantic) that belong to given document for the given analyzer by calculating them.
Expand Down Expand Up @@ -185,8 +182,8 @@ private async Task<ImmutableDictionary<DiagnosticAnalyzer, DiagnosticAnalysisRes

try
{
var resultAndTelemetry = await _diagnosticAnalyzerRunner.AnalyzeDocumentAsync(analysisScope, _compilationWithAnalyzers,
_isExplicit, _logPerformanceInfo, getTelemetryInfo: false, cancellationToken).ConfigureAwait(false);
var resultAndTelemetry = await _diagnosticAnalyzerRunner.AnalyzeDocumentAsync(
analysisScope, _compilationWithAnalyzers, _logPerformanceInfo, getTelemetryInfo: false, cancellationToken).ConfigureAwait(false);
return resultAndTelemetry.AnalysisResult;
}
catch when (_onAnalysisException != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public async Task<ImmutableArray<DiagnosticData>> GetDiagnosticsForSpanAsync(
Func<string, bool>? shouldIncludeDiagnostic,
ICodeActionRequestPriorityProvider priorityProvider,
DiagnosticKind diagnosticKind,
bool isExplicit,
CancellationToken cancellationToken)
{
var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -236,7 +235,7 @@ async Task ComputeDocumentDiagnosticsAsync(
var projectAnalyzers = analyzers.WhereAsArray(static (a, info) => !info.IsHostAnalyzer(a), hostAnalyzerInfo);
var hostAnalyzers = analyzers.WhereAsArray(static (a, info) => info.IsHostAnalyzer(a), hostAnalyzerInfo);
var analysisScope = new DocumentAnalysisScope(document, span, projectAnalyzers, hostAnalyzers, kind);
var executor = new DocumentAnalysisExecutor(analysisScope, compilationWithAnalyzers, _diagnosticAnalyzerRunner, isExplicit, logPerformanceInfo);
var executor = new DocumentAnalysisExecutor(analysisScope, compilationWithAnalyzers, _diagnosticAnalyzerRunner, logPerformanceInfo);
var version = await GetDiagnosticVersionAsync(document.Project, cancellationToken).ConfigureAwait(false);

ImmutableDictionary<DiagnosticAnalyzer, ImmutableArray<DiagnosticData>> diagnosticsMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,23 @@ public InProcOrRemoteHostAnalyzerRunner(
public Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>> AnalyzeDocumentAsync(
DocumentAnalysisScope documentAnalysisScope,
CompilationWithAnalyzersPair compilationWithAnalyzers,
bool isExplicit,
bool logPerformanceInfo,
bool getTelemetryInfo,
CancellationToken cancellationToken)
=> AnalyzeAsync(documentAnalysisScope, documentAnalysisScope.TextDocument.Project, compilationWithAnalyzers,
isExplicit, logPerformanceInfo, getTelemetryInfo, cancellationToken);
=> AnalyzeAsync(documentAnalysisScope, documentAnalysisScope.TextDocument.Project, compilationWithAnalyzers, logPerformanceInfo, getTelemetryInfo, cancellationToken);

public Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>> AnalyzeProjectAsync(
Project project,
CompilationWithAnalyzersPair compilationWithAnalyzers,
bool logPerformanceInfo,
bool getTelemetryInfo,
CancellationToken cancellationToken)
=> AnalyzeAsync(documentAnalysisScope: null, project, compilationWithAnalyzers,
isExplicit: false, logPerformanceInfo, getTelemetryInfo, cancellationToken);
=> AnalyzeAsync(documentAnalysisScope: null, project, compilationWithAnalyzers, logPerformanceInfo, getTelemetryInfo, cancellationToken);

private async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>> AnalyzeAsync(
DocumentAnalysisScope? documentAnalysisScope,
Project project,
CompilationWithAnalyzersPair compilationWithAnalyzers,
bool isExplicit,
bool logPerformanceInfo,
bool getTelemetryInfo,
CancellationToken cancellationToken)
Expand All @@ -79,7 +75,7 @@ async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisRes
if (remoteHostClient != null)
{
return await AnalyzeOutOfProcAsync(documentAnalysisScope, project, compilationWithAnalyzers, remoteHostClient,
isExplicit, logPerformanceInfo, getTelemetryInfo, cancellationToken).ConfigureAwait(false);
logPerformanceInfo, getTelemetryInfo, cancellationToken).ConfigureAwait(false);
}

return await AnalyzeInProcAsync(documentAnalysisScope, project, compilationWithAnalyzers,
Expand Down Expand Up @@ -192,7 +188,6 @@ private static async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, Diagno
Project project,
CompilationWithAnalyzersPair compilationWithAnalyzers,
RemoteHostClient client,
bool isExplicit,
bool logPerformanceInfo,
bool getTelemetryInfo,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -221,8 +216,7 @@ private static async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, Diagno
documentAnalysisScope?.Kind,
project.Id,
[.. projectAnalyzerMap.Keys],
[.. hostAnalyzerMap.Keys],
isExplicit);
[.. hostAnalyzerMap.Keys]);

var result = await client.TryInvokeAsync<IRemoteDiagnosticAnalyzerService, SerializableDiagnosticAnalysisResults>(
project.Solution,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Public Sub RequestDiagnosticRefresh() Implements IDiagnosticAnalyzerService.RequestDiagnosticRefresh
End Sub

Public Function GetDiagnosticsForSpanAsync(document As TextDocument, range As TextSpan?, shouldIncludeDiagnostic As Func(Of String, Boolean), priority As ICodeActionRequestPriorityProvider, diagnosticKinds As DiagnosticKind, isExplicit As Boolean, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetDiagnosticsForSpanAsync
Public Function GetDiagnosticsForSpanAsync(document As TextDocument, range As TextSpan?, shouldIncludeDiagnostic As Func(Of String, Boolean), priority As ICodeActionRequestPriorityProvider, diagnosticKinds As DiagnosticKind, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of DiagnosticData)) Implements IDiagnosticAnalyzerService.GetDiagnosticsForSpanAsync
Return SpecializedTasks.EmptyImmutableArray(Of DiagnosticData)
End Function

Expand Down
Loading
Loading