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


Java TypeConversionUtil.boxingConversionApplicable方法代码示例

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


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

示例1: isAssignable

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
private static boolean isAssignable( boolean structural, boolean covariant, PsiType to, PsiType from )
{
  if( to.equals( from ) )
  {
    return true;
  }

  if( structural )
  {
    return TypeConversionUtil.isAssignable( to, from ) ||
           arePrimitiveTypesAssignable( to, from ) ||
           isStructurallyAssignable( to, from, structural ) ||
           TypeConversionUtil.boxingConversionApplicable( to, from );
  }

  if( covariant )
  {
    TypeConversionUtil.isAssignable( to, from );
  }

  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:23,代码来源:TypeUtil.java

示例2: processBoxingConversions

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
private static void processBoxingConversions(final PsiParameter[] declaredParams,
                                             final PsiExpression[] actualArgumentExpressions,
                                             final PsiSubstitutor methodResolveSubstitutor,
                                             final Evaluator[] argumentEvaluators) {
  if (declaredParams.length > 0) {
    final int paramCount = Math.max(declaredParams.length, actualArgumentExpressions.length);
    PsiType varargType = null;
    for (int idx = 0; idx < paramCount; idx++) {
      if (idx >= actualArgumentExpressions.length) {
        break; // actual arguments count is less than number of declared params
      }
      PsiType declaredParamType;
      if (idx < declaredParams.length) {
        declaredParamType = methodResolveSubstitutor.substitute(declaredParams[idx].getType());
        if (declaredParamType instanceof PsiEllipsisType) {
          declaredParamType = varargType = ((PsiEllipsisType)declaredParamType).getComponentType();
        }
      }
      else if (varargType != null) {
        declaredParamType = varargType;
      }
      else {
        break;
      }
      final PsiType actualArgType = actualArgumentExpressions[idx].getType();
      if (TypeConversionUtil.boxingConversionApplicable(declaredParamType, actualArgType)) {
        final Evaluator argEval = argumentEvaluators[idx];
        argumentEvaluators[idx] = declaredParamType instanceof PsiPrimitiveType ? new UnBoxingEvaluator(argEval) : new BoxingEvaluator(argEval);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:EvaluatorBuilderImpl.java

示例3: visitTypeCastExpression

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitTypeCastExpression(PsiTypeCastExpression expression) {
  PsiExpression operandExpr = expression.getOperand();
  if (operandExpr == null) {
    throwExpressionInvalid(expression);
  }
  operandExpr.accept(this);
  Evaluator operandEvaluator = myResult;
  PsiTypeElement castTypeElem = expression.getCastType();
  if (castTypeElem == null) {
    throwExpressionInvalid(expression);
  }
  PsiType castType = castTypeElem.getType();
  PsiType operandType = operandExpr.getType();

  // if operand type can not be resolved in current context - leave it for runtime checks
  if (operandType != null &&
      !TypeConversionUtil.areTypesConvertible(operandType, castType) &&
      PsiUtil.resolveClassInType(operandType) != null) {
    throw new EvaluateRuntimeException(
      new EvaluateException(JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil
        .formatType(castType)))
    );
  }

  boolean shouldPerformBoxingConversion = operandType != null && TypeConversionUtil.boxingConversionApplicable(castType, operandType);
  final boolean castingToPrimitive = castType instanceof PsiPrimitiveType;
  if (shouldPerformBoxingConversion && castingToPrimitive) {
    operandEvaluator = new UnBoxingEvaluator(operandEvaluator);
  }

  final boolean performCastToWrapperClass = shouldPerformBoxingConversion && !castingToPrimitive;

  if (!(PsiUtil.resolveClassInClassTypeOnly(castType) instanceof PsiTypeParameter)) {
    String castTypeName = castType.getCanonicalText();
    if (performCastToWrapperClass) {
      final PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(castType);
      if (unboxedType != null) {
        castTypeName = unboxedType.getCanonicalText();
      }
    }

    myResult = new TypeCastEvaluator(operandEvaluator, castTypeName, castingToPrimitive);
  }

  if (performCastToWrapperClass) {
    myResult = new BoxingEvaluator(myResult);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:EvaluatorBuilderImpl.java

示例4: areTypesConvertible

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public boolean areTypesConvertible(final PsiType exprType, final PsiType parameterType, final PsiElement context) {
  return !(exprType instanceof PsiPrimitiveType) && !(parameterType instanceof PsiPrimitiveType) || TypeConversionUtil.boxingConversionApplicable(exprType, parameterType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AddTypeArgumentsFix.java


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