changed.removeAll(unchanged);
// First remove any stale units.
for (Iterator<CompilationUnit> it = unitMap.values().iterator(); it.hasNext();) {
CompilationUnit unit = it.next();
SourceFileCompilationUnit sourceFileUnit = (SourceFileCompilationUnit) unit;
if (!unchanged.contains(sourceFileUnit.getSourceFile())) {
unit.setFresh();
it.remove();
}
}
// Then add any new source files.
for (Resource newSourceFile : changed) {
String typeName = SourceFileCompilationUnit.getTypeName(newSourceFile);
assert (!unitMap.containsKey(typeName));
unitMap.put(typeName, new SourceFileCompilationUnit(newSourceFile));
// invalid a graveyard unit, if a new unit has the same type.
CompilationUnit graveyardUnit = graveyardUnits.remove(typeName);
if (graveyardUnit != null) {
graveyardUnit.setFresh();
}