void () { ThreadingAssertions.assertEventDispatchThread(); TreePath[] selected = getSelectionPaths(); if (selected == null) return; if (!getContext().getUIOptions().FILTER_RESOLVED_ITEMS) { for (TreePath path : selected) { InspectionTreeNode node = (InspectionTreeNode)path.getLastPathComponent(); myModel.traverse(node).forEach(InspectionTreeNode::dropProblemCountCaches); } return; } Set<InspectionTreeNode> processedNodes = new HashSet<>(); List<InspectionTreeNode> toRemove = new ArrayList<>(); for (TreePath path : selected) { Object[] nodePath = path.getPath(); // ignore root for (int i = 1; i < nodePath.length; i++) { InspectionTreeNode node = (InspectionTreeNode) nodePath[i]; if (!processedNodes.add(node)) continue; if (shouldDelete(node)) { toRemove.add(node); break; } } } if (toRemove.isEmpty()) return; TreePath pathToSelect = null; if (selected.length == 1) { final InspectionTreeNode nextNode = myModel .traverseFrom((InspectionTreeNode) selected[0].getLastPathComponent(), true) .filter(n -> !shouldDelete(n)).first(); if (nextNode != null) pathToSelect = TreeUtil.getPathFromRoot(nextNode); } else { TreePath commonAliveAncestorPath = TreePathUtil.findCommonAncestor(selected); while (commonAliveAncestorPath != null && shouldDelete((InspectionTreeNode) commonAliveAncestorPath.getLastPathComponent())) { commonAliveAncestorPath = commonAliveAncestorPath.getParentPath(); } if (commonAliveAncestorPath != null) pathToSelect = commonAliveAncestorPath; } Set<InspectionTreeNode> parents = new HashSet<>(); for (InspectionTreeNode node : toRemove) { InspectionTreeNode parent = node.getParent(); if (parent != null) { myModel.remove(node); parents.add(parent); } } for (InspectionTreeNode parent : parents) { parent.dropProblemCountCaches(); } TreeUtil.selectPath(this, pathToSelect); revalidate(); repaint(); }