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


Java TypeConversionUtil.NULL_TYPE属性代码示例

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


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

示例1: doGetType

@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,代码行数:16,代码来源:PsiPolyadicExpressionImpl.java

示例2: getType

@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f) {
  final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck();
  PsiType type = isOverloadCheck ? null : myCalculatedTypes.get(expr);
  if (type == null) {
    final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
    type = f.fun(expr);
    if (!dStackStamp.mayCacheNow() || isOverloadCheck) {
      return type;
    }
    if (type == null) type = TypeConversionUtil.NULL_TYPE;
    myCalculatedTypes.put(expr, type);

    if (type instanceof PsiClassReferenceType) {
      // convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
      PsiClassType.ClassResolveResult result = ((PsiClassReferenceType)type).resolveGenerics();
      PsiClass psiClass = result.getElement();
      type = psiClass == null
             ? type // for type with unresolved reference, leave it in the cache
                    // for clients still might be able to retrieve its getCanonicalText() from the reference text
             : new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType)type).getLanguageLevel(), type.getAnnotations());
    }
  }

  if (!type.isValid()) {
    if (expr.isValid()) {
      PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType)type).getReference() : null;
      @NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: "+refInside + " ("+refInside.getClass()+") valid:"+refInside.isValid());
      LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
    }
    else {
      LOG.error("Expression: '"+expr+"' is invalid, must not be used for getType()");
    }
  }

  return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:JavaResolveCache.java

示例3: doGetType

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,代码行数:13,代码来源:PsiBinaryExpressionImpl.java


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