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


Java TType.isTypeVariable方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType.isTypeVariable方法的典型用法代码示例。如果您正苦于以下问题:Java TType.isTypeVariable方法的具体用法?Java TType.isTypeVariable怎么用?Java TType.isTypeVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType的用法示例。


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

示例1: pushSupertypes

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; //导入方法依赖的package包/类
private void pushSupertypes(TType type) {
  if (type.isJavaLangObject()) return;

  if (type.isTypeVariable() || type.isCaptureType()) {
    TType[] bounds = ((AbstractTypeVariable) type).getBounds();
    for (int i = 0; i < bounds.length; i++) fWorklist.push(bounds[i].getTypeDeclaration());

  } else {
    TType superclass = type.getSuperclass();
    if (superclass == null) {
      if (type.isInterface()) fWorklist.push(type.getEnvironment().getJavaLangObject());
    } else {
      fWorklist.push(superclass.getTypeDeclaration());
    }
    TType[] interfaces = type.getInterfaces();
    for (int i = 0; i < interfaces.length; i++)
      fWorklist.push(interfaces[i].getTypeDeclaration());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:TTypes.java

示例2: canAssignTo

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; //导入方法依赖的package包/类
/**
 * @param rhs
 * @param lhs
 * @return <code>true</code> iff an expression of type 'rhs' can be assigned to a variable of type
 *     'lhs'. Type arguments of generic / raw / parameterized types are <b>not</b> considered.
 */
public static boolean canAssignTo(TType rhs, TType lhs) {
  if (rhs.isHierarchyType() && lhs.isHierarchyType()) {
    HierarchyType rhsGeneric = (HierarchyType) rhs.getTypeDeclaration();
    HierarchyType lhsGeneric = (HierarchyType) lhs.getTypeDeclaration();
    return lhs.isJavaLangObject()
        || rhsGeneric.equals(lhsGeneric)
        || rhsGeneric.isSubType(lhsGeneric);

  } else if (rhs.isTypeVariable()) {
    if (rhs.canAssignTo(lhs)) return true;
    TType[] bounds = ((TypeVariable) rhs).getBounds();
    for (int i = 0; i < bounds.length; i++) {
      if (canAssignTo(bounds[i], lhs)) return true;
    }
    return lhs.isJavaLangObject();

  } else {
    return rhs.canAssignTo(lhs);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:TTypes.java

示例3: makeSupertypeElementVariables

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; //导入方法依赖的package包/类
private void makeSupertypeElementVariables(ConstraintVariable2 expressionCv, TType supertype) {
  if (supertype.isParameterizedType() || supertype.isRawType()) {
    TType[] typeArguments = null;
    if (supertype.isParameterizedType()) {
      typeArguments = ((ParameterizedType) supertype).getTypeArguments();
    }
    TypeVariable[] typeParameters =
        ((GenericType) supertype.getTypeDeclaration()).getTypeParameters();
    for (int i = 0; i < typeParameters.length; i++) {
      TypeVariable typeParameter = typeParameters[i];
      TType referenceTypeArgument;
      if (typeArguments == null) { // raw type
        referenceTypeArgument = typeParameter.getErasure();
      } else {
        referenceTypeArgument = typeArguments[i];
      }
      if (referenceTypeArgument.isTypeVariable()) {
        CollectionElementVariable2 referenceTypeArgumentCv =
            getElementVariable(expressionCv, (TypeVariable) referenceTypeArgument);
        if (referenceTypeArgumentCv != null) {
          setElementVariable(expressionCv, referenceTypeArgumentCv, typeParameter);
          continue;
        }
      }
      makeElementVariable(
          expressionCv,
          typeParameter,
          CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
    }
  }
  makeElementVariablesFromSupertypes(expressionCv, supertype);
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:InferTypeArgumentsTCModel.java

示例4: makeFixedSupertypeElementVariables

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; //导入方法依赖的package包/类
private void makeFixedSupertypeElementVariables(
    ConstraintVariable2 expressionCv, TType supertype) {
  if (supertype.isParameterizedType() || supertype.isRawType()) {
    TType[] typeArguments = null;
    if (supertype.isParameterizedType())
      typeArguments = ((ParameterizedType) supertype).getTypeArguments();

    TypeVariable[] typeParameters =
        ((GenericType) supertype.getTypeDeclaration()).getTypeParameters();
    for (int i = 0; i < typeParameters.length; i++) {
      TypeVariable typeParameter = typeParameters[i];
      TType referenceTypeArgument;
      if (typeArguments == null) { // raw type
        continue; // do not consider
      } else {
        referenceTypeArgument = typeArguments[i];
      }
      if (referenceTypeArgument.isTypeVariable()) {
        CollectionElementVariable2 referenceTypeArgumentCv =
            getElementVariable(expressionCv, (TypeVariable) referenceTypeArgument);
        setElementVariable(expressionCv, referenceTypeArgumentCv, typeParameter);
      } else {
        CollectionElementVariable2 elementCv =
            makeElementVariable(
                expressionCv,
                typeParameter,
                CollectionElementVariable2.NOT_DECLARED_TYPE_VARIABLE_INDEX);
        createEqualsConstraint(elementCv, makeImmutableTypeVariable(referenceTypeArgument));
      }
    }
  }
  makeFixedElementVariablesFromSupertypes(expressionCv, supertype);
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:InferTypeArgumentsTCModel.java

示例5: getElementTypeCv

import org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types.TType; //导入方法依赖的package包/类
private ConstraintVariable2 getElementTypeCv(
    TType elementType,
    ConstraintVariable2 expressionCv,
    Map<String, IndependentTypeVariable2> methodTypeVariables) {
  if (elementType.isTypeVariable()) {
    ConstraintVariable2 elementTypeCv = methodTypeVariables.get(elementType.getBindingKey());
    if (elementTypeCv != null) return elementTypeCv;
    if (expressionCv != null) return getElementVariable(expressionCv, (TypeVariable) elementType);
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:InferTypeArgumentsTCModel.java


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