mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-210108 Create new test window misses interface methods
This commit is contained in:
@@ -127,7 +127,10 @@ public class TestIntegrationUtils {
|
||||
@Override
|
||||
public boolean includeMember(PsiMember member) {
|
||||
if (!(member instanceof PsiMethod)) return false;
|
||||
if (member.hasModifierProperty(PsiModifier.PRIVATE) || member.hasModifierProperty(PsiModifier.ABSTRACT)) return false;
|
||||
if (member.hasModifierProperty(PsiModifier.PRIVATE) ||
|
||||
(member.hasModifierProperty(PsiModifier.ABSTRACT) && member.getContainingClass() != clazz)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.PsiJavaFile;
|
||||
import com.intellij.refactoring.classMembers.MemberInfoBase;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TestIntegrationUtilsTest extends LightPlatformTestCase {
|
||||
|
||||
public void testExtractClassMethods() {
|
||||
doTest("class Foo {void bar() {} private void baz() {}}", false, "bar():void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", false, "bar():void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", true, "qux():void", "bar():void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {void qux();}", true, "bar():void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {default void qux() {}}", true, "qux():void", "bar():void");
|
||||
doTest("interface Foo extends I {void bar();} interface I {void qux();}", true, "bar():void");
|
||||
}
|
||||
|
||||
private static void doTest(@Language("JAVA") String text, boolean inherited, String... expected) {
|
||||
PsiJavaFile file = (PsiJavaFile)PsiFileFactory.getInstance(getProject()).createFileFromText("Test.java", JavaFileType.INSTANCE, text);
|
||||
PsiClass firstClass = file.getClasses()[0];
|
||||
List<MemberInfo> infos = TestIntegrationUtils.extractClassMethods(firstClass, inherited);
|
||||
List<String> actual = ContainerUtil.map(infos, MemberInfoBase::getDisplayName);
|
||||
assertEquals(Arrays.asList(expected), actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user