void (@NotNull String newName) { DataContext editorContext = ((EditorEx)editor).getDataContext(); DataContext context = CustomizedDataContext.create(editorContext, dataId -> PsiElementRenameHandler.DEFAULT_NAME.is(dataId) ? newName : null); RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context); assertNotNull("No handler for this context", renameHandler); renameHandler.invoke(getProject(), editor, getFile(), context); }