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


Java MethodCandidateInfo.getCurrentMethod方法代码示例

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


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

示例1: getCalledMethod

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static PsiMethod getCalledMethod(PsiCall arg) {
  final PsiExpressionList argumentList = arg.getArgumentList();
  if (argumentList == null) {
    return null;
  }

  MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
  if (properties != null) {
    return properties.getMethod();
  }
  final JavaResolveResult resolveResult = getMethodResult(arg);
  if (resolveResult instanceof MethodCandidateInfo) {
    return (PsiMethod)resolveResult.getElement();
  }
  else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:InferenceSession.java

示例2: collectAdditionalConstraints

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private void collectAdditionalConstraints(final Set<ConstraintFormula> additionalConstraints,
                                          final PsiCall callExpression) {
  PsiExpressionList argumentList = callExpression.getArgumentList();
  if (argumentList != null) {
    final JavaResolveResult result = getMethodResult(callExpression);
    MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
    final PsiMethod method = result instanceof MethodCandidateInfo ? ((MethodCandidateInfo)result).getElement() : properties != null ? properties.getMethod() : null;
    if (method != null) {
      final PsiExpression[] newArgs = argumentList.getExpressions();
      final PsiParameter[] newParams = method.getParameterList().getParameters();
      if (newParams.length > 0) {
        collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints, chooseVarargsMode(properties, result));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InferenceSession.java

示例3: getMethodResult

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static JavaResolveResult getMethodResult(final PsiCall callExpression) {
  final PsiExpressionList argumentList = callExpression.getArgumentList();

  final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(argumentList, PsiLambdaExpression.class);
  final Computable<JavaResolveResult> computableResolve = new Computable<JavaResolveResult>() {
    @Override
    public JavaResolveResult compute() {
      return getResolveResult(callExpression, argumentList);
    }
  };
  MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
  return properties != null ? null :
         expression == null || !PsiResolveHelper.ourGraphGuard.currentStack().contains(expression)
         ? computableResolve.compute()
         : PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, false, computableResolve);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InferenceSession.java

示例4: TypeParamsChecker

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public TypeParamsChecker(PsiElement expression, PsiClass aClass) {
  myClass = aClass;
  PsiElement parent = expression != null ? expression.getParent() : null;
  while (parent instanceof PsiParenthesizedExpression) {
    parent = parent.getParent();
  }
  if (parent instanceof PsiExpressionList) {
    final PsiElement gParent = parent.getParent();
    if (gParent instanceof PsiCall) {
      final MethodCandidateInfo.CurrentCandidateProperties pair = MethodCandidateInfo.getCurrentMethod(parent);
      myMethod = pair != null ? pair.getMethod() : null;
      if (myMethod == null) {
        myMethod = ((PsiCall)gParent).resolveMethod();
      }
      if (myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false)) {
        myMethod = null;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LambdaUtil.java

示例5: resolveConflict

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
public final CandidateInfo resolveConflict(@NotNull final List<CandidateInfo> conflicts)
{
	final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(myArgumentsList);
	if(properties != null && properties.isApplicabilityCheck())
	{
		final PsiMethod method = properties.getMethod();
		LOG.error("Recursive conflict resolution for:" + method + "; " +
				myArgumentsList.getText() + "; " +
				"file=" + (method == null ? "<unknown>" : method.getContainingFile()));
	}
	return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, false, new Computable<CandidateInfo>()
	{
		@Override
		public CandidateInfo compute()
		{
			return guardedOverloadResolution(conflicts);
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:JavaMethodsConflictResolver.java

示例6: getCalledMethod

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static PsiMethod getCalledMethod(PsiCall arg)
{
	final PsiExpressionList argumentList = arg.getArgumentList();
	if(argumentList == null)
	{
		return null;
	}

	MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
	if(properties != null)
	{
		return properties.getMethod();
	}
	final JavaResolveResult resolveResult = getResolveResult(arg);
	if(resolveResult instanceof MethodCandidateInfo)
	{
		return (PsiMethod) resolveResult.getElement();
	}
	else
	{
		return null;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:InferenceSession.java

示例7: collectAdditionalConstraints

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private void collectAdditionalConstraints(final Set<ConstraintFormula> additionalConstraints,
		final Set<ConstraintFormula> ignoredConstraints,
		final PsiCall callExpression,
		PsiSubstitutor initialSubstitutor)
{
	PsiExpressionList argumentList = callExpression.getArgumentList();
	if(argumentList != null)
	{
		MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
		final JavaResolveResult result = properties != null ? null : getResolveResult(callExpression);
		final PsiMethod method = properties != null ? properties.getMethod() : result instanceof MethodCandidateInfo ? ((MethodCandidateInfo) result).getElement() : null;
		if(method != null)
		{
			final PsiExpression[] newArgs = argumentList.getExpressions();
			final PsiParameter[] newParams = method.getParameterList().getParameters();
			if(newParams.length > 0)
			{
				collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints, ignoredConstraints, chooseVarargsMode
						(properties, result), initialSubstitutor);
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:InferenceSession.java

示例8: TypeParamsChecker

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public TypeParamsChecker(PsiElement expression, PsiClass aClass)
{
	myClass = aClass;
	PsiElement parent = expression != null ? expression.getParent() : null;
	while(parent instanceof PsiParenthesizedExpression)
	{
		parent = parent.getParent();
	}
	if(parent instanceof PsiExpressionList)
	{
		final PsiElement gParent = parent.getParent();
		if(gParent instanceof PsiCall)
		{
			final MethodCandidateInfo.CurrentCandidateProperties pair = MethodCandidateInfo.getCurrentMethod(parent);
			myMethod = pair != null ? pair.getMethod() : null;
			if(myMethod == null)
			{
				myMethod = ((PsiCall) gParent).resolveMethod();
			}
			if(myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false))
			{
				myMethod = null;
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:LambdaUtil.java

示例9: isPolyExpression

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static boolean isPolyExpression(final PsiExpression expression) {
  if (expression instanceof PsiFunctionalExpression) {
    return true;
  } 
  else if (expression instanceof PsiParenthesizedExpression) {
    return isPolyExpression(((PsiParenthesizedExpression)expression).getExpression());
  }
  else if (expression instanceof PsiNewExpression) {
    final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expression).getClassOrAnonymousClassReference();
    if (classReference != null) {
      final PsiReferenceParameterList parameterList = classReference.getParameterList();
      if (parameterList != null) {
        final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements();
        if (typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) {
          return isInAssignmentOrInvocationContext(expression);
        }
      }
    }
  } else if (expression instanceof PsiMethodCallExpression) {
    final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(((PsiMethodCallExpression)expression).getArgumentList());
    return isMethodCallPolyExpression(expression, candidateProperties != null ? candidateProperties.getMethod() : ((PsiMethodCallExpression)expression).resolveMethod());
  }
  else if (expression instanceof PsiConditionalExpression) {
    final ConditionalKind conditionalKind = isBooleanOrNumeric(expression);
    if (conditionalKind == null) {
      return isInAssignmentOrInvocationContext(expression);
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:PsiPolyExpressionUtil.java

示例10: getCurrentProperties

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo.CurrentCandidateProperties getCurrentProperties(PsiElement parent)
{
	if(parent instanceof PsiCall)
	{
		return MethodCandidateInfo.getCurrentMethod(((PsiCall) parent).getArgumentList());
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:InferenceSession.java

示例11: isPolyExpression

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static boolean isPolyExpression(final PsiExpression expression)
{
	if(expression instanceof PsiFunctionalExpression)
	{
		return true;
	}
	else if(expression instanceof PsiParenthesizedExpression)
	{
		return isPolyExpression(((PsiParenthesizedExpression) expression).getExpression());
	}
	else if(expression instanceof PsiNewExpression && PsiDiamondType.hasDiamond((PsiNewExpression) expression))
	{
		return isInAssignmentOrInvocationContext(expression);
	}
	else if(expression instanceof PsiMethodCallExpression)
	{
		final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(((PsiMethodCallExpression) expression).getArgumentList());
		return isMethodCallPolyExpression(expression, candidateProperties != null ? candidateProperties.getMethod() : ((PsiMethodCallExpression) expression).resolveMethod());
	}
	else if(expression instanceof PsiConditionalExpression)
	{
		final ConditionalKind conditionalKind = isBooleanOrNumeric(expression);
		if(conditionalKind == null)
		{
			return isInAssignmentOrInvocationContext(expression);
		}
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:PsiPolyExpressionUtil.java

示例12: 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

示例13: getCurrentProperties

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo.CurrentCandidateProperties getCurrentProperties(PsiElement parent) {
  if (parent instanceof PsiCall) {
    return MethodCandidateInfo.getCurrentMethod(((PsiCall)parent).getArgumentList());
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:InferenceSession.java

示例14: getTargetType

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static PsiType getTargetType(final PsiElement context) {
  PsiType targetType = PsiTypesUtil.getExpectedTypeByParent(context);
  if (targetType != null) {
    return targetType;
  }
  final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
  if (parent instanceof PsiExpressionList) {
    PsiElement gParent = parent.getParent();
    if (gParent instanceof PsiAnonymousClass) {
      gParent = gParent.getParent();
    }
    if (gParent instanceof PsiCall) {
      final PsiExpressionList argumentList = ((PsiCall)gParent).getArgumentList();
      if (argumentList != null) {
        final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
        if (properties != null && properties.isApplicabilityCheck()) {
          return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor());
        }
        final JavaResolveResult result = properties != null ? properties.getInfo() : ((PsiCall)gParent).resolveMethodGenerics();
        final boolean varargs = chooseVarargsMode(properties, result);
        PsiSubstitutor substitutor = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(context, false,
                                                                                          new Computable<PsiSubstitutor>() {
                                                                                            @Override
                                                                                            public PsiSubstitutor compute() {
                                                                                              return result.getSubstitutor();
                                                                                            }
                                                                                          }
        );
        if (substitutor == null && properties != null) {
          substitutor = properties.getSubstitutor();
        }
        return getTypeByMethod(context, argumentList, result.getElement(), varargs, substitutor);
      }
    }
  } else if (parent instanceof PsiConditionalExpression) {
    return getTargetType((PsiExpression)parent);
  }
  else if (parent instanceof PsiLambdaExpression) {
    return getTargetTypeByContainingLambda((PsiLambdaExpression)parent);
  }
  else if (parent instanceof PsiReturnStatement) {
    return getTargetTypeByContainingLambda(PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:InferenceSession.java

示例15: isAcceptable

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
public boolean isAcceptable(PsiType leftType) {
  if (leftType instanceof PsiIntersectionType) {
    for (PsiType conjunctType : ((PsiIntersectionType)leftType).getConjuncts()) {
      if (isAcceptable(conjunctType)) return true;
    }
    return false;
  }
  final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);

  if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
    final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
    if (candidateProperties != null) {
      final PsiMethod method = candidateProperties.getMethod();
      if (hasFormalParameterTypes() && !InferenceSession.isPertinentToApplicability(this, method)) {
        return true;
      }

      if (LambdaUtil.isPotentiallyCompatibleWithTypeParameter(this, argsList, method)) {
        return true;
      }
    }
  }

  leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
  if (!isPotentiallyCompatible(leftType)) {
    return false;
  }

  if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList) && !hasFormalParameterTypes()) {
    return true;
  }

  final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
  final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
  if (interfaceMethod == null) return false;

  if (interfaceMethod.hasTypeParameters()) return false;

  final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);

  if (hasFormalParameterTypes()) {
    final PsiParameter[] lambdaParameters = getParameterList().getParameters();
    final PsiType[] parameterTypes = interfaceMethod.getSignature(substitutor).getParameterTypes();
    for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
      PsiParameter parameter = lambdaParameters[lambdaParamIdx];
      final PsiTypeElement typeElement = parameter.getTypeElement();
      if (typeElement != null) {
        final PsiType lambdaFormalType = toArray(typeElement.getType());
        final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
        if (!lambdaFormalType.equals(methodParameterType)) {
          return false;
        }
      }
    }
  }

  PsiType methodReturnType = interfaceMethod.getReturnType();
  if (methodReturnType != null && methodReturnType != PsiType.VOID) {
    Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
    try {
      if (map.put(this, leftType) != null) {
        return false;
      }
      return LambdaUtil.checkReturnTypeCompatible(this, substitutor.substitute(methodReturnType)) == null;
    }
    finally {
      map.remove(this);
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:73,代码来源:PsiLambdaExpressionImpl.java


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