private void pasteAfterCopy(PsiElement[] elements, Module module, PsiElement target, boolean tryFromFiles) {
      PsiDirectory targetDirectory = elements.length == 1 && elements[0] == target ? null : getTargetDirectory(module, target);
      try {
        if (CopyHandler.canCopy(elements)) {
          CopyHandler.doCopy(elements, targetDirectory);
        }
        else if (tryFromFiles) {
          List<File> files = PsiCopyPasteManager.asFileList(elements);
          if (files != null) {
            PsiManager manager = elements[0].getManager();
            PsiFileSystemItem[] items = files.stream()
              .map(file -> LocalFileSystem.getInstance().findFileByIoFile(file))
              .map(file -> {
                if (file != null) {
                  return file.isDirectory() ? manager.findDirectory(file)
                                            : manager.findFile(file);
                }
                return null;
              })
              .filter(file -> file != null)
              .toArray(PsiFileSystemItem[]::new);
            pasteAfterCopy(items, module, target, false);
          }
        }
      }
      finally {
        if (targetDirectory != null) {
          targetDirectory.putCopyableUserData(SHOW_CHOOSER_KEY, null);
        }
      }
    }
private void pasteAfterCopy(PsiElement[] elements, Module module, PsiElement target, boolean tryFromFiles)