author | mcimadamore |
Fri, 13 Feb 2009 11:57:33 +0000 | |
changeset 2085 | 4792e12a8ca2 |
parent 1591 | e5a618442f5f |
child 2221 | cd6557bcaa0a |
child 2212 | 1d3dc0e0ba0c |
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 |
||
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
27 |
import java.util.Arrays; |
942 | 28 |
import java.util.Collection; |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
29 |
import java.util.EnumSet; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
30 |
import java.util.HashMap; |
942 | 31 |
import java.util.Locale; |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
32 |
import java.util.Map; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
33 |
import java.util.Set; |
942 | 34 |
import javax.tools.JavaFileObject; |
35 |
||
36 |
import com.sun.tools.javac.api.DiagnosticFormatter; |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
37 |
import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
38 |
import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
39 |
import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind; |
942 | 40 |
import com.sun.tools.javac.api.Formattable; |
41 |
import com.sun.tools.javac.file.JavacFileManager; |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
42 |
|
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
43 |
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; |
942 | 44 |
|
45 |
/** |
|
46 |
* This abstract class provides a basic implementation of the functionalities that should be provided |
|
47 |
* by any formatter used by javac. Among the main features provided by AbstractDiagnosticFormatter are: |
|
48 |
* |
|
49 |
* <ul> |
|
50 |
* <li> Provides a standard implementation of the visitor-like methods defined in the interface DiagnisticFormatter. |
|
51 |
* Those implementations are specifically targeting JCDiagnostic objects. |
|
52 |
* <li> Provides basic support for i18n and a method for executing all locale-dependent conversions |
|
53 |
* <li> Provides the formatting logic for rendering the arguments of a JCDiagnostic object. |
|
54 |
* <ul> |
|
55 |
* |
|
56 |
*/ |
|
57 |
public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter<JCDiagnostic> { |
|
58 |
||
59 |
/** |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
60 |
* JavacMessages object used by this formatter for i18n. |
942 | 61 |
*/ |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
62 |
protected JavacMessages messages; |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
63 |
private SimpleConfiguration config; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
64 |
protected int depth = 0; |
942 | 65 |
|
66 |
/** |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
67 |
* Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object. |
942 | 68 |
* @param messages |
69 |
*/ |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
70 |
protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) { |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
71 |
this.messages = messages; |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
72 |
this.config = config; |
942 | 73 |
} |
74 |
||
75 |
public String formatKind(JCDiagnostic d, Locale l) { |
|
76 |
switch (d.getType()) { |
|
77 |
case FRAGMENT: return ""; |
|
78 |
case NOTE: return localize(l, "compiler.note.note"); |
|
79 |
case WARNING: return localize(l, "compiler.warn.warning"); |
|
80 |
case ERROR: return localize(l, "compiler.err.error"); |
|
81 |
default: |
|
82 |
throw new AssertionError("Unknown diagnostic type: " + d.getType()); |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
public String formatPosition(JCDiagnostic d, PositionKind pk,Locale l) { |
|
87 |
assert (d.getPosition() != Position.NOPOS); |
|
88 |
return String.valueOf(getPosition(d, pk)); |
|
89 |
} |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
90 |
//where |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
91 |
private long getPosition(JCDiagnostic d, PositionKind pk) { |
942 | 92 |
switch (pk) { |
93 |
case START: return d.getIntStartPosition(); |
|
94 |
case END: return d.getIntEndPosition(); |
|
95 |
case LINE: return d.getLineNumber(); |
|
96 |
case COLUMN: return d.getColumnNumber(); |
|
97 |
case OFFSET: return d.getIntPosition(); |
|
98 |
default: |
|
99 |
throw new AssertionError("Unknown diagnostic position: " + pk); |
|
100 |
} |
|
101 |
} |
|
102 |
||
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
103 |
public String formatSource(JCDiagnostic d, boolean fullname, Locale l) { |
942 | 104 |
assert (d.getSource() != null); |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
105 |
return fullname ? d.getSourceName() : d.getSource().getName(); |
942 | 106 |
} |
107 |
||
108 |
/** |
|
109 |
* Format the arguments of a given diagnostic. |
|
110 |
* |
|
111 |
* @param d diagnostic whose arguments are to be formatted |
|
112 |
* @param l locale object to be used for i18n |
|
113 |
* @return a Collection whose elements are the formatted arguments of the diagnostic |
|
114 |
*/ |
|
115 |
protected Collection<String> formatArguments(JCDiagnostic d, Locale l) { |
|
116 |
ListBuffer<String> buf = new ListBuffer<String>(); |
|
117 |
for (Object o : d.getArgs()) { |
|
118 |
buf.append(formatArgument(d, o, l)); |
|
119 |
} |
|
120 |
return buf.toList(); |
|
121 |
} |
|
122 |
||
123 |
/** |
|
124 |
* Format a single argument of a given diagnostic. |
|
125 |
* |
|
126 |
* @param d diagnostic whose argument is to be formatted |
|
127 |
* @param arg argument to be formatted |
|
128 |
* @param l locale object to be used for i18n |
|
129 |
* @return string representation of the diagnostic argument |
|
130 |
*/ |
|
131 |
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) { |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
132 |
if (arg instanceof JCDiagnostic) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
133 |
String s = null; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
134 |
depth++; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
135 |
try { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
136 |
s = formatMessage((JCDiagnostic)arg, l); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
137 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
138 |
finally { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
139 |
depth--; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
140 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
141 |
return s; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
142 |
} |
942 | 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 |
/** |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
174 |
* Format all the subdiagnostics attached to a given diagnostic. |
1591
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 |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
178 |
* @return list of all string representations of the subdiagnostics |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
179 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
180 |
protected List<String> formatSubdiagnostics(JCDiagnostic d, Locale l) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
181 |
List<String> subdiagnostics = List.nil(); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
182 |
int maxDepth = config.getMultilineLimit(MultilineLimit.DEPTH); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
183 |
if (maxDepth == -1 || depth < maxDepth) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
184 |
depth++; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
185 |
try { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
186 |
int maxCount = config.getMultilineLimit(MultilineLimit.LENGTH); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
187 |
int count = 0; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
188 |
for (JCDiagnostic d2 : d.getSubdiagnostics()) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
189 |
if (maxCount == -1 || count < maxCount) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
190 |
subdiagnostics = subdiagnostics.append(formatSubdiagnostic(d, d2, l)); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
191 |
count++; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
192 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
193 |
else |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
194 |
break; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
195 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
196 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
197 |
finally { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
198 |
depth--; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
199 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
200 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
201 |
return subdiagnostics; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
202 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
203 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
204 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
205 |
* Format a subdiagnostics attached to a given diagnostic. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
206 |
* |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
207 |
* @param parent multiline diagnostic whose subdiagnostics is to be formatted |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
208 |
* @param sub subdiagnostic to be formatted |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
209 |
* @param l locale object to be used for i18n |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
210 |
* @return string representation of the subdiagnostics |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
211 |
*/ |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
212 |
protected String formatSubdiagnostic(JCDiagnostic parent, JCDiagnostic sub, Locale l) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
213 |
return formatMessage(sub, l); |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
214 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
215 |
|
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
216 |
/** 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
|
217 |
* @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
|
218 |
*/ |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
219 |
protected String formatSourceLine(JCDiagnostic d, int nSpaces) { |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
220 |
StringBuilder buf = new StringBuilder(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
221 |
DiagnosticSource source = d.getDiagnosticSource(); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
222 |
int pos = d.getIntPosition(); |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
223 |
if (d.getIntPosition() == Position.NOPOS) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
224 |
throw new AssertionError(); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
225 |
String line = (source == null ? null : source.getLine(pos)); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
226 |
if (line == null) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
227 |
return ""; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
228 |
buf.append(indent(line, nSpaces)); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
229 |
int col = source.getColumnNumber(pos, false); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
230 |
if (config.isCaretEnabled()) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
231 |
buf.append("\n"); |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
232 |
for (int i = 0; i < col - 1; i++) { |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
233 |
buf.append((line.charAt(i) == '\t') ? "\t" : " "); |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
234 |
} |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
235 |
buf.append(indent("^", nSpaces)); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
236 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
237 |
return buf.toString(); |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
238 |
} |
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
239 |
|
942 | 240 |
/** |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
241 |
* Converts a String into a locale-dependent representation accordingly to a given locale. |
942 | 242 |
* |
243 |
* @param l locale object to be used for i18n |
|
244 |
* @param key locale-independent key used for looking up in a resource file |
|
245 |
* @param args localization arguments |
|
246 |
* @return a locale-dependent string |
|
247 |
*/ |
|
248 |
protected String localize(Locale l, String key, Object... args) { |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
249 |
return messages.getLocalizedString(l, key, args); |
942 | 250 |
} |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
251 |
|
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
252 |
public boolean displaySource(JCDiagnostic d) { |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
253 |
return config.getVisible().contains(DiagnosticPart.SOURCE) && |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
254 |
d.getType() != FRAGMENT && |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
255 |
d.getIntPosition() != Position.NOPOS; |
1472
1e09e143438c
6731573: diagnostic output should optionally include source line
mcimadamore
parents:
1471
diff
changeset
|
256 |
} |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
257 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
258 |
/** |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
259 |
* Creates a string with a given amount of empty spaces. Useful for |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
260 |
* indenting the text of a diagnostic message. |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
261 |
* |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
262 |
* @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
|
263 |
* @return the indentation string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
264 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
265 |
protected String indentString(int nSpaces) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
266 |
String spaces = " "; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
267 |
if (nSpaces <= spaces.length()) |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
268 |
return spaces.substring(0, nSpaces); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
269 |
else { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
270 |
StringBuilder buf = new StringBuilder(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
271 |
for (int i = 0 ; i < nSpaces ; i++) |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
272 |
buf.append(" "); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
273 |
return buf.toString(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
274 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
275 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
276 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
277 |
/** |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
278 |
* Indent a string by prepending a given amount of empty spaces to each line |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
279 |
* of the string. |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
280 |
* |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
281 |
* @param s the string to be indented |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
282 |
* @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
|
283 |
* of the string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
284 |
* @return an indented string |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
285 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
286 |
protected String indent(String s, int nSpaces) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
287 |
String indent = indentString(nSpaces); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
288 |
StringBuilder buf = new StringBuilder(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
289 |
String nl = ""; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
290 |
for (String line : s.split("\n")) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
291 |
buf.append(nl); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
292 |
buf.append(indent + line); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
293 |
nl = "\n"; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
294 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
295 |
return buf.toString(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1472
diff
changeset
|
296 |
} |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
297 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
298 |
public SimpleConfiguration getConfiguration() { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
299 |
return config; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
300 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
301 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
302 |
static public class SimpleConfiguration implements Configuration { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
303 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
304 |
protected Map<MultilineLimit, Integer> multilineLimits; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
305 |
protected EnumSet<DiagnosticPart> visibleParts; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
306 |
protected boolean caretEnabled; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
307 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
308 |
public SimpleConfiguration(Set<DiagnosticPart> parts) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
309 |
multilineLimits = new HashMap<MultilineLimit, Integer>(); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
310 |
setVisible(parts); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
311 |
setMultilineLimit(MultilineLimit.DEPTH, -1); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
312 |
setMultilineLimit(MultilineLimit.LENGTH, -1); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
313 |
setCaretEnabled(true); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
314 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
315 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
316 |
@SuppressWarnings("fallthrough") |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
317 |
public SimpleConfiguration(Options options, Set<DiagnosticPart> parts) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
318 |
this(parts); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
319 |
String showSource = null; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
320 |
if ((showSource = options.get("showSource")) != null) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
321 |
if (showSource.equals("true")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
322 |
visibleParts.add(DiagnosticPart.SOURCE); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
323 |
else if (showSource.equals("false")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
324 |
visibleParts.remove(DiagnosticPart.SOURCE); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
325 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
326 |
String diagOpts = options.get("diags"); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
327 |
if (diagOpts != null) {//override -XDshowSource |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
328 |
Collection<String> args = Arrays.asList(diagOpts.split(",")); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
329 |
if (args.contains("short")) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
330 |
visibleParts.remove(DiagnosticPart.DETAILS); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
331 |
visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
332 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
333 |
if (args.contains("source")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
334 |
visibleParts.add(DiagnosticPart.SOURCE); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
335 |
if (args.contains("-source")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
336 |
visibleParts.remove(DiagnosticPart.SOURCE); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
337 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
338 |
String multiPolicy = null; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
339 |
if ((multiPolicy = options.get("multilinePolicy")) != null) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
340 |
if (multiPolicy.equals("disabled")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
341 |
visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
342 |
else if (multiPolicy.startsWith("limit:")) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
343 |
String limitString = multiPolicy.substring("limit:".length()); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
344 |
String[] limits = limitString.split(":"); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
345 |
try { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
346 |
switch (limits.length) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
347 |
case 2: { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
348 |
if (!limits[1].equals("*")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
349 |
setMultilineLimit(MultilineLimit.DEPTH, Integer.parseInt(limits[1])); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
350 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
351 |
case 1: { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
352 |
if (!limits[0].equals("*")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
353 |
setMultilineLimit(MultilineLimit.LENGTH, Integer.parseInt(limits[0])); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
354 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
355 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
356 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
357 |
catch(NumberFormatException ex) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
358 |
setMultilineLimit(MultilineLimit.DEPTH, -1); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
359 |
setMultilineLimit(MultilineLimit.LENGTH, -1); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
360 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
361 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
362 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
363 |
String showCaret = null; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
364 |
if (((showCaret = options.get("showCaret")) != null) && |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
365 |
showCaret.equals("false")) |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
366 |
setCaretEnabled(false); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
367 |
else |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
368 |
setCaretEnabled(true); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
369 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
370 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
371 |
public int getMultilineLimit(MultilineLimit limit) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
372 |
return multilineLimits.get(limit); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
373 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
374 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
375 |
public EnumSet<DiagnosticPart> getVisible() { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
376 |
return EnumSet.copyOf(visibleParts); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
377 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
378 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
379 |
public void setMultilineLimit(MultilineLimit limit, int value) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
380 |
multilineLimits.put(limit, value < -1 ? -1 : value); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
381 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
382 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
383 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
384 |
public void setVisible(Set<DiagnosticPart> diagParts) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
385 |
visibleParts = EnumSet.copyOf(diagParts); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
386 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
387 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
388 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
389 |
* Shows a '^' sign under the source line displayed by the formatter |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
390 |
* (if applicable). |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
391 |
* |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
392 |
* @param caretEnabled if true enables caret |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
393 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
394 |
public void setCaretEnabled(boolean caretEnabled) { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
395 |
this.caretEnabled = caretEnabled; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
396 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
397 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
398 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
399 |
* Tells whether the caret display is active or not. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
400 |
* |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
401 |
* @param caretEnabled if true the caret is enabled |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
402 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
403 |
public boolean isCaretEnabled() { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
404 |
return caretEnabled; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
405 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1591
diff
changeset
|
406 |
} |
942 | 407 |
} |