void () { final String className = "Foo"; final VirtualFile vfile = myFixture.addClass("class " + className + " { void bar() {} }").getContainingFile().getVirtualFile(); final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject()); final List<Boolean> foundClass = new ArrayList<>(Arrays.asList(false)); final List<Boolean> foundMethod = new ArrayList<>(Arrays.asList(false)); try { StubIndex.getInstance() .processElements(JavaStubIndexKeys.CLASS_SHORT_NAMES, className, getProject(), scope, PsiClass.class, aClass -> { foundClass.set(0, true); StubIndex.getInstance() .processElements(JavaStubIndexKeys.METHODS, "bar", getProject(), scope, PsiMethod.class, method -> { foundMethod.set(0, true); return true; }); return true; }); } catch (Exception e) { if (!(e instanceof RuntimeException)) throw e; } assertTrue(foundClass.get(0)); assertTrue(foundMethod.get(0));// allow access stub index processing other index final List<Boolean> foundClassProcessAll = new ArrayList<>(Arrays.asList(false)); final List<Boolean> foundClassStub = new ArrayList<>(Arrays.asList(false)); try { StubIndex.getInstance().processAllKeys(JavaStubIndexKeys.CLASS_SHORT_NAMES, getProject(), aClass -> { if (!className.equals(aClass)) return true; foundClassProcessAll.set(0, true); StubIndex.getInstance() .processElements(JavaStubIndexKeys.CLASS_SHORT_NAMES, aClass, getProject(), scope, PsiClass.class, clazz -> { foundClassStub.set(0, true); return true; }); return true; }); } catch (Exception e) { if (!(e instanceof RuntimeException)) throw e; } assertTrue(foundClassProcessAll.get(0)); assertTrue(foundClassStub.get(0)); final List<Boolean> foundId = new ArrayList<>(Arrays.asList(false)); final List<Boolean> foundStub = new ArrayList<>(Arrays.asList(false)); try { FileBasedIndex.getInstance() .processValues(IdIndex.NAME, new IdIndexEntry("Foo", true), null, (file, value) -> { foundId.set(0, true); FileBasedIndex.getInstance() .processValues(StubUpdatingIndex.INDEX_ID, assertInstanceOf(vfile, VirtualFileWithId.class).getId(), null, (file2, value2) -> { foundStub.set(0, true); return true; }, scope); return true; }, scope); } catch (Exception e) { if (!(e instanceof RuntimeException)) throw e; } assertTrue(foundId.get(0)); assertTrue(foundStub.get(0)); }