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
type.createField("public int fCount;", null, true, null);
		res1.clear();
		AllTypesCache.getTypes(workspaceScope, IJavaSearchConstants.TYPE, null, res1);		
		assertTrue("still 543 types in workspace expected, is " + res1.size(), res1.size() == 543);
		
		assertTrue("cache was flushed", nFlushes == AllTypesCache.getNumberOfCacheFlushes());
		
		type.createType("public class AInner {}", null, true, null);
		res1.clear();
		AllTypesCache.getTypes(workspaceScope, IJavaSearchConstants.TYPE, null, res1);		
		assertNotNull("AInner not found", findTypeRef(res1, "A.AInner"));
		assertTrue("still 544 types in workspace expected, is " + res1.size(), res1.size() == 544);
		
		assertTrue("cache not flushed after inner type creation", nFlushes != AllTypesCache.getNumberOfCacheFlushes());
	}	
	
	
	private TypeInfo findTypeRef(List refs, String fullname) {
		for (int i= 0; i <refs.size(); i++) {
			TypeInfo curr= (TypeInfo) refs.get(i);
			if (fullname.equals(curr.getFullyQualifiedName())) {
				return curr;
			}
		}
		return null;
	}
		
	
}