@NotNull
  protected String doExtract(final PsiDirectory targetDirectory,
                             final String targetfileName,
                             final T first,
                             final T last,
                             final Language includingLanguage) throws IncorrectOperationException {
    final PsiFile file = targetDirectory.createFile(targetfileName);
    Project project = targetDirectory.getProject();
    final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    final Document document = documentManager.getDocument(file);
    document.replaceString(0, document.getTextLength(), first.getText().trim());
    documentManager.commitDocument(document);
    CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()).reformat(file);  //TODO: adjustLineIndent

    final String relativePath = PsiFileSystemItemUtil.findRelativePath(first.getContainingFile(), file);
    if (relativePath == null) throw new IncorrectOperationException("Cannot extract!");
    return relativePath;
  }
@NotNull
  protected String doExtract(final PsiDirectory targetDirectory,
                             final String targetfileName,
                             final T first,
                             final T last,
                             final Language includingLanguage)