@Nullable public static PsiSubstitutor inferSubstitutor(final PsiMethod method, final PsiMethodCallExpression callExpr, boolean forCompletion) { final PsiResolveHelper helper = JavaPsiFacade.getInstance(method.getProject()).getResolveHelper(); final PsiParameter[] parameters = method.getParameterList().getParameters(); PsiExpression[] args = callExpr.getArgumentList().getExpressions(); PsiSubstitutor result = PsiSubstitutor.EMPTY; for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(method.getContainingClass())) { PsiType type = helper.inferTypeForMethodTypeParameter(typeParameter, parameters, args, PsiSubstitutor.EMPTY, callExpr.getParent(), forCompletion ? CompletionParameterTypeInferencePolicy.INSTANCE : DefaultParameterTypeInferencePolicy.INSTANCE); if (PsiType.NULL.equals(type)) return null; result = result.put(typeParameter, type); } return result; }
private static PsiSubstitutor getCandidateInfoSubstitutor(CandidateInfo candidate) { return candidate instanceof MethodCandidateInfo && ((MethodCandidateInfo)candidate).isInferencePossible() ? ((MethodCandidateInfo)candidate).inferTypeArguments(CompletionParameterTypeInferencePolicy.INSTANCE, true) : candidate.getSubstitutor(); }
private static PsiSubstitutor getCandidateInfoSubstitutor(CandidateInfo candidate) { return candidate instanceof MethodCandidateInfo && ((MethodCandidateInfo)candidate).isInferencePossible() ? ((MethodCandidateInfo)candidate).inferTypeArguments(CompletionParameterTypeInferencePolicy.INSTANCE) : candidate.getSubstitutor(); }
private static PsiSubstitutor getCandidateInfoSubstitutor(CandidateInfo candidate) { return candidate instanceof MethodCandidateInfo && ((MethodCandidateInfo) candidate).isInferencePossible() ? ((MethodCandidateInfo) candidate).inferTypeArguments (CompletionParameterTypeInferencePolicy.INSTANCE, true) : candidate.getSubstitutor(); }