Mappings (@NotNull List<VcsDirectoryMapping> mappings, @Nullable List<MappedRoot> reuseMappedRoots) { Map<VirtualFile, MappedRoot> mappedRoots = new HashMap<>(); Disposable pointerDisposable = Disposer.newDisposable(); if (!TrustedProjects.isTrusted(myProject)) { return new Mappings(Collections.emptyList(), pointerDisposable); } try { // direct mappings have priority over <Project> mappings for (VcsDirectoryMapping mapping : mappings) { if (mapping.isDefaultMapping()) { continue; } MappedRoot mappedRoot = findDirectMappingFor(mapping, pointerDisposable); if (mappedRoot != null) mappedRoots.putIfAbsent(mappedRoot.root, mappedRoot); } for (VcsDirectoryMapping mapping : mappings) { if (!mapping.isDefaultMapping()) { continue; } List<MappedRoot> defaultMappings; if (reuseMappedRoots != null) { defaultMappings = reuseDefaultMappingsFrom(mapping, reuseMappedRoots, pointerDisposable); } else { Set<VirtualFile> directMappingDirs = ContainerUtil.map2Set(mappedRoots.values(), it -> it.root); defaultMappings = findDefaultMappingsFor(mapping, directMappingDirs, pointerDisposable); } for (MappedRoot mappedRoot : defaultMappings) { mappedRoots.putIfAbsent(mappedRoot.root, mappedRoot); } } List<MappedRoot> result = ContainerUtil.sorted(mappedRoots.values(), ROOT_COMPARATOR); for (MappedRoot root : result) { if (myVcsManager.isIgnored(VcsUtil.getFilePath(root.root))) { LOG.warn("Root mapping is under ignored root: " + root.root); } } return new Mappings(result, pointerDisposable); } catch (Throwable e) { Disposer.dispose(pointerDisposable); ExceptionUtil.rethrow(e); return null; } }