本文整理汇总了Java中com.intellij.psi.util.TypeConversionUtil.isBinaryOperatorApplicable方法的典型用法代码示例。如果您正苦于以下问题:Java TypeConversionUtil.isBinaryOperatorApplicable方法的具体用法?Java TypeConversionUtil.isBinaryOperatorApplicable怎么用?Java TypeConversionUtil.isBinaryOperatorApplicable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.TypeConversionUtil
的用法示例。
在下文中一共展示了TypeConversionUtil.isBinaryOperatorApplicable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitPolyadicExpression
import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitPolyadicExpression(PsiPolyadicExpression expression) {
super.visitPolyadicExpression(expression);
final PsiExpression[] operands = expression.getOperands();
if (operands.length == 0) return;
final IElementType operationTokenType = expression.getOperationTokenType();
PsiExpression lOperand = operands[0];
TypeView left = new TypeView(lOperand);
for(int i = 1; i < operands.length; i++) {
final PsiExpression rOperand = operands[i];
if (rOperand == null) return;
final TypeView right = new TypeView(rOperand);
if (!TypeConversionUtil.isBinaryOperatorApplicable(operationTokenType, left.getType(), right.getType(), false)) {
if (left.isChanged()) {
findConversionOrFail(expression, lOperand, left.getTypePair());
}
if (right.isChanged()) {
findConversionOrFail(expression, rOperand, right.getTypePair());
}
}
lOperand = rOperand;
left = right;
}
}
示例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.");
}
}