// different problems. If they were not then we would be firing the
// event unnecessarily but that is probably not that much of a problem.
// If it was then we would have to remember the previous diagnostics
// and compare the two lists to see whether they were the same.
if (hadDiagnostics || diagnostics != null) {
DiagnosticEvent event = new DiagnosticEvent(this, true);
// Take a copy of a reference to the array of listeners just in case
// it is modified by one of the listeners.
List listeners = diagnosticListeners;
for (int i = 0; i < listeners.size(); i++) {