void (@NotNull Project project, Editor editor, PsiFile file) { VirtualFile vFile = file.getVirtualFile(); Document document = PsiDocumentManager.getInstance(project).getDocument(file); FileDocumentManager.getInstance().saveDocument(document); try { vFile.rename(file.getManager(), myNewFileName); } catch (IOException e) { MessagesEx.error(project, e.getMessage()).showLater(); } }