IDEA-101461 Groovy - good code red

This commit is contained in:
Max Medvedev
2013-02-20 23:36:45 +04:00
parent a72d792672
commit bd137e7e50
2 changed files with 15 additions and 1 deletions
@@ -50,6 +50,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpres
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
@@ -603,7 +604,7 @@ public class ResolveUtil {
}
public static boolean isKeyOfMap(GrReferenceExpression ref) {
if (isCall(ref)) return false;
if (!(ref.getParent() instanceof GrIndexProperty) && isCall(ref)) return false;
if (ref.multiResolve(false).length > 0) return false;
return mayBeKeyOfMap(ref);
}
@@ -1085,4 +1085,17 @@ def book = new Book(title: "Other Title", author: [name: "Other Name"])
assert book.toString() == 'Other Title by Other Name'
''')
}
void testArrayAccessForMapProperty() {
testHighlighting('''\
def bar() {
return [list:[1, 2, 3]]
}
def testConfig = bar()
print testConfig.list[0]
print testConfig.<warning descr="Cannot resolve symbol 'foo'">foo</warning>()
''', true, false, false, GrUnresolvedAccessInspection)
}
}