ModCommand (@NotNull ActionContext context) { int offset = context.offset(); PsiElement element = findElement(context.file(), offset); if (element == null) return ModCommand.nop(); PsiTryStatement tryStatement = (PsiTryStatement)element.getParent(); List<PsiClassType> unhandledExceptions = new ArrayList<>(getExceptions(element, null)); if (unhandledExceptions.isEmpty()) return ModCommand.nop(); ExceptionUtil.sortExceptionsByHierarchy(unhandledExceptions); return ModCommand.psiUpdate(tryStatement, (ts, updater) -> invoke(ts, unhandledExceptions, updater)); }