File tree Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Expand file tree Collapse file tree 5 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ category : fix
3+ ---
4+ * We now correctly handle empty block comments, like ` /**/ ` . Previously these could be mistaken for Javadoc comments and led to attribution of Javadoc tags to the wrong declaration.
Original file line number Diff line number Diff line change @@ -33,7 +33,11 @@ class Javadoc extends JavadocParent, @javadoc {
3333 string getAuthor ( ) { result = this .getATag ( "@author" ) .getChild ( 0 ) .toString ( ) }
3434
3535 override string toString ( ) {
36- result = this .toStringPrefix ( ) + this .getChild ( 0 ) + this .toStringPostfix ( )
36+ exists ( string childStr |
37+ if exists ( this .getChild ( 0 ) ) then childStr = this .getChild ( 0 ) .toString ( ) else childStr = ""
38+ |
39+ result = this .toStringPrefix ( ) + childStr + this .toStringPostfix ( )
40+ )
3741 }
3842
3943 private string toStringPrefix ( ) {
@@ -48,7 +52,7 @@ class Javadoc extends JavadocParent, @javadoc {
4852 if isEolComment ( this )
4953 then result = ""
5054 else (
51- if strictcount ( this .getAChild ( ) ) = 1 then result = " */" else result = " ... */"
55+ if strictcount ( this .getAChild ( ) ) > 1 then result = " ... */" else result = " */"
5256 )
5357 }
5458
Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ Test.java:
1414# 21| 3: [Method] test
1515# 21| 3: [TypeAccess] void
1616# 21| 5: [BlockStmt] { ... }
17+ # 23| 4: [Method] method1
18+ # 23| 3: [TypeAccess] void
19+ # 23| 5: [BlockStmt] { ... }
20+ # 24| 5: [Method] method2
21+ # 24| 3: [TypeAccess] void
22+ # 24| 5: [BlockStmt] { ... }
23+ # 28| 6: [Method] method3
24+ #-----| 0: (Javadoc)
25+ # 25| 1: [Javadoc] /** JavaDoc for method3 */
26+ # 26| 0: [JavadocText] JavaDoc for method3
27+ # 28| 3: [TypeAccess] void
28+ # 28| 5: [BlockStmt] { ... }
1729TestWindows.java:
1830# 0| [CompilationUnit] TestWindows
1931# 5| 1: [Class] TestWindows
Original file line number Diff line number Diff line change @@ -19,4 +19,11 @@ void m() {
1919 // an end-of-line comment with trailing whitespace
2020 //an end-of-line comment without a leading space
2121 void test () {} // an end-of-line comment with preceding code
22+
23+ void method1 () { /**/ } // A block comment containing the /** JavaDoc prefix }
24+ void method2 () { }
25+ /**
26+ * JavaDoc for method3
27+ */
28+ void method3 () { }
2229}
Original file line number Diff line number Diff line change 88| Test.java:19:2:19:59 | // an end-of-line comment with trailing whitespace |
99| Test.java:20:2:20:49 | //an end-of-line comment without a leading space |
1010| Test.java:21:17:21:61 | // an end-of-line comment with preceding code |
11+ | Test.java:23:26:23:29 | /* */ |
12+ | Test.java:23:33:23:86 | // A block comment containing the /** JavaDoc prefix } |
13+ | Test.java:25:9:27:11 | /** JavaDoc for method3 */ |
1114| TestWindows.java:1:1:4:3 | /** A JavaDoc comment ... */ |
1215| TestWindows.java:6:2:6:45 | /** A JavaDoc comment with a single line. */ |
1316| TestWindows.java:8:3:8:27 | // a single-line comment |
You can’t perform that action at this time.
0 commit comments