String (PsiElement element, String text, String presentablePath) { if (text.startsWith("(") && text.endsWith(")")) { text = text.substring(1, text.length() - 1); } if (presentablePath == null && (text.contains("/") || text.contains(File.separator)) && element instanceof PsiFileSystemItem) { Project project = element.getProject(); String basePath = Optional.ofNullable(project.getBasePath()) .map(FileUtil::toSystemDependentName) .orElse(null); VirtualFile file = ((PsiFileSystemItem)element).getVirtualFile(); if (file != null) { text = FileUtil.toSystemDependentName(text); String filePath = FileUtil.toSystemDependentName(file.getPath()); if (basePath != null && FileUtil.isAncestor(basePath, filePath, true)) { text = ObjectUtils.notNull(FileUtil.getRelativePath(basePath, text, File.separatorChar), text); } else { String rootPath = Optional.ofNullable(GotoFileCellRenderer.getAnyRoot(file, project)) .map(root -> FileUtil.toSystemDependentName(root.getPath())) .filter(root -> basePath != null && FileUtil.isAncestor(basePath, root, true)) .orElse(null); text = rootPath != null ? ObjectUtils.notNull(FileUtil.getRelativePath(rootPath, text, File.separatorChar), text) : FileUtil.getLocationRelativeToUserHome(text); } } } return text; }