@Override
  public @NotNull PsiFile copyFileFrom(@NotNull String newName, @NotNull PsiFile originalFile) throws IncorrectOperationException {
    checkCreateFile(newName);

    Document document = PsiDocumentManager.getInstance(getProject()).getDocument(originalFile);
    if (document != null) {
      FileDocumentManager.getInstance().saveDocument(document);
    }

    VirtualFile parent = getVirtualFile();
    try {
      VirtualFile vFile = originalFile.getVirtualFile();
      if (vFile == null) throw new IncorrectOperationException("Cannot copy non-physical file: " + originalFile);

      VirtualFile copyVFile;
      if (parent.getFileSystem() == vFile.getFileSystem()) {
        copyVFile = vFile.copy(this, parent, newName);
      }
      else if (vFile instanceof LightVirtualFile) {
        copyVFile = parent.createChildData(this, newName);
        copyVFile.setBinaryContent(vFile.contentsToByteArray());
      }
      else {
        copyVFile = VfsUtilCore.copyFile(this, vFile, parent, newName);
      }
      if (UPDATE_ADDED_FILE_KEY.get(this, true)) {
        DumbService.getInstance(getProject()).completeJustSubmittedTasks();
        PsiFile copyPsi = findCopy(copyVFile, vFile);
        UpdateAddedFileProcessor.updateAddedFiles(Collections.singletonList(copyPsi), Collections.singletonList(originalFile));
        return copyPsi;
      }
      return findCopy(copyVFile, vFile);
    }
    catch (IOException e) {
      throw new IncorrectOperationException(e);
    }
  }
@Override
  public @NotNull PsiFile copyFileFrom(@NotNull String newName, @NotNull PsiFile originalFile)