PsiTreeChangeEvent error


Hello, I am trying to make plugin which shows hints after end of each line. There is already such plugin, but it has same bug i am getting in my experiments.

I made small test plugin which shows balloon with hints information(start offset, end offset, line, description) on each key press.

The problem is sometimes i am getting "IndexOutOfBoundsException: Wrong offset" on backspace press.

I think it has to do with multithreading but i don't understand what is the problem.

My questions is what is the correct way to handle such events?

1 comment
Comment actions Permalink

The problem is indeed in multi-threading access. You are accessing HIghlightInfos after the document has changed but before these HighlightInfos are updated,and getStartOffset() returns invalid value. HighlightInfo is a very low-level concept which usually shouldn't be used. Instead, please consider using Annotator or LocalInspectionTool. (please see )


Please sign in to leave a comment.