void (XmlFile xmlFile) { sortItems(xmlFile); PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myPsiManager.getProject()); Document doc = documentManager.getDocument(xmlFile); assert doc != null; documentManager.doPostponedOperationsAndUnblockDocument(doc); FileDocumentManager.getInstance().saveDocument(doc); }