public static boolean isSurrogatePair(@NotNull Document document, int offset) {
    CharSequence text = document.getImmutableCharSequence();
    return offset >= 0 &&
           offset + 1 < text.length() &&
           Character.isHighSurrogate(text.charAt(offset)) &&
           Character.isLowSurrogate(text.charAt(offset + 1));
  }
public static boolean isSurrogatePair(@NotNull Document document, int offset)