Collection<SyntheticLibraryIteratorBuilder> (List<? extends SyntheticLibraryDescriptor> librariesDescriptorsAfter, Collection<VirtualFile> files) { if (files.isEmpty()) return Collections.emptyList(); List<SyntheticLibraryIteratorBuilder> builders = new ArrayList<>(); for (SyntheticLibraryDescriptor lib : librariesDescriptorsAfter) { List<VirtualFile> roots = new ArrayList<>(); Iterator<VirtualFile> iterator = files.iterator(); while (iterator.hasNext()) { VirtualFile file = iterator.next(); if (lib.contains(file)) { roots.add(file); iterator.remove(); } } if (!roots.isEmpty()) { builders.add(new SyntheticLibraryIteratorBuilder(lib.library, lib.presentableLibraryName, roots)); } if (files.isEmpty()) { return builders; } } LOG.error("Failed fo find SyntheticLibrary roots for " + StringUtil.join(files, "\n")); return builders; }