public static @NotNull String getRelativePath(@NotNull Project project, @NotNull String text) {
    text = text.trim();
    if (project.isDefault() || project.getBasePath() == null || Strings.isEmptyOrSpaces(text)) {
      return text;
    }

    Path file = Paths.get(text);
    if (!file.isAbsolute()) {
      return text;
    }

    String relativePath = FileUtil.getRelativePath(project.getBasePath(), FileUtil.toSystemIndependentName(file.toString()), '/');
    if (relativePath != null) {
      return relativePath;
    }

    VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByNioFile(file);
    if (virtualFile == null) {
      return text;
    }

    VirtualFile projectBaseDir = LocalFileSystem.getInstance().findFileByPath(project.getBasePath());
    if (projectBaseDir == null) {
      return text;
    }

    if (isMeaningfulAncestor(VfsUtilCore.getCommonAncestor(virtualFile, projectBaseDir))) {
      String path = VfsUtilCore.findRelativePath(projectBaseDir, virtualFile, File.separatorChar);
      if (path != null) {
        return path;
      }
    }
    return text;
  }
public static @NotNull String getRelativePath(@NotNull Project project, @NotNull String text)