Ignore irrelevant java classes in search results

It looks like JavaClassInheritorsSearcher started to give classes based on useScope
This commit is contained in:
Nikolay Krasko
2016-09-08 17:20:19 +03:00
parent 6cdb578f76
commit bf12908dfc
2 changed files with 31 additions and 2 deletions
@@ -2,3 +2,8 @@ class A: Object() {}
// CLASS: java.lang.Object
// SEARCH: class:A
// IGNORE_CLASSES: java.
// IGNORE_CLASSES: javax.
// IGNORE_CLASSES: sun.
// IGNORE_CLASSES: org.
@@ -25,6 +25,8 @@ import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import com.intellij.util.Query;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor;
import org.jetbrains.kotlin.idea.test.TestUtilsKt;
@@ -58,13 +60,35 @@ public abstract class AbstractSearcherTest extends LightCodeInsightFixtureTestCa
}
protected void checkResult(Query<?> actual) throws IOException {
List<String> expected = InTextDirectivesUtils.findListWithPrefixes(FileUtil.loadFile(new File(getPathToFile()), true), "// SEARCH: ");
String text = FileUtil.loadFile(new File(getPathToFile()), true);
List<String> classFqnFilters = InTextDirectivesUtils.findListWithPrefixes(text, "// IGNORE_CLASSES: ");
List<String> actualModified = new ArrayList<String>();
for (Object member : actual) {
if (member instanceof PsiClass) {
final String qualifiedName = ((PsiClass) member).getQualifiedName();
assert qualifiedName != null;
boolean filterOut = CollectionsKt.any(classFqnFilters, new Function1<String, Boolean>() {
@Override
public Boolean invoke(String s) {
return qualifiedName.startsWith(s);
}
});
if (filterOut) {
continue;
}
}
actualModified.add(stringRepresentation(member));
}
Collections.sort(expected);
Collections.sort(actualModified);
List<String> expected = InTextDirectivesUtils.findListWithPrefixes(text, "// SEARCH: ");
Collections.sort(expected);
assertOrderedEquals(actualModified, expected);
}