Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState s
}
var message =
seeminglyJavadocableTrees.contains(token.pos())
? "This comment seems to be attached to a method or class, but methods and classes"
+ " nested within methods cannot be documented with Javadoc."
? "Local classes (or methods within local classes) cannot be documented with"
+ " Javadoc."
: message();
state.reportMatch(
buildDescription(getDiagnosticPosition(comment.getSourcePos(0), tree))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void nestedClass() {
"""
class Test {
void test() {
// BUG: Diagnostic contains: nested
// BUG: Diagnostic contains: Local classes
/** Not Javadoc. */
class A {}
}
Expand All @@ -72,6 +72,25 @@ class A {}
.doTest();
}

@Test
public void nestedClassWithMethod() {
// TODO(kak): we should also fix the "javadocs" on the method inside the local class
compilationHelper
.addSourceLines(
"Test.java",
"""
class Test {
void test() {
class A {
/** Not Javadoc. */
void method() {}
}
}
}
""")
.doTest();
}

@Test
public void doubleJavadoc() {
helper
Expand All @@ -97,17 +116,24 @@ public void notJavadocOnLocalClass() {
class Test {
void test() {
/** Not Javadoc. */
class A {}
class A {
/** Not Javadoc. */
void method() {}
}
}
}
""")
// TODO(kak): we should also fix the "javadocs" on the method inside the local class
.addOutputLines(
"Test.java",
"""
class Test {
void test() {
/* Not Javadoc. */
class A {}
class A {
/** Not Javadoc. */
void method() {}
}
}
}
""")
Expand Down
Loading