boolean (InsertionContext context, int startOffset, LookupElement item) { PsiFile file = context.getFile(); if (!(file instanceof GroovyFile)) return false; PsiElement element = file.findElementAt(startOffset); while (element != null && !(element instanceof PsiFile) && !(element instanceof GrDocComment)) { element = element.getParent(); } if (!(element instanceof GrDocComment)) return false; int offset = context.getEditor().getCaretModel().getOffset(); String text = file.getText(); return offset < text.length() && item.getObject() instanceof PsiMethod; }