use of com.intellij.openapi.editor.markup.GutterIconRenderer in project intellij-community by JetBrains.
the class LineMarkersPass method queryLineMarkersForInjected.
private static void queryLineMarkersForInjected(@NotNull PsiElement element, @NotNull final PsiFile containingFile, @NotNull Set<PsiFile> visitedInjectedFiles, @NotNull final PairConsumer<PsiElement, LineMarkerInfo> consumer) {
if (containingFile.getViewProvider() instanceof InjectedFileViewProvider)
return;
final InjectedLanguageManager manager = InjectedLanguageManager.getInstance(containingFile.getProject());
InjectedLanguageUtil.enumerate(element, containingFile, false, (injectedPsi, places) -> {
// there may be several concatenated literals making the one injected file
if (!visitedInjectedFiles.add(injectedPsi))
return;
final Project project = injectedPsi.getProject();
Document document = PsiDocumentManager.getInstance(project).getCachedDocument(injectedPsi);
if (!(document instanceof DocumentWindow))
return;
List<PsiElement> injElements = CollectHighlightsUtil.getElementsInRange(injectedPsi, 0, injectedPsi.getTextLength());
final List<LineMarkerProvider> providers = getMarkerProviders(injectedPsi.getLanguage(), project);
queryProviders(injElements, injectedPsi, providers, (injectedElement, injectedMarker) -> {
GutterIconRenderer gutterRenderer = injectedMarker.createGutterRenderer();
TextRange injectedRange = new TextRange(injectedMarker.startOffset, injectedMarker.endOffset);
List<TextRange> editables = manager.intersectWithAllEditableFragments(injectedPsi, injectedRange);
for (TextRange editable : editables) {
TextRange hostRange = manager.injectedToHost(injectedPsi, editable);
Icon icon = gutterRenderer == null ? null : gutterRenderer.getIcon();
GutterIconNavigationHandler<PsiElement> navigationHandler = injectedMarker.getNavigationHandler();
LineMarkerInfo<PsiElement> converted = new LineMarkerInfo<>(injectedElement, hostRange, icon, injectedMarker.updatePass, e -> injectedMarker.getLineMarkerTooltip(), navigationHandler, GutterIconRenderer.Alignment.RIGHT);
consumer.consume(injectedElement, converted);
}
});
});
}
Aggregations