[groovy] don't highlight null in GString key inspection (IDEA-174890)

This commit is contained in:
Daniil Ovchinnikov
2017-09-12 21:02:30 +02:00
parent 4ccc9f4b2b
commit 35fbe16c29
2 changed files with 6 additions and 7 deletions
@@ -27,7 +27,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgument
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import static com.intellij.psi.CommonClassNames.JAVA_UTIL_MAP;
import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_LANG_GSTRING;
@@ -100,11 +99,7 @@ public class GroovyGStringKeyInspection extends BaseInspection {
private static boolean isGStringType(@NotNull GrExpression expression) {
PsiType expressionType = expression.getType();
if (expressionType == null) {
return false;
}
PsiClassType type = TypesUtil.createTypeByFQClassName(GROOVY_LANG_GSTRING, expression);
return type.isAssignableFrom(expressionType);
return expressionType != null && expressionType.equalsToText(GROOVY_LANG_GSTRING);
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -88,4 +88,8 @@ class GroovyGStringKeyInspectionTest extends GrHighlightingTestBase {
[:]."${key}"='bar'
''')
}
void 'test do not highlight null'() {
testHighlighting '[(null):1]'
}
}