KtVisitorVoid can not cast to PsiElementVisitor in kotlin intelij plugin

Answered

Hey,
I am trying to learn to build an IntelliJ plug, I am trying to build something that works on Kotlin files, I am using the Kotlin plugin but it seems KtVisitorVoid class (psi/src/org/jetbrains/kotlin/psi/KtVisitorVoid.java) can not be cast to PsiElementVisitor.
this is the current code throwing the error,

class HelloWorldWithKotlinClassesInspection : AbstractKotlinInspection() {

override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
return object : KtVisitorVoid() {
//
}
}
}

 

the error I get is

> 2021-11-12 08:22:50,880 [ 333360] ERROR -
> aemon.impl.PassExecutorService - class
> com.github.me.KotlinInspection$buildVisitor$1
> cannot be cast to class com.intellij.psi.PsiElementVisitor
> (com.github.me.KotlinInspection$buildVisitor$1
> is in unnamed module of loader
> com.intellij.ide.plugins.cl.PluginClassLoader @6be5f3e1;
> com.intellij.psi.PsiElementVisitor is in unnamed module of loader
> com.intellij.util.lang.UrlClassLoader @7921b0a2)
> java.lang.ClassCastException: class
> com.github.me.KotlinInspection$buildVisitor$1
> cannot be cast to class com.intellij.psi.PsiElementVisitor
> (com.github.me.KotlinInspection$buildVisitor$1
> is in unnamed module of loader
> com.intellij.ide.plugins.cl.PluginClassLoader @6be5f3e1;
> com.intellij.psi.PsiElementVisitor is in unnamed module of loader
> com.intellij.util.lang.UrlClassLoader @7921b0a2)

1 comment
Comment actions Permalink

How did you setup your project? Please verify you followed instructions 100% from https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html. If still doesn't work, link to sources, please?

0

Please sign in to leave a comment.