Hi!
I'm trying to get method return type in a way which works for both Kotlin and Java. I'm overriding visitMethod but when I call uMethod.returnType.canonicalText then it works in Java but for Kotlin code it always returns java.lang.Object. I tried many different things but nothing worked except for this:
(((uMethod.sourcePsi as KtNamedFunction).typeReference as KtTypeReference)
.typeElement as KtUserType)
.referenceExpression.getUastParentOfType<UTypeReferenceExpression>()
.getQualifiedName()
But it feels wrong. What is the proper way to do it? I would like to get a fully qualified name. For example for code like this:
interface Foo {
fun test(): String
}
I would like to get java.lang.String.
Best,
Michał