int (@NotNull String name, boolean valueStartCaseMatch, @Nullable FList<? extends TextRange> fragments) { if (fragments == null) return Integer.MIN_VALUE; if (fragments.isEmpty()) return 0; final TextRange first = fragments.getHead(); boolean startMatch = first.getStartOffset() == 0; boolean valuedStartMatch = startMatch && valueStartCaseMatch; int errors = 0; int matchingCase = 0; int p = -1; int skippedHumps = 0; int nextHumpStart = 0; boolean humpStartMatchedUpperCase = false; for (TextRange range : fragments) { for (int i = range.getStartOffset(); i < range.getEndOffset(); i++) { boolean afterGap = i == range.getStartOffset() && first != range; boolean isHumpStart = false; while (nextHumpStart <= i) { if (nextHumpStart == i) { isHumpStart = true; } else if (afterGap) { skippedHumps++; } nextHumpStart = nextWord(name, nextHumpStart, false); } char c = name.charAt(i); p = Strings.indexOf(myPattern, c, p + 1, myPattern.length, false); if (p < 0) { break; } if (isHumpStart) { humpStartMatchedUpperCase = c == myPattern[p] && isUpperCase[p]; } matchingCase += evaluateCaseMatching(valuedStartMatch, p, humpStartMatchedUpperCase, i, afterGap, isHumpStart, c); } errors += 2000.0 * Math.pow(1.0 * ((Range)range).getErrorCount() / range.getLength(), 2); } int startIndex = first.getStartOffset(); boolean afterSeparator = Strings.indexOfAny(name, myHardSeparators, 0, startIndex) >= 0; boolean wordStart = startIndex == 0 || NameUtilCore.isWordStart(name, startIndex) && !NameUtilCore.isWordStart(name, startIndex - 1); boolean finalMatch = fragments.get(fragments.size() - 1).getEndOffset() == name.length(); return (wordStart ? 1000 : 0) + matchingCase - fragments.size() + -skippedHumps * 10 - errors + (afterSeparator ? 0 : 2) + (startMatch ? 1 : 0) + (finalMatch ? 1 : 0); }