public static boolean isRoot(PsiFileSystemItem directory) { if (directory == null) return true; VirtualFile vFile = directory.getVirtualFile(); if (vFile == null) return true; ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(directory.getProject()); return Comparing.equal(fileIndex.getClassRootForFile(vFile), vFile) || Comparing.equal(fileIndex.getContentRootForFile(vFile), vFile) || Comparing.equal(fileIndex.getSourceRootForFile(vFile), vFile); }
@Override protected String getContainerText(PsiFileSystemItem element, String name) { PsiFileSystemItem parent = element.getParent(); final PsiDirectory psiDirectory = parent instanceof PsiDirectory ? (PsiDirectory) parent : null; if (psiDirectory == null) return null; final VirtualFile virtualFile = psiDirectory.getVirtualFile(); final String relativePath = getRelativePath(virtualFile, element.getProject()); if (relativePath == null) return "( " + File.separator + " )"; String path = FilePathSplittingPolicy.SPLIT_BY_SEPARATOR.getOptimalTextForComponent( name + " ", new File(relativePath), this, myMaxWidth); return "(" + path + ")"; }