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


Java MethodCandidateInfo类代码示例

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


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

示例1: getSubstitutor

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
private static PsiSubstitutor getSubstitutor(final JavaResolveResult result, PsiCallExpression methodCall) {
  final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(methodCall, PsiLambdaExpression.class);
  final PsiSubstitutor substitutor;
  if (expression != null) {
    final PsiElement parent = methodCall.getParent();
    final boolean callInReturnStatement = parent == expression || 
                                          parent instanceof PsiReturnStatement && PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class, true, PsiMethod.class) == expression;
    substitutor = callInReturnStatement ? ourThrowsGuard.doPreventingRecursion(expression, false, new Computable<PsiSubstitutor>() {
      @Override
      public PsiSubstitutor compute() {
        return result.getSubstitutor();
      }
    }) : result.getSubstitutor();
  } else {
    substitutor = result.getSubstitutor();
  }
  return substitutor == null ? ((MethodCandidateInfo)result).getSiteSubstitutor() : substitutor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ExceptionUtil.java

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

示例3: resolveConflict

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
@Override
public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts){
  if (conflicts.size() == 1) return conflicts.get(0);
  final Map<Object, CandidateInfo> uniqueItems = new HashMap<Object, CandidateInfo>();
  for (CandidateInfo info : conflicts) {
    final PsiElement element = info.getElement();
    Object key;
    if (info instanceof MethodCandidateInfo) {
      key = ((PsiMethod)element).getSignature(((MethodCandidateInfo)info).getSubstitutor(false));
    }
    else {
      key = PsiUtilCore.getName(element);
    }

    if (!uniqueItems.containsKey(key)) {
      uniqueItems.put(key, info);
    }
  }

  if(uniqueItems.size() == 1) return uniqueItems.values().iterator().next();
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DuplicateConflictResolver.java

示例4: resolveConflict

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
@Override
public final CandidateInfo resolveConflict(@NotNull final List<CandidateInfo> conflicts){
  /*
  //non-default policies
  final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(myArgumentsList);
  if (properties != null) {
    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, true, new Computable<CandidateInfo>() {
    @Override
    public CandidateInfo compute() {
      return guardedOverloadResolution(conflicts);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaMethodsConflictResolver.java

示例5: checkAccessStaticLevels

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
protected static void checkAccessStaticLevels(@NotNull List<CandidateInfo> conflicts, boolean checkAccessible) {
  int conflictsCount = conflicts.size();

  int maxCheckLevel = -1;
  int[] checkLevels = new int[conflictsCount];
  int index = 0;
  for (final CandidateInfo conflict : conflicts) {
    ProgressManager.checkCanceled();
    final MethodCandidateInfo method = (MethodCandidateInfo)conflict;
    final int level = checkAccessible ? getCheckAccessLevel(method) : getCheckStaticLevel(method);
    checkLevels[index++] = level;
    maxCheckLevel = Math.max(maxCheckLevel, level);
  }

  for (int i = conflictsCount - 1; i >= 0; i--) {
    // check for level
    if (checkLevels[i] < maxCheckLevel) {
      conflicts.remove(i);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaMethodsConflictResolver.java

示例6: checkStaticMethodsOfInterfaces

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
/**
 * choose to accept static interface methods during search to get "Static interface methods must be invoked on containing interface class only" error
 * instead of non clear javac message that symbol not found
 * 
 * but these methods should be ignored during overload resolution if another methods are present
 */
private void checkStaticMethodsOfInterfaces(@NotNull List<CandidateInfo> conflicts) {
  if (!(myArgumentsList instanceof PsiExpressionList)) return;
  PsiClass qualifierClass = null;
  for (Iterator<CandidateInfo> iterator = conflicts.iterator(); iterator.hasNext(); ) {
    CandidateInfo conflict = iterator.next();
    if (!(conflict instanceof MethodCandidateInfo)) continue;
    final PsiMethod method = ((MethodCandidateInfo)conflict).getElement();
    if (method.hasModifierProperty(PsiModifier.STATIC)) {
      if (conflict.getCurrentFileResolveScope() instanceof PsiImportStaticStatement) continue;
      final PsiClass containingClass = method.getContainingClass();
      if (containingClass != null && containingClass.isInterface()) {
        if (qualifierClass == null) {
          qualifierClass = getQualifiedClass(method);
          if (qualifierClass == null) return;
        }
        if (!containingClass.getManager().areElementsEquivalent(containingClass, qualifierClass)) {
          iterator.remove();
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:JavaMethodsConflictResolver.java

示例7: isApplicableTo

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
private boolean isApplicableTo(@NotNull PsiType[] types2AtSite,
                               @NotNull PsiMethod method1,
                               @NotNull LanguageLevel languageLevel,
                               boolean varargsPosition,
                               @NotNull PsiSubstitutor methodSubstitutor1,
                               @NotNull PsiMethod method2, 
                               PsiSubstitutor siteSubstitutor1) {
  if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && method1.getTypeParameters().length > 0 && myArgumentsList instanceof PsiExpressionList) {
    final PsiElement parent = myArgumentsList.getParent();
    if (parent instanceof PsiCallExpression) {
      return InferenceSession.isMoreSpecific(method2, method1, siteSubstitutor1,  ((PsiExpressionList)myArgumentsList).getExpressions(), myArgumentsList, varargsPosition);
    }
  }
  final PsiUtil.ApplicabilityChecker applicabilityChecker = languageLevel.isAtLeast(LanguageLevel.JDK_1_8) 
  ? new PsiUtil.ApplicabilityChecker() {
    @Override
    public boolean isApplicable(PsiType left, PsiType right,
                                boolean allowUncheckedConversion, int argId) {
      return isTypeMoreSpecific(left, right, argId);
    }
  } 
  : PsiUtil.ApplicabilityChecker.ASSIGNABILITY_CHECKER;
  final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method1, methodSubstitutor1, types2AtSite, languageLevel, false, varargsPosition, applicabilityChecker);
  return applicabilityLevel > MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaMethodsConflictResolver.java

示例8: initExpressionConstraints

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
public void initExpressionConstraints(PsiParameter[] parameters,
                                      PsiExpression[] args,
                                      PsiElement parent,
                                      PsiMethod method,
                                      boolean varargs) {
  final MethodCandidateInfo.CurrentCandidateProperties currentProperties = getCurrentProperties(parent);
  if (method == null) {
    if (currentProperties != null) {
      method = currentProperties.getMethod();
    }
  }
  if (method != null) {
    initThrowsConstraints(method);
  }
  if (parameters.length > 0) {
    for (int i = 0; i < args.length; i++) {
      if (args[i] != null && isPertinentToApplicability(args[i], method)) {
        PsiType parameterType = getParameterType(parameters, i, mySiteSubstitutor, varargs);
        addConstraint(new ExpressionCompatibilityConstraint(args[i], substituteWithInferenceVariables(parameterType)));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InferenceSession.java

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

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

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

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

示例13: registerMethodReturnFixAction

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
private static void registerMethodReturnFixAction(HighlightInfo highlightInfo,
                                                  MethodCandidateInfo candidate,
                                                  PsiCall methodCall) {
  if (methodCall.getParent() instanceof PsiReturnStatement) {
    final PsiMethod containerMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class, true, PsiLambdaExpression.class);
    if (containerMethod != null) {
      final PsiMethod method = candidate.getElement();
      final PsiExpression methodCallCopy =
        JavaPsiFacade.getElementFactory(method.getProject()).createExpressionFromText(methodCall.getText(), methodCall);
      PsiType methodCallTypeByArgs = methodCallCopy.getType();
      //ensure type params are not included
      methodCallTypeByArgs = JavaPsiFacade.getElementFactory(method.getProject())
        .createRawSubstitutor(method).substitute(methodCallTypeByArgs);
      QuickFixAction.registerQuickFixAction(highlightInfo, 
                                            getFixRange(methodCall),
                                            QUICK_FIX_FACTORY.createMethodReturnFix(containerMethod, methodCallTypeByArgs, true));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HighlightMethodUtil.java

示例14: createAmbiguousMethodHtmlTooltipMethodRow

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
@Language("HTML")
private static String createAmbiguousMethodHtmlTooltipMethodRow(final MethodCandidateInfo methodCandidate) {
  PsiMethod method = methodCandidate.getElement();
  PsiParameter[] parameters = method.getParameterList().getParameters();
  PsiSubstitutor substitutor = methodCandidate.getSubstitutor();
  @NonNls @Language("HTML") String ms = "<td><b>" + method.getName() + "</b></td>";

  for (int j = 0; j < parameters.length; j++) {
    PsiParameter parameter = parameters[j];
    PsiType type = substitutor.substitute(parameter.getType());
    ms += "<td><b>" + (j == 0 ? "(" : "") +
          XmlStringUtil.escapeString(type.getPresentableText())
          + (j == parameters.length - 1 ? ")" : ",") + "</b></td>";
  }
  if (parameters.length == 0) {
    ms += "<td><b>()</b></td>";
  }
  return ms;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:HighlightMethodUtil.java

示例15: checkVarargParameterErasureToBeAccessible

import com.intellij.psi.infos.MethodCandidateInfo; //导入依赖的package包/类
/**
 * If the compile-time declaration is applicable by variable arity invocation,
 * then where the last formal parameter type of the invocation type of the method is Fn[], 
 * it is a compile-time error if the type which is the erasure of Fn is not accessible at the point of invocation.
 */
private static HighlightInfo checkVarargParameterErasureToBeAccessible(MethodCandidateInfo info, PsiCall place) {
  final PsiMethod method = info.getElement();
  if (info.isVarargs() || method.isVarArgs() && !PsiUtil.isLanguageLevel8OrHigher(place)) {
    final PsiParameter[] parameters = method.getParameterList().getParameters();
    final PsiType componentType = ((PsiEllipsisType)parameters[parameters.length - 1].getType()).getComponentType();
    final PsiType substitutedTypeErasure = TypeConversionUtil.erasure(info.getSubstitutor().substitute(componentType));
    final PsiClass targetClass = PsiUtil.resolveClassInClassTypeOnly(substitutedTypeErasure);
    if (targetClass != null && !PsiUtil.isAccessible(targetClass, place, null)) {
      final PsiExpressionList argumentList = place.getArgumentList();
      return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
        .descriptionAndTooltip("Formal varargs element type " +
                               PsiFormatUtil.formatClass(targetClass, PsiFormatUtilBase.SHOW_FQ_NAME) +
                               " is inaccessible here")
        .range(argumentList != null ? argumentList : place)
        .create();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:HighlightMethodUtil.java


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