PsiElementPredicate () { return new PsiElementPredicate() { @Override public boolean satisfiedBy(@NotNull PsiElement element) { if (!(element instanceof GrReferenceElement<?> ref)) return false; final PsiElement parent = ref.getParent(); if (!(parent instanceof GrReferenceElement)) return false; final PsiElement resolved = ref.resolve(); if (resolved == null) return false; return resolved instanceof PsiClass; } }; }