From e320cfff7df946f91d089af374f5bf6f35201250 Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Wed, 17 Feb 2016 13:28:19 -0800 Subject: [PATCH] Clean up code. --- .../SuggestedActionsSourceProvider.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs b/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs index cfde85f9cdf..9e648050507 100644 --- a/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Suggestions/SuggestedActionsSourceProvider.cs @@ -274,7 +274,7 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa { 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 ? null : applicableFixes.Count == collection.Fixes.Length @@ -282,6 +282,20 @@ private CodeFixCollection FilterOnUIThread(CodeFixCollection collection, Workspa : 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 FilterOnUIThread(List refactorings, Workspace workspace) { return refactorings.Select(r => FilterOnUIThread(r, workspace)).WhereNotNull().ToList(); @@ -289,7 +303,7 @@ private List FilterOnUIThread(List refactoring 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 ? null : actions.Count == refactoring.Actions.Count -- GitLab