void () { initProject("findInClassHierarchy", "src"); FindModel findModel = new FindModel(); findModel.setStringToFind("instanceof"); findModel.setWholeWordsOnly(true); findModel.setFromCursor(false); findModel.setGlobal(true); findModel.setMultipleFiles(true); final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject()); final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); PsiClass baseClass = Objects.requireNonNull(facade.findClass("A", scope)); PsiClass implClass = Objects.requireNonNull(facade.findClass("AImpl", scope)); findModel.setCustomScope(new LocalSearchScope(new PsiElement[]{baseClass, implClass})); List<UsageInfo> usages = findInProject(findModel); assertEquals(2, usages.size()); PsiClass aClass = Objects.requireNonNull(facade.findClass("B", scope)); findModel.setCustomScope(new LocalSearchScope(aClass)); assertSize(1, findInProject(findModel)); }