Assertation in fidnMethodsAndTheirSubstitutors

I get the following exception from custom language plugin after
editing an referenced Java-class. What I am doing wrong?
Before no errors were displayed, after editing I get this exception
and the findMethodsAndTheirSubstitutors() return only an part of
the methods.

Assertion failed: getManager() == null!
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:78)
at
com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.multiResolve(PsiJavaCodeReferenceElementImpl.java:216)
at
com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.advancedResolve(PsiJavaCodeReferenceElementImpl.java:238)
at
com.intellij.psi.impl.source.PsiClassReferenceType.resolveGenerics(PsiClassReferenceType.java:12)
at com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:231)
at
com.intellij.psi.impl.PsiClassImplUtil.processDeclarationsInClassNotCached(PsiClassImplUtil.java:116)
at com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:224)
at
com.intellij.psi.impl.PsiClassImplUtil.access$000(PsiClassImplUtil.java:35)
at
com.intellij.psi.impl.PsiClassImplUtil$MyCachedValueProvider.compute(PsiClassImplUtil.java)
at com.intellij.psi.impl.CachedValueImpl.getValue(CachedValueImpl.java:76)
at com.intellij.psi.impl.PsiClassImplUtil.b(PsiClassImplUtil.java:140)
at
com.intellij.psi.impl.PsiClassImplUtil.findMethodsAndTheirSubstitutorsByName(PsiClassImplUtil.java:32)
at
com.intellij.psi.impl.source.PsiClassImpl.findMethodsAndTheirSubstitutorsByName(PsiClassImpl.java:243)
at
framework.plugins.idea.web.psitree.util.WCIResolveUtils.findMethods(WCIResolveUtils.java:95)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.resolveMethod(WCIJavaExpressionReference.java:312)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.resolveMethod(WCIJavaExpressionReference.java:338)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.resolve(WCIJavaExpressionReference.java:67)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle(WCIReferenceBase.java:125)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.getReferenceType(WCIReferenceBase.java:113)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.getReferenceType(WCIJavaReferenceImpl.java:88)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceContext(WCIJavaReference.java:59)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceContext(WCIJavaReference.java:44)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.resolveMethod(WCIJavaExpressionReference.java:330)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.resolve(WCIJavaExpressionReference.java:67)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle(WCIReferenceBase.java:125)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.validate(WCIJavaReference.java:109)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.validate(WCIJavaReferenceImpl.java:72)
at
framework.plugins.idea.web.validation.WCIAnnotationVisitor.visitElement(WCIAnnotationVisitor.java:27)
at
framework.plugins.idea.web.psitree.WCIElementVisitor.visitWCIJavaReference(WCIElementVisitor.java:95)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJavaReferenceImpl.java:93)
at
framework.plugins.idea.web.validation.WCIAnnotationVisitor.annotate(WCIAnnotationVisitor.java:22)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visitElement(HighlightVisitorImpl.java:518)
at
com.intellij.extapi.psi.ASTWrapperPsiElement.accept(ASTWrapperPsiElement.java:60)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJavaReferenceImpl.java:95)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.visit(HighlightVisitorImpl.java:560)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(GeneralHighlightingPass.java:16)
at
com.intellij.psi.impl.PsiManagerImpl.performActionWithFormatterDisabled(PsiManagerImpl.java:7)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(GeneralHighlightingPass.java:111)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollectInformation(GeneralHighlightingPass.java:153)
at
com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:5)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.java:0)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:230)
at com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:2)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThread.java:42)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.java:3)
at
com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:52)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.java:8)

2 comments

Hello Sven,

This stuff usually happens when accessing invalidated PsiElement (.isValid()
== false), which is normal situation after file have been reparsed.
Most probably, you're holding an instance of PsiClass (or another element),
which is only guaranteed to stay valid inside single Application.runReadAction().

-


Maxim Shafirov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I get the following exception from custom language plugin after
editing an referenced Java-class. What I am doing wrong?
Before no errors were displayed, after editing I get this exception
and the findMethodsAndTheirSubstitutors() return only an part of
the methods.
Assertion failed: getManager() == null!
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:78)
at
com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.multiReso
lve(PsiJavaCodeReferenceElementImpl.java:216)
at
com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.advancedR
esolve(PsiJavaCodeReferenceElementImpl.java:238)
at
com.intellij.psi.impl.source.PsiClassReferenceType.resolveGenerics(Psi
ClassReferenceType.java:12)
at
com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:231)
at
com.intellij.psi.impl.PsiClassImplUtil.processDeclarationsInClassNotCa
ched(PsiClassImplUtil.java:116)
at
com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:224)
at
com.intellij.psi.impl.PsiClassImplUtil.access$000(PsiClassImplUtil.jav
a:35)
at
com.intellij.psi.impl.PsiClassImplUtil$MyCachedValueProvider.compute(P
siClassImplUtil.java)
at
com.intellij.psi.impl.CachedValueImpl.getValue(CachedValueImpl.java:76
)
at
com.intellij.psi.impl.PsiClassImplUtil.b(PsiClassImplUtil.java:140)
at
com.intellij.psi.impl.PsiClassImplUtil.findMethodsAndTheirSubstitutors
ByName(PsiClassImplUtil.java:32)
at
com.intellij.psi.impl.source.PsiClassImpl.findMethodsAndTheirSubstitut
orsByName(PsiClassImpl.java:243)
at
framework.plugins.idea.web.psitree.util.WCIResolveUtils.findMethods(WC
IResolveUtils.java:95)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
olveMethod(WCIJavaExpressionReference.java:312)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
olveMethod(WCIJavaExpressionReference.java:338)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
olve(WCIJavaExpressionReference.java:67)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle
(WCIReferenceBase.java:125)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.getReferenceT
ype(WCIReferenceBase.java:113)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.getReferenceTy
pe(WCIJavaReferenceImpl.java:88)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceC
ontext(WCIJavaReference.java:59)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceC
ontext(WCIJavaReference.java:44)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
olveMethod(WCIJavaExpressionReference.java:330)
at
framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
olve(WCIJavaExpressionReference.java:67)
at
framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle
(WCIReferenceBase.java:125)
at
framework.plugins.idea.web.psitree.refs.WCIJavaReference.validate(WCIJ
avaReference.java:109)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.validate(WCIJa
vaReferenceImpl.java:72)
at
framework.plugins.idea.web.validation.WCIAnnotationVisitor.visitElemen
t(WCIAnnotationVisitor.java:27)
at
framework.plugins.idea.web.psitree.WCIElementVisitor.visitWCIJavaRefer
ence(WCIElementVisitor.java:95)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJava
ReferenceImpl.java:93)
at
framework.plugins.idea.web.validation.WCIAnnotationVisitor.annotate(WC
IAnnotationVisitor.java:22)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
itElement(HighlightVisitorImpl.java:518)
at
com.intellij.extapi.psi.ASTWrapperPsiElement.accept(ASTWrapperPsiEleme
nt.java:60)
at
framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJava
ReferenceImpl.java:95)
at
com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
it(HighlightVisitorImpl.java:560)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(Gen
eralHighlightingPass.java:16)
at
com.intellij.psi.impl.PsiManagerImpl.performActionWithFormatterDisable
d(PsiManagerImpl.java:7)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(General
HighlightingPass.java:111)
at
com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollect
Information(GeneralHighlightingPass.java:153)
at
com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPass.collec
tInformation(TextEditorHighlightingPass.java:5)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.j
ava:0)
at
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(Ap
plicationImpl.java:230)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:
2)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThr
ead.java:42)
at
com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.j
ava:3)
at
com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(Prog
ressManagerImpl.java:52)
at
com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.jav
a:8)



0

Thanks, that's it.
So in custom languages plugin I should better use no caching at all.

Maxim Shafirov (JetBrains) schrieb:

Hello Sven,

This stuff usually happens when accessing invalidated PsiElement
(.isValid() == false), which is normal situation after file have been
reparsed.
Most probably, you're holding an instance of PsiClass (or another
element), which is only guaranteed to stay valid inside single
Application.runReadAction().

------------------
Maxim Shafirov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> I get the following exception from custom language plugin after
>> editing an referenced Java-class. What I am doing wrong?
>> Before no errors were displayed, after editing I get this exception
>> and the findMethodsAndTheirSubstitutors() return only an part of
>> the methods.
>> Assertion failed: getManager() == null!
>> java.lang.Throwable
>> at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:78)
>> at
>> com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.multiReso
>> lve(PsiJavaCodeReferenceElementImpl.java:216)
>> at
>> com.intellij.psi.impl.source.PsiJavaCodeReferenceElementImpl.advancedR
>> esolve(PsiJavaCodeReferenceElementImpl.java:238)
>> at
>> com.intellij.psi.impl.source.PsiClassReferenceType.resolveGenerics(Psi
>> ClassReferenceType.java:12)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:231)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.processDeclarationsInClassNotCa
>> ched(PsiClassImplUtil.java:116)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.a(PsiClassImplUtil.java:224)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.access$000(PsiClassImplUtil.jav
>> a:35)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil$MyCachedValueProvider.compute(P
>> siClassImplUtil.java)
>> at
>> com.intellij.psi.impl.CachedValueImpl.getValue(CachedValueImpl.java:76
>> )
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.b(PsiClassImplUtil.java:140)
>> at
>> com.intellij.psi.impl.PsiClassImplUtil.findMethodsAndTheirSubstitutors
>> ByName(PsiClassImplUtil.java:32)
>> at
>> com.intellij.psi.impl.source.PsiClassImpl.findMethodsAndTheirSubstitut
>> orsByName(PsiClassImpl.java:243)
>> at
>> framework.plugins.idea.web.psitree.util.WCIResolveUtils.findMethods(WC
>> IResolveUtils.java:95)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
>> olveMethod(WCIJavaExpressionReference.java:312)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
>> olveMethod(WCIJavaExpressionReference.java:338)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
>> olve(WCIJavaExpressionReference.java:67)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle
>> (WCIReferenceBase.java:125)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIReferenceBase.getReferenceT
>> ype(WCIReferenceBase.java:113)
>> at
>> framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.getReferenceTy
>> pe(WCIJavaReferenceImpl.java:88)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceC
>> ontext(WCIJavaReference.java:59)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaReference.getReferenceC
>> ontext(WCIJavaReference.java:44)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
>> olveMethod(WCIJavaExpressionReference.java:330)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaExpressionReference.res
>> olve(WCIJavaExpressionReference.java:67)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIReferenceBase.resolveSingle
>> (WCIReferenceBase.java:125)
>> at
>> framework.plugins.idea.web.psitree.refs.WCIJavaReference.validate(WCIJ
>> avaReference.java:109)
>> at
>> framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.validate(WCIJa
>> vaReferenceImpl.java:72)
>> at
>> framework.plugins.idea.web.validation.WCIAnnotationVisitor.visitElemen
>> t(WCIAnnotationVisitor.java:27)
>> at
>> framework.plugins.idea.web.psitree.WCIElementVisitor.visitWCIJavaRefer
>> ence(WCIElementVisitor.java:95)
>> at
>> framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJava
>> ReferenceImpl.java:93)
>> at
>> framework.plugins.idea.web.validation.WCIAnnotationVisitor.annotate(WC
>> IAnnotationVisitor.java:22)
>> at
>> com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
>> itElement(HighlightVisitorImpl.java:518)
>> at
>> com.intellij.extapi.psi.ASTWrapperPsiElement.accept(ASTWrapperPsiEleme
>> nt.java:60)
>> at
>> framework.plugins.idea.web.psitree.WCIJavaReferenceImpl.accept(WCIJava
>> ReferenceImpl.java:95)
>> at
>> com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl.vis
>> it(HighlightVisitorImpl.java:560)
>> at
>> com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass$1.run(Gen
>> eralHighlightingPass.java:16)
>> at
>> com.intellij.psi.impl.PsiManagerImpl.performActionWithFormatterDisable
>> d(PsiManagerImpl.java:7)
>> at
>> com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.a(General
>> HighlightingPass.java:111)
>> at
>> com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.doCollect
>> Information(GeneralHighlightingPass.java:153)
>> at
>> com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPass.collec
>> tInformation(TextEditorHighlightingPass.java:5)
>> at
>> com.intellij.codeInsight.daemon.impl.UpdateThread$2.run(UpdateThread.j
>> ava:0)
>> at
>> com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(Ap
>> plicationImpl.java:230)
>> at
>> com.intellij.codeInsight.daemon.impl.UpdateThread.a(UpdateThread.java:
>> 2)
>> at
>> com.intellij.codeInsight.daemon.impl.UpdateThread.access$100(UpdateThr
>> ead.java:42)
>> at
>> com.intellij.codeInsight.daemon.impl.UpdateThread$1.run(UpdateThread.j
>> ava:3)
>> at
>> com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(Prog
>> ressManagerImpl.java:52)
>> at
>> com.intellij.codeInsight.daemon.impl.UpdateThread.run(UpdateThread.jav
>> a:8)


0

Please sign in to leave a comment.