RangeMarker quiestions

So I found in the OpenAPI where it's possible to create a "RangeMarker" . Here is the relevant documentation-

from class Document at

RangeMarker createRangeMarker(int startOffset, int endOffset)
Creates a range marker which points to the specified range of text in the document and is automatically adjusted when the document text is changed.

I want to keep track of the statements my plugin generates in the plug-in user's code (it generates plain old java statements in code as if the user had written them).

If I associate a RangeMarker with the statements and save off the information at closing,

I am looking for insights to any of the following :

question 1 )
what can go wrong?

question 2)
Is this how one would implement this functionality?

question 3)
Is this the API that is in fact used to implement Bookmarks?

question 4)
The promise of the RangeMarker surviving refactorings sounds too good to be true. In the extreme case, (not a use-case I am anticipating for my plug in, but in general) the statement itself could either be mutated so much it's hard to say whether it's even the same statement anymore or not. Do you know how that eventuality is dealt with?



Please sign in to leave a comment.