PsiAnnotationPattern (@NotNull final String attributeName, @NotNull final ElementPattern<? extends PsiAnnotation> parentAnnoPattern) { return with(new PatternCondition<PsiAnnotation>("insideAnnotationAttribute") { final PsiNameValuePairPattern attrPattern = psiNameValuePair().withName(attributeName).withSuperParent(2, parentAnnoPattern); @Override public boolean accepts(@NotNull PsiAnnotation annotation, ProcessingContext context) { PsiElement attr = getParentElement(annotation); if (attr instanceof PsiArrayInitializerMemberValue) attr = getParentElement(attr); return attrPattern.accepts(attr); } }); }