ClassNotFoundException for PsiTreeUtilKt in WebStorm

I'm getting a `ClassNotFoundException` for com.intellij.psi.util.PsiTreeUtilKt when invoking an intention action in my plugin on WebStorm (WS-173.4127.31).

There are a couple of weird things about this:

  1. The same plugin JAR runs without an exception on IntelliJ community edition (#IC-173.3727.127).
  2. The file that is apparently trying to load PsiTreeUtilKt does not use PsiTreeUtil anywhere (although it does use an inline extension function on PsiElement which uses PsiTreeUtil in its body)
  3. The stack trace for the ClassNotFoundException references the last line of the file (ElmImportIntentionAction.kt has 297 lines total)

See stack trace below.

More info about my plugin setup:

  • using IDEA Ultimate (#IU-173.4127.27) for plugin development
  • my IntelliJ plugin SDK is based on CE (#IC-173.3727.127)
  • JDK: 1.8.0-152
  • macOS 10.13.2

 

The stack trace:

com/intellij/psi/util/PsiTreeUtilKt
java.lang.NoClassDefFoundError: com/intellij/psi/util/PsiTreeUtilKt
at org.elm.ide.intentions.ElmImportIntentionAction.findApplicableContext(ElmImportIntentionAction.kt:298)
at org.elm.ide.intentions.ElmImportIntentionAction.findApplicableContext(ElmImportIntentionAction.kt:44)
at org.elm.ide.intentions.ElmAtCaretIntentionActionBase.isAvailable(ElmAtCaretIntentionActionBase.kt:52)
at com.intellij.codeInsight.intention.BaseElementAtCaretIntentionAction.isAvailable(BaseElementAtCaretIntentionAction.java:41)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.a(ShowIntentionsPass.java:182)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.a(ShowIntentionsPass.java:115)
at java.util.ArrayList.forEach(ArrayList.java:1251)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getAvailableFixes(ShowIntentionsPass.java:115)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.getActionsToShow(ShowIntentionsPass.java:315)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.a(ShowIntentionsPass.java:269)
at com.intellij.codeInsight.daemon.impl.ShowIntentionsPass.doCollectInformation(ShowIntentionsPass.java:245)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:70)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.a(PassExecutorService.java:437)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1127)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.c(PassExecutorService.java:430)
at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.d(PassExecutorService.java:429)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.b(PassExecutorService.java:405)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:143)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:229)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:403)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:170)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.ClassNotFoundException: com.intellij.psi.util.PsiTreeUtilKt PluginClassLoader[org.elm.klazuka, 0.9.1] com.intellij.ide.plugins.cl.PluginClassLoader@2eeb080e
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 28 more

 

 

0

When I package my plugin for development, it generates a JAR that just contains my project's class files--there are no JARs bundled with it. I'm new to IntelliJ plugin development so maybe I'm missing something simple. Are there any plugin support JARs that I need to bundle?

0

Hi,

unfortunately, PsiTreeUtilKt resides in the java-impl module which is available only in IDEs with Java support (IntelliJ Community and Ultimate). While we can consider moving these extension methods to the platform core, it won't happen until 2018.1 which means that if you want your plugin compatible with 2017.3 you'll have to use plain PsiTreeUtil methods

1

Yep, that was it. Thanks! I had my own `parentOfType` inline Kotlin function but was accidentally importing the one from java-impl.

Is there a way for me to run my tests against products like WebStorm?

0

Yes, you can set it up as a Platform SDK just like you did with IntelliJ

0

Hi, any progress with moving this into platform core? I got the same error due to autocompletion while plugin development. Unfortunately, I've noticed the exception after my plugin has been released.

0

Roman, it was moved to platform-lang.impl in 2019.2, see aeb88acd3cc7b277e353c0433f7274d3a1914e1a

0

请先登录再写评论。