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


Java PsiUtil.typeParametersIterator方法代码示例

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


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

示例1: getCallSubstitutor

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private PsiSubstitutor getCallSubstitutor(PsiMethodCallExpression methodCall) {
  JavaResolveResult resolveResult = methodCall.getMethodExpression().advancedResolve(false);
  LOG.assertTrue(myManager.areElementsEquivalent(resolveResult.getElement(), myMethod));
  if (resolveResult.getSubstitutor() != PsiSubstitutor.EMPTY) {
    Iterator<PsiTypeParameter> oldTypeParameters = PsiUtil.typeParametersIterator(myMethod);
    Iterator<PsiTypeParameter> newTypeParameters = PsiUtil.typeParametersIterator(myMethodCopy);
    PsiSubstitutor substitutor = resolveResult.getSubstitutor();
    while (newTypeParameters.hasNext()) {
      final PsiTypeParameter newTypeParameter = newTypeParameters.next();
      final PsiTypeParameter oldTypeParameter = oldTypeParameters.next();
      substitutor = substitutor.put(newTypeParameter, resolveResult.getSubstitutor().substitute(oldTypeParameter));
    }
    return substitutor;
  }

  return PsiSubstitutor.EMPTY;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:InlineMethodProcessor.java

示例2: mirrorSubstitutor

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor mirrorSubstitutor(@NotNull PsiClass from, @NotNull final PsiClass to, @NotNull PsiSubstitutor substitutor) {
  Iterator<PsiTypeParameter> baseParams = PsiUtil.typeParametersIterator(to);
  Iterator<PsiTypeParameter> candidateParams = PsiUtil.typeParametersIterator(from);

  PsiSubstitutor answer = PsiSubstitutor.EMPTY;
  while (baseParams.hasNext()) {
    // if equivalent classes "from" and "to" have different number of type parameters, then treat "to" as a raw type
    if (!candidateParams.hasNext()) return JavaClassSupersImpl.createRawSubstitutor(to); 

    answer = answer.put(baseParams.next(), substitutor.substitute(candidateParams.next()));
  }
  return answer;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ScopedClassHierarchy.java

示例3: isAssignableForNativeTypes

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
private static Boolean isAssignableForNativeTypes(@NotNull PsiType lType,
                                                  @NotNull PsiClassType rType,
                                                  @NotNull PsiElement context) {
  if (!(lType instanceof PsiClassType)) return null;
  final PsiClassType.ClassResolveResult leftResult = ((PsiClassType)lType).resolveGenerics();
  final PsiClassType.ClassResolveResult rightResult = rType.resolveGenerics();
  final PsiClass leftClass = leftResult.getElement();
  PsiClass rightClass = rightResult.getElement();
  if (rightClass == null || leftClass == null) return null;

  if (!InheritanceUtil.isInheritorOrSelf(rightClass, leftClass, true)) return Boolean.FALSE;

  PsiSubstitutor rightSubstitutor = rightResult.getSubstitutor();

  if (!leftClass.hasTypeParameters()) return Boolean.TRUE;
  PsiSubstitutor leftSubstitutor = leftResult.getSubstitutor();

  if (!leftClass.getManager().areElementsEquivalent(leftClass, rightClass)) {
    rightSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(leftClass, rightClass, rightSubstitutor);
    rightClass = leftClass;
  }
  else if (!rightClass.hasTypeParameters()) return Boolean.TRUE;

  Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
  Iterator<PsiTypeParameter> ri = PsiUtil.typeParametersIterator(rightClass);
  while (li.hasNext()) {
    if (!ri.hasNext()) return Boolean.FALSE;
    PsiTypeParameter lp = li.next();
    PsiTypeParameter rp = ri.next();
    final PsiType typeLeft = leftSubstitutor.substitute(lp);
    if (typeLeft == null) continue;
    final PsiType typeRight = rightSubstitutor.substituteWithBoundsPromotion(rp);
    if (typeRight == null) {
      return Boolean.TRUE;
    }
    if (!isAssignableWithoutConversions(typeLeft, typeRight, context)) return Boolean.FALSE;
  }
  return Boolean.TRUE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:TypesUtil.java

示例4: typeParametersAgree

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean typeParametersAgree(@NotNull PsiClass leftClass,
                                           @NotNull PsiClass rightClass,
                                           @NotNull PsiSubstitutor leftSubstitutor,
                                           @NotNull PsiSubstitutor rightSubstitutor,
                                           @NotNull PsiElement context) {

  if (!leftClass.hasTypeParameters()) return true;

  if (!leftClass.getManager().areElementsEquivalent(leftClass, rightClass)) {
    rightSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(leftClass, rightClass, rightSubstitutor);
    rightClass = leftClass;
  }
  else if (!rightClass.hasTypeParameters()) return true;

  Iterator<PsiTypeParameter> li = PsiUtil.typeParametersIterator(leftClass);
  Iterator<PsiTypeParameter> ri = PsiUtil.typeParametersIterator(rightClass);

  while (li.hasNext()) {
    if (!ri.hasNext()) return false;
    PsiTypeParameter lp = li.next();
    PsiTypeParameter rp = ri.next();
    final PsiType typeLeft = leftSubstitutor.substitute(lp);
    if (typeLeft == null) continue;
    final PsiType typeRight = rightSubstitutor.substituteWithBoundsPromotion(rp);
    if (typeRight == null) {
      // compatibility feature: allow to assign raw types to generic ones
      return true;
    }

    if (typeLeft instanceof PsiClassType && typeRight instanceof PsiClassType) {
      if (!TypesUtil.isAssignableByMethodCallConversion(typeLeft, typeRight, context)) {
        return false;
      }
    }
    else if (!TypeConversionUtil.typesAgree(typeLeft, typeRight, true)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:GrGenericTypeConverter.java


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