本文整理汇总了Java中com.intellij.psi.util.PsiUtil.getApplicabilityLevel方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtil.getApplicabilityLevel方法的具体用法?Java PsiUtil.getApplicabilityLevel怎么用?Java PsiUtil.getApplicabilityLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtil
的用法示例。
在下文中一共展示了PsiUtil.getApplicabilityLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getApplicabilityLevelInner
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@ApplicabilityLevelConstant
private int getApplicabilityLevelInner() {
final PsiType[] argumentTypes = getArgumentTypes();
if (argumentTypes == null) return ApplicabilityLevel.NOT_APPLICABLE;
int level = PsiUtil.getApplicabilityLevel(getElement(), getSubstitutor(), argumentTypes, myLanguageLevel);
if (level > ApplicabilityLevel.NOT_APPLICABLE && !isTypeArgumentsApplicable()) level = ApplicabilityLevel.NOT_APPLICABLE;
return level;
}
示例2: captureReturnType
import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static PsiType captureReturnType(PsiMethodCallExpression call,
PsiMethod method,
PsiType ret,
JavaResolveResult result,
LanguageLevel languageLevel) {
PsiSubstitutor substitutor = result.getSubstitutor();
PsiType substitutedReturnType = substitutor.substitute(ret);
if (substitutedReturnType == null) {
return TypeConversionUtil.erasure(ret);
}
if (InferenceSession.wasUncheckedConversionPerformed(call)) {
// 18.5.2
// if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type,
// while the return type and thrown types are given by the erasure of m's type (without applying θ').
return TypeConversionUtil.erasure(substitutedReturnType);
}
//15.12.2.6. Method Invocation Type
// If unchecked conversion was necessary for the method to be applicable,
// the parameter types of the invocation type are the parameter types of the method's type,
// and the return type and thrown types are given by the erasures of the return type and thrown types of the method's type.
if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8) &&
(method.hasTypeParameters() || JavaVersionService.getInstance().isAtLeast(call, JavaSdkVersion.JDK_1_8)) &&
result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isApplicable()) {
final PsiType[] args = call.getArgumentList().getExpressionTypes();
final boolean allowUncheckedConversion = false;
final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method, substitutor, args, languageLevel, allowUncheckedConversion, true);
if (applicabilityLevel == MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE) {
return TypeConversionUtil.erasure(substitutedReturnType);
}
}
if (PsiUtil.isRawSubstitutor(method, substitutor)) {
final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret);
if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) {
return returnTypeErasure;
}
}
return PsiImplUtil.normalizeWildcardTypeByPosition(substitutedReturnType, call);
}