void (@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) { if (!EditorModificationUtil.checkModificationAllowed(editor)) return; if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) { return; } final PsiElementClassMember target = chooseTarget(file, editor, project); if (target == null) return; final PsiMethodMember[] candidates = chooseMethods(target, file, editor, project); if (candidates == null || candidates.length == 0) return; ApplicationManager.getApplication().runWriteAction(() -> { try { int offset = editor.getCaretModel().getOffset(); List<PsiGenerationInfo<PsiMethod>> prototypes = new ArrayList<>(candidates.length); for (PsiMethodMember candidate : candidates) { prototypes.add(generateDelegatePrototype(candidate, target.getElement())); } List<PsiGenerationInfo<PsiMethod>> results = GenerateMembersUtil.insertMembersAtOffset(file, offset, prototypes); if (!results.isEmpty()) { PsiMethod firstMethod = results.get(0).getPsiMember(); final PsiCodeBlock block = firstMethod.getBody(); assert block != null; final PsiElement first = block.getFirstBodyElement(); assert first != null; editor.getCaretModel().moveToOffset(first.getTextRange().getStartOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); } } catch (IncorrectOperationException e) { LOG.error(e); } }); }