本文整理汇总了Java中com.intellij.psi.util.TypeConversionUtil.isAssignableFromPrimitiveWrapper方法的典型用法代码示例。如果您正苦于以下问题:Java TypeConversionUtil.isAssignableFromPrimitiveWrapper方法的具体用法?Java TypeConversionUtil.isAssignableFromPrimitiveWrapper怎么用?Java TypeConversionUtil.isAssignableFromPrimitiveWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.TypeConversionUtil
的用法示例。
在下文中一共展示了TypeConversionUtil.isAssignableFromPrimitiveWrapper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkExpression
import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
private void checkExpression(PsiExpression expression) {
if (expression.getParent() instanceof PsiParenthesizedExpression) {
return;
}
final PsiType expressionType = expression.getType();
if (!TypeConversionUtil.isAssignableFromPrimitiveWrapper(expressionType)) {
return;
}
final PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, false, true);
if (!TypeConversionUtil.isPrimitiveAndNotNull(expectedType)) {
return;
}
if (!(expression.getParent() instanceof PsiTypeCastExpression)) {
final PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(expressionType);
if (unboxedType == null || !expectedType.isAssignableFrom(unboxedType)) {
return;
}
}
registerError(expression, expression);
}
示例2: visitReferenceExpression
import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
super.visitReferenceExpression(expression);
if (expression instanceof PsiMethodReferenceExpression) {
final PsiMethodReferenceExpression methodReferenceExpression = (PsiMethodReferenceExpression)expression;
if (methodReferenceExpression.isConstructor()) {
return;
}
final PsiElement referenceNameElement = methodReferenceExpression.getReferenceNameElement();
if (referenceNameElement == null) {
return;
}
final PsiElement target = methodReferenceExpression.resolve();
if (!(target instanceof PsiMethod)) {
return;
}
final PsiMethod method = (PsiMethod)target;
final PsiType returnType = method.getReturnType();
if (!TypeConversionUtil.isAssignableFromPrimitiveWrapper(returnType)) {
return;
}
final PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(returnType);
if (unboxedType == null) {
return;
}
final PsiType functionalInterfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(methodReferenceExpression);
if (functionalInterfaceReturnType == null || !ClassUtils.isPrimitive(functionalInterfaceReturnType) ||
!functionalInterfaceReturnType.isAssignableFrom(unboxedType)) {
return;
}
registerError(referenceNameElement);
}
else {
checkExpression(expression);
}
}