private FixAllState( FixAllProvider fixAllProvider, Document document, Project project, CodeFixProvider codeFixProvider, FixAllScope scope, string codeActionEquivalenceKey, IEnumerable <string> diagnosticIds, FixAllContext.DiagnosticProvider fixAllDiagnosticProvider) { Contract.ThrowIfNull(project); if (diagnosticIds == null) { throw new ArgumentNullException(nameof(diagnosticIds)); } if (diagnosticIds.Any(d => d == null)) { throw new ArgumentException(WorkspacesResources.Supplied_diagnostic_cannot_be_null, nameof(diagnosticIds)); } this.FixAllProvider = fixAllProvider; this.Document = document; this.Project = project; this.CodeFixProvider = codeFixProvider ?? throw new ArgumentNullException(nameof(codeFixProvider)); this.Scope = scope; this.CodeActionEquivalenceKey = codeActionEquivalenceKey; this.DiagnosticIds = ImmutableHashSet.CreateRange(diagnosticIds); this.DiagnosticProvider = fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider)); }
private async Task<CodeAction> GetFixAllCodeActionAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext) { using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation, fixAllContext.CancellationToken)) { CodeAction action = null; try { action = await fixAllProvider.GetFixAsync(fixAllContext).ConfigureAwait(false); } catch (OperationCanceledException) { FixAllLogger.LogComputationResult(completed: false); } finally { if (action != null) { FixAllLogger.LogComputationResult(completed: true); } else { FixAllLogger.LogComputationResult(completed: false, timedOut: true); } } return action; } }
private FixAllProviderInfo( FixAllProvider fixAllProvider, ImmutableArray <FixAllScope> supportedScopes) { FixAllProvider = fixAllProvider; SupportedScopes = supportedScopes; }
private FixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable<FixAllScope> supportedScopes) { this.FixAllProvider = fixAllProvider; this.SupportedScopes = supportedScopes; }
private FixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable <FixAllScope> supportedScopes) { this.FixAllProvider = fixAllProvider; this.SupportedScopes = supportedScopes; }
private FixAllState( FixAllProvider fixAllProvider, Document document, Project project, CodeFixProvider codeFixProvider, FixAllScope scope, string codeActionEquivalenceKey, IEnumerable<string> diagnosticIds, FixAllContext.DiagnosticProvider fixAllDiagnosticProvider) { Contract.ThrowIfNull(project); if (diagnosticIds == null) { throw new ArgumentNullException(nameof(diagnosticIds)); } if (diagnosticIds.Any(d => d == null)) { throw new ArgumentException(WorkspacesResources.Supplied_diagnostic_cannot_be_null, nameof(diagnosticIds)); } this.FixAllProvider = fixAllProvider; this.Document = document; this.Project = project; this.CodeFixProvider = codeFixProvider ?? throw new ArgumentNullException(nameof(codeFixProvider)); this.Scope = scope; this.CodeActionEquivalenceKey = codeActionEquivalenceKey; this.DiagnosticIds = ImmutableHashSet.CreateRange(diagnosticIds); this.DiagnosticProvider = fixAllDiagnosticProvider ?? throw new ArgumentNullException(nameof(fixAllDiagnosticProvider)); }
private FixAllProviderInfo( FixAllProvider fixAllProvider, ImmutableArray<FixAllScope> supportedScopes) { FixAllProvider = fixAllProvider; SupportedScopes = supportedScopes; }
public SuppressionFixerFixAllProviderInfo( FixAllProvider fixAllProvider, ISuppressionFixProvider suppressionFixer, ImmutableArray <FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { _canBeSuppressedOrUnsuppressed = suppressionFixer.CanBeSuppressedOrUnsuppressed; }
public SuppressionFixerFixAllProviderInfo( FixAllProvider fixAllProvider, ISuppressionFixProvider suppressionFixer, IEnumerable <FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { this._canBeSuppressedOrTriaged = suppressionFixer.CanBeSuppressed; }
public SuppressionFixerFixAllProviderInfo( FixAllProvider fixAllProvider, IConfigurationFixProvider suppressionFixer, ImmutableArray <FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { _canBeSuppressedOrUnsuppressed = suppressionFixer.IsFixableDiagnostic; }
public CodeFixerFixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable <string> supportedDiagnosticIds, IEnumerable <FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { this._supportedDiagnosticIds = supportedDiagnosticIds; }
private FixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable <string> supportedDiagnosticIds, IEnumerable <FixAllScope> supportedScopes) { this.FixAllProvider = fixAllProvider; this.SupportedDiagnosticIds = supportedDiagnosticIds; this.SupportedScopes = supportedScopes; }
private FixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable<string> supportedDiagnosticIds, IEnumerable<FixAllScope> supportedScopes) { this.FixAllProvider = fixAllProvider; this.SupportedDiagnosticIds = supportedDiagnosticIds; this.SupportedScopes = supportedScopes; }
public async Task<IEnumerable<CodeActionOperation>> GetFixAllOperationsAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext, bool showPreviewChangesDialog) { var codeAction = await GetFixAllCodeActionAsync(fixAllProvider, fixAllContext).ConfigureAwait(false); if (codeAction == null) { return null; } return await GetFixAllOperationsAsync(codeAction, fixAllContext, showPreviewChangesDialog).ConfigureAwait(false); }
public async Task<Solution> GetFixAllChangedSolutionAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext) { var codeAction = await GetFixAllCodeActionAsync(fixAllProvider, fixAllContext).ConfigureAwait(false); if (codeAction == null) { return fixAllContext.Solution; } fixAllContext.CancellationToken.ThrowIfCancellationRequested(); return await codeAction.GetChangedSolutionInternalAsync(cancellationToken: fixAllContext.CancellationToken).ConfigureAwait(false); }
public CodeFixCollection( object provider, TextSpan span, IEnumerable <CodeFix> fixes, FixAllProvider fixAllProvider, FixAllContext fixAllContext, IEnumerable <FixAllScope> supportedScopes, Diagnostic firstDiagnostic) : this(provider, span, fixes.ToImmutableArray(), fixAllProvider, fixAllContext, supportedScopes, firstDiagnostic) { }
private FixMultipleSuggestedAction GetSuggestedAction( FixMultipleContext fixMultipleContext, Workspace workspace, FixAllProvider fixAllProvider, string title, string waitDialogMessage, bool showPreviewChangesDialog, CancellationToken cancellationToken) { var fixMultipleCodeAction = new FixMultipleCodeAction(fixMultipleContext, fixAllProvider, title, waitDialogMessage, showPreviewChangesDialog); return new FixMultipleSuggestedAction(_listener, workspace, _editHandler, _waitIndicator, fixMultipleCodeAction, fixAllProvider); }
internal FixMultipleSuggestedAction( Workspace workspace, ICodeActionEditHandlerService editHandler, FixMultipleCodeAction codeAction, FixAllProvider provider, ITextBuffer subjectBufferOpt = null) : base(workspace, subjectBufferOpt, editHandler, codeAction, provider, originalFixedDiagnostic: codeAction.GetTriggerDiagnostic()) { _triggerDocumentOpt = codeAction.FixAllContext.Document; _telemetryId = GetTelemetryId(codeAction.FixAllContext.DiagnosticIds); }
private CodeFixEquivalenceGroup( string equivalenceKey, Solution solution, FixAllProvider fixAllProvider, CodeFixProvider codeFixProvider, ImmutableArray<Diagnostic> diagnosticsToFix) { this.CodeFixEquivalenceKey = equivalenceKey; this.Solution = solution; this.FixAllProvider = fixAllProvider; this.CodeFixProvider = codeFixProvider; this.DiagnosticsToFix = diagnosticsToFix; }
public async Task<IEnumerable<CodeActionOperation>> GetFixAllOperationsAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext, string fixAllTitle, string waitDialogMessage, bool showPreviewChangesDialog) { // Compute fix all occurrences code fix for the given fix all context. // Bring up a cancellable wait dialog. bool userCancelled; var codeAction = GetFixAllCodeAction(fixAllProvider, fixAllContext, fixAllTitle, waitDialogMessage, out userCancelled); if (codeAction == null) { return null; } return await GetFixAllOperationsAsync(codeAction, fixAllContext, fixAllTitle, showPreviewChangesDialog).ConfigureAwait(false); }
private void ComputeAndApplyFix( FixMultipleContext fixMultipleContext, Workspace workspace, FixAllProvider fixAllProvider, string waitDialogAndPreviewChangesTitle, string waitDialogMessage, bool showPreviewChangesDialog, CancellationToken cancellationToken) { var fixMultipleCodeAction = new FixMultipleCodeAction(fixMultipleContext, fixAllProvider, title: waitDialogAndPreviewChangesTitle, previewChangesDialogTitle: waitDialogAndPreviewChangesTitle, computingFixWaitDialogMessage: waitDialogMessage, showPreviewChangesDialog: showPreviewChangesDialog); var fixMultipleSuggestedAction = new FixMultipleSuggestedAction(workspace, _editHandler, fixMultipleCodeAction, fixAllProvider); fixMultipleSuggestedAction.Invoke(cancellationToken); }
public async Task<Solution> GetFixAllChangedSolutionAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext, string fixAllTitle, string waitDialogMessage) { // Compute fix all occurrences code fix for the given fix all context. // Bring up a cancellable wait dialog. bool userCancelled; var codeAction = GetFixAllCodeAction(fixAllProvider, fixAllContext, fixAllTitle, waitDialogMessage, out userCancelled); if (codeAction == null) { return userCancelled ? null : fixAllContext.Solution; } fixAllContext.CancellationToken.ThrowIfCancellationRequested(); return await codeAction.GetChangedSolutionInternalAsync(cancellationToken: fixAllContext.CancellationToken).ConfigureAwait(false); }
public void ComputeAndApplyFix( ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string waitDialogAndPreviewChangesTitle, string waitDialogMessage, bool showPreviewChangesDialog, CancellationToken cancellationToken) { var fixMultipleContext = FixMultipleContext.Create(diagnosticsToFix, fixProvider, equivalenceKey, cancellationToken); ComputeAndApplyFix(fixMultipleContext, workspace, fixAllProvider, waitDialogAndPreviewChangesTitle, waitDialogMessage, showPreviewChangesDialog, cancellationToken); }
public Solution GetFix( ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, CancellationToken cancellationToken) { var fixMultipleContext = FixMultipleContext.Create(diagnosticsToFix, fixProvider, equivalenceKey, cancellationToken); var suggestedAction = GetSuggestedAction(fixMultipleContext, workspace, fixAllProvider, waitDialogTitle, waitDialogMessage, showPreviewChangesDialog: false, cancellationToken: cancellationToken); return suggestedAction.GetChangedSolution(cancellationToken); }
internal FixMultipleSuggestedAction( IAsynchronousOperationListener operationListener, Workspace workspace, ICodeActionEditHandlerService editHandler, IWaitIndicator waitIndicator, FixMultipleCodeAction codeAction, FixAllProvider provider, ITextBuffer subjectBufferOpt = null) : base(workspace, subjectBufferOpt, editHandler, waitIndicator, codeAction, provider, originalFixedDiagnostic: codeAction.GetTriggerDiagnostic(), operationListener: operationListener) { _triggerDocumentOpt = codeAction.FixAllState.Document; _telemetryId = GetTelemetryId(codeAction.FixAllState.DiagnosticIds); }
private CodeAction GetFixAllCodeAction(FixAllProvider fixAllProvider, FixAllContext fixAllContext, string fixAllTitle, string waitDialogMessage, out bool userCancelled) { userCancelled = false; // Compute fix all occurrences code fix for the given fix all context. // Bring up a cancellable wait dialog. CodeAction codeAction = null; using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation, fixAllContext.CancellationToken)) { var result = _waitIndicator.Wait( fixAllTitle, waitDialogMessage, allowCancel: true, action: waitContext => { fixAllContext.CancellationToken.ThrowIfCancellationRequested(); using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(waitContext.CancellationToken, fixAllContext.CancellationToken)) { try { var fixAllContextWithCancellation = fixAllContext.WithCancellationToken(linkedCts.Token); var fixTask = fixAllProvider.GetFixAsync(fixAllContextWithCancellation); if (fixTask != null) { codeAction = fixTask.WaitAndGetResult(linkedCts.Token); } } catch (OperationCanceledException) { fixAllContext.CancellationToken.ThrowIfCancellationRequested(); } } }); userCancelled = result == WaitIndicatorResult.Canceled; var cancelled = userCancelled || codeAction == null; if (cancelled) { FixAllLogger.LogComputationResult(completed: false, timedOut: result != WaitIndicatorResult.Canceled); return null; } } FixAllLogger.LogComputationResult(completed: true); return codeAction; }
internal FixAllState( FixAllProvider fixAllProvider, Project project, CodeFixProvider codeFixProvider, FixAllScope scope, string codeActionEquivalenceKey, IEnumerable <string> diagnosticIds, FixAllContext.DiagnosticProvider fixAllDiagnosticProvider) : this(fixAllProvider, null, project, codeFixProvider, scope, codeActionEquivalenceKey, diagnosticIds, fixAllDiagnosticProvider) { if (project == null) { throw new ArgumentNullException(nameof(project)); } }
internal static FixAllState Create( FixAllProvider fixAllProvider, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, CodeFixProvider codeFixProvider, string codeActionEquivalenceKey) { var triggerProject = diagnosticsToFix.First().Key; var diagnosticIds = GetDiagnosticsIds(diagnosticsToFix.Values); var diagnosticProvider = new FixMultipleDiagnosticProvider(diagnosticsToFix); return new FixAllState( fixAllProvider, triggerProject, codeFixProvider, FixAllScope.Custom, codeActionEquivalenceKey, diagnosticIds, diagnosticProvider); }
internal FixAllState( FixAllProvider fixAllProvider, Project project, CodeFixProvider codeFixProvider, FixAllScope scope, string codeActionEquivalenceKey, IEnumerable<string> diagnosticIds, FixAllContext.DiagnosticProvider fixAllDiagnosticProvider) : this(fixAllProvider, null, project, codeFixProvider, scope, codeActionEquivalenceKey, diagnosticIds, fixAllDiagnosticProvider) { if (project == null) { throw new ArgumentNullException(nameof(project)); } }
public void ComputeAndApplyFix( ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string title, string waitDialogMessage, bool showPreviewChangesDialog, CancellationToken cancellationToken) { var fixMultipleContext = FixMultipleContext.Create(diagnosticsToFix, fixProvider, equivalenceKey, cancellationToken); var suggestedAction = GetSuggestedAction(fixMultipleContext, workspace, fixAllProvider, title, waitDialogMessage, showPreviewChangesDialog, cancellationToken); suggestedAction.Invoke(cancellationToken); }
private async Task <List <CodeFixCollection> > AppendFixesOrSuppressionsAsync( Document document, TextSpan span, IEnumerable <DiagnosticData> diagnosticsWithSameSpan, List <CodeFixCollection> result, object fixer, Func <Diagnostic, bool> hasFix, Func <ImmutableArray <Diagnostic>, Task <IEnumerable <CodeFix> > > getFixes, CancellationToken cancellationToken) { var diagnostics = (await diagnosticsWithSameSpan.OrderByDescending(d => d.Severity).ToDiagnosticsAsync(document.Project, cancellationToken).ConfigureAwait(false)).Where(d => hasFix(d)).ToImmutableArray(); if (diagnostics.Length <= 0) { // this can happen for suppression case where all diagnostics can't be suppressed return(result); } var extensionManager = document.Project.Solution.Workspace.Services.GetService <IExtensionManager>(); var fixes = await extensionManager.PerformFunctionAsync(fixer, () => getFixes(diagnostics), defaultValue : SpecializedCollections.EmptyEnumerable <CodeFix>()).ConfigureAwait(false); if (fixes != null && fixes.Any()) { // If the fix provider supports fix all occurrences, then get the corresponding FixAllProviderInfo and fix all context. var fixAllProviderInfo = extensionManager.PerformFunction(fixer, () => ImmutableInterlocked.GetOrAdd(ref _fixAllProviderMap, fixer, FixAllProviderInfo.Create), defaultValue: null); FixAllProvider fixAllProvider = null; FixAllContext fixAllContext = null; IEnumerable <FixAllScope> supportedScopes = null; if (fixAllProviderInfo != null) { var codeFixProvider = (fixer as CodeFixProvider) ?? new WrapperCodeFixProvider((ISuppressionFixProvider)fixer, diagnostics.Select(d => d.Id)); fixAllProvider = fixAllProviderInfo.FixAllProvider; fixAllContext = FixAllContext.Create( document, fixAllProviderInfo, codeFixProvider, diagnostics, this.GetDocumentDiagnosticsAsync, this.GetProjectDiagnosticsAsync, cancellationToken); supportedScopes = fixAllProviderInfo.SupportedScopes; } result = result ?? new List <CodeFixCollection>(); var codeFix = new CodeFixCollection( fixer, span, fixes, fixAllProvider, fixAllContext, supportedScopes, diagnostics.First()); result.Add(codeFix); } return(result); }
public Solution GetFix( ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, CancellationToken cancellationToken) { var fixMultipleState = FixAllState.Create(fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey); var triggerDiagnostic = diagnosticsToFix.First().Value.First(); var suggestedAction = GetSuggestedAction(fixMultipleState, triggerDiagnostic, workspace, waitDialogTitle, waitDialogMessage, showPreviewChangesDialog: false, cancellationToken: cancellationToken); return suggestedAction.GetChangedSolution(cancellationToken); }
public async Task<IEnumerable<CodeActionOperation>> GetFixAllOperationsAsync(FixAllProvider fixAllProvider, FixAllContext fixAllContext) { // Compute fix all occurrences code fix for the given fix all context. // Bring up a cancellable wait dialog. CodeAction codeAction = null; using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesComputation, fixAllContext.CancellationToken)) { var result = _waitIndicator.Wait( EditorFeaturesResources.FixAllOccurrences, EditorFeaturesResources.ComputingFixAllOccurrences, allowCancel: true, action: waitContext => { fixAllContext.CancellationToken.ThrowIfCancellationRequested(); using (var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(waitContext.CancellationToken, fixAllContext.CancellationToken)) { try { var fixAllContextWithCancellation = fixAllContext.WithCancellationToken(linkedCts.Token); var fixTask = fixAllProvider.GetFixAsync(fixAllContextWithCancellation); if (fixTask != null) { codeAction = fixTask.WaitAndGetResult(linkedCts.Token); } } catch (OperationCanceledException) { fixAllContext.CancellationToken.ThrowIfCancellationRequested(); } } }); var cancelled = result == WaitIndicatorResult.Canceled || codeAction == null; if (cancelled) { FixAllLogger.LogComputationResult(completed: false, timedOut: result != WaitIndicatorResult.Canceled); return null; } } FixAllLogger.LogComputationResult(completed: true); return await GetFixAllOperationsAsync(codeAction, fixAllContext).ConfigureAwait(false); }
public CodeFixCollection( object provider, TextSpan span, ImmutableArray <CodeFix> fixes, FixAllProvider fixAllProvider, FixAllContext fixAllContext, IEnumerable <FixAllScope> supportedScopes, Diagnostic firstDiagnostic) { this.Provider = provider; this.TextSpan = span; this.Fixes = fixes; this.FixAllProvider = fixAllProvider; this.FixAllContext = fixAllContext; this.SupportedScopes = supportedScopes; this.FirstDiagnostic = firstDiagnostic; }
private CodeFixEquivalenceGroup( string equivalenceKey, Solution solution, FixAllProvider fixAllProvider, CodeFixProvider codeFixProvider, ImmutableDictionary<ProjectId, ImmutableDictionary<string, ImmutableArray<Diagnostic>>> documentDiagnosticsToFix, ImmutableDictionary<ProjectId, ImmutableArray<Diagnostic>> projectDiagnosticsToFix) { this.CodeFixEquivalenceKey = equivalenceKey; this.Solution = solution; this.FixAllProvider = fixAllProvider; this.CodeFixProvider = codeFixProvider; this.DocumentDiagnosticsToFix = documentDiagnosticsToFix; this.ProjectDiagnosticsToFix = projectDiagnosticsToFix; this.NumberOfDiagnostics = documentDiagnosticsToFix.SelectMany(x => x.Value.Select(y => y.Value).SelectMany(y => y)).Count() + projectDiagnosticsToFix.SelectMany(x => x.Value).Count(); }
public Solution GetFix( ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, CancellationToken cancellationToken) { var fixMultipleState = FixAllState.Create( fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey); return GetFixedSolution( fixMultipleState, workspace, waitDialogTitle, waitDialogMessage, cancellationToken); }
public Solution GetFix( ImmutableDictionary<Document, ImmutableArray<Diagnostic>> diagnosticsToFix, Workspace workspace, CodeFixProvider fixProvider, FixAllProvider fixAllProvider, string equivalenceKey, string waitDialogTitle, string waitDialogMessage, CancellationToken cancellationToken) { var fixMultipleState = FixAllState.Create(fixAllProvider, diagnosticsToFix, fixProvider, equivalenceKey); var triggerDiagnostic = diagnosticsToFix.First().Value.First(); var result = GetFixedSolution( fixMultipleState, triggerDiagnostic, workspace, waitDialogTitle, waitDialogMessage, cancellationToken); return result; }
internal static FixAllState Create( FixAllProvider fixAllProvider, Project project, FixAllProviderInfo fixAllProviderInfo, CodeFixProvider originalFixProvider, IEnumerable <Diagnostic> originalFixDiagnostics, Func <Document, ImmutableHashSet <string>, CancellationToken, Task <IEnumerable <Diagnostic> > > getDocumentDiagnosticsAsync, Func <Project, bool, ImmutableHashSet <string>, CancellationToken, Task <IEnumerable <Diagnostic> > > getProjectDiagnosticsAsync) { var diagnosticIds = GetFixAllDiagnosticIds(fixAllProviderInfo, originalFixDiagnostics).ToImmutableHashSet(); var diagnosticProvider = new FixAllDiagnosticProvider(diagnosticIds, getDocumentDiagnosticsAsync, getProjectDiagnosticsAsync); return(new FixAllState( fixAllProvider: fixAllProvider, project: project, codeFixProvider: originalFixProvider, scope: FixAllScope.Project, codeActionEquivalenceKey: null, diagnosticIds: diagnosticIds, fixAllDiagnosticProvider: diagnosticProvider)); }
internal FixAllState CreateFixAllState( FixAllProvider fixAllProvider, Document document, FixAllProviderInfo fixAllProviderInfo, CodeFixProvider originalFixProvider, IEnumerable <Diagnostic> originalFixDiagnostics, Func <Document, ImmutableHashSet <string>, CancellationToken, Task <IEnumerable <Diagnostic> > > getDocumentDiagnosticsAsync, Func <Project, bool, ImmutableHashSet <string>, CancellationToken, Task <IEnumerable <Diagnostic> > > getProjectDiagnosticsAsync) { var diagnosticIds = originalFixDiagnostics.Where(fixAllProviderInfo.CanBeFixed) .Select(d => d.Id) .ToImmutableHashSet(); var diagnosticProvider = new FixAllDiagnosticProvider(this, diagnosticIds); return(new FixAllState( fixAllProvider: fixAllProvider, document: document, codeFixProvider: originalFixProvider, scope: FixAllScope.Document, codeActionEquivalenceKey: null, diagnosticIds: diagnosticIds, fixAllDiagnosticProvider: diagnosticProvider)); }
internal FixAllCodeAction(FixAllContext fixAllContext, FixAllProvider fixAllProvider) { _fixAllContext = fixAllContext; _fixAllProvider = fixAllProvider; }
internal static FixAllState Create( FixAllProvider fixAllProvider, Project project, FixAllProviderInfo fixAllProviderInfo, CodeFixProvider originalFixProvider, IEnumerable<Diagnostic> originalFixDiagnostics, Func<Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getDocumentDiagnosticsAsync, Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getProjectDiagnosticsAsync) { var diagnosticIds = GetFixAllDiagnosticIds(fixAllProviderInfo, originalFixDiagnostics).ToImmutableHashSet(); var diagnosticProvider = new FixAllDiagnosticProvider(diagnosticIds, getDocumentDiagnosticsAsync, getProjectDiagnosticsAsync); return new FixAllState( fixAllProvider: fixAllProvider, project: project, codeFixProvider: originalFixProvider, scope: FixAllScope.Project, codeActionEquivalenceKey: null, diagnosticIds: diagnosticIds, fixAllDiagnosticProvider: diagnosticProvider); }
internal static FixAllState Create( FixAllProvider fixAllProvider, ImmutableDictionary<Project, ImmutableArray<Diagnostic>> diagnosticsToFix, CodeFixProvider codeFixProvider, string codeActionEquivalenceKey) { var triggerProject = diagnosticsToFix.First().Key; var diagnosticIds = GetDiagnosticsIds(diagnosticsToFix.Values); var diagnosticProvider = new FixMultipleDiagnosticProvider(diagnosticsToFix); return new FixAllState( fixAllProvider, triggerProject, codeFixProvider, FixAllScope.Custom, codeActionEquivalenceKey, diagnosticIds, diagnosticProvider); }
internal FixAllCodeAction(FixAllContext fixAllContext, FixAllProvider fixAllProvider, bool showPreviewChangesDialog) { _fixAllContext = fixAllContext; _fixAllProvider = fixAllProvider; _showPreviewChangesDialog = showPreviewChangesDialog; }
public CodeFixerFixAllProviderInfo( FixAllProvider fixAllProvider, IEnumerable<string> supportedDiagnosticIds, IEnumerable<FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { _supportedDiagnosticIds = supportedDiagnosticIds; }
public SuppressionFixerFixAllProviderInfo( FixAllProvider fixAllProvider, ISuppressionFixProvider suppressionFixer, IEnumerable<FixAllScope> supportedScopes) : base(fixAllProvider, supportedScopes) { _canBeSuppressedOrUnsuppressed = suppressionFixer.CanBeSuppressedOrUnsuppressed; }
internal FixAllCodeAction(FixAllContext fixAllContext, FixAllProvider fixAllProvider) { this.fixAllContext = fixAllContext; this.fixAllProvider = fixAllProvider; }
private static FixAllState GetFixAllState( FixAllProvider fixAllProvider, IEnumerable<Diagnostic> diagnostics, DiagnosticAnalyzer provider, CodeFixProvider fixer, TestDiagnosticAnalyzerDriver testDriver, Document document, FixAllScope scope, string fixAllActionId) { Assert.NotEmpty(diagnostics); if (scope == FixAllScope.Custom) { // Bulk fixing diagnostics in selected scope. var diagnosticsToFix = ImmutableDictionary.CreateRange(SpecializedCollections.SingletonEnumerable(KeyValuePair.Create(document, diagnostics.ToImmutableArray()))); return FixAllState.Create(fixAllProvider, diagnosticsToFix, fixer, fixAllActionId); } var diagnostic = diagnostics.First(); Func<Document, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getDocumentDiagnosticsAsync = async (d, diagIds, c) => { var root = await d.GetSyntaxRootAsync(); var diags = await testDriver.GetDocumentDiagnosticsAsync(provider, d, root.FullSpan); diags = diags.Where(diag => diagIds.Contains(diag.Id)); return diags; }; Func<Project, bool, ImmutableHashSet<string>, CancellationToken, Task<IEnumerable<Diagnostic>>> getProjectDiagnosticsAsync = async (p, includeAllDocumentDiagnostics, diagIds, c) => { var diags = includeAllDocumentDiagnostics ? await testDriver.GetAllDiagnosticsAsync(provider, p) : await testDriver.GetProjectDiagnosticsAsync(provider, p); diags = diags.Where(diag => diagIds.Contains(diag.Id)); return diags; }; var diagnosticIds = ImmutableHashSet.Create(diagnostic.Id); var fixAllDiagnosticProvider = new FixAllState.FixAllDiagnosticProvider(diagnosticIds, getDocumentDiagnosticsAsync, getProjectDiagnosticsAsync); return diagnostic.Location.IsInSource ? new FixAllState(fixAllProvider, document, fixer, scope, fixAllActionId, diagnosticIds, fixAllDiagnosticProvider) : new FixAllState(fixAllProvider, document.Project, fixer, scope, fixAllActionId, diagnosticIds, fixAllDiagnosticProvider); }
internal FixAllCodeAction(FixAllContext fixAllContext, FixAllProvider fixAllProvider) { _fixAllContext = fixAllContext; _fixAllProvider = fixAllProvider; }