EA-1071353 Filter out null elements in ProjectViewImpl.SelectionInfo.create

Likely the exception happens because something is invalidated or disposed.
We can safely ignore nulls here, the worst that can happen is that some
element won't be re-selected properly, which is still much better than
an exception being thrown, and at least other, still valid, elements
will be re-selected.

GitOrigin-RevId: ce9cd345dd96175e3f53db249d1e3a9725c31efc
This commit is contained in:
Sergei Tachenov
2024-02-12 11:29:58 +02:00
committed by intellij-monorepo-bot
parent 54354060a6
commit e3b8643771

View File

@@ -1735,9 +1735,9 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
}
private static final class SelectionInfo {
private final Object @NotNull [] elements;
private final @NotNull Object @NotNull [] elements;
private SelectionInfo(Object @NotNull [] elements) {
private SelectionInfo(@NotNull Object @NotNull [] elements) {
this.elements = elements;
}
@@ -1768,7 +1768,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
for (TreePath path : selectionPaths) {
NodeDescriptor<?> descriptor = TreeUtil.getLastUserObject(NodeDescriptor.class, path);
if (descriptor != null) {
selectedElements.add(descriptor.getElement());
Object element = descriptor.getElement();
if (element != null) {
selectedElements.add(element);
}
}
}
}