mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[test frameworks] KTIJ-36152 Fix abstract inherited method check
GitOrigin-RevId: dc74892ac1a507b4d66226010dbb02736f0844bf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
18b0c43dcd
commit
39223c2ce3
@@ -100,6 +100,7 @@ jvm_library(
|
||||
"//java/codeserver/core",
|
||||
"//xml/xml-psi-api:psi",
|
||||
"//java/java-syntax:syntax",
|
||||
"//java/java-psi-api:psi",
|
||||
],
|
||||
exports = [
|
||||
"//platform/lang-impl",
|
||||
|
||||
@@ -123,6 +123,7 @@
|
||||
<orderEntry type="module" module-name="intellij.java.codeserver.core" />
|
||||
<orderEntry type="module" module-name="intellij.xml.psi" />
|
||||
<orderEntry type="module" module-name="intellij.java.syntax" />
|
||||
<orderEntry type="module" module-name="intellij.java.psi" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiSuperMethodUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -128,30 +129,31 @@ public final class TestIntegrationUtils {
|
||||
classes.addAll(InheritanceUtil.getSuperClasses(clazz).reversed());
|
||||
}
|
||||
|
||||
List<MemberInfo> temp = new ArrayList<>();
|
||||
List<MemberInfo> result = new ArrayList<>();
|
||||
Map<String, List<PsiMethod>> methodsByName = new HashMap<>();
|
||||
for (PsiClass aClass : classes) {
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(aClass.getQualifiedName())) continue;
|
||||
MemberInfo.extractClassMembers(aClass, temp, new MemberInfo.Filter<>() {
|
||||
MemberInfo.extractClassMembers(aClass, result, new MemberInfo.Filter<>() {
|
||||
@Override
|
||||
public boolean includeMember(PsiMember member) {
|
||||
if (!(member instanceof PsiMethod)) return false;
|
||||
if (member.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
return false;
|
||||
if (!(member instanceof PsiMethod method)) return false;
|
||||
if (member.hasModifierProperty(PsiModifier.PRIVATE)) return false;
|
||||
|
||||
String name = method.getName();
|
||||
List<PsiMethod> methods = methodsByName.computeIfAbsent(name, __ -> new ArrayList<>());
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
// rely on the order of collected classes: from descendant to ancestors
|
||||
if (PsiSuperMethodUtil.isSuperMethod(psiMethod, method)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
methods.add(method);
|
||||
|
||||
return true;
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
// to avoid duplicates due to abstract default methods
|
||||
Set<String> uniqueDisplayNames = new HashSet<>();
|
||||
List<MemberInfo> result = new ArrayList<>();
|
||||
for (MemberInfo info : temp) {
|
||||
if (uniqueDisplayNames.add(info.getDisplayName())) {
|
||||
result.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public class TestIntegrationUtilsTest extends LightPlatformTestCase {
|
||||
doTest("class Foo implements I {void bar() {}} interface I {void qux();}", true, "bar(): void", "qux(): void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {default void qux() {}}", true, "bar(): void", "qux(): void");
|
||||
doTest("interface Foo extends I {void bar();} interface I {void qux();}", true, "bar(): void", "qux(): void");
|
||||
doTest("interface Foo extends I {void bar();} interface I extends B {} interface B {void qux();}", true, "bar(): void", "qux(): void");
|
||||
doTest("class Foo extends I {@Override void bar();} interface I {void bar();default void foo(){}}", true, "bar(): void", "foo(): void");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user