1
- using Mono . TextEditor ;
1
+ using LinesCount ;
2
+ using Mono . TextEditor ;
2
3
using MonoDevelop . Core ;
3
4
using MonoDevelop . Ide . Gui ;
4
5
using MonoDevelop . Ide ;
@@ -13,6 +14,8 @@ public class LinesCountWriter
13
14
private TextEditorData textEditorData ;
14
15
private Document linesCountDocument ;
15
16
17
+ int linesOfCode , sourceLines , effectiveLines , commentLines ;
18
+
16
19
/// <summary>
17
20
/// Initializes a new instance of the <see cref="DateInserter.LinesCountWriter"/> class.
18
21
/// </summary>
@@ -23,6 +26,8 @@ public LinesCountWriter(string linesCountDocumentName)
23
26
if ( linesCountDocument == null )
24
27
linesCountDocument = IdeApp . Workbench . NewDocument ( linesCountDocumentName , "text/plain" , "" ) ;
25
28
textEditorData = linesCountDocument . GetContent < ITextEditorDataProvider > ( ) . GetTextEditorData ( ) ;
29
+
30
+ linesOfCode = sourceLines = effectiveLines = commentLines = 0 ;
26
31
}
27
32
28
33
/// <summary>
@@ -32,6 +37,7 @@ public LinesCountWriter(string linesCountDocumentName)
32
37
public void WriteInfoOfSelectedItem ( object selectedItem )
33
38
{
34
39
textEditorData . Document . Text = "" ;
40
+ Write ( String . Format ( " {0, -80} {1, 15} {2, 15} {3, 15} {4, 15}" , "File" , "Lines of code" , "Source lines" , "Effective lines" , "Comment lines" ) ) ;
35
41
36
42
Solution selectedSolution = selectedItem as Solution ;
37
43
if ( selectedSolution != null )
@@ -44,7 +50,7 @@ public void WriteInfoOfSelectedItem(object selectedItem)
44
50
ProjectFile selectedFile = selectedItem as ProjectFile ;
45
51
if ( selectedFile != null )
46
52
ShowProjectFile ( selectedFile ) ;
47
-
53
+ Write ( String . Format ( " {0, -80} {1, 15} {2, 15} {3, 15} {4, 15}" , " " , linesOfCode , sourceLines , effectiveLines , commentLines ) ) ;
48
54
linesCountDocument . Select ( ) ;
49
55
}
50
56
@@ -92,8 +98,15 @@ public static bool IsCSharpFile(ProjectFile projectFile)
92
98
private void WriteFileInfo ( FilePath filePath )
93
99
{
94
100
string [ ] lines = File . ReadAllLines ( filePath . ToString ( ) ) ;
101
+ SourceFile s = new SourceFile ( filePath . ToString ( ) , lines , new CSharpSourceLineAnalyzer ( ) ) ;
95
102
string fittingPath = filePath . ToString ( ) . Length > 80 ? filePath . ToString ( ) . Substring ( 0 , 79 ) : filePath . ToString ( ) ;
96
- string info = String . Format ( "{0, -80} {1, 3}" , fittingPath , lines . Length ) ;
103
+
104
+ linesOfCode += s . LinesOfCode ;
105
+ sourceLines += s . SourceLinesOfCode ;
106
+ effectiveLines += s . EffectiveLinesOfCode ;
107
+ commentLines += s . CommentLines ;
108
+
109
+ string info = String . Format ( "{0, -80} {1, 15} {2, 15} {3, 15} {4, 15}" , fittingPath , s . LinesOfCode , s . SourceLinesOfCode , s . EffectiveLinesOfCode , s . CommentLines ) ;
97
110
Write ( " " + info ) ;
98
111
}
99
112
0 commit comments