code: public void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object ... args) {
          JCDiagnostic d = diags.error(source, pos, key, args);
          d.setFlag(flag);
          report(d);
      }
docs: Report an error, unless another error was already reported at same
  source position.
  @param flag   A flag to set on the diagnostic
  @param pos    The source position at which to report the error.
  @param key    The key for the localized error message.
  @param args   Fields of the error message.