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


Java TypeConversionUtil.calcTypeForBinaryExpression方法代码示例

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


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

示例1: doGetType

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Nullable
private static PsiType doGetType(PsiPolyadicExpressionImpl param) {
  PsiExpression[] operands = param.getOperands();
  PsiType lType = null;

  IElementType sign = param.getOperationTokenType();
  for (int i=1; i<operands.length;i++) {
    PsiType rType = operands[i].getType();
    // optimization: if we can calculate type based on right type only
    PsiType type = TypeConversionUtil.calcTypeForBinaryExpression(null, rType, sign, false);
    if (type != TypeConversionUtil.NULL_TYPE) return type;
    if (lType == null) lType = operands[0].getType();
    lType = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, sign, true);
  }
  return lType;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiPolyadicExpressionImpl.java

示例2: visitPolyadicExpression

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitPolyadicExpression(PsiPolyadicExpression expression) {
  super.visitPolyadicExpression(expression);
  final IElementType tokenType = expression.getOperationTokenType();
  if (ComparisonUtils.isComparisonOperation(tokenType)) {
    return;
  }
  final PsiExpression[] operands = expression.getOperands();
  PsiType leftType = operands[0].getType();
  for (int i = 1; i < operands.length; i++) {
    final PsiExpression operand = operands[i];
    final PsiType rightType = operand.getType();
    final PsiType expressionType = TypeConversionUtil.calcTypeForBinaryExpression(leftType, rightType, tokenType, true);
    if (TypeUtils.isJavaLangString(expressionType)) {
      return;
    }
    if (PsiType.CHAR.equals(rightType)) {
      registerError(operand, operand);
    }
    if (PsiType.CHAR.equals(leftType) && i == 1) {
      registerError(operands[0], operands[0]);
    }
    leftType = rightType;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CharUsedInArithmeticContextInspection.java

示例3: doGetType

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
private static PsiType doGetType(PsiBinaryExpressionImpl param) {
  PsiExpression lOperand = param.getLOperand();
  PsiExpression rOperand = param.getROperand();
  if (rOperand == null) return null;
  PsiType rType = rOperand.getType();
  IElementType sign = param.getOperationTokenType();
  // optimization: if we can calculate type based on right type only
  PsiType type = TypeConversionUtil.calcTypeForBinaryExpression(null, rType, sign, false);
  if (type != TypeConversionUtil.NULL_TYPE) return type;

  PsiType lType = lOperand.getType();
  return TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, sign, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PsiBinaryExpressionImpl.java

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

示例5: visitPolyadicExpression

import com.intellij.psi.util.TypeConversionUtil; //导入方法依赖的package包/类
@Override
public void visitPolyadicExpression(PsiPolyadicExpression wideExpression) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("visitPolyadicExpression " + wideExpression);
  }
  PsiExpression[] operands = wideExpression.getOperands();
  operands[0].accept(this);
  Evaluator result = myResult;
  PsiType lType = operands[0].getType();
  for (int i = 1; i < operands.length; i++) {
    PsiExpression expression = operands[i];
    if (expression == null) {
      throwExpressionInvalid(wideExpression);
    }
    expression.accept(this);
    Evaluator rResult = myResult;
    IElementType opType = wideExpression.getOperationTokenType();
    PsiType rType = expression.getType();
    if (rType == null) {
      throwEvaluateException(DebuggerBundle.message("evaluation.error.unknown.expression.type", expression.getText()));
    }
    final PsiType typeForBinOp = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, opType, true);
    if (typeForBinOp == null) {
      throwEvaluateException(DebuggerBundle.message("evaluation.error.unknown.expression.type", wideExpression.getText()));
    }
    myResult = createBinaryEvaluator(result, lType, rResult, rType, opType, typeForBinOp);
    lType = typeForBinOp;
    result = myResult;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:EvaluatorBuilderImpl.java


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