langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
changeset 1471 57506cdfb7b4
parent 1109 853d8c191eac
child 1472 1e09e143438c
equal deleted inserted replaced
1470:6ff8524783fa 1471:57506cdfb7b4
    57 
    57 
    58     /**
    58     /**
    59      * Create a basic formatter based on the supplied options.
    59      * Create a basic formatter based on the supplied options.
    60      *
    60      *
    61      * @param opts list of command-line options
    61      * @param opts list of command-line options
    62      * @param msgs Messages object used for i18n
    62      * @param msgs JavacMessages object used for i18n
    63      */
    63      */
    64     BasicDiagnosticFormatter(Options opts, Messages msgs) {
    64     BasicDiagnosticFormatter(Options opts, JavacMessages msgs) {
    65         this(msgs); //common init
    65         this(msgs); //common init
    66         String fmt = opts.get("diags");
    66         String fmt = opts.get("diags");
    67         if (fmt != null) {
    67         if (fmt != null) {
    68             String[] formats = fmt.split("\\|");
    68             String[] formats = fmt.split("\\|");
    69             switch (formats.length) {
    69             switch (formats.length) {
    78     }
    78     }
    79 
    79 
    80     /**
    80     /**
    81      * Create a standard basic formatter
    81      * Create a standard basic formatter
    82      *
    82      *
    83      * @param msgs Messages object used for i18n
    83      * @param msgs JavacMessages object used for i18n
    84      */
    84      */
    85     public BasicDiagnosticFormatter(Messages msgs) {
    85     public BasicDiagnosticFormatter(JavacMessages msgs) {
    86         super(msgs);
    86         super(msgs);
    87         availableFormats = new HashMap<BasicFormatKind, String>();
    87         availableFormats = new HashMap<BasicFormatKind, String>();
    88         availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m");
    88         availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m");
    89         availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m");
    89         availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m");
    90         availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m");
    90         availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m");
    91     }
    91     }
    92 
    92 
    93     public String format(JCDiagnostic d, Locale l) {
    93     public String format(JCDiagnostic d, Locale l) {
       
    94         if (l == null)
       
    95             l = messages.getCurrentLocale();
    94         String format = selectFormat(d);
    96         String format = selectFormat(d);
    95         StringBuilder buf = new StringBuilder();
    97         StringBuilder buf = new StringBuilder();
    96         for (int i = 0; i < format.length(); i++) {
    98         for (int i = 0; i < format.length(); i++) {
    97             char c = format.charAt(i);
    99             char c = format.charAt(i);
    98             boolean meta = false;
   100             boolean meta = false;