How to commit Document changes to Virtual File?
I would like to use a PsiElementVisitor to register various PsiElements in the currently active file, shortly after code completion is invoked. My issue is, the actual string which is inserted via code completion is useless and is therefore removed immediately via document.deleteString(), in the code completion insert handler which I provide. After this, I perform the aforementioned process of registering the PsiElements via psiFile.accept(new PsiElementVisitor() { ... }). However, in the PsiElementVisitor, the entry string (which was deleted from the document) is still present in the PsiFile.
So my question is, is there a way to either not have the entry string inserted at all, or to commit document changes to the PsiFile just before the PsiElementVisitor?
Any help would be greatly appreciated,
Alex
Please sign in to leave a comment.
Found the solution to my issue. Needed to use PsiDocumentManaget.getInstance(project).commitDocument(document), before I called psiFile.accept()