Say I have a following XML file:
In that file one of the XmlTags would have some userData set. Now if I modify the "Other" text by e.g. adding one new letter thus changing it to "Otther", it would seem that the userData stored in the XmlTag is lost. This happens when the same tag is searched again from the file.
That leads me to believe that the whole structure of the file has been recreated because of that (rather minor) modification and the old XmlTag object has been discarded and replaced with a new one. Is that true?
To put the same question differently, does any modification of a PsiFile cause the whole structure of that PsiFile to be recreated from the scratch?
This would seem to make it very inconvenient to store userData in PsiElements that describe the structure of a Java class or an XML file. Also it probably doesn't make sense to store references to any of those elements as any change to the file would basically make those references outdated, i.e. they would reference to a PsiElement that isn't used anymore.
Is all this true or is there something I don't understand?