11using dinfo . core . Utils . Globals ;
22using System . Text ;
3- using System . Text . RegularExpressions ;
3+ using static dinfo . core . Utils . RegularExpressions . RegexHelpers ;
44
55namespace dinfo . core . Helpers . FilesTools ;
66
@@ -15,15 +15,6 @@ public static async Task<int> CountLinesAsync(string fileName, CancellationToken
1515
1616 public static async Task < int > GetCommentsLinesAsync ( string fileName , CancellationToken cancellationToken = default )
1717 {
18- var slashComment = new Regex ( @"^\s*//" ) ; // //
19- var hashComment = new Regex ( @"^\s*#" ) ; // #
20- var multiLineCommentStart = new Regex ( @"^\s*/\*" ) ; // /*
21- var multiLineCommentEnd = new Regex ( @"\s*\*/" ) ; // */
22- var multiLineMarkupStart = new Regex ( @"^\s*<!--" ) ; // <!--
23- var multiLineMarkupEnd = new Regex ( @"\s*-->$" ) ; // -->
24- var dashComment = new Regex ( @"^\s*--" ) ; // --
25- var semicolonComment = new Regex ( @"^\s*;" ) ; // ;
26-
2718 IEnumerable < string > lines = await File . ReadAllLinesAsync ( fileName , cancellationToken ) . ConfigureAwait ( false ) ;
2819
2920 bool inMultiLineComment = false ;
@@ -37,26 +28,26 @@ public static async Task<int> GetCommentsLinesAsync(string fileName, Cancellatio
3728 {
3829 commentLines ++ ;
3930 if (
40- multiLineCommentEnd . IsMatch ( trimmedLine )
41- || multiLineMarkupEnd . IsMatch ( trimmedLine )
31+ MultiLineCommentEnd ( ) . IsMatch ( trimmedLine )
32+ || MultiLineMarkupEnd ( ) . IsMatch ( trimmedLine )
4233 )
4334 {
4435 inMultiLineComment = false ;
4536 }
4637 }
4738 else if (
48- multiLineCommentStart . IsMatch ( trimmedLine )
49- || multiLineMarkupStart . IsMatch ( trimmedLine )
39+ MultiLineCommentStart ( ) . IsMatch ( trimmedLine )
40+ || MultiLineMarkupStart ( ) . IsMatch ( trimmedLine )
5041 )
5142 {
5243 commentLines ++ ;
5344 inMultiLineComment = true ;
5445 }
5546 else if (
56- slashComment . IsMatch ( trimmedLine )
57- || hashComment . IsMatch ( trimmedLine )
58- || dashComment . IsMatch ( trimmedLine )
59- || semicolonComment . IsMatch ( trimmedLine )
47+ SlashComment ( ) . IsMatch ( trimmedLine )
48+ || HashComment ( ) . IsMatch ( trimmedLine )
49+ || DashComment ( ) . IsMatch ( trimmedLine )
50+ || SemicolonComment ( ) . IsMatch ( trimmedLine )
6051 )
6152 {
6253 commentLines ++ ;
0 commit comments