PsiMethodPattern (final ElementPattern<? extends PsiClass> pattern) { return with(new PatternConditionPlus<PsiMethod, PsiClass>("definedInClass", pattern) { @Override public boolean processValues(PsiMethod t, final ProcessingContext context, final PairProcessor<? super PsiClass, ? super ProcessingContext> processor) { if (!processor.process(t.getContainingClass(), context)) return false; final Ref<Boolean> result = Ref.create(Boolean.TRUE); SuperMethodsSearch.search(t, null, true, false).forEach(signature -> { if (!processor.process(signature.getMethod().getContainingClass(), context)) { result.set(Boolean.FALSE); return false; } return true; }); return result.get(); } }); }