Skip to content

Commit b42c84f

Browse files
graememorganError Prone Team
authored and
Error Prone Team
committed
Strip enough "*"s to turn something into non-Javadoc.
PiperOrigin-RevId: 540839980
1 parent 12b90df commit b42c84f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

core/src/main/java/com/google/errorprone/bugpatterns/javadoc/NotJavadoc.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
6464
if (javadocableTrees.containsKey(token.pos())) {
6565
continue;
6666
}
67+
68+
int endPos = 2;
69+
while (comment.getText().charAt(endPos) == '*') {
70+
endPos++;
71+
}
72+
6773
state.reportMatch(
6874
describeMatch(
6975
getDiagnosticPosition(comment.getSourcePos(0), tree),
70-
replace(comment.getSourcePos(1), comment.getSourcePos(2), "")));
76+
replace(comment.getSourcePos(1), comment.getSourcePos(endPos - 1), "")));
7177
}
7278
}
7379
return NO_MATCH;

core/src/test/java/com/google/errorprone/bugpatterns/javadoc/NotJavadocTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ public void notJavadocOnLocalClass() {
8686
.doTest(TEXT_MATCH);
8787
}
8888

89+
@Test
90+
public void notJavadocWithLotsOfAsterisks() {
91+
helper
92+
.addInputLines(
93+
"Test.java",
94+
"class Test {",
95+
" void test() {",
96+
" /******** Not Javadoc. */",
97+
" class A {}",
98+
" }",
99+
"}")
100+
.addOutputLines(
101+
"Test.java",
102+
"class Test {",
103+
" void test() {",
104+
" /* Not Javadoc. */",
105+
" class A {}",
106+
" }",
107+
"}")
108+
.doTest(TEXT_MATCH);
109+
}
110+
89111
@Test
90112
public void actuallyJavadoc() {
91113
helper

0 commit comments

Comments
 (0)