Inconsistent behavior when building structureview in intellij and pycharm


I'm the author of r4intellij. I've implemented the structure view as suggested in the manual. See here for the code. It works well in intellij itself, however users of pycharm (same for webstorm) reported the following NPE:

at com.intellij.ide.structureView.TextEditorBasedStructureViewModel.(
at com.r4intellij.psi.RScriptStructureViewFactory$RStructureViewModel.(
at com.r4intellij.psi.RScriptStructureViewFactory$1.createStructureViewModel(
at com.intellij.ide.structureView.TreeBasedStructureViewBuilder.createStructureView(
at com.intellij.ide.impl.StructureViewWrapperImpl.rebuild(
at com.intellij.ide.impl.StructureViewWrapperImpl$
at com.intellij.util.ui.update.MergingUpdateQueue.execute(
at com.intellij.util.ui.update.MergingUpdateQueue.execute(
at com.intellij.util.ui.update.MergingUpdateQueue$
at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(

It seems that the psiFile provided by the WebStorm to my PsiStructureViewFactory implmementation is null. Since it is perfectly fine for the plugin-in idea, I don't know how to track down the problem. Do you have any ideas?

Both windows and macos are affected, so it's more likely to be a classpath/openapi versioning issue.

Thank you,
best regards,
Holger Brandl

1 comment
Comment actions Permalink

This is a bug in PyCharm. As a workaround, please use the constructor of TextEditorBasedStructureViewModel that takes two parameters (Editor and PsiFile).


Please sign in to leave a comment.