author | vromero |
Fri, 02 Feb 2018 07:43:54 -0500 | |
changeset 48721 | ef3557eb4306 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
867 | 1 |
/* |
48721
ef3557eb4306
8196403: remove the remaining use of string keys for errors and warnings in the compiler
vromero
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
867 | 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 |
867 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
867 | 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. |
|
867 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.util; |
|
27 |
||
28 |
import java.util.HashMap; |
|
29 |
import java.util.Map; |
|
30 |
import javax.tools.JavaFileObject; |
|
31 |
||
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
32 |
import com.sun.tools.javac.code.Lint.LintCategory; |
7076
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
33 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag; |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
34 |
import com.sun.tools.javac.util.JCDiagnostic.Error; |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
35 |
import com.sun.tools.javac.util.JCDiagnostic.Note; |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
36 |
import com.sun.tools.javac.util.JCDiagnostic.Warning; |
867 | 37 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
38 |
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; |
|
39 |
||
40 |
||
41 |
/** |
|
42 |
* A base class for error logs. Reports errors and warnings, and |
|
43 |
* keeps track of error numbers and positions. |
|
44 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
45 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
46 |
* If you write code that depends on this, you do so at your own risk. |
867 | 47 |
* This code and its internal interfaces are subject to change or |
48 |
* deletion without notice.</b> |
|
49 |
*/ |
|
50 |
public abstract class AbstractLog { |
|
22163 | 51 |
/** Factory for diagnostics |
52 |
*/ |
|
53 |
protected JCDiagnostic.Factory diags; |
|
54 |
||
55 |
/** The file that's currently being translated. |
|
56 |
*/ |
|
57 |
protected DiagnosticSource source; |
|
58 |
||
59 |
/** A cache of lightweight DiagnosticSource objects. |
|
60 |
*/ |
|
61 |
protected Map<JavaFileObject, DiagnosticSource> sourceMap; |
|
62 |
||
867 | 63 |
AbstractLog(JCDiagnostic.Factory diags) { |
64 |
this.diags = diags; |
|
22163 | 65 |
sourceMap = new HashMap<>(); |
867 | 66 |
} |
67 |
||
68 |
/** Re-assign source, returning previous setting. |
|
69 |
*/ |
|
70 |
public JavaFileObject useSource(JavaFileObject file) { |
|
71 |
JavaFileObject prev = (source == null ? null : source.getFile()); |
|
72 |
source = getSource(file); |
|
73 |
return prev; |
|
74 |
} |
|
75 |
||
76 |
protected DiagnosticSource getSource(JavaFileObject file) { |
|
77 |
if (file == null) |
|
3144
202fa249dc34
6852595: Accessing scope using JSR199 API on erroneous tree causes Illegal Argument Exception
mcimadamore
parents:
1591
diff
changeset
|
78 |
return DiagnosticSource.NO_SOURCE; |
867 | 79 |
DiagnosticSource s = sourceMap.get(file); |
80 |
if (s == null) { |
|
81 |
s = new DiagnosticSource(file, this); |
|
82 |
sourceMap.put(file, s); |
|
83 |
} |
|
84 |
return s; |
|
85 |
} |
|
86 |
||
1591 | 87 |
/** Return the underlying diagnostic source |
88 |
*/ |
|
89 |
public DiagnosticSource currentSource() { |
|
90 |
return source; |
|
91 |
} |
|
92 |
||
867 | 93 |
/** Report an error, unless another error was already reported at same |
94 |
* source position. |
|
95 |
* @param key The key for the localized error message. |
|
96 |
* @param args Fields of the error message. |
|
97 |
*/ |
|
98 |
public void error(String key, Object ... args) { |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
99 |
error(diags.errorKey(key, args)); |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
100 |
} |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
101 |
|
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
102 |
/** Report an error, unless another error was already reported at same |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
103 |
* source position. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
104 |
* @param errorKey The key for the localized error message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
105 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
106 |
public void error(Error errorKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
107 |
report(diags.error(null, source, null, errorKey)); |
867 | 108 |
} |
109 |
||
110 |
/** Report an error, unless another error was already reported at same |
|
111 |
* source position. |
|
112 |
* @param pos The source position at which to report the error. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
113 |
* @param errorKey The key for the localized error message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
114 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
115 |
public void error(DiagnosticPosition pos, Error errorKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
116 |
report(diags.error(null, source, pos, errorKey)); |
867 | 117 |
} |
118 |
||
119 |
/** Report an error, unless another error was already reported at same |
|
120 |
* source position. |
|
10455
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
121 |
* @param flag A flag to set on the diagnostic |
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
122 |
* @param pos The source position at which to report the error. |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
123 |
* @param errorKey The key for the localized error message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
124 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
125 |
public void error(DiagnosticFlag flag, DiagnosticPosition pos, Error errorKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
126 |
report(diags.error(flag, source, pos, errorKey)); |
10455
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
127 |
} |
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
128 |
|
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
129 |
/** Report an error, unless another error was already reported at same |
3d070be0fff8
7073631: (javac) javac parser improvements for error position reporting
ksrini
parents:
7681
diff
changeset
|
130 |
* source position. |
867 | 131 |
* @param pos The source position at which to report the error. |
132 |
* @param key The key for the localized error message. |
|
133 |
* @param args Fields of the error message. |
|
134 |
*/ |
|
135 |
public void error(int pos, String key, Object ... args) { |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
136 |
error(pos, diags.errorKey(key, args)); |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
137 |
} |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
138 |
|
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
139 |
/** Report an error, unless another error was already reported at same |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
140 |
* source position. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
141 |
* @param pos The source position at which to report the error. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
142 |
* @param errorKey The key for the localized error message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
143 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
144 |
public void error(int pos, Error errorKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
145 |
report(diags.error(null, source, wrap(pos), errorKey)); |
867 | 146 |
} |
147 |
||
7076
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
148 |
/** Report an error, unless another error was already reported at same |
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
149 |
* source position. |
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
150 |
* @param flag A flag to set on the diagnostic |
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
151 |
* @param pos The source position at which to report the error. |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
152 |
* @param errorKey The key for the localized error message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
153 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
154 |
public void error(DiagnosticFlag flag, int pos, Error errorKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
155 |
report(diags.error(flag, source, wrap(pos), errorKey)); |
7076
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
156 |
} |
c96fa26247c8
6994946: option to specify only syntax errors as unrecoverable
jjg
parents:
6151
diff
changeset
|
157 |
|
867 | 158 |
/** Report a warning, unless suppressed by the -nowarn option or the |
159 |
* maximum number of warnings has been reached. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
160 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
161 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
162 |
public void warning(Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
163 |
report(diags.warning(null, source, null, warningKey)); |
867 | 164 |
} |
165 |
||
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
166 |
/** Report a lint warning, unless suppressed by the -nowarn option or the |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
167 |
* maximum number of warnings has been reached. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
168 |
* @param lc The lint category for the diagnostic |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
169 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
170 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
171 |
public void warning(LintCategory lc, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
172 |
report(diags.warning(lc, null, null, warningKey)); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
173 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
174 |
|
867 | 175 |
/** Report a warning, unless suppressed by the -nowarn option or the |
176 |
* maximum number of warnings has been reached. |
|
177 |
* @param pos The source position at which to report the warning. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
178 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
179 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
180 |
public void warning(DiagnosticPosition pos, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
181 |
report(diags.warning(null, source, pos, warningKey)); |
867 | 182 |
} |
183 |
||
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
184 |
/** Report a lint warning, unless suppressed by the -nowarn option or the |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
185 |
* maximum number of warnings has been reached. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
186 |
* @param lc The lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
187 |
* @param pos The source position at which to report the warning. |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
188 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
189 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
190 |
public void warning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
191 |
report(diags.warning(lc, source, pos, warningKey)); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
192 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
193 |
|
867 | 194 |
/** Report a warning, unless suppressed by the -nowarn option or the |
195 |
* maximum number of warnings has been reached. |
|
196 |
* @param pos The source position at which to report the warning. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
197 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
198 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
199 |
public void warning(int pos, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
200 |
report(diags.warning(null, source, wrap(pos), warningKey)); |
867 | 201 |
} |
202 |
||
203 |
/** Report a warning. |
|
204 |
* @param pos The source position at which to report the warning. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
205 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
206 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
207 |
public void mandatoryWarning(DiagnosticPosition pos, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
208 |
report(diags.mandatoryWarning(null, source, pos, warningKey)); |
867 | 209 |
} |
210 |
||
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
211 |
/** Report a warning. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
212 |
* @param lc The lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
213 |
* @param pos The source position at which to report the warning. |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
214 |
* @param warningKey The key for the localized warning message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
215 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
216 |
public void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, Warning warningKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
217 |
report(diags.mandatoryWarning(lc, source, pos, warningKey)); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
218 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
219 |
|
867 | 220 |
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. |
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
221 |
* @param noteKey The key for the localized notification message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
222 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
223 |
public void note(Note noteKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
224 |
report(diags.note(source, null, noteKey)); |
867 | 225 |
} |
226 |
||
227 |
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
228 |
* @param noteKey The key for the localized notification message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
229 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
230 |
public void note(DiagnosticPosition pos, Note noteKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
231 |
report(diags.note(source, pos, noteKey)); |
867 | 232 |
} |
233 |
||
234 |
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
235 |
* @param noteKey The key for the localized notification message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
236 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
237 |
public void note(int pos, Note noteKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
238 |
report(diags.note(source, wrap(pos), noteKey)); |
867 | 239 |
} |
240 |
||
241 |
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
242 |
* @param noteKey The key for the localized notification message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
243 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
244 |
public void note(JavaFileObject file, Note noteKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
245 |
report(diags.note(getSource(file), null, noteKey)); |
867 | 246 |
} |
247 |
||
248 |
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. |
|
28334
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
249 |
* @param noteKey The key for the localized notification message. |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
250 |
*/ |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
251 |
public void mandatoryNote(final JavaFileObject file, Note noteKey) { |
1633de6070ae
8058542: Devise scheme for better diagnostic creation
mcimadamore
parents:
25874
diff
changeset
|
252 |
report(diags.mandatoryNote(getSource(file), noteKey)); |
867 | 253 |
} |
254 |
||
255 |
protected abstract void report(JCDiagnostic diagnostic); |
|
256 |
||
257 |
protected abstract void directError(String key, Object... args); |
|
258 |
||
259 |
private DiagnosticPosition wrap(int pos) { |
|
260 |
return (pos == Position.NOPOS ? null : new SimpleDiagnosticPosition(pos)); |
|
261 |
} |
|
262 |
} |