@SuppressWarnings("AssignmentToForLoopParameter")
  private static @NotNull String fixCapitalization(@NotNull String s, String @NotNull [] wordsToIgnore, boolean title, boolean mnemonics) {
    StringBuilder buffer = null;
    int length = s.length();
    for (int i = 0; i < length; i++) {
      char prevChar = i == 0 ? ' ' : s.charAt(i - 1);
      char currChar = s.charAt(i);
      if (!Character.isLetterOrDigit(prevChar) && prevChar != '\'') {
        if (Character.isLetterOrDigit(currChar)) {
          if (title || Character.isUpperCase(currChar)) {
            int start = i;
            for (i++; i < length; i++) {
              char c = s.charAt(i);
              if (mnemonics && (c == '&' || c == '_')) continue;
              if (!Character.isLetterOrDigit(c)) break;
            }
            if (!title && i > start + 1 && !Character.isLowerCase(s.charAt(start + 1))) {
              // filter out abbreviations like I18n, SQL and CSS
              continue;
            }
            char prevPrevChar = start > 1 ? s.charAt(start - 2) : 0;
            if (prevChar == '.' && (prevPrevChar == ' ' || prevPrevChar == '*')) {
              // file extension like .java or *.java; don't change its capitalization
              continue;
            }
            if (prevChar == '~' && prevPrevChar == ' ') {
              // special string like ~java or _java; keep it as is
              continue;
            }
            if (!isPreposition(s, start, i - 1, ourOtherNonCapitalizableWords)) {
              boolean firstWord = start == 0 || isPunctuation(prevPrevChar);
              boolean lastWord = i >= length - 1|| isPunctuation(s.charAt(i + 1));
              if (!title || firstWord || lastWord || !isPreposition(s, start, i - 1, wordsToIgnore)) {
                if (buffer == null) {
                  buffer = new StringBuilder(s);
                }
                buffer.setCharAt(start, title ? toUpperCase(currChar) : toLowerCase(currChar));
              }
            }
          }
        }
      }
    }
    return buffer == null ? s : buffer.toString();
  }
@SuppressWarnings("AssignmentToForLoopParameter")
  private static @NotNull String fixCapitalization(@NotNull String s, String @NotNull [] wordsToIgnore, boolean title, boolean mnemonics)