Cannot distinguish StubFileElementTypes in plugin without file stubs
Hello,
I'm getting this error that I cannot figure out how to solve with a plugin that I maintain. The plugin is called “Jsgf” and its available on the Jetbrains marketplace. The error is similar to other issues that have been solved (here and here). Both of those issues are marked as resolved in version 2023.2, but I get the following error while running in 2023.2.2.
Here is the stack trace:
java.lang.Throwable: Cannot distinguish StubFileElementTypes. This might worsen the performance. Providing unique externalId or adding a distinctive debugName when instantiating StubFileElementTypes can help. Version: psi.file:0:FILE -> [com.intellij.psi.tree.IStubFileElementType{psi.file;FILE;Language: JSGF}, com.intellij.psi.tree.IStubFileElementType{psi.file;FILE;Language: ANY}]
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:370)
at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.lambda$determinePreviousFileElementType$8(PerFileElementTypeStubModificationTracker.java:222)
at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.determinePreviousFileElementType(PerFileElementTypeStubModificationTracker.java:218)
at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.fastCheck(PerFileElementTypeStubModificationTracker.java:118)
at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.lambda$endUpdatesBatch$2(PerFileElementTypeStubModificationTracker.java:92)
at com.intellij.openapi.application.ReadAction.lambda$run$1(ReadAction.java:64)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:923)
at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:76)
at com.intellij.openapi.application.ReadAction.run(ReadAction.java:63)
at com.intellij.psi.stubs.PerFileElementTypeStubModificationTracker.endUpdatesBatch(PerFileElementTypeStubModificationTracker.java:91)
at com.intellij.util.indexing.events.ChangedFilesCollector$4.endBatch(ChangedFilesCollector.java:252)
at com.intellij.util.indexing.events.ChangedFilesCollector$5.lambda$endBatch$2(ChangedFilesCollector.java:289)
at com.intellij.util.ConcurrencyUtil.withLock(ConcurrencyUtil.java:264)
at com.intellij.util.indexing.events.ChangedFilesCollector$5.endBatch(ChangedFilesCollector.java:288)
at com.intellij.util.indexing.events.VfsEventsMerger.processChanges(VfsEventsMerger.java:109)
at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesInReadAction(ChangedFilesCollector.java:271)
at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesToUpdateInReadAction(ChangedFilesCollector.java:230)
at com.intellij.util.indexing.events.ChangedFilesCollector.lambda$processFilesInReadActionWithYieldingToWriteAction$3(ChangedFilesCollector.java:324)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:20)
at com.intellij.util.RunnableCallable.call(RunnableCallable.java:11)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor.callWrapped(NonBlockingReadActionImpl.java:832)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$OTelMonitor$MonitoredComputation.call(NonBlockingReadActionImpl.java:864)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.insideReadAction(NonBlockingReadActionImpl.java:602)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$attemptComputation$4(NonBlockingReadActionImpl.java:565)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:76)
at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:133)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:114)
at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:71)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:71)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:111)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:76)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.attemptComputation(NonBlockingReadActionImpl.java:565)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.executeSynchronously(NonBlockingReadActionImpl.java:492)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl.executeSynchronously(NonBlockingReadActionImpl.java:222)
at com.intellij.util.indexing.events.ChangedFilesCollector.processFilesInReadActionWithYieldingToWriteAction(ChangedFilesCollector.java:324)
at com.intellij.util.indexing.events.ChangedFilesCollector.ensureUpToDate(ChangedFilesCollector.java:194)
at com.intellij.util.indexing.events.ChangedFilesCollector.getAllFilesToUpdate(ChangedFilesCollector.java:111)
at com.intellij.util.indexing.FileBasedIndexImpl.getFilesToUpdate(FileBasedIndexImpl.java:1322)
at com.intellij.util.indexing.ProjectChangedFilesScanner.scan(ProjectChangedFilesScanner.java:33)
at com.intellij.util.indexing.UnindexedFilesIndexer.getRefreshedFiles(UnindexedFilesIndexer.java:131)
at com.intellij.util.indexing.UnindexedFilesIndexer.doIndexFiles(UnindexedFilesIndexer.java:121)
at com.intellij.util.indexing.UnindexedFilesIndexer.indexFiles(UnindexedFilesIndexer.java:92)
at com.intellij.util.indexing.UnindexedFilesIndexer.lambda$performInDumbMode$1(UnindexedFilesIndexer.java:210)
at com.intellij.util.gist.GistManagerImpl.runWithMergingDependentCacheInvalidations(GistManagerImpl.java:163)
at com.intellij.util.indexing.UnindexedFilesIndexer.performInDumbMode(UnindexedFilesIndexer.java:210)
at com.intellij.openapi.project.DumbModeTask.perform(DumbModeTask.java:41)
at com.intellij.openapi.project.MergingTaskQueue$QueuedTask.executeTask(MergingTaskQueue.java:336)
at com.intellij.openapi.project.MergingTaskQueue$QueuedTask.executeTask(MergingTaskQueue.java:318)
at com.intellij.openapi.project.MergingQueueGuiExecutor.runSingleTask$lambda$6(MergingQueueGuiExecutor.kt:218)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
at com.intellij.openapi.project.MergingQueueGuiExecutor.runSingleTask(MergingQueueGuiExecutor.kt:215)
at com.intellij.openapi.project.DumbServiceGuiExecutor.runSingleTask$lambda$1(DumbServiceGuiExecutor.kt:55)
at com.intellij.util.io.storage.HeavyProcessLatch.performOperation(HeavyProcessLatch.java:58)
at com.intellij.openapi.project.DumbServiceGuiExecutor.runSingleTask(DumbServiceGuiExecutor.kt:54)
at com.intellij.openapi.project.MergingQueueGuiExecutor.processTasksWithProgress$lambda$3(MergingQueueGuiExecutor.kt:129)
at com.intellij.openapi.project.MergingQueueGuiSuspender.setCurrentSuspenderAndSuspendIfRequested(MergingQueueGuiSuspender.kt:53)
at com.intellij.openapi.project.MergingQueueGuiExecutor.processTasksWithProgress(MergingQueueGuiExecutor.kt:113)
at com.intellij.openapi.project.DumbServiceGuiExecutor.processTasksWithProgress(DumbServiceGuiExecutor.kt:34)
at com.intellij.openapi.project.MergingQueueGuiExecutor.runBackgroundProcessWithSuspender(MergingQueueGuiExecutor.kt:206)
at com.intellij.openapi.project.MergingQueueGuiExecutor.lambda$1$lambda$0(MergingQueueGuiExecutor.kt:105)
at com.intellij.openapi.project.MergingQueueGuiExecutor.runWithCallbacks(MergingQueueGuiExecutor.kt:190)
at com.intellij.openapi.project.MergingQueueGuiExecutor._init_$lambda$1(MergingQueueGuiExecutor.kt:104)
at com.intellij.openapi.project.SingleTaskExecutor$StateAwareTask.run$lambda$0(SingleTaskExecutor.kt:37)
at com.intellij.openapi.project.SingleTaskExecutor.runWithStateHandling(SingleTaskExecutor.kt:63)
at com.intellij.openapi.project.SingleTaskExecutor.access$runWithStateHandling(SingleTaskExecutor.kt:22)
at com.intellij.openapi.project.SingleTaskExecutor$StateAwareTask.run(SingleTaskExecutor.kt:37)
at com.intellij.openapi.project.MergingQueueGuiExecutor$startBackgroundProcess$1$1.run(MergingQueueGuiExecutor.kt:153)
at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:428)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:115)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:478)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:251)
at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:71)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:71)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:251)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$launchTask$18(ProgressRunner.java:465)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:833)
To reproduce:
- install the plugin
- restart IntelliJ
- create a new file with the extension “.jsgf”
- make a change to the file (any change should cause the error to occur)
Also, it error seems to happen only once while the IDE is running as far as I can tell, so maybe it's not a big deal, but I would prefer to fix it.
What confuses me is that I don't have Stub Files in my project. I have stubs for elements within the files, but I don't define any subclass of IStubFileElementType in my plugin, so I don't know how to “Providing unique externalId or adding a distinctive debugName” for my files.
Please sign in to leave a comment.
> I have stubs for elements within the files, but I don't define any subclass of IStubFileElementType in my plugin
Why do you have stub elements in your PSI if your PsiFile is not stub-enabled? Or do I misunderstand?
Perhaps I don't know how to properly use stubs. I thought only the Psi elements which I wanted to cache and retrieve quickly need to be stubbed. Here's some of my PsiFile class:
And here's some of my GrammarName Psi interface:
And the implementation:
Am I doing something wrong? Is it required to use a stub based psi file if I'm using any stubs?
That's not correct, you must follow all steps exactly as outlined here https://plugins.jetbrains.com/docs/intellij/stub-indexes.html
Alright! Thank you!
Turns out I did have a IStubFileElementType. I just instantiated a generic one:
Instead, I implemented a custom file element type for my language which has a unique external id and debug name, and this seems to have fix the problem: