PsiType (GrReferenceExpression ref, @Nullable PsiElement resolved) { if (!(resolved instanceof GroovyMapProperty)) return null; GrExpression qualifierExpression = ref.getQualifierExpression(); if (qualifierExpression == null) return null; PsiType mapType = qualifierExpression.getType(); if (!InheritanceUtil.isInheritor(mapType, CommonClassNames.JAVA_UTIL_MAP)) { return null; } PsiElement qResolved; if (qualifierExpression instanceof GrReferenceExpression) { qResolved = ((GrReferenceExpression)qualifierExpression).resolve(); } else if (qualifierExpression instanceof GrMethodCall) { qResolved = ((GrMethodCall)qualifierExpression).resolveMethod(); } else { return null; } String key = ref.getReferenceName(); if (key == null) return null; for (GroovyMapContentProvider provider : GroovyMapContentProvider.EP_NAME.getExtensions()) { PsiType type = provider.getValueType(qualifierExpression, qResolved, key); if (type != null) { return type; } } if (mapType instanceof GrMapType) { return ((GrMapType)mapType).getTypeByStringKey(key); } return null; }