If the insertString() method is used on the Document available from the Editor are the text offsets for all following PsiElements automatically recalculated? If not is there a way to get them to recalculate?
I am trying to get the text "this." in front of all member variables. I find the text offsets of all PsiReferenceExpressions and if "this." isn't there already I add it with document.insertString(offset, charsequence). This actually works somewhat, but it seems like if it adds more than a couple of strings the offsets for the following elements are not correct anymore, after a couple of insertString the "this." isn't added in the right location.
This actually seems odd to me because it seems like anything after the first one would be off. However, it doesn't really start to get off until after the 3rd one (or so) is inserted.
It would be neat if PsiElement had a setText() method. However, I can understand why it doesn't as in most cases setting the text would probably make it a different element (if I am understanding the document model correctly).