I’ve got a plugin that I would like to enhance with functionality that depends on knowing whether a PsiElement is on a line that has been modified compared to what’s in VCS. This must be possible since that’s what the green gutter marker does, but I’m having trouble figuring out how.
I’ve read How to get the Local History programatically?, but it’s still not clear to me how I would go from a PsiElement to answering the question “is this PsiElement on a line that’s been modified locally?”. Can anyone provide pointers?
Take a look at VcsFacade.getInstance().getChangedRangesInfo(file). You pass that a PsiFile and it returns a ChangedRangesInfo which has a property, allChangedRanges, that is all text ranges in that file that are modified relative to VCS (if active). If your test PsiElement is in one of those ranges, it’s modified relative to VCS. Hope that helps!