How to integrate KotlinPlugin's PSI classes
I have added kotlin plugin jar to my SDK class list, and have added the correct <depends> tag to my plugin.xml. The IDE resolves the class reference and compiles.
But when I call:
if (psiElement is KtPackageDirective)
or
if (psiElement is KtFile)
The statement is never true, even if the psiElement matches the class. AFAIK there is only 1 kotlin plugin.jar on the classpath.
And a cast results in:
java.lang.ClassCastException: org.jetbrains.kotlin.psi.KtFile cannot be cast to org.jetbrains.kotlin.psi.KtFile
So obviously there are 2 versions of the class defined.
Does anyone have any suggestions on how to resolve this issue?
Please sign in to leave a comment.
Different classloaders. So how to correct...
It turns out I needed to add kotlin-compiler.jar instead of kotlin-plugin.jar to the SDK classes. But now the IDE can't navigate to the source code for classes such as KDoc.
Did you manage to resolve the issue with setting up a project to use Kotlin Psi? Thanks.
I get the same problem, but I use a gradle project. Any idea of how to fix the problem? Can it be fixed in the gradle setup? This is my build.gradle so far:
Edit: realised we used different type of projects
In gradle, instead of;