void (@NotNull PackageWrapper aPackage, @NotNull List<? extends VirtualFile> contentSourceRoots, @NotNull LinkedHashSet<? super PsiDirectory> targetDirectories, @NotNull Map<PsiDirectory, String> relativePathsToCreate) { final PsiDirectory[] directories = aPackage.getDirectories(); sourceRoots: for (VirtualFile root : contentSourceRoots) { if (!root.isDirectory()) continue; for (PsiDirectory directory : directories) { if (VfsUtilCore.isAncestor(root, directory.getVirtualFile(), false)) { targetDirectories.add(directory); continue sourceRoots; } } String qNameToCreate; try { qNameToCreate = CommonJavaRefactoringUtil.qNameToCreateInSourceRoot(aPackage, root); } catch (IncorrectOperationException e) { continue; } PsiDirectory currentDirectory = aPackage.getManager().findDirectory(root); if (currentDirectory == null) continue; final String[] shortNames = qNameToCreate.split("\\."); for (int j = 0; j < shortNames.length; j++) { String shortName = shortNames[j]; final PsiDirectory subdirectory = currentDirectory.findSubdirectory(shortName); if (subdirectory == null) { targetDirectories.add(currentDirectory); final StringBuilder postfix = new StringBuilder(); for (int k = j; k < shortNames.length; k++) { String name = shortNames[k]; postfix.append(File.separatorChar); postfix.append(name); } relativePathsToCreate.put(currentDirectory, postfix.toString()); continue sourceRoots; } else { currentDirectory = subdirectory; } } } LOG.assertTrue(targetDirectories.size() <= contentSourceRoots.size()); LOG.assertTrue(relativePathsToCreate.size() <= contentSourceRoots.size()); }