/**
  * Create an error diagnostic
  *
  * @param source The source of the compilation unit, if any, in which to report the error.
  * @param pos The source position at which to report the error.
  * @param errorKey The key for the localized error message.
  */
 public JCDiagnostic error(
     DiagnosticFlag flag, DiagnosticSource source, DiagnosticPosition pos, Error errorKey) {
   JCDiagnostic diag = create(null, EnumSet.copyOf(defaultErrorFlags), source, pos, errorKey);
   if (flag != null) {
     diag.setFlag(flag);
   }
   return diag;
 }