So I'm working on a custom language plugin which fetches all code diagnostics from an external analyser process. The returned diagnostics are simply a list of ranges each with an error/warning/info/... message.
Given that both `LocalInspectionTool` and `Annotator` will visit every PSI element in a file (with a `PsiElementVisitor` in the case of `LocalInspectionTool` and a call to `annotate(...)` on every element in the case of `Annotator`) I am forced to look for a diagnostic for every single element, which is very inefficient especially that generally most elements will not have a diagnostic. I could implement some sort of smart consumer that tries to find diagnostics faster and removes those that were found to speed up subsequent lookups, but I doubt it would be significantly better since it wouldn't change the fact that every element will be visited and checked.
So my question is: does the API currently provide a way to do code annotation "the other way around"? Ideally, I would like to be able to just tell the IDE: "there, put an error from this offset to this offset with this message, a warning from that offset to that offset with that message, etc."