void (@NotNull List<VirtualFile> newRootFiles) { List<Root> oldRoots = model.roots; if (oldRoots == null) { LOG.error("Roots have not been calculated yet, new roots won't be set due to a possible race condition"); return; } List<VirtualFile> oldRootFiles = toRootFiles(oldRoots); if (LOG.isDebugEnabled()) { LOG.debug("New roots: " + newRootFiles + ", old roots: " + oldRootFiles); } removeRoots(oldRoots, findNewElementIndices(oldRootFiles, newRootFiles)); List<Root> rootsToAdd = newRootFiles.stream().filter(root -> !oldRootFiles.contains(root)) .map(root -> new Root(this, root)).collect(Collectors.toList()); addRoots(model.roots, rootsToAdd); }