src/share/classes/com/sun/tools/javac/util/Log.java

changeset 664
4124840b35fe
parent 604
a5454419dd46
child 700
7b413ac1a720
     1.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java	Fri Aug 27 17:59:08 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Aug 30 18:03:35 2010 -0700
     1.3 @@ -27,8 +27,10 @@
     1.4  
     1.5  import java.io.*;
     1.6  import java.util.Arrays;
     1.7 +import java.util.EnumSet;
     1.8  import java.util.HashSet;
     1.9  import java.util.Map;
    1.10 +import java.util.Queue;
    1.11  import java.util.Set;
    1.12  import javax.tools.DiagnosticListener;
    1.13  import javax.tools.JavaFileObject;
    1.14 @@ -110,6 +112,12 @@
    1.15       */
    1.16      private JavacMessages messages;
    1.17  
    1.18 +    /**
    1.19 +     * Deferred diagnostics
    1.20 +     */
    1.21 +    public boolean deferDiagnostics;
    1.22 +    public Queue<JCDiagnostic> deferredDiagnostics = new ListBuffer<JCDiagnostic>();
    1.23 +
    1.24      /** Construct a log with given I/O redirections.
    1.25       */
    1.26      @Deprecated
    1.27 @@ -204,12 +212,6 @@
    1.28       */
    1.29      public int nwarnings = 0;
    1.30  
    1.31 -    /**
    1.32 -     * Whether or not an unrecoverable error has been seen.
    1.33 -     * Unrecoverable errors prevent subsequent annotation processing.
    1.34 -     */
    1.35 -    public boolean unrecoverableError;
    1.36 -
    1.37      /** A set of all errors generated so far. This is used to avoid printing an
    1.38       *  error message more than once. For each error, a pair consisting of the
    1.39       *  source file name and source code position of the error is added to the set.
    1.40 @@ -347,12 +349,32 @@
    1.41          nwarnings++;
    1.42      }
    1.43  
    1.44 +    /** Report all deferred diagnostics, and clear the deferDiagnostics flag. */
    1.45 +    public void reportDeferredDiagnostics() {
    1.46 +        reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
    1.47 +    }
    1.48 +
    1.49 +    /** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */
    1.50 +    public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
    1.51 +        deferDiagnostics = false;
    1.52 +        JCDiagnostic d;
    1.53 +        while ((d = deferredDiagnostics.poll()) != null) {
    1.54 +            if (kinds.contains(d.getKind()))
    1.55 +                report(d);
    1.56 +        }
    1.57 +    }
    1.58 +
    1.59      /**
    1.60       * Common diagnostic handling.
    1.61       * The diagnostic is counted, and depending on the options and how many diagnostics have been
    1.62       * reported so far, the diagnostic may be handed off to writeDiagnostic.
    1.63       */
    1.64      public void report(JCDiagnostic diagnostic) {
    1.65 +        if (deferDiagnostics) {
    1.66 +            deferredDiagnostics.add(diagnostic);
    1.67 +            return;
    1.68 +        }
    1.69 +
    1.70          if (expectDiagKeys != null)
    1.71              expectDiagKeys.remove(diagnostic.getCode());
    1.72  

mercurial