private static ElementFilter createAnnotationFilter(PsiElement position) { OrFilter orFilter = new OrFilter( ElementClassFilter.CLASS, ElementClassFilter.PACKAGE_FILTER, new AndFilter( new ClassFilter(PsiField.class), new ModifierFilter(PsiModifier.STATIC, PsiModifier.FINAL))); if (psiElement().insideStarting(psiNameValuePair()).accepts(position)) { orFilter.addFilter( new ClassFilter(PsiAnnotationMethod.class) { @Override public boolean isAcceptable(Object element, PsiElement context) { return element instanceof PsiAnnotationMethod && PsiUtil.isAnnotationMethod((PsiElement) element); } }); } return orFilter; }
public OrFilter(ElementFilter... filters) { for (ElementFilter filter : filters) { addFilter(filter); } }