langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java
author jjg
Tue, 15 Jul 2008 09:50:36 -0700
changeset 867 1dff24b5f407
child 1591 e5a618442f5f
permissions -rw-r--r--
6724071: refactor Log into a front end and back end Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
867
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     1
/*
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     4
 *
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    10
 *
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    15
 * accompanied this code).
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    16
 *
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    20
 *
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    23
 * have any questions.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    24
 */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    25
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    26
package com.sun.tools.javac.util;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    27
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    28
import java.util.HashMap;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    29
import java.util.Map;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    30
import javax.tools.JavaFileObject;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    31
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    32
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    33
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    34
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    35
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    36
/**
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    37
 *  A base class for error logs. Reports errors and warnings, and
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    38
 *  keeps track of error numbers and positions.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    39
 *
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    40
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    41
 *  you write code that depends on this, you do so at your own risk.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    42
 *  This code and its internal interfaces are subject to change or
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    43
 *  deletion without notice.</b>
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    44
 */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    45
public abstract class AbstractLog {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    46
    AbstractLog(JCDiagnostic.Factory diags) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    47
        this.diags = diags;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    48
        sourceMap = new HashMap<JavaFileObject, DiagnosticSource>();
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    49
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    50
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    51
    /** Re-assign source, returning previous setting.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    52
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    53
    public JavaFileObject useSource(JavaFileObject file) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    54
        JavaFileObject prev = (source == null ? null : source.getFile());
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    55
        source = getSource(file);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    56
        return prev;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    57
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    58
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    59
    protected DiagnosticSource getSource(JavaFileObject file) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    60
        if (file == null)
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    61
            return null;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    62
        DiagnosticSource s = sourceMap.get(file);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    63
        if (s == null) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    64
            s = new DiagnosticSource(file, this);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    65
            sourceMap.put(file, s);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    66
        }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    67
        return s;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    68
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    69
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    70
    /** Report an error, unless another error was already reported at same
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    71
     *  source position.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    72
     *  @param key    The key for the localized error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    73
     *  @param args   Fields of the error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    74
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    75
    public void error(String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    76
        report(diags.error(source, null, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    77
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    78
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    79
    /** Report an error, unless another error was already reported at same
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    80
     *  source position.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    81
     *  @param pos    The source position at which to report the error.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    82
     *  @param key    The key for the localized error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    83
     *  @param args   Fields of the error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    84
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    85
    public void error(DiagnosticPosition pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    86
        report(diags.error(source, pos, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    87
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    88
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    89
    /** Report an error, unless another error was already reported at same
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    90
     *  source position.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    91
     *  @param pos    The source position at which to report the error.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    92
     *  @param key    The key for the localized error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    93
     *  @param args   Fields of the error message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    94
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    95
    public void error(int pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    96
        report(diags.error(source, wrap(pos), key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    97
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    98
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
    99
    /** Report a warning, unless suppressed by the  -nowarn option or the
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   100
     *  maximum number of warnings has been reached.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   101
     *  @param pos    The source position at which to report the warning.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   102
     *  @param key    The key for the localized warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   103
     *  @param args   Fields of the warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   104
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   105
    public void warning(String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   106
        report(diags.warning(source, null, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   107
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   108
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   109
    /** Report a warning, unless suppressed by the  -nowarn option or the
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   110
     *  maximum number of warnings has been reached.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   111
     *  @param pos    The source position at which to report the warning.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   112
     *  @param key    The key for the localized warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   113
     *  @param args   Fields of the warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   114
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   115
    public void warning(DiagnosticPosition pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   116
        report(diags.warning(source, pos, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   117
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   118
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   119
    /** Report a warning, unless suppressed by the  -nowarn option or the
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   120
     *  maximum number of warnings has been reached.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   121
     *  @param pos    The source position at which to report the warning.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   122
     *  @param key    The key for the localized warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   123
     *  @param args   Fields of the warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   124
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   125
    public void warning(int pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   126
        report(diags.warning(source, wrap(pos), key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   127
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   128
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   129
    /** Report a warning.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   130
     *  @param pos    The source position at which to report the warning.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   131
     *  @param key    The key for the localized warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   132
     *  @param args   Fields of the warning message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   133
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   134
    public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   135
        report(diags.mandatoryWarning(source, pos, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   136
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   137
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   138
    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   139
     *  @param key    The key for the localized notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   140
     *  @param args   Fields of the notint an error or warning message:
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   141
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   142
    public void note(String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   143
        report(diags.note(source, null, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   144
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   145
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   146
    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   147
     *  @param key    The key for the localized notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   148
     *  @param args   Fields of the notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   149
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   150
    public void note(DiagnosticPosition pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   151
        report(diags.note(source, pos, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   152
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   153
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   154
    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   155
     *  @param key    The key for the localized notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   156
     *  @param args   Fields of the notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   157
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   158
    public void note(int pos, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   159
        report(diags.note(source, wrap(pos), key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   160
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   161
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   162
    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   163
     *  @param key    The key for the localized notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   164
     *  @param args   Fields of the notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   165
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   166
    public void note(JavaFileObject file, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   167
        report(diags.note(getSource(file), null, key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   168
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   169
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   170
    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   171
     *  @param key    The key for the localized notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   172
     *  @param args   Fields of the notification message.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   173
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   174
    public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   175
        report(diags.mandatoryNote(getSource(file), key, args));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   176
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   177
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   178
    protected abstract void report(JCDiagnostic diagnostic);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   179
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   180
    protected abstract void directError(String key, Object... args);
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   181
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   182
    private DiagnosticPosition wrap(int pos) {
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   183
        return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos));
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   184
    }
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   185
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   186
    /** Factory for diagnostics
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   187
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   188
    protected JCDiagnostic.Factory diags;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   189
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   190
    /** The file that's currently being translated.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   191
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   192
    protected DiagnosticSource source;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   193
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   194
    /** A cache of lightweight DiagnosticSource objects.
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   195
     */
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   196
    protected Map<JavaFileObject, DiagnosticSource> sourceMap;
1dff24b5f407 6724071: refactor Log into a front end and back end
jjg
parents:
diff changeset
   197
}