@@ -72,15 +72,18 @@ public class QuickFixCommandViewModel : ViewModelBase
72
72
public IQuickFix Fix { get ; }
73
73
public string Key { get ; }
74
74
public ICommand Command { get ; }
75
+ public bool IsVisible { get ; }
75
76
76
77
public QuickFixCommandViewModel (
77
78
IQuickFix fix ,
78
79
string key ,
79
- ICommand command )
80
+ ICommand command ,
81
+ bool isVisible )
80
82
{
81
83
Fix = fix ;
82
84
Key = key ;
83
85
Command = command ;
86
+ IsVisible = isVisible ;
84
87
}
85
88
}
86
89
@@ -142,14 +145,14 @@ public InspectionResultsViewModel(
142
145
CollapseAllCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteCollapseAll ) ;
143
146
ExpandAllCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteExpandAll ) ;
144
147
145
- QuickFixCommands = new List < ( ICommand command , string key ) >
148
+ QuickFixCommands = new List < ( ICommand command , string key , Func < IQuickFix , bool > visibility ) >
146
149
{
147
- ( QuickFixCommand , "QuickFix_Instance" ) ,
148
- ( QuickFixSelectedItemsCommand , "QuickFix_Selection" ) ,
149
- ( QuickFixInProcedureCommand , "QuickFix_ThisProcedure" ) ,
150
- ( QuickFixInModuleCommand , "QuickFix_ThisModule" ) ,
151
- ( QuickFixInProjectCommand , "QuickFix_ThisProject" ) ,
152
- ( QuickFixInAllProjectsCommand , "QuickFix_All" )
150
+ ( QuickFixCommand , "QuickFix_Instance" , quickFix => true ) ,
151
+ ( QuickFixSelectedItemsCommand , "QuickFix_Selection" , quickFix => quickFix . CanFixMultiple ) ,
152
+ ( QuickFixInProcedureCommand , "QuickFix_ThisProcedure" , quickFix => quickFix . CanFixInProcedure ) ,
153
+ ( QuickFixInModuleCommand , "QuickFix_ThisModule" , quickFix => quickFix . CanFixInModule ) ,
154
+ ( QuickFixInProjectCommand , "QuickFix_ThisProject" , quickFix => quickFix . CanFixInProject ) ,
155
+ ( QuickFixInAllProjectsCommand , "QuickFix_All" , quickFix => quickFix . CanFixAll )
153
156
} ;
154
157
155
158
_configService . SettingsChanged += _configService_SettingsChanged ;
@@ -239,11 +242,11 @@ public IEnumerable<QuickFixViewModel> QuickFixes
239
242
}
240
243
}
241
244
242
- private List < ( ICommand command , string key ) > QuickFixCommands { get ; }
245
+ private List < ( ICommand command , string key , Func < IQuickFix , bool > visibility ) > QuickFixCommands { get ; }
243
246
244
247
private QuickFixViewModel DisplayQuickFix ( IQuickFix quickFix , IInspectionResult result )
245
248
{
246
- var commands = QuickFixCommands . Select ( tpl => new QuickFixCommandViewModel ( quickFix , tpl . key , tpl . command ) ) ;
249
+ var commands = QuickFixCommands . Select ( tpl => new QuickFixCommandViewModel ( quickFix , tpl . key , tpl . command , tpl . visibility ( quickFix ) ) ) ;
247
250
return new QuickFixViewModel ( quickFix , result , commands ) ;
248
251
}
249
252
0 commit comments