提交 e320cfff 编写于 作者: C CyrusNajmabadi

Clean up code.

上级 1dd8ba21
...@@ -274,7 +274,7 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa ...@@ -274,7 +274,7 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa
{ {
this.AssertIsForeground(); this.AssertIsForeground();
var applicableFixes = collection.Fixes.Where(f => f.Action.IsApplicable(workspace)).ToList(); var applicableFixes = collection.Fixes.Where(f => IsApplicable(f.Action, workspace)).ToList();
return applicableFixes.Count == 0 return applicableFixes.Count == 0
? null ? null
: applicableFixes.Count == collection.Fixes.Length : applicableFixes.Count == collection.Fixes.Length
...@@ -282,6 +282,20 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa ...@@ -282,6 +282,20 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa
: new CodeFixCollection(collection.Provider, collection.TextSpan, applicableFixes, collection.FixAllContext); : new CodeFixCollection(collection.Provider, collection.TextSpan, applicableFixes, collection.FixAllContext);
} }
private bool IsApplicable(CodeAction action, Workspace workspace)
{
if (!action.PerformFinalApplicabilityCheck)
{
// If we don't even need to perform the final applicability check,
// then the code actoin is applicable.
return true;
}
// Otherwise, defer to the action to make the decision.
this.AssertIsForeground();
return action.IsApplicable(workspace);
}
private List<CodeRefactoring> FilterOnUIThread(List<CodeRefactoring> refactorings, Workspace workspace) private List<CodeRefactoring> FilterOnUIThread(List<CodeRefactoring> refactorings, Workspace workspace)
{ {
return refactorings.Select(r => FilterOnUIThread(r, workspace)).WhereNotNull().ToList(); return refactorings.Select(r => FilterOnUIThread(r, workspace)).WhereNotNull().ToList();
...@@ -289,7 +303,7 @@ private List<CodeRefactoring> FilterOnUIThread(List<CodeRefactoring> refactoring ...@@ -289,7 +303,7 @@ private List<CodeRefactoring> FilterOnUIThread(List<CodeRefactoring> refactoring
private CodeRefactoring FilterOnUIThread(CodeRefactoring refactoring, Workspace workspace) private CodeRefactoring FilterOnUIThread(CodeRefactoring refactoring, Workspace workspace)
{ {
var actions = refactoring.Actions.Where(a => a.IsApplicable(workspace)).ToList(); var actions = refactoring.Actions.Where(a => IsApplicable(a, workspace)).ToList();
return actions.Count == 0 return actions.Count == 0
? null ? null
: actions.Count == refactoring.Actions.Count : actions.Count == refactoring.Actions.Count
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册