KtLightMethodImpl::getBody returns null


#1

KtLightMethodImpl::getBody returns null. Why can’t it return method body and will it ever do that? Or is there another way to get Kotlin method body when developing plugin?


#2

KtLightMethodImpl is a representation of a Kotlin method using the Java PSI structure. Since it’s not possible to fully represent Kotlin source code as Java PSI, this method does not and will not return a method body.

If you have a KtLightMethod, the correct way to access its body is to go back to the Kotlin PSI using the kotlinOrigin property.