you may take a look how traffic renderer works (upper right corner box which shows you how many errors, warning, etc there are): com.intellij.codeInsight.daemon.impl.TrafficLightRenderer#TrafficLightRenderer. It uses com.intellij.openapi.editor.markup.MarkupModel#getAllHighlighters and com.intellij.codeInsight.daemon.impl.TrafficLightRenderer#incErrorCount which detect the severity of available highliters.
you may take a look how traffic renderer works (upper right corner box which shows you how many errors, warning, etc there are): com.intellij.codeInsight.daemon.impl.TrafficLightRenderer#TrafficLightRenderer. It uses com.intellij.openapi.editor.markup.MarkupModel#getAllHighlighters and com.intellij.codeInsight.daemon.impl.TrafficLightRenderer#incErrorCount which detect the severity of available highliters.
Anna
I had already tried the MarkupModel but there were some casting tricks I wasn't using. The TrafficLightRenderer source was the key! Thanks!