Skip to content

Commit ff2509e

Browse files
committed
Replace all comments by whitespace when preprocessing sources
1 parent e9ad9dd commit ff2509e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugins/sources/src/org/graalvm/visualvm/sources/java/JavaSourceUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
final class JavaSourceUtils {
3535

36-
private static final char COMMENT_MASK_CHAR = '-'; // NOI18N
36+
private static final char COMMENT_MASK_CHAR = ' '; // NOI18N
3737
private static final char STRING_MASK_CHAR = '+'; // NOI18N
3838
private static final char NONBLOCK_MASK_CHAR = '='; // NOI18N
3939
private static final char CLASS_MASK_CHAR = '_'; // NOI18N
@@ -154,14 +154,14 @@ static String maskNonCode(String text) {
154154

155155
if (!lineComment && !chardef && !string) {
156156
if (!blockComment && '/' == lastChar && '*' == currentChar) { // NOI18N
157+
newText[position - 1] = COMMENT_MASK_CHAR;
157158
blockComment = true;
158-
} else if (blockComment && '*' == lastChar && '/' == currentChar) { // NOI18N
159-
blockComment = false;
160159
}
161160
}
162161

163162
if (!blockComment && !chardef && !string) {
164163
if (!lineComment && '/' == lastChar && '/' == currentChar) { // NOI18N
164+
newText[position - 1] = COMMENT_MASK_CHAR;
165165
lineComment = true;
166166
} else if (lineComment && ('\r' == currentChar || '\n' == currentChar)) { // NOI18N
167167
lineComment = false;
@@ -203,6 +203,12 @@ static String maskNonCode(String text) {
203203
else if (lineComment || blockComment) newText[position] = COMMENT_MASK_CHAR;
204204
else newText[position] = currentChar;
205205

206+
if (!lineComment && !chardef && !string) {
207+
if (blockComment && '*' == lastChar && '/' == currentChar) { // NOI18N
208+
blockComment = false;
209+
}
210+
}
211+
206212
lastChar = currentChar;
207213
}
208214

0 commit comments

Comments
 (0)