本文整理汇总了Java中com.intellij.psi.util.TypeConversionUtil.convertEQtoOperation方法的典型用法代码示例。如果您正苦于以下问题:Java TypeConversionUtil.convertEQtoOperation方法的具体用法?Java TypeConversionUtil.convertEQtoOperation怎么用?Java TypeConversionUtil.convertEQtoOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.TypeConversionUtil
的用法示例。
在下文中一共展示了TypeConversionUtil.convertEQtoOperation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitAssignmentExpression
import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
final PsiExpression rExpression = expression.getRExpression();
if(rExpression == null) {
throwExpressionInvalid(expression);
}
rExpression.accept(this);
Evaluator rEvaluator = myResult;
final PsiExpression lExpression = expression.getLExpression();
final PsiType lType = lExpression.getType();
if(lType == null) {
throwEvaluateException(DebuggerBundle.message("evaluation.error.unknown.expression.type", lExpression.getText()));
}
IElementType assignmentType = expression.getOperationTokenType();
PsiType rType = rExpression.getType();
if(!TypeConversionUtil.areTypesAssignmentCompatible(lType, rExpression) && rType != null) {
throwEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", expression.getOperationSign().getText()));
}
lExpression.accept(this);
Evaluator lEvaluator = myResult;
rEvaluator = handleAssignmentBoxingAndPrimitiveTypeConversions(lType, rType, rEvaluator);
if (assignmentType != JavaTokenType.EQ) {
IElementType opType = TypeConversionUtil.convertEQtoOperation(assignmentType);
final PsiType typeForBinOp = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, opType, true);
if (typeForBinOp == null || rType == null) {
throwEvaluateException(DebuggerBundle.message("evaluation.error.unknown.expression.type", expression.getText()));
}
rEvaluator = createBinaryEvaluator(lEvaluator, lType, rEvaluator, rType, opType, typeForBinOp);
}
myResult = new AssignmentEvaluator(lEvaluator, rEvaluator);
}
示例2: visitAssignmentExpression
import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitAssignmentExpression(PsiAssignmentExpression expression) {
super.visitAssignmentExpression(expression);
final PsiExpression lExpression = expression.getLExpression();
final TypeView left = new TypeView(lExpression);
final PsiExpression rExpression = expression.getRExpression();
if (rExpression == null) return;
final TypeView right = new TypeView(rExpression);
final IElementType sign = expression.getOperationTokenType();
final PsiType ltype = left.getType();
final PsiType rtype = right.getType();
if (ltype == null || rtype == null) return;
if (sign != JavaTokenType.EQ) {
final IElementType binaryOperator = TypeConversionUtil.convertEQtoOperation(sign);
if (!TypeConversionUtil.isBinaryOperatorApplicable(binaryOperator, ltype, rtype, false)) {
if (left.isChanged()) {
findConversionOrFail(expression, lExpression, left.getTypePair());
}
if (right.isChanged()) {
findConversionOrFail(expression, rExpression, right.getTypePair());
}
return;
}
}
switch (TypeInfection.getInfection(left, right)) {
case TypeInfection.NONE_INFECTED:
break;
case TypeInfection.LEFT_INFECTED:
myLabeler.migrateExpressionType(rExpression, ltype, myStatement, TypeConversionUtil.isAssignable(ltype, rtype), true);
break;
case TypeInfection.RIGHT_INFECTED:
myLabeler.migrateExpressionType(lExpression, rtype, myStatement, TypeConversionUtil.isAssignable(ltype, rtype), false);
break;
case TypeInfection.BOTH_INFECTED:
addTypeUsage(lExpression);
addTypeUsage(rExpression);
break;
default:
LOG.error("Must not happen.");
}
}