mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PSI equivalence bug for method type parameters
This commit is contained in:
@@ -946,16 +946,35 @@ public class PsiClassImplUtil {
|
||||
return aClass1 != null && aClass2 != null && field.getManager().areElementsEquivalent(aClass1, aClass2);
|
||||
}
|
||||
|
||||
public static boolean isMethodEquivalentTo(PsiMethod method, PsiElement another) {
|
||||
public static boolean isMethodEquivalentTo(PsiMethod method1, PsiElement another) {
|
||||
if (!(another instanceof PsiMethod)) return false;
|
||||
PsiMethod method2 = (PsiMethod)another;
|
||||
String name1 = method.getName();
|
||||
String name1 = method1.getName();
|
||||
if (!another.isValid()) return false;
|
||||
String name2 = method2.getName();
|
||||
if (!name1.equals(name2)) return false;
|
||||
PsiClass aClass1 = method.getContainingClass();
|
||||
PsiClass aClass1 = method1.getContainingClass();
|
||||
PsiClass aClass2 = method2.getContainingClass();
|
||||
return aClass1 != null && aClass2 != null && method.getManager().areElementsEquivalent(aClass1, aClass2) &&
|
||||
MethodSignatureUtil.areSignaturesEqual(method.getSignature(PsiSubstitutor.EMPTY), method2.getSignature(PsiSubstitutor.EMPTY));
|
||||
PsiManager manager = method1.getManager();
|
||||
if (!(aClass1 != null && aClass2 != null && manager.areElementsEquivalent(aClass1, aClass2))) return false;
|
||||
|
||||
PsiParameter[] parameters1 = method1.getParameterList().getParameters();
|
||||
PsiParameter[] parameters2 = method2.getParameterList().getParameters();
|
||||
if (parameters1.length != parameters2.length) return false;
|
||||
for (int i = 0; i < parameters1.length; i++) {
|
||||
PsiParameter parameter1 = parameters1[i];
|
||||
PsiParameter parameter2 = parameters2[i];
|
||||
PsiType type1 = parameter1.getType();
|
||||
PsiType type2 = parameter2.getType();
|
||||
if (!(type1 instanceof PsiClassType) || !(type2 instanceof PsiClassType)) {
|
||||
if (!type1.equals(type2)) return false;
|
||||
}
|
||||
else {
|
||||
PsiClass class1 = ((PsiClassType)type1).resolve();
|
||||
PsiClass class2 = ((PsiClassType)type2).resolve();
|
||||
if (!manager.areElementsEquivalent(class1, class2)) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.psi.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
@@ -43,15 +42,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
return name == null ? 0 : name.hashCode();
|
||||
}
|
||||
public boolean equals(PsiTypeParameter element1, PsiTypeParameter element2) {
|
||||
if (element1 == element2 || element1.equals(element2)) return true;
|
||||
if (!Comparing.strEqual(element1.getName(), element2.getName())) return false;
|
||||
PsiTypeParameterListOwner owner1 = element1.getOwner();
|
||||
PsiTypeParameterListOwner owner2 = element2.getOwner();
|
||||
boolean b = owner1 instanceof PsiClass && owner2 instanceof PsiClass && element1.getManager().areElementsEquivalent(owner1, owner2);
|
||||
if (b) {
|
||||
return b;
|
||||
}
|
||||
return false;
|
||||
return element1.getManager().areElementsEquivalent(element1, element2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -303,7 +294,8 @@ public class PsiSubstitutorImpl implements PsiSubstitutor {
|
||||
if (aClass != null) {
|
||||
if (aClass instanceof PsiTypeParameter) {
|
||||
return rawTypeForTypeParameter((PsiTypeParameter)aClass);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(aClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class MethodSignatureUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean areSignaturesEqualLightweight(MethodSignature sig1, MethodSignature sig2) {
|
||||
public static boolean areSignaturesEqualLightweight(MethodSignature sig1, MethodSignature sig2) {
|
||||
String name1 = sig1.getName();
|
||||
String name2 = sig2.getName();
|
||||
if (!name1.equals(name2)) return false;
|
||||
|
||||
Reference in New Issue
Block a user