void (GrAnnotation annotation) { if (!GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO_TARGET.equals(annotation.getQualifiedName())) return; final PsiElement owner = annotation.getParent().getParent(); if (!(owner instanceof GrParameter)) return; final boolean isTargetDeclared = annotation.findDeclaredAttributeValue("value") != null; String targetName = GrAnnotationUtil.inferStringAttribute(annotation, "value"); final GrParameterList parameterList = (GrParameterList)owner.getParent(); for (GrParameter parameter : parameterList.getParameters()) { final PsiAnnotation delegatesTo = parameter.getModifierList().findAnnotation(GroovyCommonClassNames.GROOVY_LANG_DELEGATES_TO); if (delegatesTo != null) { if (isTargetDeclared) { final String curTarget = GrAnnotationUtil.inferStringAttribute(delegatesTo, "target"); if (curTarget != null && curTarget.equals(targetName)) { return; //target is used } } else { if (delegatesTo.findDeclaredAttributeValue("target") == null && delegatesTo.findDeclaredAttributeValue("value") == null) { return; // target is used } } } } registerError(annotation.getClassReference(), GroovyBundle.message("target.annotation.is.unused"), LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING); }