static @Nullable String collapse2EclipseVariabledPath(final LibraryOrderEntry libraryOrderEntry, OrderRootType type) {
    final VirtualFile[] virtualFiles = libraryOrderEntry.getRootFiles(type);
    if (virtualFiles.length > 0) {
      VirtualFile jarFile = virtualFiles[0];
      if (jarFile.getFileSystem() instanceof JarFileSystem) {
        jarFile = JarFileSystem.getInstance().getVirtualFileForJar(jarFile);
      }
      if (jarFile == null) {
        return null;
      }
      final Project project = libraryOrderEntry.getOwnerModule().getProject();
      final VirtualFile baseDir = project.getBaseDir();
      final String filePath = jarFile.getPath();
      if (baseDir != null && !VfsUtilCore.isAncestor(baseDir, jarFile, false)) {
         final String ideaCollapsed = PathMacroManager.getInstance(project).collapsePath(filePath);
         if (ideaCollapsed.contains("..")) return null;
        final int index = ideaCollapsed.indexOf('$');
        if (index < 0) return null;
        return ideaCollapsed.substring(index).replace("$", "");
      }
    }
    for (String url : libraryOrderEntry.getRootUrls(type)) {
      //check if existing eclipse variable points inside project or doesn't exist
      String filePath = VirtualFileManager.extractPath(url);
      final int jarSeparatorIdx = filePath.indexOf(JarFileSystem.JAR_SEPARATOR);
      if (jarSeparatorIdx > -1) {
        filePath = filePath.substring(0, jarSeparatorIdx);
      }
      final Map<String, String> pathMacros = PathMacros.getInstance().getUserMacros();
      for (String name : pathMacros.keySet()) {
        final String path = FileUtil.toSystemIndependentName(pathMacros.get(name));
        if (filePath.startsWith(path + "/")) {
          final String substr = filePath.substring(path.length());
          return name + (substr.startsWith("/") || substr.isEmpty() ? substr : "/" + substr);
        }
      }
    }
    return null;
  }
static @Nullable String collapse2EclipseVariabledPath(final LibraryOrderEntry libraryOrderEntry, OrderRootType type)