当前位置: 首页>>代码示例>>Java>>正文


Java MethodCandidateInfo.isOverloadCheck方法代码示例

本文整理汇总了Java中com.intellij.psi.infos.MethodCandidateInfo.isOverloadCheck方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCandidateInfo.isOverloadCheck方法的具体用法?Java MethodCandidateInfo.isOverloadCheck怎么用?Java MethodCandidateInfo.isOverloadCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.infos.MethodCandidateInfo的用法示例。


在下文中一共展示了MethodCandidateInfo.isOverloadCheck方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCandidateInfo

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
protected MethodCandidateInfo createCandidateInfo(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor,
                                                  final boolean staticProblem, final boolean accessible, final boolean varargs) {
  final PsiExpressionList argumentList = getArgumentList();
  return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
                                 null, getTypeArguments(), getLanguageLevel()) {

    private PsiType[] myExpressionTypes;

    @Override
    public PsiType[] getArgumentTypes() {
      if (myExpressionTypes == null && argumentList != null) {
        final PsiType[] expressionTypes = getExpressionTypes(argumentList);
        if (MethodCandidateInfo.isOverloadCheck()) {
          return expressionTypes;
        }
        myExpressionTypes = expressionTypes;
      }
      return myExpressionTypes;
    }

    @Override
    public boolean isVarargs() {
      return varargs;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MethodCandidatesProcessor.java

示例2: isOverloadCheck

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private boolean isOverloadCheck()
{
	if(myContext != null)
	{
		for(Object o : MethodCandidateInfo.ourOverloadGuard.currentStack())
		{
			//method references do not contain nested arguments anyway
			if(o instanceof PsiExpressionList)
			{
				final PsiExpressionList element = (PsiExpressionList) o;
				for(PsiExpression expression : element.getExpressions())
				{
					if(expression == myContext)
					{
						return true;
					}
				}
			}
		}
		return false;
	}
	return MethodCandidateInfo.isOverloadCheck();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:InferenceSession.java

示例3: createMethodCandidate

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo createMethodCandidate(@NotNull final PsiMethod staticFactoryMethod,
                                                         final PsiElement parent,
                                                         final boolean varargs,
                                                         final PsiExpressionList argumentList) {
  return new MethodCandidateInfo(staticFactoryMethod, PsiSubstitutor.EMPTY, false, false, argumentList, parent, null, null) {
    private PsiType[] myExpressionTypes;

    @Override
    public boolean isVarargs() {
      return varargs;
    }

    @Override
    protected PsiElement getParent() {
      return parent;
    }

    @Override
    public PsiType[] getArgumentTypes() {
      if (myExpressionTypes == null) {
        final PsiType[] expressionTypes = argumentList.getExpressionTypes();
        if (MethodCandidateInfo.isOverloadCheck()) {
          return expressionTypes;
        }
        myExpressionTypes = expressionTypes;
      }
      return myExpressionTypes;
    }

    @Override
    protected PsiElement getMarkerList() {
      return parent instanceof PsiNewExpression ? ((PsiNewExpression)parent).getArgumentList() : super.getMarkerList();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PsiDiamondTypeImpl.java

示例4: collectAdditionalConstraints

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private void collectAdditionalConstraints(PsiParameter[] parameters,
                                          PsiExpression[] args,
                                          PsiMethod parentMethod,
                                          PsiSubstitutor siteSubstitutor,
                                          Set<ConstraintFormula> additionalConstraints,
                                          boolean varargs) {
  for (int i = 0; i < args.length; i++) {
    final PsiExpression arg = PsiUtil.skipParenthesizedExprDown(args[i]);
    if (arg != null) {
      if (MethodCandidateInfo.isOverloadCheck() && arg instanceof PsiLambdaExpression) {
        for (Object expr : MethodCandidateInfo.ourOverloadGuard.currentStack()) {
          if (PsiTreeUtil.getParentOfType((PsiElement)expr, PsiLambdaExpression.class) == arg) {
            return;
          }
        }
      }
      final InferenceSession nestedCallSession = findNestedCallSession(arg);
      final PsiType parameterType =
        nestedCallSession.substituteWithInferenceVariables(getParameterType(parameters, i, siteSubstitutor, varargs));
      if (!isPertinentToApplicability(arg, parentMethod)) {
        additionalConstraints.add(new ExpressionCompatibilityConstraint(arg, parameterType));
      }
      additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(arg, parameterType));
      if (arg instanceof PsiCall) {
        //If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12), 
        //the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
        final PsiMethod calledMethod = getCalledMethod((PsiCall)arg);
        if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
          collectAdditionalConstraints(additionalConstraints, (PsiCall)arg);
        }
      }
      else if (arg instanceof PsiLambdaExpression && 
               isPertinentToApplicability(arg, parentMethod) && 
               !isProperType(retrieveNonPrimitiveEqualsBounds(myInferenceVariables).substitute(parameterType))) {
        collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)arg, parameterType);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:InferenceSession.java

示例5: getType

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f) {
  final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck();
  PsiType type = isOverloadCheck ? null : myCalculatedTypes.get(expr);
  if (type == null) {
    final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
    type = f.fun(expr);
    if (!dStackStamp.mayCacheNow() || isOverloadCheck) {
      return type;
    }
    if (type == null) type = TypeConversionUtil.NULL_TYPE;
    myCalculatedTypes.put(expr, type);

    if (type instanceof PsiClassReferenceType) {
      // convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
      PsiClassType.ClassResolveResult result = ((PsiClassReferenceType)type).resolveGenerics();
      PsiClass psiClass = result.getElement();
      type = psiClass == null
             ? type // for type with unresolved reference, leave it in the cache
                    // for clients still might be able to retrieve its getCanonicalText() from the reference text
             : new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType)type).getLanguageLevel(), type.getAnnotations());
    }
  }

  if (!type.isValid()) {
    if (expr.isValid()) {
      PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType)type).getReference() : null;
      @NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: "+refInside + " ("+refInside.getClass()+") valid:"+refInside.isValid());
      LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
    }
    else {
      LOG.error("Expression: '"+expr+"' is invalid, must not be used for getType()");
    }
  }

  return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaResolveCache.java

示例6: createMethodCandidate

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo createMethodCandidate(@NotNull final PsiMethod staticFactoryMethod, final PsiElement parent, final boolean varargs, final PsiExpressionList argumentList)
{
	return new MethodCandidateInfo(staticFactoryMethod, PsiSubstitutor.EMPTY, false, false, argumentList, parent, null, null)
	{
		private PsiType[] myExpressionTypes;

		@Override
		public boolean isVarargs()
		{
			return varargs;
		}

		@Override
		protected PsiElement getParent()
		{
			return parent;
		}

		@Override
		public PsiType[] getArgumentTypes()
		{
			if(myExpressionTypes == null)
			{
				final PsiType[] expressionTypes = argumentList.getExpressionTypes();
				if(MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck())
				{
					return expressionTypes;
				}
				myExpressionTypes = expressionTypes;
			}
			return myExpressionTypes;
		}

		@Override
		protected PsiElement getMarkerList()
		{
			return parent instanceof PsiNewExpression ? ((PsiNewExpression) parent).getArgumentList() : super.getMarkerList();
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:41,代码来源:PsiDiamondTypeImpl.java

示例7: createCandidateInfo

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
protected MethodCandidateInfo createCandidateInfo(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, final boolean staticProblem, final boolean accessible, final boolean varargs)
{
	final PsiExpressionList argumentList = getArgumentList();
	return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext, null, getTypeArguments(), getLanguageLevel())
	{

		private PsiType[] myExpressionTypes;

		@Override
		public PsiType[] getArgumentTypes()
		{
			if(myExpressionTypes == null && argumentList != null)
			{
				final PsiType[] expressionTypes = getExpressionTypes(argumentList);
				if(MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck())
				{
					return expressionTypes;
				}
				myExpressionTypes = expressionTypes;
			}
			return myExpressionTypes;
		}

		@Override
		public boolean isVarargs()
		{
			return varargs;
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:MethodCandidatesProcessor.java

示例8: getUnhandledExceptions

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall,
                                                        @Nullable final PsiElement topElement,
                                                        final boolean includeSelfCalls) {
  //exceptions only influence the invocation type after overload resolution is complete
  if (MethodCandidateInfo.isOverloadCheck()) {
    return Collections.emptyList();
  }
  final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(methodCall.getArgumentList());
  final JavaResolveResult result = properties != null ? properties.getInfo() : methodCall.resolveMethodGenerics();
  final PsiMethod method = (PsiMethod)result.getElement();
  if (method == null) {
    return Collections.emptyList();
  }
  final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
  if (!includeSelfCalls && method == containingMethod) {
    return Collections.emptyList();
  }

  final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
  if (thrownExceptions.length == 0) {
    return Collections.emptyList();
  }

  final PsiSubstitutor substitutor = getSubstitutor(result, methodCall);
  if (!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
    final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
    final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile);
    try {
      PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
      final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(
        processor.getResults(), new Function<CandidateInfo, Pair<PsiMethod, PsiSubstitutor>>() {
        @Override
        public Pair<PsiMethod, PsiSubstitutor> fun(CandidateInfo info) {
          PsiElement element = info.getElement();
          if (element instanceof PsiMethod &&
              MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) &&
              !MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) {
            return Pair.create((PsiMethod)element, getSubstitutor(info, methodCall));
          }
          return null;
        }
      });
      if (candidates.size() > 1) {
        GlobalSearchScope scope = methodCall.getResolveScope();
        final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions, scope);
        for (Pair<PsiMethod, PsiSubstitutor> pair : candidates) {
          final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes();
          if (exceptions.length == 0) {
            return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
          }
          retainExceptions(ex, collectSubstituted(pair.second, exceptions, scope));
        }
        return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
      }
    }
    catch (MethodProcessorSetupFailedException ignore) {
      return Collections.emptyList();
    }
  }

  return getUnhandledExceptions(method, methodCall, topElement, substitutor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:64,代码来源:ExceptionUtil.java

示例9: getUnhandledExceptions

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall, @Nullable final PsiElement topElement, final boolean includeSelfCalls)
{
	//exceptions only influence the invocation type after overload resolution is complete
	if(MethodCandidateInfo.isOverloadCheck())
	{
		return Collections.emptyList();
	}
	final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(methodCall.getArgumentList());
	final JavaResolveResult result = properties != null ? properties.getInfo() : PsiDiamondType.getDiamondsAwareResolveResult(methodCall);
	final PsiElement element = result.getElement();
	final PsiMethod method = element instanceof PsiMethod ? (PsiMethod) element : null;
	if(method == null)
	{
		return Collections.emptyList();
	}
	final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
	if(!includeSelfCalls && method == containingMethod)
	{
		return Collections.emptyList();
	}

	if(properties != null)
	{
		PsiUtilCore.ensureValid(method);
	}

	final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
	if(thrownExceptions.length == 0)
	{
		return Collections.emptyList();
	}

	final PsiSubstitutor substitutor = result.getSubstitutor();
	if(!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression)
	{
		final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
		final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression) methodCall, containingFile);
		try
		{
			PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
			final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(processor.getResults(), info ->
			{
				PsiElement element1 = info.getElement();
				if(info instanceof MethodCandidateInfo && element1 != method && //don't check self
						MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod) element1) && !MethodSignatureUtil.isSuperMethod((PsiMethod) element1, method) && !(((MethodCandidateInfo) info)
						.isToInferApplicability() && !((MethodCandidateInfo) info).isApplicable()))
				{
					return Pair.create((PsiMethod) element1, ((MethodCandidateInfo) info).getSubstitutor(false));
				}
				return null;
			});
			if(!candidates.isEmpty())
			{
				GlobalSearchScope scope = methodCall.getResolveScope();
				final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions, scope);
				for(Pair<PsiMethod, PsiSubstitutor> pair : candidates)
				{
					final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes();
					if(exceptions.length == 0)
					{
						return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
					}
					retainExceptions(ex, collectSubstituted(pair.second, exceptions, scope));
				}
				return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
			}
		}
		catch(MethodProcessorSetupFailedException ignore)
		{
			return Collections.emptyList();
		}
	}

	return getUnhandledExceptions(method, methodCall, topElement, substitutor);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:77,代码来源:ExceptionUtil.java

示例10: getType

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f)
{
	final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck() || LambdaUtil.isLambdaParameterCheck();
	final boolean polyExpression = PsiPolyExpressionUtil.isPolyExpression(expr);
	PsiType type = isOverloadCheck && polyExpression ? null : myCalculatedTypes.get(expr);
	if(type == null)
	{
		final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
		type = f.fun(expr);
		if(!dStackStamp.mayCacheNow())
		{
			return type;
		}

		//cache standalone expression types as they do not depend on the context
		if(isOverloadCheck && polyExpression)
		{
			return type;
		}

		if(type == null)
		{
			type = TypeConversionUtil.NULL_TYPE;
		}
		myCalculatedTypes.put(expr, type);

		if(type instanceof PsiClassReferenceType)
		{
			// convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
			PsiClassType.ClassResolveResult result = ((PsiClassReferenceType) type).resolveGenerics();
			PsiClass psiClass = result.getElement();
			type = psiClass == null ? type // for type with unresolved reference, leave it in the cache
					// for clients still might be able to retrieve its getCanonicalText() from the reference text
					: new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType) type).getLanguageLevel(), type.getAnnotationProvider());
		}
	}

	if(!type.isValid())
	{
		if(expr.isValid())
		{
			PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType) type).getReference() : null;
			@NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: " + refInside + " (" + refInside.getClass() + ") valid:" + refInside.isValid
					());
			LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
		}
		else
		{
			LOG.error("Expression: '" + expr + "' is invalid, must not be used for getType()");
		}
	}

	return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:56,代码来源:JavaResolveCache.java


注:本文中的com.intellij.psi.infos.MethodCandidateInfo.isOverloadCheck方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。