public void report(JCDiagnostic diagnostic) { if (expectDiagKeys != null) expectDiagKeys.remove(diagnostic.getCode()); switch (diagnostic.getType()) { case FRAGMENT: throw new IllegalArgumentException(); case NOTE: // Print out notes only when we are permitted to report warnings // Notes are only generated at the end of a compilation, so should be small // in number. if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) { writeDiagnostic(diagnostic); } break; case WARNING: if (emitWarnings || diagnostic.isMandatory()) { if (nwarnings < MaxWarnings) { writeDiagnostic(diagnostic); nwarnings++; } } break; case ERROR: if (nerrors < MaxErrors && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) { writeDiagnostic(diagnostic); nerrors++; } break; } }