Bug 40793 Primary working copies: Type search does not find type in modified CU
M2 See test cases AllTypesCacheTest.testWorkingCopies() & testWorkingCopies2(): Editor is opened and the type name of the opened type is modfied. testWorkingCopies(): editor is saved: new type is found in index but also old type is still found testWorkingCopies2(): editor is not saved: new type is not found in index
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/AllTypesCacheTest.java
assertNull("mylib.Foo still found", findTypeRef(res1, "mylib.Foo"));
		
		assertTrue("539 types in workspace expected, is " + res1.size(), res1.size() == 539);
		
		assertTrue("cache not flushed", nFlushes != AllTypesCache.getNumberOfCacheFlushes());
	}
	
	public void testNewElementCreation() throws Exception {
		IJavaSearchScope workspaceScope= SearchEngine.createWorkspaceScope();
	
		ArrayList res1= new ArrayList();
		
		AllTypesCache.getTypes(workspaceScope, IJavaSearchConstants.TYPE, null, res1);
		assertTrue("542 types expected, is " + res1.size(), res1.size() == 542);
		
		int nFlushes= AllTypesCache.getNumberOfCacheFlushes();
		
		IPackageFragment pack= fSourceFolder.getPackageFragment("");
		ICompilationUnit newCU= pack.getCompilationUnit("A.java");
		IType type= newCU.createType("public class A {\n}\n", null, true, null);
		
		res1.clear();
		AllTypesCache.getTypes(workspaceScope, IJavaSearchConstants.TYPE, null, res1);
		assertNotNull("A not found", findTypeRef(res1, "A"));
		
		assertTrue("543 types in workspace expected, is " + res1.size(), res1.size() == 543);
		
		assertTrue("cache not flushed", nFlushes != AllTypesCache.getNumberOfCacheFlushes());
		nFlushes= AllTypesCache.getNumberOfCacheFlushes();