提交 458a7217 编写于 作者: C CyrusNajmabadi

Extract method.

上级 cd399c4d
......@@ -220,34 +220,37 @@ public async Task<ImmutableArray<CodeFixCollection>> GetFixesAsync(Document docu
{
cancellationToken.ThrowIfCancellationRequested();
Func<Diagnostic, bool> hasFix = (d) => this.GetFixableDiagnosticIds(fixer, extensionManager).Contains(d.Id);
Func<ImmutableArray<Diagnostic>, Task<ImmutableArray<CodeFix>>> getFixes =
async (dxs) =>
{
var fixes = ArrayBuilder<CodeFix>.GetInstance();
var context = new CodeFixContext(document, span, dxs,
// TODO: Can we share code between similar lambdas that we pass to this API in BatchFixAllProvider.cs, CodeFixService.cs and CodeRefactoringService.cs?
(action, applicableDiagnostics) =>
{
// Serialize access for thread safety - we don't know what thread the fix provider will call this delegate from.
lock (fixes)
{
fixes.Add(new CodeFix(document.Project, action, applicableDiagnostics));
}
},
verifyArguments: false,
cancellationToken: cancellationToken);
var task = fixer.RegisterCodeFixesAsync(context) ?? SpecializedTasks.EmptyTask;
await task.ConfigureAwait(false);
return fixes.ToImmutableAndFree();
};
await AppendFixesOrSuppressionsAsync(document, span, diagnostics, result, fixer,
hasFix, getFixes, cancellationToken).ConfigureAwait(false);
await AppendFixesOrSuppressionsAsync(
document, span, diagnostics, result, fixer,
hasFix: d => this.GetFixableDiagnosticIds(fixer, extensionManager).Contains(d.Id),
getFixes: dxs => GetCodeFixesAsync(document, span, fixer, dxs, cancellationToken),
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
private async Task<ImmutableArray<CodeFix>> GetCodeFixesAsync(
Document document, TextSpan span, CodeFixProvider fixer,
ImmutableArray<Diagnostic> diagnostics, CancellationToken cancellationToken)
{
var fixes = ArrayBuilder<CodeFix>.GetInstance();
var context = new CodeFixContext(document, span, diagnostics,
// TODO: Can we share code between similar lambdas that we pass to this API in BatchFixAllProvider.cs, CodeFixService.cs and CodeRefactoringService.cs?
(action, applicableDiagnostics) =>
{
// Serialize access for thread safety - we don't know what thread the fix provider will call this delegate from.
lock (fixes)
{
fixes.Add(new CodeFix(document.Project, action, applicableDiagnostics));
}
},
verifyArguments: false,
cancellationToken: cancellationToken);
var task = fixer.RegisterCodeFixesAsync(context) ?? SpecializedTasks.EmptyTask;
await task.ConfigureAwait(false);
return fixes.ToImmutableAndFree();
}
private async Task AppendSuppressionsAsync(
Document document, TextSpan span, IEnumerable<DiagnosticData> diagnostics,
ArrayBuilder<CodeFixCollection> result, CancellationToken cancellationToken)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册