use of com.intellij.openapi.editor.markup.CustomHighlighterRenderer in project sonarlint-intellij by SonarSource.
the class SonarLintHighlighting method highlightFlowsWithHighlightersUtil.
/**
* Create highlighting with {@link UpdateHighlightersUtil}. It will manage internally the {@link RangeHighlighter}, and get
* it similarly to the way {@link com.intellij.codeHighlighting.Pass} do it.
* Tooltip will be displayed on mouse hover by {@link com.intellij.codeInsight.daemon.impl.DaemonListeners}.
* Creating the {@link HighlightInfo} with high severity will ensure that it will override most other highlighters.
* The alternative would be to get and manage directly {@link RangeHighlighter} with a {@link MarkupModel} from the
* document (or editors). This would allow to use a custom renderer, but we would have to manage tooltips by ourselves, separately.
*
* @see com.intellij.codeInsight.hint.HintManager
* @see com.intellij.codeInsight.hint.ShowParameterInfoHandler
* @see HintHint
* @see CustomHighlighterRenderer
* @see com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
* @see com.intellij.codeInsight.highlighting.BraceHighlightingHandler
*/
public void highlightFlowsWithHighlightersUtil(RangeMarker rangeMarker, @Nullable String message, List<LiveIssue.Flow> flows) {
stopBlinking();
HighlightInfo primaryInfo = createHighlight(rangeMarker, message);
List<HighlightInfo> infos = flows.stream().flatMap(f -> f.locations().stream().filter(Objects::nonNull).map(l -> createHighlight(l.location(), l.message()))).collect(Collectors.toList());
infos.add(primaryInfo);
UpdateHighlightersUtil.setHighlightersToEditor(project, rangeMarker.getDocument(), 0, rangeMarker.getDocument().getTextLength(), infos, null, HIGHLIGHT_GROUP_ID);
currentHighlightedDoc = rangeMarker.getDocument();
Editor[] editors = EditorFactory.getInstance().getEditors(rangeMarker.getDocument(), project);
List<Segment> segments = Stream.concat(flows.stream().flatMap(f -> f.locations().stream().map(LiveIssue.IssueLocation::location)), Stream.of(rangeMarker)).collect(Collectors.toList());
Arrays.stream(editors).forEach(editor -> {
blinker = new RangeBlinker(editor, new TextAttributes(null, null, JBColor.YELLOW, EffectType.BOXED, Font.PLAIN), 3);
blinker.resetMarkers(segments);
blinker.startBlinking();
});
}
Aggregations