ChainCompletionContext (PsiMethodCallExpression parent, CompletionParameters parameters) { PsiMethod method = parent.resolveMethod(); if (method == null) return null; PsiExpression expression = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiExpression.class); PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiExpressionList.class); if (expressionList == null) return null; int exprPosition = Arrays.asList(expressionList.getExpressions()).indexOf(expression); PsiParameter[] methodParameters = method.getParameterList().getParameters(); if (exprPosition < methodParameters.length) { PsiParameter methodParameter = methodParameters[exprPosition]; return ChainCompletionContext.createContext(methodParameter.getType(), PsiTreeUtil.getParentOfType(expression, PsiMethodCallExpression.class), suggestIterators(parameters)); } return null; }