private static int indexOfUnicodeEscape(@NotNull String text,int offset){
  final int length=text.length();
  for (int i=0; i < length; i++) {
    final char c=text.charAt(i);
    if (c != '\\') {
      continue;
    }
    boolean isEscape=true;
    int previousChar=i - 1;
    while (previousChar >= 0 && text.charAt(previousChar) == '\\') {
      isEscape=!isEscape;
      previousChar--;
    }
    if (!isEscape) {
      continue;
    }
    int nextChar=i;
    do {
      nextChar++;
      if (nextChar >= length) {
        break;
      }
    }
 while (text.charAt(nextChar) == 'u');
    if (nextChar == i + 1 || nextChar + 3 >= length) {
      break;
    }
    if (StringUtil.isHexDigit(text.charAt(nextChar)) && StringUtil.isHexDigit(text.charAt(nextChar + 1)) && StringUtil.isHexDigit(text.charAt(nextChar + 2))&& StringUtil.isHexDigit(text.charAt(nextChar + 3))) {
      final int escapeEnd=nextChar + 4;
      if (offset <= escapeEnd) {
        return i;
      }
    }
  }
  return -1;
}

private static int indexOfUnicodeEscape ( @ NotNull String text , int offset ) { final int length = text . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { final char c = text . charAt ( i ) ; if ( c != '\\' ) { continue ; } boolean isEscape = true ; int previousChar = i - 1 ; while ( previousChar >= 0 && text . charAt ( previousChar ) == '\\' ) { isEscape = ! isEscape ; previousChar -- ; } if ( ! isEscape ) { continue ; } int nextChar = i ; do { nextChar ++ ; if ( nextChar >= length ) { break ; } } while ( text . charAt ( nextChar ) == 'u' ) ; if ( nextChar == i + 1 || nextChar + 3 >= length ) { break ; } if ( StringUtil . isHexDigit ( text . charAt ( nextChar ) ) && StringUtil . isHexDigit ( text . charAt ( nextChar + 1 ) ) && StringUtil . isHexDigit ( text . charAt ( nextChar + 2 ) ) && StringUtil . isHexDigit ( text . charAt ( nextChar + 3 ) ) ) { final int escapeEnd = nextChar + 4 ; if ( offset <= escapeEnd ) { return i ; } } } return - 1 ; }
see jls 3 . 3 . unicode escapes
