本文整理汇总了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;
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}