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

Skip to content

Commit b460c92

Browse files
committed
Kotlin: Add modifiers to object INSTANCEs
1 parent 112fac6 commit b460c92

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,9 @@ open class KotlinFileExtractor(
889889
val type = useSimpleTypeClass(c, emptyList(), false)
890890
tw.writeFields(instance.id, instance.name, type.javaResult.id, type.kotlinResult.id, id, instance.id)
891891
tw.writeHasLocation(instance.id, locId)
892+
tw.writeHasModifier(instance.id, extractModifier("public"))
893+
tw.writeHasModifier(instance.id, extractModifier("static"))
894+
tw.writeHasModifier(instance.id, extractModifier("final"))
892895
@Suppress("UNCHECKED_CAST")
893896
tw.writeClass_object(id as Label<DbClass>, instance.id)
894897
}
@@ -1675,6 +1678,14 @@ open class KotlinFileExtractor(
16751678
}
16761679
}
16771680

1681+
fun extractModifier(m: String): Label<DbModifier> {
1682+
val modifierLabel = "@\"modifier;$m\""
1683+
val id: Label<DbModifier> = tw.getLabelFor(modifierLabel, {
1684+
tw.writeModifiers(it, m)
1685+
})
1686+
return id
1687+
}
1688+
16781689
fun extractTypeAccess(t: IrType, parent: Label<out DbExprparent>, idx: Int, elementForLocation: IrElement) {
16791690
// TODO: elementForLocation allows us to give some sort of
16801691
// location, but a proper location for the type access will
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| objects.kt:2:1:4:1 | MyObject | objects.kt:2:1:4:1 | INSTANCE |
1+
| objects.kt:2:1:4:1 | MyObject | objects.kt:2:1:4:1 | INSTANCE | final,public,static |
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import java
22

3-
from ClassObject co
3+
from ClassObject co, Field f
44
where co.fromSource()
5-
select co, co.getInstance()
5+
and f = co.getInstance()
6+
select co, f, concat(f.getAModifier().toString(), ",")

0 commit comments

Comments
 (0)