src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java

changeset 689
77cc34d5e548
parent 612
d1bd93028447
child 798
4868a36f6fd8
     1.1 --- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Sat Sep 18 09:54:51 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Sat Sep 18 09:56:23 2010 -0700
     1.3 @@ -65,8 +65,6 @@
     1.4   */
     1.5  public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
     1.6  
     1.7 -    protected int currentIndentation = 0;
     1.8 -
     1.9      /**
    1.10       * Create a basic formatter based on the supplied options.
    1.11       *
    1.12 @@ -107,33 +105,28 @@
    1.13      }
    1.14  
    1.15      public String formatMessage(JCDiagnostic d, Locale l) {
    1.16 -        int prevIndentation = currentIndentation;
    1.17 -        try {
    1.18 -            StringBuilder buf = new StringBuilder();
    1.19 -            Collection<String> args = formatArguments(d, l);
    1.20 -            String msg = localize(l, d.getCode(), args.toArray());
    1.21 -            String[] lines = msg.split("\n");
    1.22 -            if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
    1.23 -                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
    1.24 -                buf.append(indent(lines[0], currentIndentation)); //summary
    1.25 +        int currentIndentation = 0;
    1.26 +        StringBuilder buf = new StringBuilder();
    1.27 +        Collection<String> args = formatArguments(d, l);
    1.28 +        String msg = localize(l, d.getCode(), args.toArray());
    1.29 +        String[] lines = msg.split("\n");
    1.30 +        if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
    1.31 +            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
    1.32 +            buf.append(indent(lines[0], currentIndentation)); //summary
    1.33 +        }
    1.34 +        if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
    1.35 +            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
    1.36 +            for (int i = 1;i < lines.length; i++) {
    1.37 +                buf.append("\n" + indent(lines[i], currentIndentation));
    1.38              }
    1.39 -            if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
    1.40 -                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
    1.41 -                for (int i = 1;i < lines.length; i++) {
    1.42 -                    buf.append("\n" + indent(lines[i], currentIndentation));
    1.43 -                }
    1.44 +        }
    1.45 +        if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
    1.46 +            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
    1.47 +                for (String sub : formatSubdiagnostics(d, l)) {
    1.48 +                    buf.append("\n" + indent(sub, currentIndentation));
    1.49              }
    1.50 -            if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
    1.51 -                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
    1.52 -                for (String sub : formatSubdiagnostics(d, l)) {
    1.53 -                    buf.append("\n" + sub);
    1.54 -                }
    1.55 -            }
    1.56 -            return buf.toString();
    1.57          }
    1.58 -        finally {
    1.59 -            currentIndentation = prevIndentation;
    1.60 -        }
    1.61 +        return buf.toString();
    1.62      }
    1.63  
    1.64      protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) {

mercurial