private static int parseUnicodeEscape(boolean isAfterEscapedBackslash, @NotNull String s, int index,
                                        boolean textBlock,
                                        @NotNull StringBuilder out) {
    int len = s.length();
    // uuuuu1234 is valid too
    do {
      index++;
    }
    while (index < len && s.charAt(index) == 'u');
    if (index + 4 > len) return -1;
    try {
      char c = s.charAt(index);
      if (c == '+' || c == '-') return -1;
      int code = Integer.parseInt(s.substring(index, index + 4), 16);
      // unicode escaped line separators are invalid here when not a text block
      if (!textBlock && (code == 0x000a || code == 0x000d)) return -1;
      char escapedChar = (char)code;
      if (escapedChar == '\\') {
        if (isAfterEscapedBackslash) {
          // \u005c\u005c
          out.append('\\');
          return index + 4;
        }
        else {
          // u005cxyz
          return parseEscapedSymbol(true, s, index + 4, textBlock, out);
        }
      }
      if (isAfterEscapedBackslash) {
        // e.g. \u005c\u006e is converted to newline
        if (parseEscapedChar(escapedChar, textBlock, out)) return index + 4;
        return -1;
      }
      // just single unicode escape sequence
      out.append(escapedChar);
      return index + 4;
    }
    catch (NumberFormatException ignored) {
      return -1;
    }
  }
private static int parseUnicodeEscape(boolean isAfterEscapedBackslash, @NotNull String s, int index,
                                        boolean textBlock,
                                        @NotNull StringBuilder out)