Skip to content

Commit aa0ff2b

Browse files
authored
Merge pull request #10129 from tamasvajk/kotlin-fix-comment-type-alias
Kotlin: Extract type alias doc comments
2 parents cede617 + 25098ef commit aa0ff2b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ open class KotlinFileExtractor(
170170
is IrProperty -> return getPropertyLabel(element)
171171
is IrField -> return getFieldLabel(element)
172172
is IrEnumEntry -> return getEnumEntryLabel(element)
173+
is IrTypeAlias -> return getTypeAliasLabel(element)
173174

174175
// Fresh entities:
175176
is IrBody -> return null

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ open class KotlinUsesExtractor(
15741574
fun useEnumEntry(ee: IrEnumEntry): Label<out DbField> =
15751575
tw.getLabelFor(getEnumEntryLabel(ee))
15761576

1577-
private fun getTypeAliasLabel(ta: IrTypeAlias): String {
1577+
fun getTypeAliasLabel(ta: IrTypeAlias): String {
15781578
val parentId = useDeclarationParent(ta.parent, true)
15791579
return "@\"type_alias;{$parentId};${ta.name.asString()}\""
15801580
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ comments
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 */ |
1010
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | /**\n * A variable.\n */ |
11+
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | /**\n * A type alias comment\n */ |
1112
commentOwners
1213
| 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 |
1314
| 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 |
@@ -18,6 +19,7 @@ commentOwners
1819
| comments.kt:35:5:35:34 | /** Medium is in the middle */ | comments.kt:36:5:36:14 | Medium |
1920
| comments.kt:37:5:37:23 | /** This is high */ | comments.kt:38:5:38:11 | High |
2021
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | comments.kt:45:5:45:13 | int a |
22+
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | comments.kt:51:1:51:24 | MyType |
2123
commentSections
2224
| comments.kt:1:1:1:25 | /** Kdoc with no owner */ | Kdoc with no owner |
2325
| 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 |
@@ -28,8 +30,10 @@ commentSections
2830
| comments.kt:35:5:35:34 | /** Medium is in the middle */ | Medium is in the middle |
2931
| comments.kt:37:5:37:23 | /** This is high */ | This is high |
3032
| comments.kt:42:5:44:6 | /**\n * A variable.\n */ | A variable. |
33+
| comments.kt:48:1:50:3 | /**\n * A type alias comment\n */ | A type alias comment |
3134
commentSectionContents
3235
| 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 |
36+
| A type alias comment | A type alias comment |
3337
| A variable. | A variable. |
3438
| Adds a [member] to this group.\n | Adds a [member] to this group.\n |
3539
| Creates an empty group. | Creates an empty group. |

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ fun fn1() {
4444
*/
4545
val a = 1
4646
}
47+
48+
/**
49+
* A type alias comment
50+
*/
51+
typealias MyType = Group

0 commit comments

Comments
 (0)