From d0903fb7ef4f2dbf5a9366230759593a9c37117b Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Fri, 14 Sep 2012 16:07:52 +0400 Subject: [PATCH 1/6] nullable --- platform/util/src/com/intellij/util/containers/MultiMap.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/containers/MultiMap.java b/platform/util/src/com/intellij/util/containers/MultiMap.java index 6ad8226f9444..5c1b9863a60e 100644 --- a/platform/util/src/com/intellij/util/containers/MultiMap.java +++ b/platform/util/src/com/intellij/util/containers/MultiMap.java @@ -18,6 +18,7 @@ package com.intellij.util.containers; import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.Serializable; import java.util.*; @@ -77,7 +78,7 @@ public class MultiMap implements Serializable { list.addAll(values); } - public void putValue(K key, V value) { + public void putValue(@Nullable K key, V value) { Collection list = myMap.get(key); if (list == null) { list = createCollection(); From 0dd32936c28263e7c4ac88f0b70bd58b174910fe Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Sat, 15 Sep 2012 11:00:36 +0400 Subject: [PATCH 2/6] IDEA-90310 Groovy: Allow to resolve references inside static closure to non-static class members --- .../plugins/groovy/lang/psi/util/PsiUtil.java | 2 ++ .../groovy/lang/GroovyHighlightingTest.groovy | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java index 6e938d11d9d5..304fec55ef90 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java @@ -435,6 +435,7 @@ public class PsiUtil { PsiElement stopAt = PsiTreeUtil.findCommonParent(place, resolveContext); while (place != null && place != stopAt && !(place instanceof GrMember)) { if (place instanceof PsiFile) break; + if (place instanceof GrClosableBlock) return true; place = place.getParent(); } if (place == null || place instanceof PsiFile || place == stopAt) return true; @@ -448,6 +449,7 @@ public class PsiUtil { while (place != null) { place = place.getParent(); if (place instanceof PsiClass && InheritanceUtil.isInheritorOrSelf((PsiClass)place, containingClass, true)) return true; + if (place instanceof GrClosableBlock) return true; if (place instanceof PsiMember && ((PsiMember)place).hasModifierProperty(PsiModifier.STATIC)) { return false; } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index f973bd3303ac..057c84efb1ad 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -1474,4 +1474,22 @@ foo#ref() between objects of inconvertible types ''" + - StringUtil.escapeXml(type1.getPresentableText()) + "'' and ''" + - StringUtil.escapeXml(type2.getPresentableText()) + "'' #loc"); + "#ref() between objects of inconvertible types '" + + StringUtil.escapeXml(type1.getPresentableText()) + "' and '" + + StringUtil.escapeXml(type2.getPresentableText()) + "' #loc"); } } } \ No newline at end of file From fcda3a9299930c84ce539ac2cd91df1ef1c8eb4d Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 15 Sep 2012 16:25:40 +0200 Subject: [PATCH 5/6] only check assertEquals(Object, Object) --- ...qualsBetweenInconvertibleTypesInspection.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsBetweenInconvertibleTypesInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsBetweenInconvertibleTypesInspection.java index 15a9ac40437a..1351a29f5679 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsBetweenInconvertibleTypesInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/AssertEqualsBetweenInconvertibleTypesInspection.java @@ -17,7 +17,6 @@ package com.siyeh.ig.junit; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.TypeConversionUtil; import com.siyeh.InspectionGadgetsBundle; @@ -85,8 +84,7 @@ public class AssertEqualsBetweenInconvertibleTypesInspection extends BaseInspect final PsiExpressionList argumentList = expression.getArgumentList(); final PsiExpression[] arguments = argumentList.getExpressions(); final int argumentIndex; - if (firstParameterType.equalsToText( - CommonClassNames.JAVA_LANG_STRING)) { + if (firstParameterType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) { if (arguments.length < 3) { return; } @@ -110,18 +108,10 @@ public class AssertEqualsBetweenInconvertibleTypesInspection extends BaseInspect } final PsiType parameterType1 = parameters[argumentIndex].getType(); final PsiType parameterType2 = parameters[argumentIndex + 1].getType(); - if (!parameterType1.equals(parameterType2)) { + final PsiClassType objectType = TypeUtils.getObjectType(expression); + if (!objectType.equals(parameterType1) || !objectType.equals(parameterType2)) { return; } - if (type2 instanceof PsiPrimitiveType && parameterType2.equals(TypeUtils.getObjectType(expression))) { - final PsiPrimitiveType primitiveType = (PsiPrimitiveType)type2; - final PsiManager manager = expression.getManager(); - final GlobalSearchScope scope = expression.getResolveScope(); - final PsiClassType boxedType = primitiveType.getBoxedType(manager, scope); - if (boxedType != null && TypeConversionUtil.areTypesConvertible(type1, boxedType)) { - return; - } - } if (TypeConversionUtil.areTypesConvertible(type1, type2)) { return; } From aa24597f994ec282d00b15b6167c3e94e5e6b273 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sat, 15 Sep 2012 16:32:49 +0200 Subject: [PATCH 6/6] IDEA-91605 (TestNG assertEquals inspection should not flag (double, double, double) overloads) --- ...alsBetweenInconvertibleTypesTestNGInspection.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/AssertEqualsBetweenInconvertibleTypesTestNGInspection.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/AssertEqualsBetweenInconvertibleTypesTestNGInspection.java index c48b4180e393..cf4afa6083dd 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/AssertEqualsBetweenInconvertibleTypesTestNGInspection.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/AssertEqualsBetweenInconvertibleTypesTestNGInspection.java @@ -105,17 +105,11 @@ public class AssertEqualsBetweenInconvertibleTypesTestNGInspection extends BaseJ if (type2 == null) { return; } - if (!parameterType1.equals(parameterType2)) { - return; - } final PsiManager manager = expression.getManager(); final GlobalSearchScope scope = expression.getResolveScope(); - if (type2 instanceof PsiPrimitiveType && parameterType2.equals(PsiType.getJavaLangObject(manager, scope))) { - final PsiPrimitiveType primitiveType = (PsiPrimitiveType)type2; - final PsiClassType boxedType = primitiveType.getBoxedType(manager, scope); - if (boxedType != null && TypeConversionUtil.areTypesConvertible(type1, boxedType)) { - return; - } + final PsiClassType objectType = PsiType.getJavaLangObject(manager, scope); + if (!objectType.equals(parameterType1) || !objectType.equals(parameterType2)) { + return; } if (TypeConversionUtil.areTypesConvertible(type1, type2)) { return;