void (@NotNull Template template, boolean brokenOff) { try { LOG.assertTrue(startClassOffset.isValid(), startClassOffset); final PsiClass aTargetClass; if (idxInFile >= 0) { PsiClass[] classes = containingFile.getClasses(); LOG.assertTrue(idxInFile < classes.length, "idx: " + idxInFile + "; len: " + classes.length); aTargetClass = classes[idxInFile]; } else { final PsiElement psiElement = containingFile.findElementAt(startClassOffset.getStartOffset()); aTargetClass = PsiTreeUtil.getParentOfType(psiElement, PsiClass.class); LOG.assertTrue(aTargetClass != null, psiElement); } if (!brokenOff) { chooseAndImplement(psiClass, project, aTargetClass, editor); } } finally { startClassOffset.dispose(); } }