private static @Nullable String getRelativePath(@NotNull VirtualFile file, @NotNull Project project) {
    String basePath = project.getBasePath();
    if (basePath != null) {
      basePath = StringUtil.trimEnd(basePath, VfsUtilCore.VFS_SEPARATOR_CHAR) + VfsUtilCore.VFS_SEPARATOR_CHAR;
      String filePath = file.getPath();
      if (filePath.startsWith(basePath)) {
        return filePath.substring(basePath.length());
      }
    }
    VirtualFile contentRoot = ReadAction.compute(() -> {
      if (project.isDisposed() || !file.isValid()) return null;
      return ProjectFileIndex.getInstance(project).getContentRootForFile(file, false);
    });
    return contentRoot != null ? VfsUtilCore.findRelativePath(contentRoot, file, VfsUtilCore.VFS_SEPARATOR_CHAR) : null;
  }
private static @Nullable String getRelativePath(@NotNull VirtualFile file, @NotNull Project project)