Beispiel #1
0
    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;
      }
    }
Beispiel #2
0
  /** Write out a diagnostic. */
  protected void writeDiagnostic(JCDiagnostic diag) {
    if (diagListener != null) {
      diagListener.report(diag);
      return;
    }

    PrintWriter writer = getWriterForDiagnosticType(diag.getType());

    printRawLines(writer, diagFormatter.format(diag, messages.getCurrentLocale()));

    if (promptOnError) {
      switch (diag.getType()) {
        case ERROR:
        case WARNING:
          prompt();
      }
    }

    if (dumpOnError) new RuntimeException().printStackTrace(writer);

    writer.flush();
  }