mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
142 stars 38 forks source link

Consider using UAST #69

Closed YannCebron closed 3 years ago

YannCebron commented 3 years ago

Kotlin 1.4.32 introduces binary incompatibility with org.mapstruct.intellij:1.2.3

Method org.mapstruct.intellij.util.MapstructUtilKt.toPsiMethod(org.jetbrains.kotlin.psi.KtNamedFunction $this$toPsiMethod) : com.intellij.psi.PsiMethod contains an *invokestatic* instruction referencing an unresolved method org.jetbrains.kotlin.asJava.classes.UltraLightUtilsKt.createGeneratedMethodFromDescriptor(org.jetbrains.kotlin.asJava.classes.KtUltraLightClass, org.jetbrains.kotlin.descriptors.FunctionDescriptor, org.jetbrains.kotlin.psi.KtDeclaration) : org.jetbrains.kotlin.asJava.elements.KtLightMethod. This can lead to **NoSuchMethodError** exception at runtime.

If possible (didn't check your plugin's usage of Kotlin plugin specific API), consider switching to UAST which will shield you from such problems and allow common code for all supported JVM Languages. Reference: https://plugins.jetbrains.com/docs/intellij/uast.html

filiphr commented 3 years ago

Thanks a lot for the hint @YannCebron. I was not aware about the UAST.

The particular problem code is happening when called from here and the problematic code is here.

I guess that it shouldn't be too difficult to get the javaPsi from the UAST so we can do the logic without relying on Kotlin specifics.

This functionality was contributed by a contributor and I had (and still have) limited knowledge of the Kotlin plugin.