I'm trying to modify plugin so that it supports older version of IDEA (IC-129). One of the problems I've faced is that it uses forcePsiPostprocessAndRestoreElement
from CodeInsightUtilCore
class which does not exist in older sdk. After reading source code I still don't understand what this method is doing. Can someone explain to it's meaning or(and) point to the old way of doing same thing?
When modifying PSI, formatting is applied at the end of a write action or at the explicit call of doPostponedOperationsAndUnblockDocument. This call may be necessary if you need to modify the document, otherwise you'll get an assertion that PSI modification is not yet complete (formatting is missing). Since formatting will change the document and PSI, PsiElement that you have might get invalidated, or at least its range will likely be changed.
forcePsiPostprocessAndRestoreElement performs the postponed formatting immediately and tries to find in the updated tree a PsiElement corresponding to the one you've held before, that you might need for further processing.
Alternatively, you can create SmartPsiElementPointer to that element and hope it will survive formatter modifications (usually it will).