I've created an inspection tool, which shows problems for the current file from an offline problem-source. The problem-source was generated by a CI system on VCS commit, so if files are synchronized it shows the the problems in the right position.
When user start editing the file (e.g. addig new lines), the problems are missplaced.
I don't really know the proper solution for this problem. I guess, I should use the ChangeListManager to find the Change for the file. But the Change will only contain the plaintext contets Before and After.
I still have two ideas:
1. Create a PsiFile from the Before content string. Create PsiElement a lookup table for the problems, and find the right PsiElement in the current file.
2. Use diff tool to create patch from the Before and After content so I can count the line changes occurred above a problem place, and slide the placement of the problem if needed.
What do you think? Maybe there is a third (better) way to do this?