Java 类com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy 实例源码

项目:tools-idea    文件:MethodCandidateInfo.java   
public PsiSubstitutor inferSubstitutorFromArgs(@NotNull ParameterTypeInferencePolicy policy, final PsiExpression[] arguments) {
  if (myTypeArguments == null) {
    return inferTypeArguments(policy, arguments);
  }
  else {
    PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
    PsiMethod method = getElement();
    if (method != null) {
      PsiTypeParameter[] typeParams = method.getTypeParameters();
      for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
        incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
      }
    }
    return incompleteSubstitutor;
  }
}
项目:consulo-java    文件:InferenceSessionContainer.java   
@Nullable
private static InferenceSession startTopLevelInference(final PsiCall topLevelCall, final ParameterTypeInferencePolicy policy)
{
    final JavaResolveResult result = topLevelCall.resolveMethodGenerics();
    if(result instanceof MethodCandidateInfo)
    {
        final PsiMethod method = ((MethodCandidateInfo) result).getElement();
        final PsiParameter[] topLevelParameters = method.getParameterList().getParameters();
        final PsiExpressionList topLevelCallArgumentList = topLevelCall.getArgumentList();
        LOG.assertTrue(topLevelCallArgumentList != null, topLevelCall);
        final PsiExpression[] topLevelArguments = topLevelCallArgumentList.getExpressions();
        return PsiResolveHelper.ourGraphGuard.doPreventingRecursion(topLevelCall, true, new Computable<InferenceSession>()
        {
            @Override
            public InferenceSession compute()
            {
                final InferenceSession topLevelSession = new InferenceSession(method.getTypeParameters(), ((MethodCandidateInfo) result).getSiteSubstitutor(), topLevelCall.getManager(),
                        topLevelCall, policy);
                topLevelSession.initExpressionConstraints(topLevelParameters, topLevelArguments, topLevelCall, method, ((MethodCandidateInfo) result).isVarargs());
                topLevelSession.infer(topLevelParameters, topLevelArguments, topLevelCall, ((MethodCandidateInfo) result).createProperties());
                return topLevelSession;
            }
        });
    }
    return null;
}
项目:consulo-java    文件:PsiGraphInferenceHelper.java   
@Override
public PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @Nullable PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy)
{
    final PsiSubstitutor substitutor;
    if(parent != null)
    {
        substitutor = inferTypeArguments(new PsiTypeParameter[]{typeParameter}, parameters, arguments, partialSubstitutor, parent, policy, PsiUtil.getLanguageLevel(parent));
    }
    else
    {
        final InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager, null);
        inferenceSession.initExpressionConstraints(parameters, arguments, null);
        substitutor = inferenceSession.infer();
    }
    return substitutor.substitute(typeParameter);
}
项目:consulo-java    文件:PsiGraphInferenceHelper.java   
@NotNull
@Override
public PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @NotNull PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy,
        @NotNull LanguageLevel languageLevel)
{
    if(typeParameters.length == 0)
    {
        return partialSubstitutor;
    }

    return InferenceSessionContainer.infer(typeParameters, parameters, arguments, partialSubstitutor, parent, policy);
}
项目:consulo-java    文件:MethodCandidateInfo.java   
/**
 * If iterated through all candidates, should be called under {@link #ourOverloadGuard} guard so results won't be cached on the top level call
 */
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull final ParameterTypeInferencePolicy policy, @NotNull final PsiExpression[] arguments, boolean includeReturnConstraint)
{
    return computeForOverloadedCandidate(() ->
    {
        final PsiMethod method = this.getElement();
        PsiTypeParameter[] typeParameters = method.getTypeParameters();

        if(this.isRawSubstitution())
        {
            return JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(mySubstitutor, typeParameters);
        }

        final PsiElement parent = this.getParent();
        if(parent == null)
        {
            return PsiSubstitutor.EMPTY;
        }
        Project project = method.getProject();
        JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
        return javaPsiFacade.getResolveHelper().inferTypeArguments(typeParameters, method.getParameterList().getParameters(), arguments, mySubstitutor, parent, policy, myLanguageLevel);
    }, super.getSubstitutor(), policy.isVarargsIgnored() || isVarargs(), !includeReturnConstraint);
}
项目:intellij-ce-playground    文件:PsiGraphInferenceHelper.java   
@Override
public PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                               @NotNull PsiParameter[] parameters,
                                               @NotNull PsiExpression[] arguments,
                                               @NotNull PsiSubstitutor partialSubstitutor,
                                               @Nullable PsiElement parent,
                                               @NotNull ParameterTypeInferencePolicy policy) {
  final InferenceSession inferenceSession = new InferenceSession(new PsiTypeParameter[]{typeParameter}, partialSubstitutor, myManager, parent);
  inferenceSession.initExpressionConstraints(parameters, arguments, parent, null);
  return inferenceSession.infer(parameters, arguments, parent).substitute(typeParameter);
}
项目:intellij-ce-playground    文件:PsiGraphInferenceHelper.java   
@NotNull
@Override
public PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                         @NotNull PsiParameter[] parameters,
                                         @NotNull PsiExpression[] arguments,
                                         @NotNull PsiSubstitutor partialSubstitutor,
                                         @NotNull PsiElement parent,
                                         @NotNull ParameterTypeInferencePolicy policy,
                                         @NotNull LanguageLevel languageLevel) {
  if (typeParameters.length == 0) return partialSubstitutor;
  final InferenceSession inferenceSession = new InferenceSession(typeParameters, partialSubstitutor, myManager, parent);
  inferenceSession.initExpressionConstraints(parameters, arguments, parent, null);
  return inferenceSession.infer(parameters, arguments, parent);
}
项目:intellij-ce-playground    文件:MethodCandidateInfo.java   
public PsiSubstitutor inferSubstitutorFromArgs(@NotNull ParameterTypeInferencePolicy policy, final PsiExpression[] arguments) {
  if (myTypeArguments == null) {
    return inferTypeArguments(policy, arguments, true);
  }
  else {
    return getSiteSubstitutor();
  }
}
项目:intellij-ce-playground    文件:PsiResolveHelper.java   
/**
 * @return {@link PsiType#NULL} iff no type could be inferred
 *         null         iff the type inferred is raw
 *         inferred type otherwise
 */
PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                        @NotNull PsiParameter[] parameters,
                                        @NotNull PsiExpression[] arguments,
                                        @NotNull PsiSubstitutor partialSubstitutor,
                                        @Nullable PsiElement parent,
                                        @NotNull ParameterTypeInferencePolicy policy);
项目:intellij-ce-playground    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                  @NotNull PsiParameter[] parameters,
                                  @NotNull PsiExpression[] arguments,
                                  @NotNull PsiSubstitutor partialSubstitutor,
                                  @NotNull PsiElement parent,
                                  @NotNull ParameterTypeInferencePolicy policy);
项目:intellij-ce-playground    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                  @NotNull PsiParameter[] parameters,
                                  @NotNull PsiExpression[] arguments,
                                  @NotNull PsiSubstitutor partialSubstitutor,
                                  @NotNull PsiElement parent,
                                  @NotNull ParameterTypeInferencePolicy policy,
                                  @NotNull LanguageLevel languageLevel);
项目:intellij-ce-playground    文件:PsiInferenceHelper.java   
/**
 * @return {@link PsiType#NULL} iff no type could be inferred
 *         null         iff the type inferred is raw
 *         inferred type otherwise
 */
PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                        @NotNull PsiParameter[] parameters,
                                        @NotNull PsiExpression[] arguments,
                                        @NotNull PsiSubstitutor partialSubstitutor,
                                        @Nullable PsiElement parent,
                                        @NotNull ParameterTypeInferencePolicy policy);
项目:intellij-ce-playground    文件:PsiInferenceHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                  @NotNull PsiParameter[] parameters,
                                  @NotNull PsiExpression[] arguments,
                                  @NotNull PsiSubstitutor partialSubstitutor,
                                  @NotNull PsiElement parent,
                                  @NotNull ParameterTypeInferencePolicy policy,
                                  @NotNull LanguageLevel languageLevel);
项目:tools-idea    文件:PsiResolveHelper.java   
/**
 * @return {@link PsiType#NULL} iff no type could be inferred
 *         null         iff the type inferred is raw
 *         inferred type otherwise
 */
PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
                                        @NotNull PsiParameter[] parameters,
                                        @NotNull PsiExpression[] arguments,
                                        @NotNull PsiSubstitutor partialSubstitutor,
                                        @Nullable PsiElement parent,
                                        @NotNull ParameterTypeInferencePolicy policy);
项目:tools-idea    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                  @NotNull PsiParameter[] parameters,
                                  @NotNull PsiExpression[] arguments,
                                  @NotNull PsiSubstitutor partialSubstitutor,
                                  @NotNull PsiElement parent,
                                  @NotNull ParameterTypeInferencePolicy policy);
项目:tools-idea    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
                                  @NotNull PsiParameter[] parameters,
                                  @NotNull PsiExpression[] arguments,
                                  @NotNull PsiSubstitutor partialSubstitutor,
                                  @NotNull PsiElement parent,
                                  @NotNull ParameterTypeInferencePolicy policy,
                                  @NotNull LanguageLevel languageLevel);
项目:consulo-java    文件:PsiInferenceHelper.java   
/**
 * @return {@link PsiType#NULL} iff no type could be inferred
 * null         iff the type inferred is raw
 * inferred type otherwise
 */
PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @Nullable PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy);
项目:consulo-java    文件:PsiInferenceHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @NotNull PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy,
        @NotNull LanguageLevel languageLevel);
项目:consulo-java    文件:InferenceSession.java   
public InferenceSession(PsiTypeParameter[] typeParams, PsiSubstitutor siteSubstitutor, PsiManager manager, PsiElement context, ParameterTypeInferencePolicy policy)
{
    myManager = manager;
    mySiteSubstitutor = siteSubstitutor;
    myContext = context;
    myPolicy = policy;

    initBounds(typeParams);
}
项目:consulo-java    文件:MethodCandidateInfo.java   
public PsiSubstitutor inferSubstitutorFromArgs(@NotNull ParameterTypeInferencePolicy policy, final PsiExpression[] arguments)
{
    if(myTypeArguments == null)
    {
        return inferTypeArguments(policy, arguments, true);
    }
    else
    {
        return getSiteSubstitutor();
    }
}
项目:consulo-java    文件:PsiResolveHelper.java   
/**
 * @return {@link PsiType#NULL} iff no type could be inferred
 * null         iff the type inferred is raw
 * inferred type otherwise
 */
PsiType inferTypeForMethodTypeParameter(@NotNull PsiTypeParameter typeParameter,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @Nullable PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy);
项目:consulo-java    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @NotNull PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy);
项目:consulo-java    文件:PsiResolveHelper.java   
@NotNull
PsiSubstitutor inferTypeArguments(@NotNull PsiTypeParameter[] typeParameters,
        @NotNull PsiParameter[] parameters,
        @NotNull PsiExpression[] arguments,
        @NotNull PsiSubstitutor partialSubstitutor,
        @NotNull PsiElement parent,
        @NotNull ParameterTypeInferencePolicy policy,
        @NotNull LanguageLevel languageLevel);
项目:intellij-ce-playground    文件:MethodCandidateInfo.java   
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
  return inferTypeArguments(policy, myArgumentList instanceof PsiExpressionList
                                    ? ((PsiExpressionList)myArgumentList).getExpressions()
                                    : PsiExpression.EMPTY_ARRAY, includeReturnConstraint);
}
项目:tools-idea    文件:MethodCandidateInfo.java   
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy) {
  return inferTypeArguments(policy, myArgumentList instanceof PsiExpressionList
                                    ? ((PsiExpressionList)myArgumentList).getExpressions()
                                    : PsiExpression.EMPTY_ARRAY);
}
项目:consulo-java    文件:MethodCandidateInfo.java   
@NotNull
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint)
{
    return inferTypeArguments(policy, myArgumentList instanceof PsiExpressionList ? ((PsiExpressionList) myArgumentList).getExpressions() : PsiExpression.EMPTY_ARRAY, includeReturnConstraint);
}