23 * have any questions. |
23 * have any questions. |
24 */ |
24 */ |
25 package com.sun.tools.javac.api; |
25 package com.sun.tools.javac.api; |
26 |
26 |
27 import java.util.Locale; |
27 import java.util.Locale; |
|
28 import java.util.Set; |
28 import javax.tools.Diagnostic; |
29 import javax.tools.Diagnostic; |
|
30 import com.sun.tools.javac.api.DiagnosticFormatter.*; |
29 |
31 |
30 /** |
32 /** |
31 * Provides simple functionalities for javac diagnostic formatting |
33 * Provides simple functionalities for javac diagnostic formatting. |
32 * @param <D> type of diagnostic handled by this formatter |
34 * @param <D> type of diagnostic handled by this formatter |
33 */ |
35 */ |
34 public interface DiagnosticFormatter<D extends Diagnostic<?>> { |
36 public interface DiagnosticFormatter<D extends Diagnostic<?>> { |
35 |
37 |
36 /** |
38 /** |
37 * Whether the source code output for this diagnostic is to be displayed |
39 * Whether the source code output for this diagnostic is to be displayed. |
38 * |
40 * |
39 * @param diag diagnostic to be formatted |
41 * @param diag diagnostic to be formatted |
40 * @return true if the source line this diagnostic refers to is to be displayed |
42 * @return true if the source line this diagnostic refers to is to be displayed |
41 */ |
43 */ |
42 boolean displaySource(D diag); |
44 boolean displaySource(D diag); |
43 |
45 |
44 /** |
46 /** |
45 * Format the contents of a diagnostics |
47 * Format the contents of a diagnostics. |
46 * |
48 * |
47 * @param diag the diagnostic to be formatted |
49 * @param diag the diagnostic to be formatted |
48 * @param l locale object to be used for i18n |
50 * @param l locale object to be used for i18n |
49 * @return a string representing the diagnostic |
51 * @return a string representing the diagnostic |
50 */ |
52 */ |
113 /** |
115 /** |
114 * Offset position |
116 * Offset position |
115 */ |
117 */ |
116 OFFSET |
118 OFFSET |
117 } |
119 } |
|
120 |
|
121 /** |
|
122 * Get a list of all the enabled verbosity options. |
|
123 * @return verbosity options |
|
124 */ |
|
125 public Configuration getConfiguration(); |
|
126 //where |
|
127 |
|
128 /** |
|
129 * This interface provides functionalities for tuning the output of a |
|
130 * diagnostic formatter in multiple ways. |
|
131 */ |
|
132 interface Configuration { |
|
133 /** |
|
134 * Configure the set of diagnostic parts that should be displayed |
|
135 * by the formatter. |
|
136 * @param options options to set |
|
137 */ |
|
138 public void setVisible(Set<DiagnosticPart> visibleParts); |
|
139 |
|
140 /** |
|
141 * Retrieve the set of diagnostic parts that should be displayed |
|
142 * by the formatter. |
|
143 * @return verbosity options |
|
144 */ |
|
145 public Set<DiagnosticPart> getVisible(); |
|
146 |
|
147 //where |
|
148 /** |
|
149 * A given diagnostic message can be divided into sub-parts each of which |
|
150 * might/might not be displayed by the formatter, according to the |
|
151 * current configuration settings. |
|
152 */ |
|
153 public enum DiagnosticPart { |
|
154 /** |
|
155 * Short description of the diagnostic - usually one line long. |
|
156 */ |
|
157 SUMMARY, |
|
158 /** |
|
159 * Longer description that provides additional details w.r.t. the ones |
|
160 * in the diagnostic's description. |
|
161 */ |
|
162 DETAILS, |
|
163 /** |
|
164 * Source line the diagnostic refers to (if applicable). |
|
165 */ |
|
166 SOURCE, |
|
167 /** |
|
168 * Subdiagnostics attached to a given multiline diagnostic. |
|
169 */ |
|
170 SUBDIAGNOSTICS, |
|
171 /** |
|
172 * JLS paragraph this diagnostic might refer to (if applicable). |
|
173 */ |
|
174 JLS; |
|
175 } |
|
176 |
|
177 /** |
|
178 * Set a limit for multiline diagnostics. |
|
179 * Note: Setting a limit has no effect if multiline diagnostics are either |
|
180 * fully enabled or disabled. |
|
181 * |
|
182 * @param limit the kind of limit to be set |
|
183 * @param value the limit value |
|
184 */ |
|
185 public void setMultilineLimit(MultilineLimit limit, int value); |
|
186 |
|
187 /** |
|
188 * Get a multiline diagnostic limit. |
|
189 * |
|
190 * @param limit the kind of limit to be retrieved |
|
191 * @return limit value or -1 if no limit is set |
|
192 */ |
|
193 public int getMultilineLimit(MultilineLimit limit); |
|
194 //where |
|
195 /** |
|
196 * A multiline limit control the verbosity of multiline diagnostics |
|
197 * either by setting a maximum depth of nested multidiagnostics, |
|
198 * or by limiting the amount of subdiagnostics attached to a given |
|
199 * diagnostic (or both). |
|
200 */ |
|
201 public enum MultilineLimit { |
|
202 /** |
|
203 * Controls the maximum depth of nested multiline diagnostics. |
|
204 */ |
|
205 DEPTH, |
|
206 /** |
|
207 * Controls the maximum amount of subdiagnostics that are part of a |
|
208 * given multiline diagnostic. |
|
209 */ |
|
210 LENGTH; |
|
211 } |
|
212 } |
118 } |
213 } |