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 {
33
33
string getAuthor ( ) { result = this .getATag ( "@author" ) .getChild ( 0 ) .toString ( ) }
34
34
35
35
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
+ )
37
41
}
38
42
39
43
private string toStringPrefix ( ) {
@@ -48,7 +52,7 @@ class Javadoc extends JavadocParent, @javadoc {
48
52
if isEolComment ( this )
49
53
then result = ""
50
54
else (
51
- if strictcount ( this .getAChild ( ) ) = 1 then result = " */" else result = " ... */"
55
+ if strictcount ( this .getAChild ( ) ) > 1 then result = " ... */" else result = " */"
52
56
)
53
57
}
54
58
Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ Test.java:
14
14
# 21| 3: [Method] test
15
15
# 21| 3: [TypeAccess] void
16
16
# 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] { ... }
17
29
TestWindows.java:
18
30
# 0| [CompilationUnit] TestWindows
19
31
# 5| 1: [Class] TestWindows
Original file line number Diff line number Diff line change @@ -19,4 +19,11 @@ void m() {
19
19
// an end-of-line comment with trailing whitespace
20
20
//an end-of-line comment without a leading space
21
21
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 () { }
22
29
}
Original file line number Diff line number Diff line change 8
8
| Test.java:19:2:19:59 | // an end-of-line comment with trailing whitespace |
9
9
| Test.java:20:2:20:49 | //an end-of-line comment without a leading space |
10
10
| 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 */ |
11
14
| TestWindows.java:1:1:4:3 | /** A JavaDoc comment ... */ |
12
15
| TestWindows.java:6:2:6:45 | /** A JavaDoc comment with a single line. */ |
13
16
| TestWindows.java:8:3:8:27 | // a single-line comment |
You can’t perform that action at this time.
0 commit comments