0

当我开发 Intelij Idea 插件时。我重写了方法:

public <Psi extends PsiElement> List<Psi> getAugments(@NotNull PsiElement element,
                                                          @NotNull final Class<Psi> type,
                                                          @Nullable String nameHint)

返回列表包含一些 LightMethodBuilder。像这样创建方法:

LightMethodBuilder onParamMap = new LightMethodBuilder(psiManager, JavaLanguage.INSTANCE, "onParamMap");
            onParamMap.addModifier(PsiModifier.PUBLIC);
            onParamMap.setContainingClass(psiClass);
//        method.setNavigationElement(psiField);
            result.add(onParamMap);

在编辑器中我们可以正常调用onParamMap。但是idea抛出异常。这生成idea无法读取新文件和代码提示失败。我找不到如何解决它。我该如何解决这个问题?非常感谢。想法例外:

java.lang.ArrayStoreException: com.intellij.psi.impl.light.LightMethodBuilder
    at com.intellij.util.ArrayUtil.mergeCollections(ArrayUtil.java:238)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.calcFields(ClassInnerStuffCache.java:115)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.lambda$getFields$0(ClassInnerStuffCache.java:42)
    at com.intellij.psi.util.CachedValuesManager.lambda$getProjectPsiDependentCache$0(CachedValuesManager.java:134)
    at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:54)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227)
    at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42)
    at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227)
    at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:111)
    at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:43)
    at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:43)
    at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155)
    at com.intellij.psi.util.CachedValuesManager.getProjectPsiDependentCache(CachedValuesManager.java:132)
    at com.intellij.psi.impl.source.ClassInnerStuffCache.getFields(ClassInnerStuffCache.java:42)
    at com.intellij.psi.impl.source.PsiClassImpl.getFields(PsiClassImpl.java:271)
    at com.intellij.ide.structureView.impl.java.JavaClassTreeElement.doGetOwnChildren(JavaClassTreeElement.java:69)
    at com.intellij.ide.structureView.impl.java.JavaClassTreeElement.lambda$getOwnChildren$0(JavaClassTreeElement.java:64)
    at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:64)
    at com.intellij.ide.structureView.impl.java.JavaClassTreeElement.getOwnChildren(JavaClassTreeElement.java:64)
    at com.intellij.ide.structureView.impl.java.JavaClassTreeElement.getClassChildren(JavaClassTreeElement.java:42)
    at com.intellij.ide.structureView.impl.java.JavaClassTreeElement.getChildrenBase(JavaClassTreeElement.java:36)
    at com.intellij.ide.structureView.impl.common.PsiTreeElementBase.doGetChildren(PsiTreeElementBase.java:84)
    at com.intellij.ide.structureView.impl.common.PsiTreeElementBase.lambda$getChildren$0(PsiTreeElementBase.java:74)
    at com.intellij.ide.util.treeView.AbstractTreeUi.calculateYieldingToWriteAction(AbstractTreeUi.java:1716)
    at com.intellij.ide.structureView.impl.common.PsiTreeElementBase.getChildren(PsiTreeElementBase.java:74)
    at com.intellij.ide.structureView.impl.common.PsiTreeElementBase.getChildren(PsiTreeElementBase.java:23)
    at com.intellij.ide.util.treeView.smartTree.TreeElementWrapper.initChildren(TreeElementWrapper.java:50)
    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.getChildren(CachingChildrenTreeNode.java:33)
    at com.intellij.ide.structureView.newStructureView.StructureViewComponent$MyNodeWrapper.getChildren(StructureViewComponent.java:796)
    at com.intellij.ide.util.treeView.smartTree.SmartTreeStructure.getChildElements(SmartTreeStructure.java:62)
    at com.intellij.ui.tree.StructureTreeModel.getValidChildren(StructureTreeModel.java:382)
    at com.intellij.ui.tree.StructureTreeModel.validateChildren(StructureTreeModel.java:298)
    at com.intellij.ui.tree.StructureTreeModel.getNode(StructureTreeModel.java:292)
    at com.intellij.ui.tree.StructureTreeModel.getChildren(StructureTreeModel.java:312)
    at com.intellij.ui.tree.AsyncTreeModel$CmdGetChildren.getNode(AsyncTreeModel.java:545)
    at com.intellij.ui.tree.AsyncTreeModel$Command.get(AsyncTreeModel.java:440)
    at com.intellij.ui.tree.AsyncTreeModel$Command.get(AsyncTreeModel.java:406)
    at com.intellij.util.concurrency.Invoker$Task.run(Invoker.java:316)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1096)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runInReadActionWithWriteActionPriority$0(ProgressIndicatorUtils.java:79)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:157)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.lambda$runWithWriteActionPriority$1(ProgressIndicatorUtils.java:119)
    at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:57)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
    at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:57)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runWithWriteActionPriority(ProgressIndicatorUtils.java:116)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runInReadActionWithWriteActionPriority(ProgressIndicatorUtils.java:79)
    at com.intellij.util.concurrency.Invoker.invokeSafely(Invoker.java:205)
    at com.intellij.util.concurrency.Invoker.lambda$offerSafely$0(Invoker.java:183)
    at com.intellij.util.concurrency.Invoker$Background.lambda$offer$0(Invoker.java:541)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:184)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
    at java.base/java.lang.Thread.run(Thread.java:834)
4

0 回答 0