@Nullable private static PsiType getTypeFromMapAccess(@NotNull GrReferenceExpressionImpl ref) { // map access GrExpression qualifier = ref.getQualifierExpression(); if (qualifier != null) { PsiType qType = qualifier.getNominalType(); if (qType instanceof PsiClassType) { PsiClassType.ClassResolveResult qResult = ((PsiClassType) qType).resolveGenerics(); PsiClass clazz = qResult.getElement(); if (clazz != null) { PsiClass mapClass = JavaPsiFacade.getInstance(ref.getProject()) .findClass(CommonClassNames.JAVA_UTIL_MAP, ref.getResolveScope()); if (mapClass != null && mapClass.getTypeParameters().length == 2) { PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(mapClass, clazz, qResult.getSubstitutor()); if (substitutor != null) { return TypeConversionUtil.erasure( substitutor.substitute(mapClass.getTypeParameters()[1])); } } } } } return null; }
private void getVariantsImpl() { GrExpression qualifier = myRefExpr.getQualifierExpression(); if (qualifier == null) { ResolveUtil.treeWalkUp(myRefExpr, myProcessor, true); for (PsiElement e = myRefExpr.getParent(); e != null; e = e.getParent()) { if (e instanceof GrClosableBlock) { ResolveState state = ResolveState.initial().put(ClassHint.RESOLVE_CONTEXT, e); for (ClosureMissingMethodContributor contributor : ClosureMissingMethodContributor.EP_NAME.getExtensions()) { contributor.processMembers((GrClosableBlock) e, myProcessor, myRefExpr, state); } } } GrExpression runtimeQualifier = PsiImplUtil.getRuntimeQualifier(myRefExpr); if (runtimeQualifier != null) { getVariantsFromQualifier(runtimeQualifier); } getBindings(); } else { if (myRefExpr.getDotTokenType() != GroovyTokenTypes.mSPREAD_DOT) { getVariantsFromQualifier(qualifier); if (qualifier instanceof GrReferenceExpression && ("class".equals(((GrReferenceExpression) qualifier).getReferenceName()) || PsiUtil.isThisReference(qualifier) && !PsiUtil.isInstanceThisRef(qualifier))) { processIfJavaLangClass(qualifier.getType()); } } else { getVariantsFromQualifierForSpreadOperator(qualifier); } } ResolveUtil.processCategoryMembers(myRefExpr, myProcessor, ResolveState.initial()); }