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


Java TypeConversionUtil.isBinaryOperatorApplicable方法代码示例

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

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


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