public @Nullable Pair<F, String> suggestRootForFileWithPackageStatement(F file,
                                                                          F topmostPossibleRoot,
                                                                          NullableFunction<? super CharSequence, String> packageNameFetcher,
                                                                          boolean packagePrefixSupported) {
    if (!isFile(file)) return null;

    CharSequence chars;
    try {
      chars = loadText(file);
    }
    catch (IOException e) {
      return null;
    }

    String packageName = packageNameFetcher.fun(chars);
    if (packageName == null) return null;

    F root = getParentFile(file);
    if (root == null) return null;

    int index = packageName.length();
    while (index > 0) {
      int nextIndex = packageName.lastIndexOf('.', index - 1);
      String token = packageName.substring(nextIndex + 1, index);
      String dirName = getName(root);

      boolean equalsToToken = isCaseSensitive(root) ? dirName.equals(token) : dirName.equalsIgnoreCase(token);
      if (!equalsToToken || root.equals(topmostPossibleRoot)) {
        return !packagePrefixSupported ? null : new Pair<>(root, packageName.substring(0, index));
      }

      root = getParentFile(root);
      if (root == null) {
        return null;
      }

      index = nextIndex;
    }

    return new Pair<>(root, "");
  }
public @Nullable Pair<F, String> suggestRootForFileWithPackageStatement(F file,
                                                                          F topmostPossibleRoot,
                                                                          NullableFunction<? super CharSequence, String> packageNameFetcher,
                                                                          boolean packagePrefixSupported)