public static boolean processHighlightsOverlappingOutside( @NotNull Document document, @NotNull Project project, @Nullable("null means all") final HighlightSeverity minSeverity, final int startOffset, final int endOffset, @NotNull final Processor<HighlightInfo> processor) { LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project); MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true); return model.processRangeHighlightersOutside( startOffset, endOffset, new Processor<RangeHighlighterEx>() { public boolean process(RangeHighlighterEx marker) { Object tt = marker.getErrorStripeTooltip(); if (!(tt instanceof HighlightInfo)) return true; HighlightInfo info = (HighlightInfo) tt; return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 || info.highlighter == null || processor.process(info); } }); }
public TrafficLightRenderer(Project project, Document document, PsiFile file) { myProject = project; myDaemonCodeAnalyzer = project == null ? null : (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project); myDocument = document; myFile = file; mySeverityRegistrar = SeverityRegistrar.getInstance(myProject); refresh(); if (project != null) { MarkupModelEx model = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true); model.addMarkupModelListener( this, new MarkupModelListener() { @Override public void afterAdded(@NotNull RangeHighlighterEx highlighter) { incErrorCount(highlighter, 1); } @Override public void beforeRemoved(@NotNull RangeHighlighterEx highlighter) { incErrorCount(highlighter, -1); } @Override public void attributesChanged(@NotNull RangeHighlighterEx highlighter) {} }); for (RangeHighlighter rangeHighlighter : model.getAllHighlighters()) { incErrorCount(rangeHighlighter, 1); } } }
public static TextAttributes getAttributesByType( @Nullable final PsiElement element, @NotNull HighlightInfoType type, @NotNull EditorColorsScheme colorsScheme) { final SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(element != null ? element.getProject() : null); final TextAttributes textAttributes = severityRegistrar.getTextAttributesBySeverity(type.getSeverity(element)); if (textAttributes != null) { return textAttributes; } TextAttributesKey key = type.getAttributesKey(); return colorsScheme.getAttributes(key); }