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


Java MethodCandidateInfo.isApplicable方法代码示例

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


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

示例1: getResolveError

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
protected ErrorType getResolveError(MethodCandidateInfo info) {
  if (myArgumentTypes == null) return ErrorType.NONE;

  if (!info.isApplicable()) {
    boolean hasNulls = false;
    //noinspection ConstantConditions
    final PsiParameter[] parameters = info.getElement().getParameterList().getParameters();
    if (myArgumentTypes.length == parameters.length) {
      for (int i = 0; i < myArgumentTypes.length; i++) {
        PsiType type = myArgumentTypes[i];
        if (type == null) {
          hasNulls = true;
        }
        else if (!parameters[i].getType().isAssignableFrom(type)) {
          return ErrorType.RESOLVE;
        }
      }
    }
    return hasNulls ? ErrorType.NONE : ErrorType.RESOLVE;
  }
  return ErrorType.NONE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaMethodResolveHelper.java

示例2: getResolveError

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
protected ErrorType getResolveError(MethodCandidateInfo info)
{
	if(myArgumentTypes == null)
	{
		return ErrorType.NONE;
	}

	if(!info.isApplicable())
	{
		boolean hasNulls = false;
		//noinspection ConstantConditions
		final PsiParameter[] parameters = info.getElement().getParameterList().getParameters();
		if(myArgumentTypes.length == parameters.length)
		{
			for(int i = 0; i < myArgumentTypes.length; i++)
			{
				PsiType type = myArgumentTypes[i];
				if(type == null)
				{
					hasNulls = true;
				}
				else if(!parameters[i].getType().isAssignableFrom(type))
				{
					return ErrorType.RESOLVE;
				}
			}
		}
		return hasNulls ? ErrorType.NONE : ErrorType.RESOLVE;
	}
	return ErrorType.NONE;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:JavaMethodResolveHelper.java

示例3: checkAmbiguousMethodCallIdentifier

import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Nullable
static HighlightInfo checkAmbiguousMethodCallIdentifier(@NotNull PsiReferenceExpression referenceToMethod,
                                              @NotNull JavaResolveResult[] resolveResults,
                                              @NotNull PsiExpressionList list,
                                              final PsiElement element,
                                              @NotNull JavaResolveResult resolveResult,
                                              @NotNull PsiMethodCallExpression methodCall,
                                              @NotNull PsiResolveHelper resolveHelper) {
  MethodCandidateInfo methodCandidate1 = null;
  MethodCandidateInfo methodCandidate2 = null;
  for (JavaResolveResult result : resolveResults) {
    if (!(result instanceof MethodCandidateInfo)) continue;
    MethodCandidateInfo candidate = (MethodCandidateInfo)result;
    if (candidate.isApplicable() && !candidate.getElement().isConstructor()) {
      if (methodCandidate1 == null) {
        methodCandidate1 = candidate;
      }
      else {
        methodCandidate2 = candidate;
        break;
      }
    }
  }
  MethodCandidateInfo[] candidates = toMethodCandidates(resolveResults);

  HighlightInfoType highlightInfoType = HighlightInfoType.ERROR;
  if (methodCandidate2 != null) {
    return null;
  }
  String description;
  PsiElement elementToHighlight;
  if (element != null && !resolveResult.isAccessible()) {
    description = HighlightUtil.buildProblemWithAccessDescription(referenceToMethod, resolveResult);
    elementToHighlight = referenceToMethod.getReferenceNameElement();
  }
  else if (element != null && !resolveResult.isStaticsScopeCorrect()) {
    final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(referenceToMethod);
    final String staticInterfaceMethodMessage = 
      element instanceof PsiMethod 
      ? LambdaUtil.getInvalidQualifier4StaticInterfaceMethodMessage((PsiMethod)element, referenceToMethod, 
                                                                    resolveResult.getCurrentFileResolveScope(), languageLevel) 
      : null;
    description = staticInterfaceMethodMessage != null 
                  ? staticInterfaceMethodMessage 
                  : HighlightUtil.buildProblemWithStaticDescription(element);
    elementToHighlight = referenceToMethod.getReferenceNameElement();
  }
  else {
    String methodName = referenceToMethod.getReferenceName() + buildArgTypesList(list);
    description = JavaErrorMessages.message("cannot.resolve.method", methodName);
    if (candidates.length == 0) {
      elementToHighlight = referenceToMethod.getReferenceNameElement();
      highlightInfoType = HighlightInfoType.WRONG_REF;
    }
    else {
      return null;
    }
  }
  String toolTip = XmlStringUtil.escapeString(description);
  HighlightInfo info =
    HighlightInfo.newHighlightInfo(highlightInfoType).range(elementToHighlight).description(description).escapedToolTip(toolTip).create();
  registerMethodCallIntentions(info, methodCall, list, resolveHelper);
  if (element != null && !resolveResult.isStaticsScopeCorrect()) {
    HighlightUtil.registerStaticProblemQuickFixAction(element, info, referenceToMethod);
  }

  TextRange fixRange = getFixRange(elementToHighlight);
  CastMethodArgumentFix.REGISTRAR.registerCastActions(candidates, methodCall, info, fixRange);
  WrapArrayToArraysAsListFix.REGISTAR.registerCastActions(candidates, methodCall, info, fixRange);
  PermuteArgumentsFix.registerFix(info, methodCall, candidates, fixRange);
  WrapExpressionFix.registerWrapAction(candidates, list.getExpressions(), info);
  registerChangeParameterClassFix(methodCall, list, info);
  return info;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:75,代码来源:HighlightMethodUtil.java


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