void (@NotNull DifferentiateResult diffResult) { final Delta delta = diffResult.getDelta(); // handle deleted nodes and sources if (!Iterators.isEmpty(diffResult.getDeletedNodes())) { Set<NodeSource> differentiatedSources = Iterators.collect(Iterators.flat(List.of(delta.getBaseSources(), delta.getSources(), delta.getDeletedSources())), new HashSet<>()); for (var deletedNode : diffResult.getDeletedNodes()) { // the set of deleted nodes includes ones corresponding to deleted sources Set<NodeSource> nodeSources = Iterators.collect(myNodeToSourcesMap.get(deletedNode.getReferenceID()), new HashSet<>()); nodeSources.removeAll(differentiatedSources); if (nodeSources.isEmpty()) { myNodeToSourcesMap.remove(deletedNode.getReferenceID()); } else { myNodeToSourcesMap.put(deletedNode.getReferenceID(), nodeSources); } } } for (NodeSource deletedSource : delta.getDeletedSources()) { mySourceToNodesMap.remove(deletedSource); } var updatedNodes = Iterators.collect(Iterators.flat(Iterators.map(delta.getSources(), s -> getNodes(s))), new HashSet<>()); for (BackDependencyIndex index : getIndices()) { BackDependencyIndex deltaIndex = delta.getIndex(index.getName()); assert deltaIndex != null; index.integrate(diffResult.getDeletedNodes(), updatedNodes, deltaIndex); } var deltaNodes = Iterators.unique(Iterators.map(Iterators.flat(Iterators.map(delta.getSources(), s -> delta.getNodes(s))), node -> node.getReferenceID())); for (ReferenceID nodeID : deltaNodes) { Set<NodeSource> sources = Iterators.collect(myNodeToSourcesMap.get(nodeID), new HashSet<>()); sources.removeAll(delta.getBaseSources()); Iterators.collect(delta.getSources(nodeID), sources); myNodeToSourcesMap.put(nodeID, sources); } for (NodeSource src : delta.getSources()) { mySourceToNodesMap.put(src, delta.getNodes(src)); } }