https://kotlinlang.org logo
#ksp
Title
# ksp
l

Lamberto Basti

01/17/2023, 8:51 AM
Given the object
User
:
Copy code
@RestRepository
object Users : Table() {
    // ...
    val cityId: Column<Int?> = integer("cityId").references(Cities.id).nullable()

    override val primaryKey = PrimaryKey(email, name = "PK_email")
}

@RestRepository
object Cities : Table() {
    val id = integer("id").autoIncrement() // Column<Int>
    val name = varchar("name", 50) // Column<String>

    override val primaryKey = PrimaryKey(id, name = "PK_Cities_ID")
}
Is it possible to analyze the initialization of
cityId
? I am interested in detecting
refenreces(Cities.id)
and in
Cities.id
. I am processing
@RestRepository
d

David Rawson

01/17/2023, 9:01 AM
e

ephemient

01/17/2023, 9:13 AM
you could maybe sorta hack it with
val (filePath, lineNumber) = symbol.location as FileLocation
and reading the source yourself, but that is outside the scope of KSP
l

Lamberto Basti

01/17/2023, 4:46 PM
i went for an additiona annotation anyway for other reasons. Thanks anyway 🙂
4 Views