throwable in PsiViewer
I got the following exception in the PsiViewer while editing an ANT
build file. Auto scroll from source was enabled, but the PsiViewer tool
window was not visible.
Bas
Error message: Assertion failed: Invalid root element
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:64)
at
com.intellij.psi.impl.source.tree.SharedImplUtil.findCharTableByTree(SharedImplUtil.java:107)
at
com.intellij.psi.impl.source.tree.LeafElementImpl.b(LeafElementImpl.java:19)
at
com.intellij.psi.impl.source.tree.LeafElementImpl.getTextLength(LeafElementImpl.java:48)
at
com.intellij.psi.impl.source.tree.TreeElement.getTextRange(TreeElement.java:69)
at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at idea.util.IntrospectionUtil.getValue(IntrospectionUtil.java:66)
at
idea.plugin.psiviewer.view.PropertySheetPanel.setTarget(PropertySheetPanel.java:66)
at
idea.plugin.psiviewer.view.PsiViewerPanel.updatePropertySheet(PsiViewerPanel.java:247)
at
idea.plugin.psiviewer.view.PsiViewerPanel.setSelectedElement(PsiViewerPanel.java:230)
at
idea.plugin.psiviewer.view.PsiViewerPanel.access$600(PsiViewerPanel.java:55)
at
idea.plugin.psiviewer.view.PsiViewerPanel$ViewerTreeSelectionListener.valueChanged(PsiViewerPanel.java:196)
at
javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(DefaultTreeSelectionModel.java:629)
at
javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(DefaultTreeSelectionModel.java:1076)
at
javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(DefaultTreeSelectionModel.java:287)
at
javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(DefaultTreeSelectionModel.java:170)
at javax.swing.JTree.setSelectionPath(JTree.java:1168)
at
idea.plugin.psiviewer.view.PsiViewerPanel.resetTree(PsiViewerPanel.java:129)
at
idea.plugin.psiviewer.view.PsiViewerPanel.showRootElement(PsiViewerPanel.java:107)
at
idea.plugin.psiviewer.view.PsiViewerPanel.setRootElement(PsiViewerPanel.java:300)
at
idea.plugin.psiviewer.view.PsiViewerPanel.selectRootElement(PsiViewerPanel.java:96)
at
idea.plugin.psiviewer.view.PsiViewerPanel.refreshRootElement(PsiViewerPanel.java:101)
at
idea.plugin.psiviewer.controller.project.EditorListener$2.actionPerformed(EditorListener.java:148)
at javax.swing.Timer.fireActionPerformed(Timer.java:271)
at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:83)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:112)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:156)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Please sign in to leave a comment.
Hi Bas,
I can't reproduce the problem on my system (#3144). Can you either set ]]> in irida/bin/log.xml and send me the relevant part of the log or show me how to cause it to happen?
Cheers,
A.
Hi Andrew,
Andrew Armstrong wrote:
Setting the priority to DEBUG slowed down IDEA so much it wasn't usable
anymore. So how I cause it to happen:
1. enable "auto scroll from source" and "properties"
2. create the following almost empty build file
]]>
3. select the [basedir="."] property and delete it.
4. wait a second for auto scroll from source to kick in and poof!
This is on IDEA #3200 by the way.
Hope this helps,
Bas
Thanks Bas, I've reproduced the problem now.
Looks like the NPE is caused in JB code when com.intellij.psi.impl.source.tree.TreeElement.getStartOffset() is called (admission: I decompiled it to find out...probably illegal, sorry JB). The getStartOffset method walks the list of child psi elements runs into a null child without defensively checking for null.
Whether this is a bug in JB code is debatable because PsiViewer is using introspection to call all the 'getters' on the psi element in question after a timer pops - so JB code is being called when it may not normally be sane to do so.
How to fix it? I'm not sure a robust solution is out there. I've tried checking for valid parent/child relationships before invoking getters, but this only mitigates the problem rather than elminating it. Hiding the property sheet while you are changing files would be a workaround, abeit a rather inconvenient one.
Cheers,
A.