langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
equal
deleted
inserted
replaced
60 * |
60 * |
61 * @param opts list of command-line options |
61 * @param opts list of command-line options |
62 * @param msgs JavacMessages object used for i18n |
62 * @param msgs JavacMessages object used for i18n |
63 */ |
63 */ |
64 BasicDiagnosticFormatter(Options opts, JavacMessages msgs) { |
64 BasicDiagnosticFormatter(Options opts, JavacMessages msgs) { |
65 this(msgs); //common init |
65 super(msgs, opts, true); |
|
66 initAvailableFormats(); |
66 String fmt = opts.get("diags"); |
67 String fmt = opts.get("diags"); |
67 if (fmt != null) { |
68 if (fmt != null) { |
68 String[] formats = fmt.split("\\|"); |
69 String[] formats = fmt.split("\\|"); |
69 switch (formats.length) { |
70 switch (formats.length) { |
70 case 3: |
71 case 3: |
81 * Create a standard basic formatter |
82 * Create a standard basic formatter |
82 * |
83 * |
83 * @param msgs JavacMessages object used for i18n |
84 * @param msgs JavacMessages object used for i18n |
84 */ |
85 */ |
85 public BasicDiagnosticFormatter(JavacMessages msgs) { |
86 public BasicDiagnosticFormatter(JavacMessages msgs) { |
86 super(msgs); |
87 super(msgs, true); |
|
88 initAvailableFormats(); |
|
89 } |
|
90 |
|
91 public void initAvailableFormats() { |
87 availableFormats = new HashMap<BasicFormatKind, String>(); |
92 availableFormats = new HashMap<BasicFormatKind, String>(); |
88 availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m"); |
93 availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m"); |
89 availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m"); |
94 availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m"); |
90 availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m"); |
95 availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m"); |
91 } |
96 } |
101 if (c == '%' && i < format.length() - 1) { |
106 if (c == '%' && i < format.length() - 1) { |
102 meta = true; |
107 meta = true; |
103 c = format.charAt(++i); |
108 c = format.charAt(++i); |
104 } |
109 } |
105 buf.append(meta ? formatMeta(c, d, l) : String.valueOf(c)); |
110 buf.append(meta ? formatMeta(c, d, l) : String.valueOf(c)); |
|
111 } |
|
112 if (displaySource(d)) { |
|
113 buf.append("\n" + formatSourceLine(d)); |
106 } |
114 } |
107 return buf.toString(); |
115 return buf.toString(); |
108 } |
116 } |
109 |
117 |
110 protected String formatMeta(char c, JCDiagnostic d, Locale l) { |
118 protected String formatMeta(char c, JCDiagnostic d, Locale l) { |
165 } |
173 } |
166 } |
174 } |
167 return format; |
175 return format; |
168 } |
176 } |
169 |
177 |
170 public boolean displaySource(JCDiagnostic d) { |
|
171 return true; |
|
172 } |
|
173 |
|
174 /** |
178 /** |
175 * This enum contains all the kinds of formatting patterns supported |
179 * This enum contains all the kinds of formatting patterns supported |
176 * by a basic diagnostic formatter. |
180 * by a basic diagnostic formatter. |
177 */ |
181 */ |
178 public enum BasicFormatKind { |
182 public enum BasicFormatKind { |