author | mcimadamore |
Wed, 12 Nov 2008 14:17:03 +0000 | |
changeset 1591 | e5a618442f5f |
parent 1472 | 1e09e143438c |
child 2085 | 4792e12a8ca2 |
permissions | -rw-r--r-- |
942 | 1 |
/* |
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
package com.sun.tools.javac.util; |
|
26 |
||
27 |
import java.util.Collection; |
|
28 |
import java.util.Locale; |
|
29 |
import javax.tools.JavaFileObject; |
|
30 |
||
31 |
import com.sun.tools.javac.api.DiagnosticFormatter; |
|
32 |
import com.sun.tools.javac.api.Formattable; |
|
33 |
import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind; |
|
34 |
import com.sun.tools.javac.file.JavacFileManager; |
|
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
35 |
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
36 |
import static com.sun.tools.javac.util.LayoutCharacters.*; |
942 | 37 |
|
38 |
/** |
|
39 |
* This abstract class provides a basic implementation of the functionalities that should be provided |
|
40 |
* by any formatter used by javac. Among the main features provided by AbstractDiagnosticFormatter are: |
|
41 |
* |
|
42 |
* <ul> |
|
43 |
* <li> Provides a standard implementation of the visitor-like methods defined in the interface DiagnisticFormatter. |
|
44 |
* Those implementations are specifically targeting JCDiagnostic objects. |
|
45 |
* <li> Provides basic support for i18n and a method for executing all locale-dependent conversions |
|
46 |
* <li> Provides the formatting logic for rendering the arguments of a JCDiagnostic object. |
|
47 |
* <ul> |
|
48 |
* |
|
49 |
*/ |
|
50 |
public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter<JCDiagnostic> { |
|
51 |
||
52 |
/** |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
53 |
* JavacMessages object used by this formatter for i18n |
942 | 54 |
*/ |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
55 |
protected JavacMessages messages; |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
56 |
protected boolean showSource; |
942 | 57 |
|
58 |
/** |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
59 |
* Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object |
942 | 60 |
* @param messages |
61 |
*/ |
|
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
62 |
protected AbstractDiagnosticFormatter(JavacMessages messages, Options options, boolean showSource) { |
942 | 63 |
this.messages = messages; |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
64 |
this.showSource = options.get("showSource") == null ? showSource : |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
65 |
options.get("showSource").equals("true"); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
66 |
} |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
67 |
|
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
68 |
protected AbstractDiagnosticFormatter(JavacMessages messages, boolean showSource) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
69 |
this.messages = messages; |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
70 |
this.showSource = showSource; |
942 | 71 |
} |
72 |
||
73 |
public String formatMessage(JCDiagnostic d, Locale l) { |
|
74 |
//this code should rely on the locale settings but it's not! See RFE 6443132 |
|
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
75 |
StringBuilder buf = new StringBuilder(); |
942 | 76 |
Collection<String> args = formatArguments(d, l); |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
77 |
buf.append(localize(l, d.getCode(), args.toArray())); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
78 |
if (d.isMultiline()) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
79 |
buf.append(formatSubdiagnostics(d, l)); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
80 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
81 |
return buf.toString(); |
942 | 82 |
} |
83 |
||
84 |
public String formatKind(JCDiagnostic d, Locale l) { |
|
85 |
switch (d.getType()) { |
|
86 |
case FRAGMENT: return ""; |
|
87 |
case NOTE: return localize(l, "compiler.note.note"); |
|
88 |
case WARNING: return localize(l, "compiler.warn.warning"); |
|
89 |
case ERROR: return localize(l, "compiler.err.error"); |
|
90 |
default: |
|
91 |
throw new AssertionError("Unknown diagnostic type: " + d.getType()); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
public String formatPosition(JCDiagnostic d, PositionKind pk,Locale l) { |
|
96 |
assert (d.getPosition() != Position.NOPOS); |
|
97 |
return String.valueOf(getPosition(d, pk)); |
|
98 |
} |
|
99 |
//WHERE |
|
100 |
public long getPosition(JCDiagnostic d, PositionKind pk) { |
|
101 |
switch (pk) { |
|
102 |
case START: return d.getIntStartPosition(); |
|
103 |
case END: return d.getIntEndPosition(); |
|
104 |
case LINE: return d.getLineNumber(); |
|
105 |
case COLUMN: return d.getColumnNumber(); |
|
106 |
case OFFSET: return d.getIntPosition(); |
|
107 |
default: |
|
108 |
throw new AssertionError("Unknown diagnostic position: " + pk); |
|
109 |
} |
|
110 |
} |
|
111 |
||
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
112 |
public String formatSource(JCDiagnostic d, boolean fullname, Locale l) { |
942 | 113 |
assert (d.getSource() != null); |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
114 |
return fullname ? d.getSourceName() : d.getSource().getName(); |
942 | 115 |
} |
116 |
||
117 |
/** |
|
118 |
* Format the arguments of a given diagnostic. |
|
119 |
* |
|
120 |
* @param d diagnostic whose arguments are to be formatted |
|
121 |
* @param l locale object to be used for i18n |
|
122 |
* @return a Collection whose elements are the formatted arguments of the diagnostic |
|
123 |
*/ |
|
124 |
protected Collection<String> formatArguments(JCDiagnostic d, Locale l) { |
|
125 |
ListBuffer<String> buf = new ListBuffer<String>(); |
|
126 |
for (Object o : d.getArgs()) { |
|
127 |
buf.append(formatArgument(d, o, l)); |
|
128 |
} |
|
129 |
return buf.toList(); |
|
130 |
} |
|
131 |
||
132 |
/** |
|
133 |
* Format a single argument of a given diagnostic. |
|
134 |
* |
|
135 |
* @param d diagnostic whose argument is to be formatted |
|
136 |
* @param arg argument to be formatted |
|
137 |
* @param l locale object to be used for i18n |
|
138 |
* @return string representation of the diagnostic argument |
|
139 |
*/ |
|
140 |
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) { |
|
141 |
if (arg instanceof JCDiagnostic) |
|
142 |
return format((JCDiagnostic)arg, l); |
|
143 |
else if (arg instanceof Iterable<?>) { |
|
144 |
return formatIterable(d, (Iterable<?>)arg, l); |
|
145 |
} |
|
146 |
else if (arg instanceof JavaFileObject) |
|
147 |
return JavacFileManager.getJavacBaseFileName((JavaFileObject)arg); |
|
148 |
else if (arg instanceof Formattable) |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
149 |
return ((Formattable)arg).toString(l, messages); |
942 | 150 |
else |
151 |
return String.valueOf(arg); |
|
152 |
} |
|
153 |
||
154 |
/** |
|
155 |
* Format an iterable argument of a given diagnostic. |
|
156 |
* |
|
157 |
* @param d diagnostic whose argument is to be formatted |
|
158 |
* @param it iterable argument to be formatted |
|
159 |
* @param l locale object to be used for i18n |
|
160 |
* @return string representation of the diagnostic iterable argument |
|
161 |
*/ |
|
162 |
protected String formatIterable(JCDiagnostic d, Iterable<?> it, Locale l) { |
|
163 |
StringBuilder sbuf = new StringBuilder(); |
|
164 |
String sep = ""; |
|
165 |
for (Object o : it) { |
|
166 |
sbuf.append(sep); |
|
167 |
sbuf.append(formatArgument(d, o, l)); |
|
168 |
sep = ","; |
|
169 |
} |
|
170 |
return sbuf.toString(); |
|
171 |
} |
|
172 |
||
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
173 |
/** |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
174 |
* Format all the subdiagnostics attached to a given diagnostic |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
175 |
* |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
176 |
* @param d diagnostic whose subdiagnostics are to be formatted |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
177 |
* @param l locale object to be used for i18n |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
178 |
* @return string representation of the subdiagnostics |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
179 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
180 |
protected String formatSubdiagnostics(JCDiagnostic d, Locale l) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
181 |
StringBuilder buf = new StringBuilder(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
182 |
for (JCDiagnostic d2 : d.getSubdiagnostics()) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
183 |
buf.append('\n'); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
184 |
String subdiagMsg = format(d2, l); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
185 |
buf.append(indent(subdiagMsg, DiagInc)); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
186 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
187 |
return buf.toString(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
188 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
189 |
|
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
190 |
/** Format the faulty source code line and point to the error. |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
191 |
* @param d The diagnostic for which the error line should be printed |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
192 |
*/ |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
193 |
protected String formatSourceLine(JCDiagnostic d) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
194 |
StringBuilder buf = new StringBuilder(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
195 |
DiagnosticSource source = d.getDiagnosticSource(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
196 |
int pos = d.getIntPosition(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
197 |
if (d.getIntPosition() != Position.NOPOS) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
198 |
String line = (source == null ? null : source.getLine(pos)); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
199 |
if (line == null) |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
200 |
return ""; |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
201 |
buf.append(line+"\n"); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
202 |
int col = source.getColumnNumber(pos, false); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
203 |
for (int i = 0; i < col - 1; i++) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
204 |
buf.append((line.charAt(i) == '\t') ? "\t" : " "); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
205 |
} |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
206 |
buf.append("^"); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
207 |
} |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
208 |
return buf.toString(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
209 |
} |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
210 |
|
942 | 211 |
/** |
212 |
* Converts a String into a locale-dependent representation accordingly to a given locale |
|
213 |
* |
|
214 |
* @param l locale object to be used for i18n |
|
215 |
* @param key locale-independent key used for looking up in a resource file |
|
216 |
* @param args localization arguments |
|
217 |
* @return a locale-dependent string |
|
218 |
*/ |
|
219 |
protected String localize(Locale l, String key, Object... args) { |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
220 |
return messages.getLocalizedString(l, key, args); |
942 | 221 |
} |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
222 |
|
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
223 |
public boolean displaySource(JCDiagnostic d) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
224 |
return showSource && d.getType() != FRAGMENT; |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
225 |
} |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
226 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
227 |
/** |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
228 |
* Creates a string with a given amount of empty spaces. Useful for |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
229 |
* indenting the text of a diagnostic message. |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
230 |
* |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
231 |
* @param nSpaces the amount of spaces to be added to the result string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
232 |
* @return the indentation string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
233 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
234 |
protected String indentString(int nSpaces) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
235 |
String spaces = " "; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
236 |
if (nSpaces <= spaces.length()) |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
237 |
return spaces.substring(0, nSpaces); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
238 |
else { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
239 |
StringBuilder buf = new StringBuilder(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
240 |
for (int i = 0 ; i < nSpaces ; i++) |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
241 |
buf.append(" "); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
242 |
return buf.toString(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
243 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
244 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
245 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
246 |
/** |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
247 |
* Indent a string by prepending a given amount of empty spaces to each line |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
248 |
* of the string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
249 |
* |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
250 |
* @param s the string to be indented |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
251 |
* @param nSpaces the amount of spaces that should be prepended to each line |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
252 |
* of the string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
253 |
* @return an indented string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
254 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
255 |
protected String indent(String s, int nSpaces) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
256 |
String indent = indentString(nSpaces); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
257 |
StringBuilder buf = new StringBuilder(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
258 |
String nl = ""; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
259 |
for (String line : s.split("\n")) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
260 |
buf.append(nl); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
261 |
buf.append(indent + line); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
262 |
nl = "\n"; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
263 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
264 |
return buf.toString(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
265 |
} |
942 | 266 |
} |