void () { LocalFileSystem lfs = LocalFileSystem.getInstance(); List<VcsDirectoryMapping> oldMappings = new ArrayList<>(getDirectoryMappings()); List<VcsDirectoryMapping> filteredMappings = new ArrayList<>(); VcsDirectoryMapping defaultMapping = ContainerUtil.find(oldMappings, it -> it.isDefaultMapping()); if (defaultMapping != null) { oldMappings.remove(defaultMapping); filteredMappings.add(defaultMapping); } MultiMap<String, VcsDirectoryMapping> groupedMappings = new MultiMap<>(); for (VcsDirectoryMapping mapping : oldMappings) { groupedMappings.putValue(mapping.getVcs(), mapping); } for (Map.Entry<String, Collection<VcsDirectoryMapping>> entry : groupedMappings.entrySet()) { String vcsName = entry.getKey(); Collection<VcsDirectoryMapping> mappings = entry.getValue(); List<Pair<VirtualFile, VcsDirectoryMapping>> objects = ContainerUtil.mapNotNull(mappings, dm -> { VirtualFile vf = lfs.refreshAndFindFileByPath(dm.getDirectory()); return vf == null ? null : Pair.create(vf, dm); }); if (StringUtil.isEmptyOrSpaces(vcsName)) { filteredMappings.addAll(ContainerUtil.map(objects, Functions.pairSecond())); } else { AbstractVcs vcs = myVcsManager.findVcsByName(vcsName); if (vcs == null) { VcsBalloonProblemNotifier.showOverChangesView( myProject, VcsBundle.message("impl.notification.content.vcs.plugin.not.found.for.mapping.to", vcsName), MessageType.ERROR ); filteredMappings.addAll(mappings); } else { filteredMappings.addAll(ContainerUtil.map(vcs.filterUniqueRoots(objects, pair -> pair.getFirst()), Functions.pairSecond())); } } } if (LOG.isDebugEnabled()) { LOG.debug("NewMappings.cleanupMappings", getDirectoryMappings(), filteredMappings); } updateVcsMappings(filteredMappings); }