private void reformatAndPostProcess(final PsiElement elementParent) {
    if (elementParent == null || !elementParent.isValid()) return;
    final PsiFile containingFile = elementParent.getContainingFile();

    replaceHandler.postProcess(elementParent, options);
    if (containingFile != null && options.isToReformatAccordingToStyle()) {
      final VirtualFile file = containingFile.getVirtualFile();
      if (file != null) {
        final Document document = FileDocumentManager.getInstance().getDocument(file);
        if (document != null) {
          PsiDocumentManager.getInstance(project).commitDocument(document);
        }
      }

      final int parentOffset = elementParent.getTextRange().getStartOffset();
      CodeStyleManager.getInstance(project).reformatRange(containingFile, parentOffset, parentOffset + elementParent.getTextLength(), true);
    }
  }
private void reformatAndPostProcess(final PsiElement elementParent)