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

Ahmed na

02/06/2023, 11:30 PM
Hi , hope i'm at the right channel Using
KSClassDeclaration
for type
ClassKind.ENUM_CLASS
is it possible to get the names of the enums ?
j

Jiaxiang

02/06/2023, 11:37 PM
from the declaration of the enum class, if you get
KSClassDeclaration.declarations
, you should get a list of declarations inside the enum class, and you can filter instances of
ClassKind.ENUM_ENTRY
to get the enum entries.
a

Ahmed na

02/06/2023, 11:48 PM
thanks for fast replay ! , i found them 😄
Copy code
fun KSClassDeclaration.getEnumEntries(): Sequence<KSDeclaration> {
    return declarations.filter { it.closestClassDeclaration()?.classKind == ClassKind.ENUM_ENTRY }
}
8 Views