String (final String url, final ModuleRootModel model) { final Project project = model.getModule().getProject(); final VirtualFile contentRoot = getContentRoot(model); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); if (file != null) { LOG.assertTrue(file.isValid()); if (file.getFileSystem() instanceof JarFileSystem) { final VirtualFile jarFile = JarFileSystem.getInstance().getVirtualFileForJar(file); if (jarFile == null) { LOG.error("Url: '" + url + "'; file: " + file); return ProjectRootManagerImpl.Companion.extractLocalPath(url); } file = jarFile; } if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, file, false)) { //inside current project return VfsUtilCore.getRelativePath(file, contentRoot, '/'); } else { final String path = collapse2eclipseRelative2OtherModule(project, file); //relative to other project if (path != null) { return path; } } } else { //try to avoid absolute path for deleted file if (contentRoot != null) { final String rootUrl = contentRoot.getUrl(); if (url.startsWith(rootUrl) && url.length() > rootUrl.length()) { return url.substring(rootUrl.length() + 1); //without leading / } } final VirtualFile projectBaseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir(); assert projectBaseDir != null; final String projectUrl = projectBaseDir.getUrl(); if (url.startsWith(projectUrl)) { return url.substring(projectUrl.length()); //leading / } final String path = VfsUtilCore.urlToPath(url); final String projectPath = projectBaseDir.getPath(); if (path.startsWith(projectPath)) { return ProjectRootManagerImpl.Companion.extractLocalPath(path.substring(projectPath.length())); } } return ProjectRootManagerImpl.Companion.extractLocalPath(url); //absolute path }