Solved it - Hardwork pays off

Within just an hour of posting the previous blog post detailing the problem, I went out for a walk and now, I’m glad to tell you I’ve found the solution to the problem (finally after 3 days! Yay!). Now, the annotations will be created and highlighted, with the highlights sticking to the respective elements.

Here is what I found. The class that I am using to create highlight information is HighlighInfo. HighlighInfo gives more control over how the annotations are displayed and can be configured (a lot) as compared to normal annotations created using annotationHolder.createAnnotation(). Further, HighlightInfo provides an API to set a boolean flag that determines whether the highlights are removed if the document is changed or not. Doesn’t it sound exactly what I was searching for? Just call HighlightInfo.needsUpdateOnTyping(false) and WE ARE DONE! The highlights will not be removed or go haywire when the document is updated. And the developer can easily go on fixing problems line by line. Awesome!

With this out of the way, I’m pumped up for the next phase. I cannot guarantee that the sailing would be smooth, but it sure will be exciting as it had been for the past 2 months, or maybe even more. 😉

Soon.