I am trying to look into properties of a type in K...
# ksp
p
I am trying to look into properties of a type in KSP and have an element which is KSReferenceElement. I can get the simple name of the type, but can't find a way how to get a fully qualified name, or package...all I am getting is the fully qualified name of the symbol (i.e. com.google.devtools.ksp.symbol.impl.kotlin.KSNameImpl) not the type it represents.
data class InspectedClass(var property1: com.mypackage.SomePropertyType) {}
I can get name SomePropertyType but not the package "com.mypackage". Any ideas?
d
How did you end up with the
KSReferenceElement
? Assuming you have a handle on your data class as a
ksClassDeclaration
, you should be able to get the FQN with something like:
Copy code
ksClassDeclaration.getAllProperties().single { it.simpleName.asString() == "property1" }.type.resolve().declaration.qualifiedName!!
p
I have
KSClassDeclaration
as well.
KSReferenceEleement
was from
type.element
However type.resolve().declaration.qualifiedName gives
com.google.devtools.ksp.symbol.impl.kotlin.KSNameImpl
not the fully qualified name of my type
d
can you try
qualifiedName.asString()
?
p
Thanks,
qualifiedName?.asString()
was exactly what I was looking for. It is kind of surprising that it is even there and toString() returns a different value, but I can live with it. Once again, big thanks.