void () { AtomicInteger targetCalled = new AtomicInteger(); GlobalSearchScope alwaysTrue = new DelegatingGlobalSearchScope(new EverythingGlobalScope()) { @Override public boolean contains(@NotNull VirtualFile file) { return true; } }; GlobalSearchScope target = new DelegatingGlobalSearchScope(new EverythingGlobalScope()) { @Override public boolean contains(@NotNull VirtualFile file) { targetCalled.incrementAndGet(); return true; } }; GlobalSearchScope trueIntersection = target.intersectWith(alwaysTrue); VirtualFile file1 = getTempDir().createVirtualFile("file1"); VirtualFile file2 = getTempDir().createVirtualFile("file2"); assertTrue(trueIntersection.contains(file2)); assertEquals(1, targetCalled.get()); assertFalse(GlobalSearchScope.fileScope(myProject, file1).intersectWith(trueIntersection).contains(file2)); assertEquals(1, targetCalled.get()); }