TargetPresentation ( @NotNull T element, @NotNull PsiElementRenderingInfo<? super T> renderingInfo, @NotNull Function<? super @NotNull T, ? extends @Nullable TextAttributes> presentableAttributesProvider, @NotNull Function<? super @NotNull T, ? extends @Nullable TextWithIcon> locationProvider, @NotNull Supplier<? extends @NotNull SimpleTextAttributes> errorAttributesSupplier ) { TargetPresentationBuilder builder = TargetPresentation.builder(renderingInfo.getPresentableText(element)); builder = builder.icon(renderingInfo.getIcon(element)); TextAttributes elementAttributes = presentableAttributesProvider.apply(element); VirtualFile vFile = PsiUtilCore.getVirtualFile(element); if (vFile == null) { builder = builder.presentableTextAttributes(elementAttributes); } else { Project project = element.getProject(); TextAttributes presentableAttributes = elementAttributes; if (presentableAttributes == null) { Color color = FileStatusManager.getInstance(project).getStatus(vFile).getColor(); if (color != null) { presentableAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color).toTextAttributes(); } } if (WolfTheProblemSolver.getInstance(project).isProblemFile(vFile)) { presentableAttributes = TextAttributes.merge(errorAttributesSupplier.get().toTextAttributes(), presentableAttributes); } builder = builder.presentableTextAttributes(presentableAttributes); builder = builder.backgroundColor(getFileBackgroundColor(project, vFile)); } String containerText = renderingInfo.getContainerText(element); if (containerText != null) { var matcher = CONTAINER_PATTERN.matcher(containerText); builder = builder.containerText(matcher.matches() ? matcher.group(2) : containerText); } TextWithIcon itemLocation = locationProvider.apply(element); if (itemLocation != null) { builder = builder.locationText(itemLocation.getText(), itemLocation.getIcon()); } return builder.presentation(); }