private static @NotNull List<TargetDirectory> getTargets(@NotNull FileReference reference,
                                                           @Nullable Module module,
                                                           String newFileName,
                                                           boolean isDirectory) {
    List<FileTargetContext> contexts = getSuitableContexts(reference, module);

    List<TargetDirectory> targetDirectories = new SmartList<>();

    for (FileTargetContext targetContext : contexts) {
      PsiFileSystemItem context = targetContext.getFileSystemItem();

      VirtualFile virtualFile = context.getVirtualFile();
      if (virtualFile == null || !virtualFile.isValid()) continue;

      if (!isDirectory) {
        FileType ft = FileTypeManager.getInstance().getFileTypeByFileName(newFileName);
        if (ft instanceof UnknownFileType) continue;
      }

      PsiDirectory directory = context.getManager().findDirectory(virtualFile);
      if (directory == null) continue;

      if (!checkFileWriteAccess(reference, directory, targetContext.getPathToCreate(), newFileName, isDirectory)) {
        continue;
      }

      if (module != null) {
        targetDirectories.add(new TargetDirectory(directory, targetContext.getPathToCreate()));
      }
      else {
        targetDirectories.add(new TargetDirectory(directory));
      }
    }
    return targetDirectories;
  }
private static @NotNull List<TargetDirectory> getTargets(@NotNull FileReference reference,
                                                           @Nullable Module module,
                                                           String newFileName,
                                                           boolean isDirectory)