1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
27 |
28 import java.util.Collection; |
28 import java.util.Collection; |
|
29 import java.util.EnumMap; |
29 import java.util.EnumSet; |
30 import java.util.EnumSet; |
30 import java.util.HashMap; |
31 import java.util.HashMap; |
31 import java.util.Locale; |
32 import java.util.Locale; |
32 import java.util.Map; |
33 import java.util.Map; |
33 import java.util.regex.Matcher; |
34 import java.util.regex.Matcher; |
224 DiagnosticPart.DETAILS, |
225 DiagnosticPart.DETAILS, |
225 DiagnosticPart.SUBDIAGNOSTICS, |
226 DiagnosticPart.SUBDIAGNOSTICS, |
226 DiagnosticPart.SOURCE)); |
227 DiagnosticPart.SOURCE)); |
227 initFormat(); |
228 initFormat(); |
228 initIndentation(); |
229 initIndentation(); |
|
230 if (options.isSet("oldDiags")) |
|
231 initOldFormat(); |
229 String fmt = options.get("diagsFormat"); |
232 String fmt = options.get("diagsFormat"); |
230 if (fmt != null) { |
233 if (fmt != null) { |
231 String[] formats = fmt.split("\\|"); |
234 if (fmt.equals("OLD")) |
232 switch (formats.length) { |
235 initOldFormat(); |
233 case 3: |
236 else |
234 setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]); |
237 initFormats(fmt); |
235 case 2: |
|
236 setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]); |
|
237 default: |
|
238 setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]); |
|
239 } |
|
240 } |
238 } |
241 String srcPos = null; |
239 String srcPos = null; |
242 if ((((srcPos = options.get("sourcePosition")) != null)) && |
240 if ((((srcPos = options.get("sourcePosition")) != null)) && |
243 srcPos.equals("bottom")) |
241 srcPos.equals("bottom")) |
244 setSourcePosition(SourcePosition.BOTTOM); |
242 setSourcePosition(SourcePosition.BOTTOM); |
278 DiagnosticPart.SUBDIAGNOSTICS, |
276 DiagnosticPart.SUBDIAGNOSTICS, |
279 DiagnosticPart.SOURCE)); |
277 DiagnosticPart.SOURCE)); |
280 initFormat(); |
278 initFormat(); |
281 initIndentation(); |
279 initIndentation(); |
282 } |
280 } |
283 //where |
281 |
284 private void initFormat() { |
282 private void initFormat() { |
285 availableFormats = new HashMap<BasicFormatKind, String>(); |
283 initFormats("%f:%l:%_%p%L%m", "%p%L%m", "%f:%_%p%L%m"); |
286 setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%L%m"); |
284 } |
287 setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%L%m"); |
285 |
288 setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%L%m"); |
286 private void initOldFormat() { |
289 } |
287 initFormats("%f:%l:%_%t%L%m", "%p%L%m", "%f:%_%t%L%m"); |
290 //where |
288 } |
|
289 |
|
290 private void initFormats(String pos, String nopos, String clazz) { |
|
291 availableFormats = new EnumMap<BasicFormatKind, String>(BasicFormatKind.class); |
|
292 setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, pos); |
|
293 setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, nopos); |
|
294 setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, clazz); |
|
295 } |
|
296 |
|
297 @SuppressWarnings("fallthrough") |
|
298 private void initFormats(String fmt) { |
|
299 String[] formats = fmt.split("\\|"); |
|
300 switch (formats.length) { |
|
301 case 3: |
|
302 setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]); |
|
303 case 2: |
|
304 setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]); |
|
305 default: |
|
306 setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]); |
|
307 } |
|
308 } |
|
309 |
291 private void initIndentation() { |
310 private void initIndentation() { |
292 indentationLevels = new HashMap<DiagnosticPart, Integer>(); |
311 indentationLevels = new HashMap<DiagnosticPart, Integer>(); |
293 setIndentation(DiagnosticPart.SUMMARY, 0); |
312 setIndentation(DiagnosticPart.SUMMARY, 0); |
294 setIndentation(DiagnosticPart.DETAILS, DetailsInc); |
313 setIndentation(DiagnosticPart.DETAILS, DetailsInc); |
295 setIndentation(DiagnosticPart.SUBDIAGNOSTICS, DiagInc); |
314 setIndentation(DiagnosticPart.SUBDIAGNOSTICS, DiagInc); |