private static @Nullable TextRange expandToWhiteSpace(@NotNull PsiElement element, int cursorOffset) {
    TextRange elementRange = element.getTextRange();
    if (cursorOffset < elementRange.getStartOffset() || cursorOffset > elementRange.getEndOffset()) return null;

    int startOffset = cursorOffset;
    for (int i = cursorOffset - 1; ; --i) {
      Character charBeforeCursor = SelectWordUtil.getCharAfterCursorInPsiElement(element, i);
      if (charBeforeCursor == null || !SelectWordUtil.isExpandableWhiteSpace(charBeforeCursor)) break;
      startOffset = i;
    }

    int endOffset = cursorOffset;
    for (int i = cursorOffset + 1; ; ++i) {
      Character charAfterCursor = SelectWordUtil.getCharBeforeCursorInPsiElement(element, i);
      if (charAfterCursor == null || !SelectWordUtil.isExpandableWhiteSpace(charAfterCursor)) break;
      endOffset = i;
    }

    if (startOffset == cursorOffset && endOffset == cursorOffset) return null;

    return new TextRange(startOffset, endOffset);
  }
private static @Nullable TextRange expandToWhiteSpace(@NotNull PsiElement element, int cursorOffset)