PsiType (GroovyResolveResult iteratorMethodResult, GrExpression tupleInitializer) { PsiElement method = iteratorMethodResult.getElement(); if (method instanceof PsiMethod) { return iteratorMethodResult.getSubstitutor().substitute(((PsiMethod)method).getReturnType()); } else { PsiType initializerType = tupleInitializer.getType(); PsiType iterableParam = PsiUtil.extractIterableTypeParameter(initializerType, false); JavaPsiFacade facade = JavaPsiFacade.getInstance(context.project); PsiClass iterableClass = facade.findClass(CommonClassNames.JAVA_UTIL_ITERATOR, tupleInitializer.getResolveScope()); if (iterableClass != null && iterableParam != null) { return facade.getElementFactory().createType(iterableClass, iterableParam); } else { return facade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_ITERATOR, tupleInitializer); } } }