@@ -132,6 +132,7 @@ public InspectionResultsViewModel(
132
132
133
133
DisableInspectionCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteDisableInspectionCommand ) ;
134
134
QuickFixCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteQuickFixCommand , CanExecuteQuickFixCommand ) ;
135
+ QuickFixSelectedItemsCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteQuickFixForSelection , CanExecuteQuickFixForSelection ) ;
135
136
QuickFixInProcedureCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteQuickFixInProcedureCommand , CanExecuteQuickFixInProcedure ) ;
136
137
QuickFixInModuleCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteQuickFixInModuleCommand , CanExecuteQuickFixInModule ) ;
137
138
QuickFixInProjectCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , ExecuteQuickFixInProjectCommand , CanExecuteQuickFixInProject ) ;
@@ -144,6 +145,7 @@ public InspectionResultsViewModel(
144
145
QuickFixCommands = new List < ( ICommand command , string key ) >
145
146
{
146
147
( QuickFixCommand , "QuickFix_Instance" ) ,
148
+ ( QuickFixSelectedItemsCommand , "QuickFix_Selection" ) ,
147
149
( QuickFixInProcedureCommand , "QuickFix_ThisProcedure" ) ,
148
150
( QuickFixInModuleCommand , "QuickFix_ThisModule" ) ,
149
151
( QuickFixInProjectCommand , "QuickFix_ThisProject" ) ,
@@ -339,6 +341,7 @@ private bool InspectionFilter(IInspectionResult result)
339
341
public INavigateCommand NavigateCommand { get ; }
340
342
public CommandBase RefreshCommand { get ; }
341
343
public CommandBase QuickFixCommand { get ; }
344
+ public CommandBase QuickFixSelectedItemsCommand { get ; }
342
345
public CommandBase QuickFixInProcedureCommand { get ; }
343
346
public CommandBase QuickFixInModuleCommand { get ; }
344
347
public CommandBase QuickFixInProjectCommand { get ; }
@@ -544,52 +547,92 @@ private void InvalidateStaleInspectionResults(ICollection<QualifiedModuleName> m
544
547
545
548
private void ExecuteQuickFixCommand ( object parameter )
546
549
{
547
- if ( ! ( parameter is IQuickFix quickFix )
550
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl )
548
551
|| ! ( SelectedItem is IInspectionResult inspectionResult ) )
549
552
{
550
553
return ;
551
554
}
552
555
556
+ var ( quickFix , _) = tpl ;
557
+
553
558
_quickFixProvider . Fix ( quickFix , inspectionResult ) ;
554
559
}
555
560
556
561
private bool CanExecuteQuickFixCommand ( object parameter )
557
562
{
558
- return ! IsBusy
559
- && parameter is IQuickFix
560
- && _state . Status == ParserState . Ready ;
563
+ return ! IsBusy
564
+ && _state . Status == ParserState . Ready
565
+ && parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > ;
566
+ }
567
+
568
+ private void ExecuteQuickFixForSelection ( object parameter )
569
+ {
570
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
571
+ {
572
+ return ;
573
+ }
574
+
575
+ var ( quickFix , selectedItems ) = tpl ;
576
+
577
+ _quickFixProvider . Fix (
578
+ quickFix ,
579
+ selectedItems ) ;
580
+ }
581
+
582
+ public bool CanExecuteQuickFixForSelection ( object parameter )
583
+ {
584
+ if ( ! CanExecuteQuickFixCommand ( parameter )
585
+ || ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
586
+ {
587
+ return false ;
588
+ }
589
+
590
+ var ( quickFix , selectedItems ) = tpl ;
591
+
592
+ return quickFix . CanFixMultiple
593
+ && ( selectedItems ? . All ( result => _quickFixProvider . CanFix ( quickFix , result ) ) ?? false ) ;
561
594
}
562
595
563
596
private void ExecuteQuickFixInProcedureCommand ( object parameter )
564
597
{
565
- if ( ! ( parameter is IQuickFix quickFix )
598
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl )
566
599
|| ! ( SelectedItem is IInspectionResult inspectionResult ) )
567
600
{
568
601
return ;
569
602
}
570
603
604
+ var ( quickFix , _) = tpl ;
605
+
571
606
_quickFixProvider . FixInProcedure (
572
- quickFix ,
607
+ quickFix ,
573
608
inspectionResult . QualifiedMemberName ,
574
- inspectionResult . Inspection . GetType ( ) ,
609
+ inspectionResult . Inspection . GetType ( ) ,
575
610
Results . OfType < IInspectionResult > ( ) ) ;
576
611
}
577
612
578
613
public bool CanExecuteQuickFixInProcedure ( object parameter )
579
614
{
580
- return CanExecuteQuickFixCommand ( parameter )
581
- && parameter is IQuickFix quickFix
582
- && quickFix . CanFixInProcedure ;
615
+ if ( ! CanExecuteQuickFixCommand ( parameter )
616
+ || ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
617
+ {
618
+ return false ;
619
+ }
620
+
621
+ var ( quickFix , _) = tpl ;
622
+
623
+ return quickFix . CanFixInProcedure ;
583
624
}
584
625
585
626
private void ExecuteQuickFixInModuleCommand ( object parameter )
586
627
{
587
- if ( ! ( parameter is IQuickFix quickFix )
628
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl )
588
629
|| ! ( SelectedItem is IInspectionResult inspectionResult ) )
589
630
{
590
631
return ;
591
632
}
592
633
634
+ var ( quickFix , _) = tpl ;
635
+
593
636
_quickFixProvider . FixInModule (
594
637
quickFix ,
595
638
inspectionResult . QualifiedSelection ,
@@ -599,19 +642,27 @@ private void ExecuteQuickFixInModuleCommand(object parameter)
599
642
600
643
public bool CanExecuteQuickFixInModule ( object parameter )
601
644
{
602
- return CanExecuteQuickFixCommand ( parameter )
603
- && parameter is IQuickFix quickFix
604
- && quickFix . CanFixInModule ;
645
+ if ( ! CanExecuteQuickFixCommand ( parameter )
646
+ || ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
647
+ {
648
+ return false ;
649
+ }
650
+
651
+ var ( quickFix , _) = tpl ;
652
+
653
+ return quickFix . CanFixInModule ;
605
654
}
606
655
607
656
private void ExecuteQuickFixInProjectCommand ( object parameter )
608
657
{
609
- if ( ! ( parameter is IQuickFix quickFix )
658
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl )
610
659
|| ! ( SelectedItem is IInspectionResult inspectionResult ) )
611
660
{
612
661
return ;
613
662
}
614
663
664
+ var ( quickFix , _) = tpl ;
665
+
615
666
_quickFixProvider . FixInProject (
616
667
quickFix ,
617
668
inspectionResult . QualifiedSelection ,
@@ -621,19 +672,27 @@ private void ExecuteQuickFixInProjectCommand(object parameter)
621
672
622
673
public bool CanExecuteQuickFixInProject ( object parameter )
623
674
{
624
- return CanExecuteQuickFixCommand ( parameter )
625
- && parameter is IQuickFix quickFix
626
- && quickFix . CanFixInProject ;
675
+ if ( ! CanExecuteQuickFixCommand ( parameter )
676
+ || ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
677
+ {
678
+ return false ;
679
+ }
680
+
681
+ var ( quickFix , _) = tpl ;
682
+
683
+ return quickFix . CanFixInProject ;
627
684
}
628
685
629
686
private void ExecuteQuickFixInAllProjectsCommand ( object parameter )
630
687
{
631
- if ( ! ( parameter is IQuickFix quickFix )
688
+ if ( ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl )
632
689
|| ! ( SelectedItem is IInspectionResult inspectionResult ) )
633
690
{
634
691
return ;
635
692
}
636
693
694
+ var ( quickFix , _) = tpl ;
695
+
637
696
_quickFixProvider . FixAll (
638
697
quickFix ,
639
698
inspectionResult . Inspection . GetType ( ) ,
@@ -642,9 +701,15 @@ private void ExecuteQuickFixInAllProjectsCommand(object parameter)
642
701
643
702
public bool CanExecuteQuickFixAll ( object parameter )
644
703
{
645
- return CanExecuteQuickFixCommand ( parameter )
646
- && parameter is IQuickFix quickFix
647
- && quickFix . CanFixAll ;
704
+ if ( ! CanExecuteQuickFixCommand ( parameter )
705
+ || ! ( parameter is ValueTuple < IQuickFix , IEnumerable < IInspectionResult > > tpl ) )
706
+ {
707
+ return false ;
708
+ }
709
+
710
+ var ( quickFix , _) = tpl ;
711
+
712
+ return quickFix . CanFixAll ;
648
713
}
649
714
650
715
private void ExecuteDisableInspectionCommand ( object parameter )
0 commit comments