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


Java TypeConversionUtil.isAssignableFromPrimitiveWrapper方法代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:AutoUnboxingInspection.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AutoUnboxingInspection.java


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