void (@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof GrReferenceExpression referenceExpression) { PsiElement resolved = referenceExpression.resolve(); if (resolved instanceof OriginInfoAwareElement && GradleNamedDomainCollectionContributor.NAMED_DOMAIN_DECLARATION.equals(((OriginInfoAwareElement)resolved).getOriginInfo())) { highlightElement(holder, referenceExpression.getReferenceNameElement()); } final GrExpression qualifier = ResolveUtil.getSelfOrWithQualifier(referenceExpression); if (qualifier == null) return; if (qualifier instanceof GrReferenceExpression && ((GrReferenceExpression)qualifier).resolve() instanceof PsiClass) return; PsiType psiType = GradleResolverUtil.getTypeOf(qualifier); if (psiType == null) return; if (InheritanceUtil.isInheritor(psiType, GradleCommonClassNames.GRADLE_API_NAMED_DOMAIN_OBJECT_COLLECTION)) { JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(element.getProject()); PsiClass defaultGroovyMethodsClass = javaPsiFacade.findClass(GroovyCommonClassNames.DEFAULT_GROOVY_METHODS, element.getResolveScope()); if (canBeMethodOf(referenceExpression.getReferenceName(), defaultGroovyMethodsClass)) return; final String qualifiedName = TypesUtil.getQualifiedName(psiType); final PsiClass containerClass = qualifiedName != null ? javaPsiFacade.findClass(qualifiedName, element.getResolveScope()) : null; if (canBeMethodOf(referenceExpression.getReferenceName(), containerClass)) return; PsiElement nameElement = referenceExpression.getReferenceNameElement(); highlightElement(holder, nameElement); } } }