本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}