Comparator<T> (@NotNull PsiElementRenderingInfo<? super T> renderingInfo) { return Comparator.comparing(element -> ReadAction.compute(() -> { String elementText = renderingInfo.getPresentableText(element); String containerText = renderingInfo.getContainerText(element); TextWithIcon moduleTextWithIcon = PsiElementListCellRenderer.getModuleTextWithIcon(element); return (containerText == null ? elementText : elementText + " " + containerText) + (moduleTextWithIcon != null ? moduleTextWithIcon.getText() : ""); })); }