ContextFilter (ElementPattern pattern) { return (descriptor, ctx) -> { PsiType type = descriptor.getPsiType(); return type instanceof PsiClassType && pattern.accepts(((PsiClassType)type).resolve()); }; }