提交 c48a1433 编写于 作者: C CyrusNajmabadi

Remove property from FixAllCodeActio

nContext
上级 e19ea0cf
...@@ -301,7 +301,9 @@ public async Task<IEnumerable<CodeFixCollection>> GetFixesAsync(Document documen ...@@ -301,7 +301,9 @@ public async Task<IEnumerable<CodeFixCollection>> GetFixesAsync(Document documen
} }
result = result ?? new List<CodeFixCollection>(); result = result ?? new List<CodeFixCollection>();
var codeFix = new CodeFixCollection(fixer, span, fixes, fixAllProvider, fixAllContext, supportedScopes); var codeFix = new CodeFixCollection(
fixer, span, fixes, fixAllProvider, fixAllContext,
supportedScopes, diagnostics.First());
result.Add(codeFix); result.Add(codeFix);
} }
......
...@@ -49,6 +49,7 @@ internal class CodeFixSuggestedAction : SuggestedActionWithFlavors, ITelemetryDi ...@@ -49,6 +49,7 @@ internal class CodeFixSuggestedAction : SuggestedActionWithFlavors, ITelemetryDi
FixAllProvider fixAllProvider, FixAllProvider fixAllProvider,
FixAllCodeActionContext fixAllCodeActionContext, FixAllCodeActionContext fixAllCodeActionContext,
IEnumerable<FixAllScope> supportedScopes, IEnumerable<FixAllScope> supportedScopes,
Diagnostic firstDiagnostic,
Workspace workspace, Workspace workspace,
ITextBuffer subjectBuffer, ITextBuffer subjectBuffer,
ICodeActionEditHandlerService editHandler, ICodeActionEditHandlerService editHandler,
...@@ -71,8 +72,8 @@ internal class CodeFixSuggestedAction : SuggestedActionWithFlavors, ITelemetryDi ...@@ -71,8 +72,8 @@ internal class CodeFixSuggestedAction : SuggestedActionWithFlavors, ITelemetryDi
var fixAllContext = GetContextForScopeAndActionId(fixAllCodeActionContext, scope, action.EquivalenceKey); var fixAllContext = GetContextForScopeAndActionId(fixAllCodeActionContext, scope, action.EquivalenceKey);
var fixAllAction = new FixAllCodeAction(fixAllContext, fixAllProvider, showPreviewChangesDialog: true); var fixAllAction = new FixAllCodeAction(fixAllContext, fixAllProvider, showPreviewChangesDialog: true);
var fixAllSuggestedAction = new FixAllSuggestedAction( var fixAllSuggestedAction = new FixAllSuggestedAction(
workspace, subjectBuffer, editHandler, waitIndicator, fixAllAction, fixAllProvider, workspace, subjectBuffer, editHandler, waitIndicator, fixAllAction,
fixAllCodeActionContext.OriginalDiagnostics.First(), operationListener); fixAllProvider, firstDiagnostic, operationListener);
fixAllSuggestedActions.Add(fixAllSuggestedAction); fixAllSuggestedActions.Add(fixAllSuggestedAction);
} }
......
...@@ -285,7 +285,8 @@ private List<CodeFixCollection> FilterOnUIThread(List<CodeFixCollection> collect ...@@ -285,7 +285,8 @@ private List<CodeFixCollection> FilterOnUIThread(List<CodeFixCollection> collect
: applicableFixes.Count == collection.Fixes.Length : applicableFixes.Count == collection.Fixes.Length
? collection ? collection
: new CodeFixCollection(collection.Provider, collection.TextSpan, applicableFixes, : new CodeFixCollection(collection.Provider, collection.TextSpan, applicableFixes,
collection.FixAllProvider, collection.FixAllContext, collection.SupportedScopes); collection.FixAllProvider, collection.FixAllContext,
collection.SupportedScopes, collection.FirstDiagnostic);
} }
private bool IsApplicable(CodeAction action, Workspace workspace) private bool IsApplicable(CodeAction action, Workspace workspace)
...@@ -349,8 +350,10 @@ private IEnumerable<SuggestedActionSet> OrganizeFixes(Workspace workspace, IEnum ...@@ -349,8 +350,10 @@ private IEnumerable<SuggestedActionSet> OrganizeFixes(Workspace workspace, IEnum
Func<CodeAction, SuggestedActionSet> getFixAllSuggestedActionSet = Func<CodeAction, SuggestedActionSet> getFixAllSuggestedActionSet =
codeAction => CodeFixSuggestedAction.GetFixAllSuggestedActionSet( codeAction => CodeFixSuggestedAction.GetFixAllSuggestedActionSet(
codeAction, fixCount, fixCollection.FixAllProvider, fixCollection.FixAllContext, fixCollection.SupportedScopes, codeAction, fixCount, fixCollection.FixAllProvider,
workspace, _subjectBuffer, _owner._editHandler, _owner._waitIndicator, _owner._listener); fixCollection.FixAllContext, fixCollection.SupportedScopes,
fixCollection.FirstDiagnostic, workspace, _subjectBuffer,
_owner._editHandler, _owner._waitIndicator, _owner._listener);
foreach (var fix in fixes) foreach (var fix in fixes)
{ {
......
...@@ -144,7 +144,7 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri ...@@ -144,7 +144,7 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri
{ {
var codeFix = new CodeFixCollection( var codeFix = new CodeFixCollection(
fixer, diagnostic.Location.SourceSpan, fixes, fixer, diagnostic.Location.SourceSpan, fixes,
fixAllProvider: null, fixAllContext: null, supportedScopes: null); fixAllProvider: null, fixAllContext: null, supportedScopes: null, firstDiagnostic: null);
result.Add(Tuple.Create(diagnostic, codeFix)); result.Add(Tuple.Create(diagnostic, codeFix));
} }
} }
...@@ -165,7 +165,7 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri ...@@ -165,7 +165,7 @@ protected Document GetDocumentAndAnnotatedSpan(TestWorkspace workspace, out stri
var diagnosticSpan = diagnostic.Location.IsInSource ? diagnostic.Location.SourceSpan : default(TextSpan); var diagnosticSpan = diagnostic.Location.IsInSource ? diagnostic.Location.SourceSpan : default(TextSpan);
var codeFix = new CodeFixCollection( var codeFix = new CodeFixCollection(
fixAllProvider, diagnosticSpan, ImmutableArray.Create(new CodeFix(document.Project, fixAllFix, diagnostic)), fixAllProvider, diagnosticSpan, ImmutableArray.Create(new CodeFix(document.Project, fixAllFix, diagnostic)),
fixAllProvider: null, fixAllContext: null, supportedScopes: null); fixAllProvider: null, fixAllContext: null, supportedScopes: null, firstDiagnostic: null);
result.Add(Tuple.Create(diagnostic, codeFix)); result.Add(Tuple.Create(diagnostic, codeFix));
} }
} }
......
...@@ -114,7 +114,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics ...@@ -114,7 +114,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics
If fixes.Any() Then If fixes.Any() Then
result.Add(Tuple.Create(diagnostic, New CodeFixCollection( result.Add(Tuple.Create(diagnostic, New CodeFixCollection(
fixer, diagnostic.Location.SourceSpan, fixes, fixer, diagnostic.Location.SourceSpan, fixes,
fixAllProvider:=Nothing, fixAllContext:=Nothing, supportedScopes:=Nothing))) fixAllProvider:=Nothing, fixAllContext:=Nothing,
supportedScopes:=Nothing, firstDiagnostic:=Nothing)))
End If End If
Next Next
......
...@@ -23,6 +23,7 @@ internal class CodeFixCollection ...@@ -23,6 +23,7 @@ internal class CodeFixCollection
public FixAllProvider FixAllProvider { get; } public FixAllProvider FixAllProvider { get; }
public FixAllCodeActionContext FixAllContext { get; } public FixAllCodeActionContext FixAllContext { get; }
public IEnumerable<FixAllScope> SupportedScopes { get; } public IEnumerable<FixAllScope> SupportedScopes { get; }
public Diagnostic FirstDiagnostic { get; }
public CodeFixCollection( public CodeFixCollection(
object provider, object provider,
...@@ -30,8 +31,9 @@ internal class CodeFixCollection ...@@ -30,8 +31,9 @@ internal class CodeFixCollection
IEnumerable<CodeFix> fixes, IEnumerable<CodeFix> fixes,
FixAllProvider fixAllProvider, FixAllProvider fixAllProvider,
FixAllCodeActionContext fixAllContext, FixAllCodeActionContext fixAllContext,
IEnumerable<FixAllScope> supportedScopes) : IEnumerable<FixAllScope> supportedScopes,
this(provider, span, fixes.ToImmutableArray(), fixAllProvider, fixAllContext, supportedScopes) Diagnostic firstDiagnostic) :
this(provider, span, fixes.ToImmutableArray(), fixAllProvider, fixAllContext, supportedScopes, firstDiagnostic)
{ {
} }
...@@ -41,7 +43,8 @@ internal class CodeFixCollection ...@@ -41,7 +43,8 @@ internal class CodeFixCollection
ImmutableArray<CodeFix> fixes, ImmutableArray<CodeFix> fixes,
FixAllProvider fixAllProvider, FixAllProvider fixAllProvider,
FixAllCodeActionContext fixAllContext, FixAllCodeActionContext fixAllContext,
IEnumerable<FixAllScope> supportedScopes) IEnumerable<FixAllScope> supportedScopes,
Diagnostic firstDiagnostic)
{ {
this.Provider = provider; this.Provider = provider;
this.TextSpan = span; this.TextSpan = span;
...@@ -49,6 +52,7 @@ internal class CodeFixCollection ...@@ -49,6 +52,7 @@ internal class CodeFixCollection
this.FixAllProvider = fixAllProvider; this.FixAllProvider = fixAllProvider;
this.FixAllContext = fixAllContext; this.FixAllContext = fixAllContext;
this.SupportedScopes = supportedScopes; this.SupportedScopes = supportedScopes;
this.FirstDiagnostic = firstDiagnostic;
} }
} }
} }
...@@ -81,13 +81,13 @@ private static IEnumerable<string> GetFixAllDiagnosticIds(FixAllProviderInfo fix ...@@ -81,13 +81,13 @@ private static IEnumerable<string> GetFixAllDiagnosticIds(FixAllProviderInfo fix
.Select(d => d.Id); .Select(d => d.Id);
} }
#if false
public IEnumerable<Diagnostic> OriginalDiagnostics public IEnumerable<Diagnostic> OriginalDiagnostics
{ {
get { return _originalFixDiagnostics; } get { return _originalFixDiagnostics; }
} }
#if false
public FixAllProvider FixAllProvider public FixAllProvider FixAllProvider
{ {
get { return _fixAllProviderInfo.FixAllProvider; } get { return _fixAllProviderInfo.FixAllProvider; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册