langtools/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java
changeset 22163 3651128c74eb
parent 20249 93f8eae31092
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    41  * If you write code that depends on this, you do so at your own risk.
    41  * If you write code that depends on this, you do so at your own risk.
    42  * This code and its internal interfaces are subject to change or
    42  * This code and its internal interfaces are subject to change or
    43  * deletion without notice.</b>
    43  * deletion without notice.</b>
    44  */
    44  */
    45 public class DeferredLintHandler {
    45 public class DeferredLintHandler {
    46     protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey =
    46     protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey = new Context.Key<>();
    47         new Context.Key<DeferredLintHandler>();
       
    48 
    47 
    49     public static DeferredLintHandler instance(Context context) {
    48     public static DeferredLintHandler instance(Context context) {
    50         DeferredLintHandler instance = context.get(deferredLintHandlerKey);
    49         DeferredLintHandler instance = context.get(deferredLintHandlerKey);
    51         if (instance == null)
    50         if (instance == null)
    52             instance = new DeferredLintHandler(context);
    51             instance = new DeferredLintHandler(context);
    65     public interface LintLogger {
    64     public interface LintLogger {
    66         void report();
    65         void report();
    67     }
    66     }
    68 
    67 
    69     private DiagnosticPosition currentPos;
    68     private DiagnosticPosition currentPos;
    70     private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<DiagnosticPosition, ListBuffer<LintLogger>>();
    69     private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<>();
    71 
    70 
    72     /**Associate the given logger with the current position as set by {@link #setPos(DiagnosticPosition) }.
    71     /**Associate the given logger with the current position as set by {@link #setPos(DiagnosticPosition) }.
    73      * Will be invoked when {@link #flush(DiagnosticPosition) } will be invoked with the same position.
    72      * Will be invoked when {@link #flush(DiagnosticPosition) } will be invoked with the same position.
    74      * <br>
    73      * <br>
    75      * Will invoke the logger synchronously if {@link #immediate() } was called
    74      * Will invoke the logger synchronously if {@link #immediate() } was called