private static boolean emptyLineCanBeDeletedAccordingToCodeStyle(PsiFile file, Document document, int offset) {
    CharSequence text = document.getImmutableCharSequence();
    String whitespace = " \t\n";
    int whitespaceStartOffset = CharArrayUtil.shiftBackward(text, offset - 1, whitespace) + 1;
    int whitespaceEndOffset = CharArrayUtil.shiftForward(text, offset, whitespace);
    int minLineFeeds = CodeStyleManager.getInstance(file.getProject()).getMinLineFeeds(file, whitespaceEndOffset);
    int actualLineFeeds = StringUtil.countNewLines(text.subSequence(whitespaceStartOffset, whitespaceEndOffset));
    return actualLineFeeds > minLineFeeds;
  }
private static boolean emptyLineCanBeDeletedAccordingToCodeStyle(PsiFile file, Document document, int offset)