void (AnnotationHolder holder, GrAnnotation annotation) { final PsiAnnotationOwner owner = annotation.getOwner(); final GrMember container = PsiTreeUtil.getParentOfType(((PsiElement)owner), GrMember.class); if (container != null) { String message; if (container.getContainingClass() instanceof GroovyScriptClass) { message = GroovyBundle.message("annotation.field.can.only.be.used.within.a.script.body"); } else { message = GroovyBundle.message("annotation.field.can.only.be.used.within.a.script"); } holder.newAnnotation(HighlightSeverity.ERROR, message).range(annotation).create(); } }