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


Java PsiUtil.isRawSubstitutor方法代码示例

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


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

示例1: isUncheckedConversion

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static boolean isUncheckedConversion(final PsiType t, final PsiType s) {
  if (t instanceof PsiClassType && !((PsiClassType)t).isRaw() && s instanceof PsiClassType) {
    final PsiClassType.ClassResolveResult tResult = ((PsiClassType)t).resolveGenerics();
    final PsiClassType.ClassResolveResult sResult = ((PsiClassType)s).resolveGenerics();
    final PsiClass tClass = tResult.getElement();
    final PsiClass sClass = sResult.getElement();
    if (tClass != null && sClass != null) {
      final PsiSubstitutor sSubstitutor = TypeConversionUtil.getClassSubstitutor(tClass, sClass, sResult.getSubstitutor());
      if (sSubstitutor != null) {
        if (PsiUtil.isRawSubstitutor(tClass, sSubstitutor)) {
          return true;
        }
      }
      else if (tClass instanceof InferenceVariable && ((PsiClassType)s).isRaw() && tClass.isInheritor(sClass, true)) {
        return true;
      }
    }
  } 
  else if (t instanceof PsiArrayType && t.getArrayDimensions() == s.getArrayDimensions()) {
    return isUncheckedConversion(t.getDeepComponentType(), s.getDeepComponentType());
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TypeCompatibilityConstraint.java

示例2: substituteTypeParameters

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@NotNull
private static PsiSubstitutor substituteTypeParameters(@NotNull JVMElementFactory factory,
                                                       @Nullable PsiElement target,
                                                       @Nullable PsiTypeParameterList sourceTypeParameterList,
                                                       @Nullable PsiTypeParameterList targetTypeParameterList,
                                                       @NotNull PsiSubstitutor substitutor, 
                                                       @NotNull PsiMethod sourceMethod) {
  if (sourceTypeParameterList == null || targetTypeParameterList == null || PsiUtil.isRawSubstitutor(sourceMethod, substitutor)) {
    return substitutor;
  }

  final Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
  for (PsiTypeParameter typeParam : sourceTypeParameterList.getTypeParameters()) {
    final PsiTypeParameter substitutedTypeParam = substituteTypeParameter(factory, typeParam, substitutor, sourceMethod);

    final PsiTypeParameter resolvedTypeParam = resolveTypeParametersCollision(factory, sourceTypeParameterList, target,
                                                                              substitutedTypeParam, substitutor);
    targetTypeParameterList.add(resolvedTypeParam);
    if (substitutedTypeParam != resolvedTypeParam) {
      substitutionMap.put(typeParam, factory.createType(resolvedTypeParam));
    }
  }
  return substitutionMap.isEmpty() ? substitutor : factory.createSubstitutor(substitutionMap);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GenerateMembersUtil.java

示例3: getSuperSubstitutorWithCaching

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
private static PsiSubstitutor getSuperSubstitutorWithCaching(@NotNull PsiClass superClass,
                                                             @NotNull PsiClass derivedClass,
                                                             @NotNull GlobalSearchScope resolveScope,
                                                             @NotNull PsiSubstitutor derivedSubstitutor) {
  PsiSubstitutor substitutor = ScopedClassHierarchy.getSuperClassSubstitutor(derivedClass, resolveScope, superClass);
  if (substitutor == null) return null;
  if (PsiUtil.isRawSubstitutor(derivedClass, derivedSubstitutor)) return createRawSubstitutor(superClass);

  return composeSubstitutors(derivedSubstitutor, substitutor, superClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaClassSupersImpl.java

示例4: equals

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public boolean equals(Object obj) {
  if (this == obj) return true;
  if (!(obj instanceof PsiClassType)) {
    return obj instanceof PsiCapturedWildcardType && 
           ((PsiCapturedWildcardType)obj).getLowerBound().equalsToText(CommonClassNames.JAVA_LANG_OBJECT) &&
           equalsToText(CommonClassNames.JAVA_LANG_OBJECT);
  }
  PsiClassType otherClassType = (PsiClassType)obj;

  String className = getClassName();
  String otherClassName = otherClassType.getClassName();
  if (!Comparing.equal(className, otherClassName)) return false;

  if (getParameterCount() != otherClassType.getParameterCount()) return false;

  final ClassResolveResult result = resolveGenerics();
  final ClassResolveResult otherResult = otherClassType.resolveGenerics();
  if (result == otherResult) return true;

  final PsiClass aClass = result.getElement();
  final PsiClass otherClass = otherResult.getElement();
  if (aClass == null || otherClass == null) {
    return aClass == otherClass;
  }
  return aClass.getManager().areElementsEquivalent(aClass, otherClass) &&
         (PsiUtil.isRawSubstitutor(aClass, result.getSubstitutor()) ||
          PsiUtil.equalOnEquivalentClasses(this, aClass, otherClassType, otherClass));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiClassType.java

示例5: substituteType

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static PsiType substituteType(final PsiSubstitutor substitutor, final PsiType type, @NotNull PsiTypeParameterListOwner owner) {
  if (PsiUtil.isRawSubstitutor(owner, substitutor)) {
    return TypeConversionUtil.erasure(type);
  }
  final PsiType psiType = substitutor.substitute(type);
  if (psiType != null) {
    final PsiType deepComponentType = psiType.getDeepComponentType();
    if (!(deepComponentType instanceof PsiCapturedWildcardType || deepComponentType instanceof PsiWildcardType)){
      return psiType;
    }
  }
  return TypeConversionUtil.erasure(type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GenerateMembersUtil.java

示例6: captureReturnType

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static PsiType captureReturnType(PsiMethodCallExpression call,
                                        PsiMethod method,
                                        PsiType ret,
                                        JavaResolveResult result, 
                                        LanguageLevel languageLevel) {
  PsiSubstitutor substitutor = result.getSubstitutor();
  PsiType substitutedReturnType = substitutor.substitute(ret);
  if (substitutedReturnType == null) {
    return TypeConversionUtil.erasure(ret);
  }

  if (InferenceSession.wasUncheckedConversionPerformed(call)) {
    // 18.5.2
    // if unchecked conversion was necessary, then this substitution provides the parameter types of the invocation type, 
    // while the return type and thrown types are given by the erasure of m's type (without applying θ').
    return TypeConversionUtil.erasure(substitutedReturnType);
  }

  //15.12.2.6. Method Invocation Type
  // If unchecked conversion was necessary for the method to be applicable, 
  // the parameter types of the invocation type are the parameter types of the method's type,
  // and the return type and thrown types are given by the erasures of the return type and thrown types of the method's type.
  if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && 
      (method.hasTypeParameters() || JavaVersionService.getInstance().isAtLeast(call, JavaSdkVersion.JDK_1_8)) &&
      result instanceof MethodCandidateInfo && ((MethodCandidateInfo)result).isApplicable()) {
    final PsiType[] args = call.getArgumentList().getExpressionTypes();
    final boolean allowUncheckedConversion = false;
    final int applicabilityLevel = PsiUtil.getApplicabilityLevel(method, substitutor, args, languageLevel, allowUncheckedConversion, true);
    if (applicabilityLevel == MethodCandidateInfo.ApplicabilityLevel.NOT_APPLICABLE) {
      return TypeConversionUtil.erasure(substitutedReturnType);
    }
  }

  if (PsiUtil.isRawSubstitutor(method, substitutor)) {
    final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret);
    if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) {
      return returnTypeErasure;
    }
  }
  return PsiImplUtil.normalizeWildcardTypeByPosition(substitutedReturnType, call);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:PsiMethodCallExpressionImpl.java

示例7: composeReturnType

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static PsiClassType composeReturnType(PsiClass containingClass, PsiSubstitutor substitutor) {
  final boolean isRawSubst = PsiUtil.isRawSubstitutor(containingClass, substitutor);
  return JavaPsiFacade.getElementFactory(containingClass.getProject()).createType(containingClass, isRawSubst ? PsiSubstitutor.EMPTY : substitutor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MethodReferenceResolver.java

示例8: generateDelegateMethod

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static PsiMethod generateDelegateMethod(PsiMethod method,
                                                PsiClass superClass,
                                                PsiSubstitutor substitutor,
                                                boolean keepParameterAnnotations) {
  final LightMethodBuilder builder = new LightMethodBuilder(superClass.getManager(), GroovyLanguage.INSTANCE, method.getName());
  builder.setContainingClass(superClass);
  builder.setMethodReturnType(substitutor.substitute(method.getReturnType()));
  builder.setNavigationElement(method);
  builder.addModifier(PsiModifier.PUBLIC);

  final PsiTypeParameter[] typeParameters = method.getTypeParameters();

  final PsiClass containingClass = method.getContainingClass();
  boolean isRaw = containingClass != null && PsiUtil.isRawSubstitutor(containingClass, substitutor);
  if (isRaw) {
    substitutor = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createRawSubstitutor(substitutor, typeParameters);
  }

  if (!isRaw) {
    for (PsiTypeParameter typeParameter : typeParameters) {
      builder.addTypeParameter(typeParameter);
    }
  }

  final PsiParameter[] originalParameters = method.getParameterList().getParameters();

  for (int i = 0; i < originalParameters.length; i++) {
    PsiParameter originalParameter = originalParameters[i];
    PsiType type;
    if (isRaw) {
      type = TypeConversionUtil.erasure(substitutor.substitute(originalParameter.getType()));
    }
    else {
      type = substitutor.substitute(originalParameter.getType());
    }
    if (type == null) {
      type = TypesUtil.getJavaLangObject(superClass);
    }
    final LightParameter lightParameter = new LightParameter(StringUtil.notNullize(originalParameter.getName(), "p" + i), type, builder, JavaLanguage.INSTANCE);
    if (keepParameterAnnotations) {
      final PsiCompositeModifierList delegatingModifierList = new PsiCompositeModifierList(method.getManager(), Collections.singletonList(originalParameter.getModifierList()));
      lightParameter.setModifierList(delegatingModifierList);
    }
    builder.addParameter(lightParameter);
  }
  builder.setBaseIcon(JetgroovyIcons.Groovy.Method);

  return new DelegatedMethod(builder, method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:DelegatedMethodsContributor.java

示例9: isRaw

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
/**
 * Checks whether the specified resolve result represents a raw type. <br>
 * Raw type is a class type for a class <i>with type parameters</i> which does not assign
 * any value to them. If a class does not have any type parameters, it cannot generate any raw type.
 */
public static boolean isRaw(ClassResolveResult resolveResult) {
  PsiClass psiClass = resolveResult.getElement();
  return psiClass != null && PsiUtil.isRawSubstitutor(psiClass, resolveResult.getSubstitutor());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiClassType.java


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