author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 3380 | a6c2bcab0fec |
child 5847 | 1908176fd6e3 |
permissions | -rw-r--r-- |
942 | 1 |
/* |
5520 | 2 |
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. |
942 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
942 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
942 | 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 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
942 | 24 |
*/ |
25 |
package com.sun.tools.javac.api; |
|
26 |
||
27 |
import java.util.Locale; |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
28 |
import java.util.Set; |
942 | 29 |
import javax.tools.Diagnostic; |
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
30 |
import com.sun.tools.javac.api.DiagnosticFormatter.*; |
942 | 31 |
|
32 |
/** |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
33 |
* Provides simple functionalities for javac diagnostic formatting. |
942 | 34 |
* @param <D> type of diagnostic handled by this formatter |
3380
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2212
diff
changeset
|
35 |
* |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2212
diff
changeset
|
36 |
* <p><b>This is NOT part of any API supported by Sun Microsystems. |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2212
diff
changeset
|
37 |
* If you write code that depends on this, you do so at your own risk. |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2212
diff
changeset
|
38 |
* This code and its internal interfaces are subject to change or |
a6c2bcab0fec
6865399: some javac files are missing Sun internal API comment
jjg
parents:
2212
diff
changeset
|
39 |
* deletion without notice.</b> |
942 | 40 |
*/ |
41 |
public interface DiagnosticFormatter<D extends Diagnostic<?>> { |
|
42 |
||
43 |
/** |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
44 |
* Whether the source code output for this diagnostic is to be displayed. |
942 | 45 |
* |
46 |
* @param diag diagnostic to be formatted |
|
47 |
* @return true if the source line this diagnostic refers to is to be displayed |
|
48 |
*/ |
|
49 |
boolean displaySource(D diag); |
|
50 |
||
51 |
/** |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
52 |
* Format the contents of a diagnostics. |
942 | 53 |
* |
54 |
* @param diag the diagnostic to be formatted |
|
55 |
* @param l locale object to be used for i18n |
|
56 |
* @return a string representing the diagnostic |
|
57 |
*/ |
|
58 |
public String format(D diag, Locale l); |
|
59 |
||
60 |
/** |
|
61 |
* Controls the way in which a diagnostic message is displayed. |
|
62 |
* |
|
63 |
* @param diag diagnostic to be formatted |
|
64 |
* @param l locale object to be used for i18n |
|
65 |
* @return string representation of the diagnostic message |
|
66 |
*/ |
|
67 |
public String formatMessage(D diag,Locale l); |
|
68 |
||
69 |
/** |
|
70 |
* Controls the way in which a diagnostic kind is displayed. |
|
71 |
* |
|
72 |
* @param diag diagnostic to be formatted |
|
73 |
* @param l locale object to be used for i18n |
|
74 |
* @return string representation of the diagnostic prefix |
|
75 |
*/ |
|
76 |
public String formatKind(D diag, Locale l); |
|
77 |
||
78 |
/** |
|
79 |
* Controls the way in which a diagnostic source is displayed. |
|
80 |
* |
|
81 |
* @param diag diagnostic to be formatted |
|
82 |
* @param l locale object to be used for i18n |
|
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
83 |
* @param fullname whether the source fullname should be printed |
942 | 84 |
* @return string representation of the diagnostic source |
85 |
*/ |
|
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
942
diff
changeset
|
86 |
public String formatSource(D diag, boolean fullname, Locale l); |
942 | 87 |
|
88 |
/** |
|
89 |
* Controls the way in which a diagnostic position is displayed. |
|
90 |
* |
|
91 |
* @param diag diagnostic to be formatted |
|
92 |
* @param pk enum constant representing the position kind |
|
93 |
* @param l locale object to be used for i18n |
|
94 |
* @return string representation of the diagnostic position |
|
95 |
*/ |
|
96 |
public String formatPosition(D diag, PositionKind pk, Locale l); |
|
97 |
//where |
|
98 |
/** |
|
99 |
* This enum defines a set of constants for all the kinds of position |
|
100 |
* that a diagnostic can be asked for. All positions are intended to be |
|
101 |
* relative to a given diagnostic source. |
|
102 |
*/ |
|
103 |
public enum PositionKind { |
|
104 |
/** |
|
105 |
* Start position |
|
106 |
*/ |
|
107 |
START, |
|
108 |
/** |
|
109 |
* End position |
|
110 |
*/ |
|
111 |
END, |
|
112 |
/** |
|
113 |
* Line number |
|
114 |
*/ |
|
115 |
LINE, |
|
116 |
/** |
|
117 |
* Column number |
|
118 |
*/ |
|
119 |
COLUMN, |
|
120 |
/** |
|
121 |
* Offset position |
|
122 |
*/ |
|
123 |
OFFSET |
|
124 |
} |
|
2085
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
125 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
126 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
127 |
* Get a list of all the enabled verbosity options. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
128 |
* @return verbosity options |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
129 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
130 |
public Configuration getConfiguration(); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
131 |
//where |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
132 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
133 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
134 |
* This interface provides functionalities for tuning the output of a |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
135 |
* diagnostic formatter in multiple ways. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
136 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
137 |
interface Configuration { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
138 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
139 |
* Configure the set of diagnostic parts that should be displayed |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
140 |
* by the formatter. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
141 |
* @param options options to set |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
142 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
143 |
public void setVisible(Set<DiagnosticPart> visibleParts); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
144 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
145 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
146 |
* Retrieve the set of diagnostic parts that should be displayed |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
147 |
* by the formatter. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
148 |
* @return verbosity options |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
149 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
150 |
public Set<DiagnosticPart> getVisible(); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
151 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
152 |
//where |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
153 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
154 |
* A given diagnostic message can be divided into sub-parts each of which |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
155 |
* might/might not be displayed by the formatter, according to the |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
156 |
* current configuration settings. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
157 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
158 |
public enum DiagnosticPart { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
159 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
160 |
* Short description of the diagnostic - usually one line long. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
161 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
162 |
SUMMARY, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
163 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
164 |
* Longer description that provides additional details w.r.t. the ones |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
165 |
* in the diagnostic's description. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
166 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
167 |
DETAILS, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
168 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
169 |
* Source line the diagnostic refers to (if applicable). |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
170 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
171 |
SOURCE, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
172 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
173 |
* Subdiagnostics attached to a given multiline diagnostic. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
174 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
175 |
SUBDIAGNOSTICS, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
176 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
177 |
* JLS paragraph this diagnostic might refer to (if applicable). |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
178 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
179 |
JLS; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
180 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
181 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
182 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
183 |
* Set a limit for multiline diagnostics. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
184 |
* Note: Setting a limit has no effect if multiline diagnostics are either |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
185 |
* fully enabled or disabled. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
186 |
* |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
187 |
* @param limit the kind of limit to be set |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
188 |
* @param value the limit value |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
189 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
190 |
public void setMultilineLimit(MultilineLimit limit, int value); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
191 |
|
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
192 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
193 |
* Get a multiline diagnostic limit. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
194 |
* |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
195 |
* @param limit the kind of limit to be retrieved |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
196 |
* @return limit value or -1 if no limit is set |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
197 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
198 |
public int getMultilineLimit(MultilineLimit limit); |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
199 |
//where |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
200 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
201 |
* A multiline limit control the verbosity of multiline diagnostics |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
202 |
* either by setting a maximum depth of nested multidiagnostics, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
203 |
* or by limiting the amount of subdiagnostics attached to a given |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
204 |
* diagnostic (or both). |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
205 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
206 |
public enum MultilineLimit { |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
207 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
208 |
* Controls the maximum depth of nested multiline diagnostics. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
209 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
210 |
DEPTH, |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
211 |
/** |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
212 |
* Controls the maximum amount of subdiagnostics that are part of a |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
213 |
* given multiline diagnostic. |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
214 |
*/ |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
215 |
LENGTH; |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
216 |
} |
4792e12a8ca2
6769027: Source line should be displayed immediately after the first diagnostic line
mcimadamore
parents:
1109
diff
changeset
|
217 |
} |
942 | 218 |
} |