Skip to content

Commit

Permalink
Strip enough "*"s to turn something into non-Javadoc.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 540839980
  • Loading branch information
graememorgan authored and Error Prone Team committed Jun 16, 2023
1 parent 12b90df commit b42c84f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
if (javadocableTrees.containsKey(token.pos())) {
continue;
}

int endPos = 2;
while (comment.getText().charAt(endPos) == '*') {
endPos++;
}

state.reportMatch(
describeMatch(
getDiagnosticPosition(comment.getSourcePos(0), tree),
replace(comment.getSourcePos(1), comment.getSourcePos(2), "")));
replace(comment.getSourcePos(1), comment.getSourcePos(endPos - 1), "")));
}
}
return NO_MATCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ public void notJavadocOnLocalClass() {
.doTest(TEXT_MATCH);
}

@Test
public void notJavadocWithLotsOfAsterisks() {
helper
.addInputLines(
"Test.java",
"class Test {",
" void test() {",
" /******** Not Javadoc. */",
" class A {}",
" }",
"}")
.addOutputLines(
"Test.java",
"class Test {",
" void test() {",
" /* Not Javadoc. */",
" class A {}",
" }",
"}")
.doTest(TEXT_MATCH);
}

@Test
public void actuallyJavadoc() {
helper
Expand Down

0 comments on commit b42c84f

Please sign in to comment.