void (@NotNull PatchBaseDirectoryDetector directoryDetector, @NotNull List<? extends FilePatch> newOrWithoutMatches, @NotNull MultiMap<VirtualFile, AbstractFilePatchInProgress<?>> result) { for (FilePatch patch : newOrWithoutMatches) { String afterName = patch.getAfterName(); String[] strings = getPathParts(afterName); FileBaseMatch best = null; boolean bestIsUnique = true; for (int i = strings.length - 2; i >= 0; --i) { final String name = strings[i]; final Collection<VirtualFile> files = findFilesFromIndex(directoryDetector, name); if (!files.isEmpty()) { // check all candidates for (VirtualFile file : files) { FileBaseMatch match = compareNamesImpl(strings, file, i); if (match != null && match.score < i) { if (best == null || isBetterMatch(match, best)) { best = match; bestIsUnique = true; } else if (!match.file.equals(best.file) && !isBetterMatch(best, match)) { bestIsUnique = false; } } } } } if (best != null && bestIsUnique) { AbstractFilePatchInProgress<?> patchInProgress = createPatchInProgress(patch, best.file); if (patchInProgress == null) { break; } processStipUp(patchInProgress, best.score); result.putValue(best.file, patchInProgress); } else { AbstractFilePatchInProgress<?> patchInProgress = createPatchInProgress(patch, myBaseDir); if (patchInProgress == null) { break; } result.putValue(myBaseDir, patchInProgress); } } }