mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] don't highlight null in GString key inspection (IDEA-174890)
This commit is contained in:
+1
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -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]'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user