Skip to content

java.lang.Throwable: psiElement is not instance of requiredClass #44

@kriegaex

Description

@kriegaex
  • IntelliJ IDEA 2023.3.4 (Ultimate Edition), Build #IU-233.14475.28, built on February 13, 2024
  • Plugin version 0.12

Today, this happened one time in my IDE. Because it is unusual - I normally do not get errors from this plugin - I want to notify the maintainer.

java.lang.Throwable: psiElement is not instance of requiredClass.
psiElement=Import statement, psiElement.class=class org.jetbrains.plugins.groovy.lang.psi.impl.toplevel.imports.GrImportStatementImpl, requiredClass=interface com.intellij.psi.PsiClass, operation=Looking for GroovyMultipleAssignmentTest in gr.class.fqn.s, stubIdList=[3].
ref: 50cf572587cf
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: PSI and index do not match.
Please report the problem to JetBrains with the files attached
 file=GroovyFileImpl:GroovyMultipleAssignmentTest.groovy, file.class=class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl, file.lang=Language: Groovy, modStamp=25
 tree consistent
 stub debugInfo=created in calcStubTree; with backReference
 viewProvider=com.intellij.psi.SingleRootFileViewProvider{vFile=file://C:/Users/alexa/Documents/java-src/spock-example/src/test/groovy/de/scrum_master/issue/i1413/GroovyMultipleAssignmentTest.groovy, vFileId=3447391, content=VirtualFileContent{size=339}, eventSystemEnabled=true}
 viewProvider stamp: 3714205; file stamp: 3714205; file modCount: 1709082540026; file length: 339
 doc saved: true; doc stamp: 3714205; doc size: 339; committed: true
indexing info: indexing timestamp = 1709082488527, binary = false, byte size = 304, char size = 339
ref: 50cf572587cf
latestIndexedStub=StubTree{myDebugInfo='created from index; with backReference', myRoot=GrFileStub}1990588258
   same size=false
   debugInfo=created from index; with backReference
	at com.intellij.openapi.diagnostic.Logger.error(Logger.java:376)
	at com.intellij.psi.stubs.StubProcessingHelperBase.inconsistencyDetected(StubProcessingHelperBase.java:156)
	at com.intellij.psi.stubs.StubProcessingHelperBase.checkType(StubProcessingHelperBase.java:90)
	at com.intellij.psi.stubs.StubProcessingHelperBase.processStubsInFile(StubProcessingHelperBase.java:61)
	at com.intellij.psi.stubs.StubIndexEx.lambda$processElements$5(StubIndexEx.java:152)
	at com.intellij.psi.stubs.StubIndexEx.processElements(StubIndexEx.java:202)
	at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:102)
	at com.intellij.psi.stubs.StubIndex.getElements(StubIndex.java:90)
	at org.jetbrains.plugins.groovy.lang.stubs.GroovyShortNamesCache.lambda$getClassesByFQName$3(GroovyShortNamesCache.java:128)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:909)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:65)
	at org.jetbrains.plugins.groovy.lang.stubs.GroovyShortNamesCache.getClassesByFQName(GroovyShortNamesCache.java:126)
	at org.jetbrains.plugins.groovy.lang.psi.impl.javaView.GroovyClassFinder.findClasses(GroovyClassFinder.java:59)
	at com.intellij.psi.impl.JavaPsiFacadeImpl.findClassesWithoutJvmFacade(JavaPsiFacadeImpl.java:163)
	at com.intellij.psi.impl.JavaPsiFacadeImpl.findClassesWithJvmFacade(JavaPsiFacadeImpl.java:134)
	at com.intellij.psi.impl.JavaPsiFacadeImpl.findClasses(JavaPsiFacadeImpl.java:126)
	at org.jetbrains.plugins.groovy.annotator.GroovyAnnotator.checkDuplicateClass(GroovyAnnotator.java:2087)
	at org.jetbrains.plugins.groovy.annotator.GroovyAnnotator.checkTypeDefinition(GroovyAnnotator.java:2044)
	at org.jetbrains.plugins.groovy.annotator.GroovyAnnotator.visitTypeDefinition(GroovyAnnotator.java:386)
	at org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor.visitClassDefinition(GroovyElementVisitor.java:283)
	at org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrClassDefinitionImpl.accept(GrClassDefinitionImpl.java:31)
	at org.jetbrains.plugins.groovy.annotator.GrAnnotatorImpl.annotate(GrAnnotatorImpl.kt:27)
	at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:128)
	at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:106)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:361)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$7(GeneralHighlightingPass.java:292)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:321)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:324)
	at com.cholick.idea.spock.highlight.SpockHighlightVisitor.analyze(SpockHighlightVisitor.java:33)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.analysis.JavaNamesHighlightVisitor.analyze(JavaNamesHighlightVisitor.java:53)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.analyze(HighlightVisitorImpl.java:222)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$8(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:91)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:324)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:287)
	at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:234)
	at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:80)
	at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:55)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:406)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:76)
	at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:34)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:401)
	at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1075)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:392)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:610)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:685)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:641)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:609)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:78)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:391)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:367)
	at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:200)
	at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:184)
	at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:365)
	at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:187)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Background: After a Spock version upgrade to 2.4-M2, one of my tests - GroovyMultipleAssignmentTest mentioned in the error message - started to fail compiling noth in Maven and IDEA. After a few more dependency upgrades, the error went away. But why it threw off the Spock Enhancements plugin, I have no idea.

Correction: I just noticed the path of the project. This is not the project where the compilation problem happened, but a small project meant to reproduce it, but without success. In that project, the error never occurred, which gave me a clue how to solve it in the big project, too. I.e., the plugin never threw this error in the problematic project, but in the new one which never had any compilation problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions