private static int getEndOffset(@NotNull Caret caret) {
      Document document = caret.getEditor().getDocument();
      int startOffset = caret.getOffset();
      int endOffset = DocumentUtil.getLineEndOffset(startOffset, document);
      if (endOffset < document.getTextLength() &&
          CharArrayUtil.isEmptyOrSpaces(document.getImmutableCharSequence(), startOffset, endOffset)) {
        endOffset++;
      }
      return endOffset;
    }
private static int getEndOffset(@NotNull Caret caret)