@@ -37,16 +37,11 @@ public static List<FileElement> parseFileLines(String fileName, List<String> lin
37
37
var line = lines .get (i );
38
38
String content = removeComments (line );
39
39
40
- if (content == null ) {
41
- content = line .replace ("##" , "#" ).strip ();
42
- }
43
- else if (content .isEmpty ()) {
40
+ if (content .isEmpty ()) {
44
41
elements .add (new VoidElement (fileName , lastLine + i , expectedIndentation ));
45
42
continue ;
46
43
}
47
44
48
- //System.out.println(content);
49
-
50
45
var lineIndentation = FileUtils .getIndentationLevel (line , false );
51
46
if (lineIndentation > expectedIndentation ) { // The line is indented too much
52
47
logger .error (
@@ -102,19 +97,17 @@ private static String removeComments(String string) {
102
97
for (char c : string .toCharArray ()) {
103
98
if (c == '#' ) {
104
99
int index = string .indexOf (c );
105
- //System.out.println(c + " : " + COMMENT_STATUS) ;
106
- //Checking if it isn't color hex and if no double # (for escaping first #)
107
- for ( int i : new int []{ 3 , 6 , 9 }) {
108
- if ( index + i <= string . length ())
109
- if (!Color .COLOR_PATTERN .matcher (string .substring (index , index + i )).matches () || string . charAt ( index + 1 ) != '#' ) {
100
+ if ( index + 1 >= string . length ()) return "" ;
101
+ if ( string . charAt ( index + 1 ) != '#' ) { // double # escape the first #
102
+ //Checking if it isn't color hex and if no double # (for escaping first #)
103
+ for ( int i : new int []{ 3 , 6 , 9 }) {
104
+ if (index + i <= string . length () - 1 && !Color .COLOR_PATTERN .matcher (string .substring (index + 1 , index + i + 1 )).matches ())
110
105
COMMENT_STATUS = 1 ;
111
- System .out .println (COMMENT_STATUS );
112
- }
106
+ }
113
107
}
114
- //System.out.println(string.substring(index, index + 2));
108
+ //set start or end of a block comment ("###" characters)
115
109
if (index + 2 <= string .length () && string .substring (index , index + 2 ).equals ("##" )) {
116
110
COMMENT_STATUS = COMMENT_STATUS == 2 ? 0 : 2 ;
117
- System .out .println (COMMENT_STATUS );
118
111
}
119
112
120
113
}
@@ -123,7 +116,6 @@ private static String removeComments(String string) {
123
116
}
124
117
}
125
118
if (COMMENT_STATUS == 1 ) COMMENT_STATUS = 0 ;
126
- //System.out.println(stringBuilder.toString());
127
119
return stringBuilder .toString ().strip ();
128
120
129
121
}
0 commit comments