boolean (InsertionContext context, Document document, int offset, PsiSubstitutor substitutor, PsiMethod method, final List<? extends ClosureParameterInfo> parameters) { document.insertString(offset, "{\n}"); PsiDocumentManager.getInstance(context.getProject()).commitDocument(document); final GrClosableBlock closure = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), offset + 1, GrClosableBlock.class, false); if (closure == null) return false; runTemplate(parameters, closure, substitutor, method, context.getProject(), context.getEditor()); return true; }