Exception: Null name for PSI element class ... on CTRL+Click

Answered

I am working on a custom language plugin, and I find I am getting an exception when CMD+clicking on a string element that I resolve references in. Sometimes the string does not resolve, and when it does, it throws an exception (Stack Trace Below). The element only resolves when I run the check shortly after editing the contents of the string. If It has been a while, the string simply resolves to itself.

The string is part of a named variable call in the plugin language. The variables have no initial declaration, so I multiResolve to every instance of the variable with that string name.

I have done everything I can to ensure name is not null, but I am not sure what name is referring to. The string type is a PsiNamedElement, and its parent type is a PsiNamedIdentifierOwner. Neither element ever returns a null string for getName.

I am not sure if it is related, but when I rename the element, it re-indexes every element containing a string element. When right clicking the string immediately after renaming, the IDE locks up for 30 seconds or more, while it indexes everything, and then the editor runs resolve over and over again until it finally succeeds to highlight all instances.

If anyone can explain how to prevent this exception, I would appreciate it.

java.lang.Throwable: Null name for PSI element class com.badahori.creatures.plugins.intellij.agenteering.caos.psi.impl.CaosScriptQuoteStringLiteralImpl (by com.intellij.ide.util.DefaultPsiElementCellRenderer[,0,0,0x0,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=])
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:145)
at com.intellij.ide.util.PsiElementListCellRenderer$LeftRenderer.customizeCellRenderer(PsiElementListCellRenderer.java:145)
at com.intellij.ui.ColoredListCellRenderer.getListCellRendererComponent(ColoredListCellRenderer.java:53)
at com.intellij.ide.util.PsiElementListCellRenderer.getListCellRendererComponent(PsiElementListCellRenderer.java:225)
at com.intellij.ui.ExpandedItemListCellRendererWrapper.getListCellRendererComponent(ExpandedItemListCellRendererWrapper.java:38)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1361)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1311)
at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(BasicListUI.java:2623)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:184)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:164)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:211)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:405)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:415)
at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:459)
at javax.swing.JList.setSelectedIndex(JList.java:2216)
at com.intellij.ui.popup.PopupListAdapter.autoSelect(PopupListAdapter.java:105)
at com.intellij.openapi.ui.popup.PopupChooserBuilder.createPopup(PopupChooserBuilder.java:317)
at com.intellij.codeInsight.navigation.NavigationUtil.getPsiElementPopup(NavigationUtil.java:118)
at com.intellij.codeInsight.navigation.NavigationUtil.getPsiElementPopup(NavigationUtil.java:89)
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.chooseAmbiguousTarget(GotoDeclarationAction.java:229)
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.chooseAmbiguousTarget(GotoDeclarationAction.java:157)
at com.intellij.codeInsight.navigation.actions.GotoDeclarationAction.invoke(GotoDeclarationAction.java:92)
at com.intellij.codeInsight.actions.CodeInsightAction.lambda$null$0(CodeInsightAction.java:59)
at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$1(CodeInsightAction.java:65)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:220)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:178)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:159)
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(CodeInsightAction.java:56)
at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:29)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:260)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:275)
at com.intellij.openapi.keymap.impl.IdeMouseEventDispatcher.dispatchMouseEvent(IdeMouseEventDispatcher.java:261)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:691)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

 

1 comment
Comment actions Permalink

Please check return value from com.intellij.psi.presentation.java.SymbolPresentationUtil#getSymbolPresentableText, is returning null from com.intellij.navigation.ItemPresentation#getPresentableText?

0

Please sign in to leave a comment.