Value of getRangeInElement for PsiReference that is a file Follow
I have an implementation of PsiReference that resolves to a PsiFile, because there is a binding between the value of an attribute and the name of the file this attribute is in, they have to be equal.
While renaming is working as expected there is something I don't like about the "Preview" window when renaming the attribute. It correctly shows the file as a reference, but since I have to return a range in getRangeInElement it shows the first N characters of that file and puts it under "References in string constants", which is not very nice.
How do I handle this situation so that it correctly considers the filename as the reference and not text within the file?
Please sign in to leave a comment.
I'm not quite understand how your reference is implemented. 'getRangeInElement' is supposed to return the range inside the underlying element (i.e. the element returned by 'getElement' method, which contains the reference), not inside the target element (returned by 'resolve' method). Could you please provide more details about your implementation?
Thank you for your reply. The element in my reference is a PsiFile. You can imagine it is like that:
PolicyA.xml contains <Policy name="PolicyA">...</Policy>
So in resolve() I am returning the XmlAttribute and the element my reference returns is the PsiFile for PolicyA.xml. Now there is no "range" inside the file, the name of the file itself should be the reference.
Did it get more clear what I mean?