Skip to content

Commit 3717179

Browse files
cushonkluever
authored andcommitted
Don't reformat javadoc comments with extra *
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=274236131
1 parent 05df9d3 commit 3717179

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ public boolean isSlashStarComment() {
154154

155155
@Override
156156
public boolean isJavadocComment() {
157-
return text.startsWith("/**") && text.length() > 4;
157+
// comments like `/***` are also javadoc, but their formatting probably won't be improved
158+
// by the javadoc formatter
159+
return text.startsWith("/**") && text.charAt("/**".length()) != '*' && text.length() > 4;
158160
}
159161

160162
@Override

core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void empty() {
5050
"class Test {}",
5151
};
5252
String[] expected = {
53-
"/** */", "class Test {}",
53+
"/***/", "class Test {}",
5454
};
5555
doFormatTest(input, expected);
5656
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*************************************************************************************************************************************************************
2+
* Copyright
3+
*
4+
* Some
5+
*
6+
* Company
7+
*************************************************************************************************************************************************************/
8+
class T {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*************************************************************************************************************************************************************
2+
* Copyright
3+
*
4+
* Some
5+
*
6+
* Company
7+
*************************************************************************************************************************************************************/
8+
class T {}

0 commit comments

Comments
 (0)