Skip to content

Commit 588b108

Browse files
committed
Don't add spaces to //$NON-NLS-x$ comments
Fixes #221 MOE_MIGRATED_REVID=197211890
1 parent 9cf8dc1 commit 588b108

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ private String indentLineComments(List<String> lines, int column0) {
102102
return builder.toString();
103103
}
104104

105+
// Preserve special `//noinspection` and `//$NON-NLS-x$` comments used by IDEs, which cannot
106+
// contain leading spaces.
105107
private static final Pattern LINE_COMMENT_MISSING_SPACE_PREFIX =
106-
Pattern.compile("^(//+)(?!noinspection)[^\\s/]");
108+
Pattern.compile("^(//+)(?!noinspection|\\$NON-NLS-\\d+\\$)[^\\s/]");
107109

108110
private List<String> wrapLineComments(
109111
List<String> lines, int column0, JavaFormatterOptions options) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class I221 {
2+
{
3+
logger.log(
4+
Level.WARNING,
5+
"Unable to obtain jst.web facet version from selected project", //$NON-NLS-1$
6+
ex);
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class I221 {
2+
{
3+
logger.log(
4+
Level.WARNING,
5+
"Unable to obtain jst.web facet version from selected project", //$NON-NLS-1$
6+
ex);
7+
}
8+
}

0 commit comments

Comments
 (0)