Skip to content

Commit 4a75e24

Browse files
authored
Merge pull request github#108 from github/kotlin-extract-fields
Allow associating comments with fields
2 parents ef29c65 + ea76455 commit 4a75e24

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ open class KotlinFileExtractor(
10401040
is IrFunction -> return getFunctionLabel(element)
10411041
is IrValueParameter -> return getValueParameterLabel(element)
10421042
is IrProperty -> return getPropertyLabel(element)
1043+
is IrField -> return getFieldLabel(element)
10431044

10441045
// Fresh entities:
10451046
is IrBody -> return null

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
comments
22
| comments.kt:1:1:1:25 | /** Kdoc with no owner */ | /** Kdoc with no owner */ |
33
| 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 */ | /**\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 */ |
4-
| comments.kt:13:5:16:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ |
5-
| comments.kt:18:9:18:25 | // A line comment | // A line comment |
6-
| comments.kt:22:5:24:6 | /*\n A block comment\n */ | /*\n A block comment\n */ |
4+
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | /**\n * Members of this group.\n */ |
5+
| comments.kt:19:5:22:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ |
6+
| comments.kt:24:9:24:25 | // A line comment | // A line comment |
7+
| comments.kt:28:5:30:6 | /*\n A block comment\n */ | /*\n A block comment\n */ |
78
commentOwners
8-
| 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:25:1 | Group |
9-
| 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:25:1 | Group |
10-
| 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:25:1 | equals |
11-
| 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:25:1 | hashCode |
12-
| 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:25:1 | other |
13-
| 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:25:1 | toString |
14-
| comments.kt:13:5:16:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | comments.kt:17:5:20:5 | add |
9+
| 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 |
10+
| 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 |
11+
| 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 | equals |
12+
| 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 | hashCode |
13+
| 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 | other |
14+
| 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 | toString |
15+
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:5:17:46 | members |
16+
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:5:17:46 | members |
17+
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | comments.kt:17:13:17:46 | <get-members> |
18+
| 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 |
1519
commentSections
1620
| comments.kt:1:1:1:25 | /** Kdoc with no owner */ | Kdoc with no owner |
1721
| 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 |
1822
| 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 */ | Creates an empty group. |
1923
| 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 */ | the name of this group. |
20-
| comments.kt:13:5:16:7 | /**\n * Adds a [member] to this group.\n * @return the new size of the group.\n */ | Adds a [member] to this group.\n |
24+
| comments.kt:14:5:16:7 | /**\n * Members of this group.\n */ | Members of this group. |
25+
| 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 |
2126
commentSectionContents
2227
| 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 |
2328
| Adds a [member] to this group.\n | Adds a [member] to this group.\n |
2429
| Creates an empty group. | Creates an empty group. |
2530
| Kdoc with no owner | Kdoc with no owner |
31+
| Members of this group. | Members of this group. |
2632
| the name of this group. | the name of this group. |
2733
commentSectionNames
2834
| Creates an empty group. | constructor |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ package foo.bar
1010
* @constructor Creates an empty group.
1111
*/
1212
class Group(val name: String) {
13+
14+
/**
15+
* Members of this group.
16+
*/
17+
private val members = mutableListOf<Any>()
18+
1319
/**
1420
* Adds a [member] to this group.
1521
* @return the new size of the group.

0 commit comments

Comments
 (0)