Line Marker best practicies Intellij SDK
Hello, I'm writing plugin for IntelliJ, and can not choose right way of implementing my custom line markers.
My plugin allows to set some line markers and stores information about markered lines in special file.
Now I'm trying to understand what exactly I need to store in my file for right recognizion of the line which needs to be markered.
For example, I can store file path and line num for each marker. In ```getLineMarkerInfo``` method of my implementation of ```LineMarkerProvider``` I will need to check line number and file path. But it's not flexible because every small row number change will break my logic. So, I want to get effect like when breakpoint moves with markered line when I type Enter.
Is there any way to get something like PsiElement ID for detection of markered PsiElement? I guess I can build some PsiElement fingerprint logic (based on parent and other context of element), but I want to know if there is some better way to solve my problem.
Thank you.
Please sign in to leave a comment.
You can try to use existing ElementSignatureProvider-s (or utility method using them - FoldingPolicy.getSignature()). They do not cover all cases, but should be somewhat better than always storing line numbers. They are used currently for persisting of folding state.
BTW, breakpoints are persisted using line numbers currently. They keep their position using basic common RangeHighlighter logic, and only when file change happens while IDEA is running.