public static @NotNull Pair<Integer, @Nls String> extractMnemonic(@Nullable @Nls String text) {
    if (text == null) return pair(0, null);

    int mnemonic = 0;
    @Nls StringBuilder plainText = new StringBuilder();
    for (int i = 0; i < text.length(); i++) {
      char ch = text.charAt(i);
      if (ch == '_' || ch == '&') {
        //noinspection AssignmentToForLoopParameter
        i++;
        if (i >= text.length()) {
          break;
        }
        ch = text.charAt(i);
        if (ch != '_' && ch != '&') {
          // Mnemonic is case-insensitive
          int vk = ch;
          if (vk >= 'a' && vk <= 'z') {
            vk -= 'a' - 'A';
          }
          mnemonic = vk;
        }
      }
      plainText.append(ch);
    }
    return pair(mnemonic, plainText.toString());
  }
public static @NotNull Pair<Integer, @Nls String> extractMnemonic(@Nullable @Nls String text)