5
5
using System . ComponentModel ;
6
6
using System . Diagnostics ;
7
7
using System . Globalization ;
8
+ using System . IO ;
8
9
using System . Linq ;
9
10
using System . Threading ;
10
11
using System . Threading . Tasks ;
13
14
using System . Windows . Input ;
14
15
using NLog ;
15
16
using Rubberduck . Common ;
17
+ using Rubberduck . Formatters ;
16
18
using Rubberduck . Inspections . Abstract ;
17
19
using Rubberduck . Interaction . Navigation ;
18
20
using Rubberduck . JunkDrawer . Extensions ;
@@ -666,15 +668,24 @@ private void ExecuteCopyResultsCommand(object parameter)
666
668
return ;
667
669
}
668
670
669
- var resultArray = Results . OfType < IExportable > ( ) . Select ( result => result . ToArray ( ) ) . ToArray ( ) ;
671
+ var resultArray = Results
672
+ . OfType < IInspectionResult > ( )
673
+ . Select ( result => new InspectionResultFormatter ( result , DocumentName ( result ) ) )
674
+ . Select ( formattedResult => formattedResult . ToArray ( ) )
675
+ . ToArray ( ) ;
670
676
671
677
var resource = resultArray . Length == 1
672
678
? Resources . RubberduckUI . CodeInspections_NumberOfIssuesFound_Singular
673
679
: Resources . RubberduckUI . CodeInspections_NumberOfIssuesFound_Plural ;
674
680
675
681
var title = string . Format ( resource , DateTime . Now . ToString ( CultureInfo . InvariantCulture ) , resultArray . Count ( ) ) ;
676
682
677
- var textResults = title + Environment . NewLine + string . Join ( string . Empty , Results . OfType < IExportable > ( ) . Select ( result => result . ToClipboardString ( ) + Environment . NewLine ) . ToArray ( ) ) ;
683
+ var resultTexts = Results
684
+ . OfType < IInspectionResult > ( )
685
+ . Select ( result => new InspectionResultFormatter ( result , DocumentName ( result ) ) )
686
+ . Select ( formattedResult => $ "{ formattedResult . ToClipboardString ( ) } { Environment . NewLine } ")
687
+ . ToArray ( ) ;
688
+ var textResults = $ "{ title } { Environment . NewLine } { string . Join ( string . Empty , resultTexts ) } ";
678
689
var csvResults = ExportFormatter . Csv ( resultArray , title , ColumnInformation ) ;
679
690
var htmlResults = ExportFormatter . HtmlClipboardFragment ( resultArray , title , ColumnInformation ) ;
680
691
var rtfResults = ExportFormatter . RTF ( resultArray , title ) ;
@@ -691,6 +702,20 @@ private void ExecuteCopyResultsCommand(object parameter)
691
702
_clipboard . Flush ( ) ;
692
703
}
693
704
705
+ private string DocumentName ( IInspectionResult result )
706
+ {
707
+ var module = result . QualifiedSelection . QualifiedName ;
708
+ var projectId = module . ProjectId ;
709
+ var project = _state . ProjectsProvider . Project ( projectId ) ;
710
+
711
+ if ( project == null )
712
+ {
713
+ return Path . GetFileName ( module . ProjectPath ) ;
714
+ }
715
+
716
+ return project . ProjectDisplayName ;
717
+ }
718
+
694
719
private bool CanExecuteCopyResultsCommand ( object parameter )
695
720
{
696
721
return ! IsBusy && _results != null && _results . Any ( ) ;
0 commit comments