Skip to content

exception when editing Go file with structure view open #2183

Closed
@sjamesr

Description

@sjamesr

The IDE gets a PsiInvalidElementAccessException when adding a field to a struct when the structure viewer is open. Here is the exception:

Element: class com.goide.psi.impl.GoAnonymousFieldDefinitionImpl because: parent is null
invalidated at: see attachment
com.intellij.psi.PsiInvalidElementAccessException: Element: class com.goide.psi.impl.GoAnonymousFieldDefinitionImpl because: parent is null
invalidated at: see attachment
    at com.intellij.extapi.psi.StubBasedPsiElementBase.getContainingFile(StubBasedPsiElementBase.java:254)
    at com.goide.psi.impl.GoStubbedElementImpl.getContainingFile(GoStubbedElementImpl.java:109)
    at com.goide.psi.impl.GoStubbedElementImpl.getContainingFile(GoStubbedElementImpl.java:37)
    at com.intellij.extapi.psi.StubBasedPsiElementBase.isPhysical(StubBasedPsiElementBase.java:294)
    at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:137)
    at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:49)
    at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:222)
    at com.intellij.psi.impl.PsiCachedValue.getValueWithLock(PsiCachedValue.java:66)
    at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:38)
    at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:129)
    at com.goide.psi.impl.GoNamedElementImpl.getGoType(GoNamedElementImpl.java:115)
    at com.goide.tree.GoStructureViewFactory$Element.getPresentationTextInner(GoStructureViewFactory.java:250)
    at com.goide.tree.GoStructureViewFactory$Element.getPresentableText(GoStructureViewFactory.java:227)
    at com.intellij.ide.projectView.PresentationData.updateFrom(PresentationData.java:183)
    at com.intellij.ide.util.treeView.smartTree.TreeElementWrapper.update(TreeElementWrapper.java:41)

The attachment it refers to looks like:

java.lang.Throwable
    at com.intellij.psi.impl.DebugUtil.startPsiModification(DebugUtil.java:530)
    at com.intellij.pom.core.impl.PomModelImpl.runTransaction(PomModelImpl.java:147)
    at com.intellij.psi.impl.DocumentCommitProcessor$2.run(DocumentCommitProcessor.java:224)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$8.compute(CodeStyleManagerImpl.java:682)
    at com.intellij.psi.impl.source.PostprocessReformattingAspect.disablePostprocessFormattingInside(PostprocessReformattingAspect.java:124)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl$10.compute(CodeStyleManagerImpl.java:717)
    at com.intellij.formatting.FormatterImpl.runWithFormattingDisabled(FormatterImpl.java:924)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:713)
    at com.intellij.psi.impl.source.codeStyle.CodeStyleManagerImpl.performActionWithFormatterDisabled(CodeStyleManagerImpl.java:679)
    at com.intellij.psi.impl.DocumentCommitProcessor.doActualPsiChange(DocumentCommitProcessor.java:209)
    at com.intellij.psi.impl.DocumentCommitProcessor$1.process(DocumentCommitProcessor.java:145)
    at com.intellij.psi.impl.DocumentCommitProcessor$1.process(DocumentCommitProcessor.java:135)
    at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommitInWriteAction(PsiDocumentManagerBase.java:333)
    at com.intellij.psi.impl.PsiDocumentManagerImpl.finishCommitInWriteAction(PsiDocumentManagerImpl.java:143)
    at com.intellij.psi.impl.PsiDocumentManagerBase$3.run(PsiDocumentManagerBase.java:298)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1002)
    at com.intellij.psi.impl.PsiDocumentManagerBase.finishCommit(PsiDocumentManagerBase.java:295)
    at com.intellij.psi.impl.DocumentCommitThread$5.run(DocumentCommitThread.java:528)

Steps to reproduce:

  1. create a new empty Go file
  2. open the structure viewer
  3. enter the following code
package main

type foo struct {
    bar string<caret>
}

While typing bar string you will get an exception like the one above. You can also reproduce by adding a field to an existing struct in some Go file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions