private @Nullable FList<TextRange> findLongestMatchingPrefix(@NotNull String name,
                                                               int patternIndex,
                                                               int nameIndex,
                                                               boolean isAsciiName,
                                                               int fragmentLength, int minFragment) {
    if (patternIndex + fragmentLength >= myPattern.length) {
      return FList.singleton(TextRange.from(nameIndex, fragmentLength));
    }

    // try to match the remainder of pattern with the remainder of name
    // it may not succeed with the longest matching fragment, then try shorter matches
    int i = fragmentLength;
    while (i >= minFragment || (i > 0 && isWildcard(patternIndex + i))) {
      FList<TextRange> ranges;
      if (isWildcard(patternIndex + i)) {
        ranges = matchWildcards(name, patternIndex + i, nameIndex + i, isAsciiName);
      }
      else {
        int nextOccurrence = findNextPatternCharOccurrence(name, nameIndex + i + 1, patternIndex + i, isAsciiName);
        nextOccurrence = checkForSpecialChars(name, nameIndex + i, nextOccurrence, patternIndex + i);
        if (nextOccurrence >= 0) {
          ranges = matchSkippingWords(name, patternIndex + i, nextOccurrence, false, isAsciiName);
        } else {
          ranges = null;
        }
      }
      if (ranges != null) {
        return prependRange(ranges, nameIndex, i);
      }
      i--;
    }
    return null;
  }
private @Nullable FList<TextRange> findLongestMatchingPrefix(@NotNull String name,
                                                               int patternIndex,
                                                               int nameIndex,
                                                               boolean isAsciiName,
                                                               int fragmentLength, int minFragment)