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


Java MethodCandidateInfo.getSubstitutor方法代码示例

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


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

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

示例2: registerSwapFixes

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static void registerSwapFixes(final PsiExpression[] expressions, final PsiCall callExpression, final List<PsiCall> permutations,
                                      MethodCandidateInfo candidate, final int incompatibilitiesCount, final int minIncompatibleIndex,
                                      final int maxIncompatibleIndex) throws IncorrectOperationException {
  PsiMethod method = candidate.getElement();
  PsiSubstitutor substitutor = candidate.getSubstitutor();
  if (incompatibilitiesCount >= 3) return; // no way we can fix it by swapping

  for (int i = minIncompatibleIndex; i < maxIncompatibleIndex; i++) {
    for (int j = i+1; j <= maxIncompatibleIndex; j++) {
      ArrayUtil.swap(expressions, i, j);
      if (PsiUtil.isApplicable(method, substitutor, expressions)) {
        PsiCall copy = (PsiCall)callExpression.copy();
        PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
        copyExpressions[i].replace(expressions[i]);
        copyExpressions[j].replace(expressions[j]);
        JavaResolveResult result = copy.resolveMethodGenerics();
        if (result.getElement() != null && result.isValidResult()) {
          permutations.add(copy);
          if (permutations.size() > 1) return;
        }
      }
      ArrayUtil.swap(expressions, i, j);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PermuteArgumentsFix.java

示例3: 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:consulo,项目名称:consulo-java,代码行数:21,代码来源:HighlightMethodUtil.java

示例4: buildOneLineMismatchDescription

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String buildOneLineMismatchDescription(@NotNull PsiExpressionList list,
                                                      @NotNull MethodCandidateInfo candidateInfo,
                                                      @NotNull Ref<PsiElement> elementToHighlight) {
  final PsiExpression[] expressions = list.getExpressions();
  final PsiMethod resolvedMethod = candidateInfo.getElement();
  final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
  final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
  if (expressions.length == parameters.length && parameters.length > 1) {
    int idx = -1;
    for (int i = 0; i < expressions.length; i++) {
      PsiExpression expression = expressions[i];
      if (!TypeConversionUtil.areTypesAssignmentCompatible(substitutor.substitute(parameters[i].getType()), expression)) {
        if (idx != -1) {
          idx = -1;
          break;
        }
        else {
          idx = i;
        }
      }
    }

    if (idx > -1) {
      final PsiExpression wrongArg = expressions[idx];
      final PsiType argType = wrongArg.getType();
      if (argType != null) {
        elementToHighlight.set(wrongArg);
        final String message = JavaErrorMessages
          .message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType.getCanonicalText());

        return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) +
                                        " <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip(candidateInfo, list)) + "\"" +
                                        (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") +
                                        ">" + DaemonBundle.message("inspection.extended.description") + "</a></body>");
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:HighlightMethodUtil.java

示例5: createMismatchedArgumentsHtmlTooltip

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String createMismatchedArgumentsHtmlTooltip(MethodCandidateInfo info, PsiExpressionList list) {
  PsiMethod method = info.getElement();
  PsiSubstitutor substitutor = info.getSubstitutor();
  PsiClass aClass = method.getContainingClass();
  PsiParameter[] parameters = method.getParameterList().getParameters();
  String methodName = method.getName();
  return createMismatchedArgumentsHtmlTooltip(list, parameters, methodName, substitutor, aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:HighlightMethodUtil.java

示例6: registerFix

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static void registerFix(HighlightInfo info, PsiCall callExpression, final CandidateInfo[] candidates, final TextRange fixRange) {
  PsiExpression[] expressions = callExpression.getArgumentList().getExpressions();
  if (expressions.length < 2) return;
  List<PsiCall> permutations = new ArrayList<PsiCall>();

  for (CandidateInfo candidate : candidates) {
    if (candidate instanceof MethodCandidateInfo) {
      MethodCandidateInfo methodCandidate = (MethodCandidateInfo)candidate;
      PsiMethod method = methodCandidate.getElement();
      PsiSubstitutor substitutor = methodCandidate.getSubstitutor();

      PsiParameter[] parameters = method.getParameterList().getParameters();
      if (expressions.length != parameters.length || parameters.length ==0) continue;
      int minIncompatibleIndex = parameters.length;
      int maxIncompatibleIndex = 0;
      int incompatibilitiesCount = 0;
      for (int i = 0; i < parameters.length; i++) {
        PsiParameter parameter = parameters[i];
        PsiType type = substitutor.substitute(parameter.getType());
        if (TypeConversionUtil.areTypesAssignmentCompatible(type, expressions[i])) continue;
        if (minIncompatibleIndex == parameters.length) minIncompatibleIndex = i;
        maxIncompatibleIndex = i;
        incompatibilitiesCount++;
      }

      try {
        registerSwapFixes(expressions, callExpression, permutations, methodCandidate, incompatibilitiesCount, minIncompatibleIndex, maxIncompatibleIndex);
        registerShiftFixes(expressions, callExpression, permutations, methodCandidate, minIncompatibleIndex, maxIncompatibleIndex);
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    }
  }
  if (permutations.size() == 1) {
    PermuteArgumentsFix fix = new PermuteArgumentsFix(callExpression, permutations.get(0));
    QuickFixAction.registerQuickFixAction(info, fixRange, fix);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:PermuteArgumentsFix.java

示例7: createMismatchedArgumentsHtmlTooltip

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String createMismatchedArgumentsHtmlTooltip(MethodCandidateInfo info, PsiExpressionList list)
{
	PsiMethod method = info.getElement();
	PsiSubstitutor substitutor = info.getSubstitutor();
	PsiClass aClass = method.getContainingClass();
	PsiParameter[] parameters = method.getParameterList().getParameters();
	String methodName = method.getName();
	return createMismatchedArgumentsHtmlTooltip(list, info, parameters, methodName, substitutor, aClass);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:HighlightMethodUtil.java

示例8: isApplicable

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
protected boolean isApplicable(PsiMethod method, PsiElement place)
{
	final PsiExpressionList argumentList = ((PsiMethodCallExpression) place).getArgumentList();
	final MethodCandidateInfo candidateInfo = new MethodCandidateInfo(method, PsiSubstitutor.EMPTY, false, false, argumentList, null, argumentList.getExpressionTypes(), null);
	PsiSubstitutor substitutorForMethod = candidateInfo.getSubstitutor();
	if(PsiUtil.isApplicable(method, substitutorForMethod, argumentList))
	{
		final PsiType returnType = substitutorForMethod.substitute(method.getReturnType());
		final PsiType expectedType = getExpectedType();
		return expectedType == null || returnType == null || TypeConversionUtil.isAssignable(expectedType, returnType);
	}
	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:15,代码来源:StaticImportMethodFix.java

示例9: guardedOverloadResolution

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Nullable
protected CandidateInfo guardedOverloadResolution(@NotNull List<CandidateInfo> conflicts) {
  if (conflicts.isEmpty()) return null;
  if (conflicts.size() == 1) return conflicts.get(0);

  boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), true);
  if (conflicts.size() == 1) return conflicts.get(0);

  final FactoryMap<MethodCandidateInfo, PsiSubstitutor> map = new FactoryMap<MethodCandidateInfo, PsiSubstitutor>() {
    @Nullable
    @Override
    protected PsiSubstitutor create(MethodCandidateInfo key) {
      return key.getSubstitutor(false);
    }
  };
  checkSameSignatures(conflicts, map);
  if (conflicts.size() == 1) return conflicts.get(0);

  checkAccessStaticLevels(conflicts, true);
  if (conflicts.size() == 1) return conflicts.get(0);

  checkParametersNumber(conflicts, getActualParametersLength(), false);
  if (conflicts.size() == 1) return conflicts.get(0);
  
  checkStaticMethodsOfInterfaces(conflicts);
  if (conflicts.size() == 1) return conflicts.get(0);

  final int applicabilityLevel = checkApplicability(conflicts);
  if (conflicts.size() == 1) return conflicts.get(0);

  // makes no sense to do further checks, because if no one candidate matches by parameters count
  // then noone can be more specific
  if (!atLeastOneMatch) return null;

  checkSpecifics(conflicts, applicabilityLevel, map, myLanguageLevel);
  if (conflicts.size() == 1) return conflicts.get(0);

  checkPrimitiveVarargs(conflicts, getActualParametersLength());
  if (conflicts.size() == 1) return conflicts.get(0);

  checkAccessStaticLevels(conflicts, false);
  if (conflicts.size() == 1) return conflicts.get(0);

  Set<CandidateInfo> uniques = new THashSet<CandidateInfo>(conflicts);
  if (uniques.size() == 1) return uniques.iterator().next();
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:JavaMethodsConflictResolver.java

示例10: getSubstitutor

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor getSubstitutor(MethodCandidateInfo existing, FactoryMap<MethodCandidateInfo, PsiSubstitutor> map) {
  return map != null ? map.get(existing) : existing.getSubstitutor(false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaMethodsConflictResolver.java

示例11: getSubstitutor

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor getSubstitutor(MethodCandidateInfo existing, FactoryMap<MethodCandidateInfo, PsiSubstitutor> map)
{
	return map != null ? map.get(existing) : existing.getSubstitutor(false);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:6,代码来源:JavaMethodsConflictResolver.java

示例12: buildOneLineMismatchDescription

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static String buildOneLineMismatchDescription(@NotNull PsiExpressionList list, @NotNull MethodCandidateInfo candidateInfo, @NotNull Ref<PsiElement> elementToHighlight)
{
	final PsiExpression[] expressions = list.getExpressions();
	final PsiMethod resolvedMethod = candidateInfo.getElement();
	final PsiSubstitutor substitutor = candidateInfo.getSubstitutor();
	final PsiParameter[] parameters = resolvedMethod.getParameterList().getParameters();
	if(expressions.length == parameters.length && parameters.length > 1)
	{
		int idx = -1;
		for(int i = 0; i < expressions.length; i++)
		{
			PsiExpression expression = expressions[i];
			if(expression instanceof PsiMethodCallExpression)
			{
				final JavaResolveResult result = ((PsiCallExpression) expression).resolveMethodGenerics();
				if(result instanceof MethodCandidateInfo && PsiUtil.isLanguageLevel8OrHigher(list) && ((MethodCandidateInfo) result).isToInferApplicability() && ((MethodCandidateInfo) result)
						.getInferenceErrorMessage() == null)
				{
					continue;
				}
			}
			if(!TypeConversionUtil.areTypesAssignmentCompatible(substitutor.substitute(parameters[i].getType()), expression))
			{
				if(idx != -1)
				{
					idx = -1;
					break;
				}
				else
				{
					idx = i;
				}
			}
		}

		if(idx > -1)
		{
			final PsiExpression wrongArg = expressions[idx];
			final PsiType argType = wrongArg.getType();
			if(argType != null)
			{
				elementToHighlight.set(wrongArg);
				final String message = JavaErrorMessages.message("incompatible.call.types", idx + 1, substitutor.substitute(parameters[idx].getType()).getCanonicalText(), argType
						.getCanonicalText());

				return XmlStringUtil.wrapInHtml("<body>" + XmlStringUtil.escapeString(message) + " <a href=\"#assignment/" + XmlStringUtil.escapeString(createMismatchedArgumentsHtmlTooltip
						(candidateInfo, list)) + "\"" + (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "") + ">" + DaemonBundle.message("inspection.extended.description") + "</a></body>");
			}
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:53,代码来源:HighlightMethodUtil.java


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