Error: A suspiciously high nesting of suppressPrioritizing, forgot to call restorePrioritizing

已回答

Hello,
I'm trying to fix the next issue in the plugin: Error: A suspiciously high nesting of suppressPrioritizing, forgot to call restorePrioritizing.
In the plugin we have StructureViewTreeElement and in the getChildren() method it calls PsiTreeUtil.hasErrorElements(psiFile). And this part produces such an error.

Maybe someone could suggest how to fix it? 

Full error


 A suspiciously high nesting of suppressPrioritizing, forgot to call restorePrioritizing?
 
 java.lang.Throwable
at com.intellij.idea.IdeaLogger.error(IdeaLogger.java:131)
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:384)
at com.intellij.openapi.progress.impl.CoreProgressManager.suppressPrioritizing(CoreProgressManager.java:824)
at com.intellij.openapi.progress.impl.CoreProgressManager.avoidBlockingPrioritizingThread(CoreProgressManager.java:879)
at com.intellij.openapi.progress.impl.CoreProgressManager.sleepIfNeededToGivePriorityToAnotherThread(CoreProgressManager.java:840)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runCheckCanceledHooks(ProgressManagerImpl.java:192)
at com.intellij.openapi.progress.impl.CoreProgressManager.doCheckCanceled(CoreProgressManager.java:145)
at com.intellij.openapi.progress.ProgressManager.checkCanceled(ProgressManager.java:231)
at com.intellij.openapi.progress.ProgressIndicatorProvider.checkCanceled(ProgressIndicatorProvider.java:23)
at com.intellij.psi.impl.source.tree.CompositeElement.getPsi(CompositeElement.java:676)
at com.intellij.psi.impl.source.SourceTreeToPsiMap.treeElementToPsi(SourceTreeToPsiMap.java:15)
at com.intellij.psi.impl.source.tree.SharedImplUtil.getNextSibling(SharedImplUtil.java:45)
at com.intellij.psi.impl.source.tree.LeafPsiElement.getNextSibling(LeafPsiElement.java:61)
at com.intellij.psi.SyntaxTraverser$PsiApi.next(SyntaxTraverser.java:308)
at com.intellij.psi.SyntaxTraverser$PsiApi.next(SyntaxTraverser.java:264)
at com.intellij.psi.SyntaxTraverser$ApiEx$1.fun(SyntaxTraverser.java:254)
at com.intellij.util.containers.JBIterable$2$1.nextImpl(JBIterable.java:129)
at com.intellij.util.containers.JBIterator.peekNext(JBIterator.java:132)
at com.intellij.util.containers.JBIterator.hasNext(JBIterator.java:92)
at com.intellij.util.containers.TreeTraversal$BiOrderIt.nextImpl(TreeTraversal.java:498)
at com.intellij.util.containers.JBIterator.peekNext(JBIterator.java:132)
at com.intellij.util.containers.JBIterator.hasNext(JBIterator.java:92)
at com.intellij.util.containers.JBIterable.isEmpty(JBIterable.java:762)
at com.intellij.psi.util.PsiTreeUtil.hasErrorElements(PsiTreeUtil.java:1222)
at ui.structureview.MyStructureViewRootElement.getChildren(MyStructureViewElements.kt:85)
at ui.structureview.MyStructureViewRootElement.getChildren(MyStructureViewElements.kt:69)
at com.intellij.ide.util.treeView.smartTree.TreeElementWrapper.initChildren(TreeElementWrapper.java:35)
at com.intellij.ide.util.treeView.smartTree.CachingChildrenTreeNode.rebuildSubtree(CachingChildrenTreeNode.java:207)
at com.intellij.ide.util.treeView.smartTree.CachingChildrenTreeNode.ensureChildrenAreInitialized(CachingChildrenTreeNode.java:41)
at com.intellij.ide.util.treeView.smartTree.CachingChildrenTreeNode.getChildre
<TRIMMED STACKTRACE>
ctionAndCancelBeforeWrite(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.util.concurrency.Invoker.invokeSafely(Invoker.java:188)
at com.intellij.util.concurrency.Invoker.lambda$offerSafely$0(Invoker.java:165)
at com.intellij.util.concurrency.Invoker$Background.lambda$offer$0(Invoker.java:433)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:31)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:215)
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)
0

Why do you call PsiTreeUtil.hasErrorElements(psiFile) for each children with psiFile, and not the current (parent) node?

0

Hi Yann

I have MyStructureViewRootElement for root elements and MyStructureViewChildElement for child elements. And PsiTreeUtil.hasErrorElements(psiFile) called inside MyStructureViewRootElement. So it's called only for root elements. 

Maybe i missed something and can simplify it? 

0

Yann,

Maybe I can add this check to some other part? Maybe there is some listener for this? I need to check where some errors and if errors exist I just don't show any child elements in my StructureView

0

Try using com.intellij.util.PsiErrorElementUtil#hasErrors(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile) which caches the results (traversing whole PsiFile potentially is a really expensive operation).

2

Thanks Yann! I'll try :)

0

请先登录再写评论。