void (@NotNull Project project, @NotNull PsiElement typeElement, @NotNull ModPsiUpdater updater) { final PsiType thrownType = myThrown.getType(); if (thrownType == null) return; if (!(typeElement.getParent() instanceof PsiParameter parameter)) return; final PsiElement catchBlock = parameter.getDeclarationScope(); if (!(catchBlock instanceof PsiCatchSection myBeforeCatchSection)) { return; } final PsiTryStatement myTryStatement = myBeforeCatchSection.getTryStatement(); final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project); final String name = codeStyleManager.suggestUniqueVariableName("e", myTryStatement.getTryBlock(), false); final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); final PsiCatchSection section = factory.createCatchSection(thrownType, name, myTryStatement); final PsiCatchSection element = (PsiCatchSection)myTryStatement.addBefore(section, myBeforeCatchSection); codeStyleManager.shortenClassReferences(element); final PsiCodeBlock newBlock = element.getCatchBlock(); assert newBlock != null; final TextRange range = SurroundWithUtil.getRangeToSelect(newBlock); updater.select(range); }