예제 #1
0
파일: Log.java 프로젝트: karianna/jdk8_tl
    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;
      }
    }
예제 #2
0
파일: Log.java 프로젝트: karianna/jdk8_tl
  /** 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();
  }