boolean (InsertionContext context, LookupElement item) { final Object obj = item.getObject(); if (!(obj instanceof PsiClass) || !((PsiClass)obj).isAnnotationType()) return false; PsiElement leaf = context.getFile().findElementAt(context.getStartOffset()); PsiAnnotation anno = PsiTreeUtil.getParentOfType(leaf, PsiAnnotation.class); return anno != null && PsiTreeUtil.isAncestor(anno.getNameReferenceElement(), leaf, false); }