Skip to content

Commit 46c52ae

Browse files
committed
Kotlin: Add test for doc comment on local functions
1 parent 6576f19 commit 46c52ae

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

java/ql/test/kotlin/library-tests/comments/comments.expected

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ comments
77
| comments.kt:28:5:30:6 | /*\n A block comment\n */ | /*\n A block comment\n */ |
88
| comments.kt:35:5:35:34 | /** Medium is in the middle */ | /** Medium is in the middle */ |
99
| comments.kt:37:5:37:23 | /** This is high */ | /** This is high */ |
10-
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | /**\n * A variable.\n */ |
10+
| comments.kt:42:5:44:7 | /**\n * A variable.\n */ | /**\n * A variable.\n */ |
1111
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | /**\n * A type alias comment\n */ |
1212
| comments.kt:54:5:56:7 | /**\n * An init block comment\n */ | /**\n * An init block comment\n */ |
13+
| comments.kt:61:5:63:7 | /**\n * A prop comment\n */ | /**\n * A prop comment\n */ |
14+
| comments.kt:65:9:67:11 | /**\n * An accessor comment\n */ | /**\n * An accessor comment\n */ |
15+
| comments.kt:71:9:73:11 | /**\n * An anonymous function comment\n */ | /**\n * An anonymous function comment\n */ |
16+
| comments.kt:79:9:81:11 | /**\n * A local function comment\n */ | /**\n * A local function comment\n */ |
1317
commentOwners
1418
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | Group |
1519
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | comments.kt:12:1:31:1 | Group |
@@ -19,9 +23,19 @@ commentOwners
1923
| comments.kt:19:5:22:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | comments.kt:23:5:26:5 | add |
2024
| comments.kt:35:5:35:34 | /** Medium is in the middle */ | comments.kt:36:5:36:14 | Medium |
2125
| comments.kt:37:5:37:23 | /** This is high */ | comments.kt:38:5:38:11 | High |
22-
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | comments.kt:45:5:45:13 | int a |
26+
| comments.kt:42:5:44:7 | /**\n * A variable.\n */ | comments.kt:45:5:45:13 | int a |
2327
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | comments.kt:51:1:51:24 | MyType |
2428
| comments.kt:54:5:56:7 | /**\n * An init block comment\n */ | comments.kt:53:1:58:1 | InitBlock |
29+
| comments.kt:61:5:63:7 | /**\n * A prop comment\n */ | comments.kt:64:5:68:17 | prop |
30+
| comments.kt:65:9:67:11 | /**\n * An accessor comment\n */ | comments.kt:68:9:68:17 | getProp |
31+
| comments.kt:71:9:73:11 | /**\n * An anonymous function comment\n */ | comments.kt:70:5:76:10 | getL |
32+
| comments.kt:71:9:73:11 | /**\n * An anonymous function comment\n */ | comments.kt:70:5:76:10 | l |
33+
| comments.kt:71:9:73:11 | /**\n * An anonymous function comment\n */ | comments.kt:70:5:76:10 | l |
34+
commentNoOwners
35+
| comments.kt:1:1:1:25 | /** Kdoc with no owner */ |
36+
| comments.kt:24:9:24:25 | // A line comment |
37+
| comments.kt:28:5:30:6 | /*\n A block comment\n */ |
38+
| comments.kt:79:9:81:11 | /**\n * A local function comment\n */ |
2539
commentSections
2640
| comments.kt:1:1:1:25 | /** Kdoc with no owner */ | Kdoc with no owner |
2741
| comments.kt:4:1:11:3 | /**\n * A group of *members*.\n *\n * This class has no useful logic; it's just a documentation example.\n *\n * @property name the name of this group.\n * @constructor Creates an empty group.\n */ | A group of *members*.\n\nThis class has no useful logic; it's just a documentation example.\n\n |
@@ -31,14 +45,22 @@ commentSections
3145
| comments.kt:19:5:22:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | Adds a [member] to this group.\n |
3246
| comments.kt:35:5:35:34 | /** Medium is in the middle */ | Medium is in the middle |
3347
| comments.kt:37:5:37:23 | /** This is high */ | This is high |
34-
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | A variable. |
48+
| comments.kt:42:5:44:7 | /**\n * A variable.\n */ | A variable. |
3549
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | A type alias comment |
3650
| comments.kt:54:5:56:7 | /**\n * An init block comment\n */ | An init block comment |
51+
| comments.kt:61:5:63:7 | /**\n * A prop comment\n */ | A prop comment |
52+
| comments.kt:65:9:67:11 | /**\n * An accessor comment\n */ | An accessor comment |
53+
| comments.kt:71:9:73:11 | /**\n * An anonymous function comment\n */ | An anonymous function comment |
54+
| comments.kt:79:9:81:11 | /**\n * A local function comment\n */ | A local function comment |
3755
commentSectionContents
3856
| A group of *members*.\n\nThis class has no useful logic; it's just a documentation example.\n\n | A group of *members*.\n\nThis class has no useful logic; it's just a documentation example.\n\n |
57+
| A local function comment | A local function comment |
58+
| A prop comment | A prop comment |
3959
| A type alias comment | A type alias comment |
4060
| A variable. | A variable. |
4161
| Adds a [member] to this group.\n | Adds a [member] to this group.\n |
62+
| An accessor comment | An accessor comment |
63+
| An anonymous function comment | An anonymous function comment |
4264
| An init block comment | An init block comment |
4365
| Creates an empty group. | Creates an empty group. |
4466
| Kdoc with no owner | Kdoc with no owner |

java/ql/test/kotlin/library-tests/comments/comments.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum class Severity(val sev: Int) {
4141
fun fn1() {
4242
/**
4343
* A variable.
44-
*/
44+
*/
4545
val a = 1
4646
}
4747

@@ -56,3 +56,29 @@ class InitBlock {
5656
*/
5757
init { }
5858
}
59+
60+
class X {
61+
/**
62+
* A prop comment
63+
*/
64+
val prop: Int
65+
/**
66+
* An accessor comment
67+
*/
68+
get() = 5
69+
70+
val l: Lazy<Int> = lazy(
71+
/**
72+
* An anonymous function comment
73+
*/
74+
fun(): Int {
75+
return 5
76+
})
77+
78+
fun fn() {
79+
/**
80+
* A local function comment
81+
*/
82+
fun localFn() {}
83+
}
84+
}

java/ql/test/kotlin/library-tests/comments/comments.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ query predicate comments(KtComment c, string s) { c.getText() = s }
44

55
query predicate commentOwners(KtComment c, Top t) { c.getOwner() = t }
66

7+
query predicate commentNoOwners(KtComment c) { not exists(c.getOwner()) }
8+
79
query predicate commentSections(KtComment c, KtCommentSection s) { c.getSections() = s }
810

911
query predicate commentSectionContents(KtCommentSection s, string c) { s.getContent() = c }

0 commit comments

Comments
 (0)