From 7f771f6bb4f0e5e97522531f62aedc142b97051e Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Fri, 4 May 2012 17:27:44 +0400 Subject: [PATCH] diamonds checking --- .../plugins/groovy/annotator/GroovyAnnotator.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index 34c8640eb8cd..e635bfcee048 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -151,6 +151,10 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { return; } + if (parent instanceof GrCodeReferenceElement) { + if (!checkDiamonds((GrCodeReferenceElement)parent, myHolder)) return; + } + final PsiTypeParameter[] parameters = ((PsiTypeParameterListOwner)resolved).getTypeParameters(); final GrTypeElement[] arguments = typeArgumentList.getTypeArgumentElements(); @@ -873,8 +877,6 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { GrCodeReferenceElement refElement = newExpression.getReferenceElement(); if (refElement == null) return; - checkDiamonds(refElement, myHolder); - final PsiElement element = refElement.resolve(); if (element instanceof PsiClass) { PsiClass clazz = (PsiClass)element; @@ -903,15 +905,17 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { } } - private static void checkDiamonds(GrCodeReferenceElement refElement, AnnotationHolder holder) { + private static boolean checkDiamonds(GrCodeReferenceElement refElement, AnnotationHolder holder) { final GroovyConfigUtils configUtils = GroovyConfigUtils.getInstance(); - if (configUtils.isVersionAtLeast(refElement, GroovyConfigUtils.GROOVY1_8)) return; + if (configUtils.isVersionAtLeast(refElement, GroovyConfigUtils.GROOVY1_8)) return true; GrTypeArgumentList typeArgumentList = refElement.getTypeArgumentList(); if (typeArgumentList != null && typeArgumentList.isDiamond()) { final String message = GroovyBundle.message("diamonds.are.not.allowed.in.groovy.0", configUtils.getSDKVersion(refElement)); holder.createErrorAnnotation(typeArgumentList, message); + return false; } + return true; } @Override