Seeking Guidance on Implementing Coverage Highlighting in IntelliJ IDEA Plugin


Hello IntelliJ IDEA Community!

I am currently working on a custom plugin for IntelliJ IDEA, and I'm looking to implement coverage highlighting similar to what's available in the IDE itself. Specifically, I want to add colored bars in the gutter to indicate which lines of code have been covered during testing.

I've explored using a custom LineMarkerProvider and a custom Icon to represent the colored bars, but I'm having difficulty achieving the exact appearance used by IntelliJ IDEA for coverage highlighting.

If anyone has experience implementing coverage highlighting in their own plugins or has insights into the styling and customization of gutter icons for this purpose, I would greatly appreciate your guidance.

Any tips, examples, or documentation references would be incredibly helpful. Thank you in advance for your assistance!

Official comment

Hi, Niko! 
I can provide some details on how the highlighting is implemented in the coverage module in IntelliJ.
You can look at the `com.intellij.coverage.CoverageEditorAnnotatorImpl` implementation:

`CoverageEditorAnnotatorImpl` is created for all opened files to highlight coverage results in the gutter. In the `createRangeHighlighter` method, a range highlighter is created and a `LineMarkerRenderer` is set.  `CoverageLineMarkerRenderer` is used as a renderer, it implements the `FillingLineMarkerRenderer` interface, so simple rectangle filling is done in the `paint` method.

Hi Maksim,

Thank you so much for your quick and detailed response! 
This is exactly what I was looking for.

Best regards, Niko


Please sign in to leave a comment.