public static @Nullable String getRelativePath(@NotNull VirtualFile virtualFile,
                                                 @NotNull ProjectFileIndex index,
                                                 final boolean useFQName,
                                                 VirtualFile projectBaseDir) {
    final VirtualFile contentRootForFile = index.getContentRootForFile(virtualFile);
    if (contentRootForFile != null) {
      String relativePath = VfsUtilCore.getRelativePath(virtualFile, contentRootForFile, '/');
      if (relativePath != null) {
        return relativePath;
      }

      if (!virtualFile.getFileSystem().equals(contentRootForFile.getFileSystem())) {
        VirtualFile parent = virtualFile.getParent();
        String relativeToParent = parent != null ? VfsUtilCore.getRelativePath(parent, contentRootForFile, '/') : null;
        if (relativeToParent != null) {
          return relativeToParent + '/' + virtualFile.getName();
        }
      }
      return null;
    }
    final Module module = index.getModuleForFile(virtualFile);
    if (module != null) {
      if (projectBaseDir != null) {
        if (VfsUtilCore.isAncestor(projectBaseDir, virtualFile, false)){
          final String projectRelativePath = VfsUtilCore.getRelativePath(virtualFile, projectBaseDir, '/');
          return useFQName ? projectRelativePath : projectRelativePath.substring(projectRelativePath.indexOf('/') + 1);
        }
      }
      return virtualFile.getPath();
    } else {
      return getLibRelativePath(virtualFile, index);
    }
  }
public static @Nullable String getRelativePath(@NotNull VirtualFile virtualFile,
                                                 @NotNull ProjectFileIndex index,
                                                 final boolean useFQName,
                                                 VirtualFile projectBaseDir)