Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb89b25

Browse files
committed
Kotlin: More expressions
1 parent 1de12e7 commit bb89b25

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,20 @@ class KotlinFileExtractor(val tw: TrapWriter) {
471471
tw.writeExprs_booleanliteral(id, typeId, parent, idx)
472472
tw.writeHasLocation(id, locId)
473473
tw.writeNamestrings(v.toString(), v.toString(), id)
474+
} is Char -> {
475+
val id = tw.getFreshIdLabel<DbCharacterliteral>()
476+
val typeId = useType(e.type)
477+
val locId = tw.getLocation(e.startOffset, e.endOffset)
478+
tw.writeExprs_characterliteral(id, typeId, parent, idx)
479+
tw.writeHasLocation(id, locId)
480+
tw.writeNamestrings(v.toString(), v.toString(), id)
481+
} is String -> {
482+
val id = tw.getFreshIdLabel<DbStringliteral>()
483+
val typeId = useType(e.type)
484+
val locId = tw.getLocation(e.startOffset, e.endOffset)
485+
tw.writeExprs_stringliteral(id, typeId, parent, idx)
486+
tw.writeHasLocation(id, locId)
487+
tw.writeNamestrings(v.toString(), v.toString(), id)
474488
} else -> {
475489
if(v == null) {
476490
extractorBug("Unrecognised IrConst: null value")

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@
3232
| exprs.kt:20:20:20:20 | y |
3333
| exprs.kt:23:14:23:17 | true |
3434
| exprs.kt:24:14:24:18 | false |
35-
| exprs.kt:28:12:28:14 | 123 |
36-
| exprs.kt:28:12:28:20 | ... + ... |
37-
| exprs.kt:28:18:28:20 | 456 |
35+
| exprs.kt:28:13:28:15 | x |
36+
| exprs.kt:29:16:29:25 | string lit |
37+
| exprs.kt:30:12:30:14 | 123 |
38+
| exprs.kt:30:12:30:20 | ... + ... |
39+
| exprs.kt:30:18:30:20 | 456 |
3840
| file://:0:0:0:0 | b1 |
3941
| file://:0:0:0:0 | b2 |
4042
| file://:0:0:0:0 | b3 |
4143
| file://:0:0:0:0 | b4 |
4244
| file://:0:0:0:0 | b5 |
45+
| file://:0:0:0:0 | c |
4346
| file://:0:0:0:0 | i1 |
4447
| file://:0:0:0:0 | i2 |
4548
| file://:0:0:0:0 | i3 |
@@ -60,3 +63,4 @@
6063
| file://:0:0:0:0 | i18 |
6164
| file://:0:0:0:0 | i20 |
6265
| file://:0:0:0:0 | i21 |
66+
| file://:0:0:0:0 | str |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fun topLevelMethod(x: Int, y: Int): Int {
2525
val b3 = b1 && b2
2626
val b4 = b1 || b2
2727
val b5 = !b1
28+
val c = 'x'
29+
val str = "string lit"
2830
return 123 + 456
2931
}
3032

0 commit comments

Comments
 (0)