Can we read value of a variable in a class using KSP?

115 views Asked by At

I have a class which has some variables, can we use kotlin symbol processing api to somehow read the value of the variable declared in the class?

resolver.getDeclarationsFromPackage("com.example")
            .filter { it is KSClassDeclaration }
            .iterator().forEach {
                val cls = it as KSClassDeclaration
                cls.getDeclaredProperties().first()
                }
1

There are 1 answers

0
Sid.The.Biker On BEST ANSWER

As of today, KSP doesn't provide the functionality to read the content of the values. However, an exception to this limitation is for Annotation classes, where you can read the arguments values.