oldBugCollection = new SortedBugCollection(); } for (Iterator i = newBugCollection.iterator(); i.hasNext(); ) { BugInstance newWarning = (BugInstance) i.next(); oldBugCollection.add(newWarning);
updateBugCollectionDestructively(bugReporter, oldBugCollection, newBugCollection);
	private void updateBugCollection(Project findBugsProject, Reporter bugReporter) throws CoreException, IOException, DocumentException {		// FIXME we do this destructively for now: should do incrementally		SortedBugCollection oldBugCollection = FindbugsPlugin.readBugCollection(project, monitor);		SortedBugCollection newBugCollection = bugReporter.getBugCollection();		// Algorithm:		// Remove all old warnings for classes which were just analyzed.		// Then add all new warnings.		if (oldBugCollection != null) {			Set analyzedClassNameSet = bugReporter.getAnalyzedClassNames();			for (Iterator i = oldBugCollection.iterator(); i.hasNext(); ) {				BugInstance oldWarning = (BugInstance) i.next();				ClassAnnotation warningClass = oldWarning.getPrimaryClass();				if (warningClass != null && analyzedClassNameSet.contains(warningClass.getClassName())) {					i.remove();				}			}		} else {			oldBugCollection = new SortedBugCollection();		}		for (Iterator i = newBugCollection.iterator(); i.hasNext(); ) {			BugInstance newWarning = (BugInstance) i.next();			oldBugCollection.add(newWarning);		}		// Store updated BugCollection		try {			FindbugsPlugin.storeBugCollection(project, oldBugCollection, findBugsProject, monitor);		} catch (IOException e) {			FindbugsPlugin.getDefault().logException(e, "Could not save FindBugs warnings for project");		} catch (CoreException e) {			FindbugsPlugin.getDefault().logException(e, "Could not save FindBugs warnings for project");		}	}