void (final @NotNull VirtualFile virtualFile) { myFile = null; myEditor = null; final Editor editor = createEditor(virtualFile); final Document document = editor.getDocument(); final EditorInfo editorInfo = new EditorInfo(document.getText()); final String newFileText = editorInfo.getNewFileText(); ApplicationManager.getApplication().runWriteAction(() -> { if (!document.getText().equals(newFileText)) { document.setText(newFileText); } PsiFile file = myPsiManager.findFile(virtualFile); if (myFile == null) myFile = file; if (myEditor == null) myEditor = editor; editorInfo.applyToEditor(editor); }); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }