author | jjg |
Mon, 23 Aug 2010 15:13:33 -0700 | |
changeset 6356 | af24929939ca |
parent 6151 | dd513881e71d |
child 7076 | c96fa26247c8 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.util; |
|
27 |
||
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
28 |
import java.util.EnumSet; |
10 | 29 |
import java.util.Locale; |
30 |
import java.util.Map; |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
31 |
import java.util.Set; |
10 | 32 |
|
33 |
import javax.tools.Diagnostic; |
|
34 |
import javax.tools.JavaFileObject; |
|
35 |
||
942 | 36 |
import com.sun.tools.javac.api.DiagnosticFormatter; |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
37 |
import com.sun.tools.javac.code.Lint.LintCategory; |
10 | 38 |
import com.sun.tools.javac.tree.JCTree; |
39 |
||
40 |
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*; |
|
41 |
||
42 |
/** An abstraction of a diagnostic message generated by the compiler. |
|
43 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
44 |
* <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
|
45 |
* If you write code that depends on this, you do so at your own risk. |
10 | 46 |
* This code and its internal interfaces are subject to change or |
47 |
* deletion without notice.</b> |
|
48 |
*/ |
|
49 |
public class JCDiagnostic implements Diagnostic<JavaFileObject> { |
|
50 |
/** A factory for creating diagnostic objects. */ |
|
51 |
public static class Factory { |
|
52 |
/** The context key for the diagnostic factory. */ |
|
53 |
protected static final Context.Key<JCDiagnostic.Factory> diagnosticFactoryKey = |
|
54 |
new Context.Key<JCDiagnostic.Factory>(); |
|
55 |
||
56 |
/** Get the Factory instance for this context. */ |
|
57 |
public static Factory instance(Context context) { |
|
58 |
Factory instance = context.get(diagnosticFactoryKey); |
|
59 |
if (instance == null) |
|
60 |
instance = new Factory(context); |
|
61 |
return instance; |
|
62 |
} |
|
63 |
||
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
64 |
DiagnosticFormatter<JCDiagnostic> formatter; |
10 | 65 |
final String prefix; |
66 |
||
67 |
/** Create a new diagnostic factory. */ |
|
68 |
protected Factory(Context context) { |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
69 |
this(JavacMessages.instance(context), "compiler"); |
10 | 70 |
context.put(diagnosticFactoryKey, this); |
71 |
} |
|
72 |
||
73 |
/** Create a new diagnostic factory. */ |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
74 |
public Factory(JavacMessages messages, String prefix) { |
10 | 75 |
this.prefix = prefix; |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
76 |
this.formatter = new BasicDiagnosticFormatter(messages); |
10 | 77 |
} |
78 |
||
79 |
/** |
|
80 |
* Create an error diagnostic. |
|
81 |
* @param source The source of the compilation unit, if any, in which to report the error. |
|
82 |
* @param pos The source position at which to report the error. |
|
83 |
* @param key The key for the localized error message. |
|
84 |
* @param args Fields of the error message. |
|
85 |
*/ |
|
86 |
public JCDiagnostic error( |
|
87 |
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
88 |
return create(ERROR, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args); |
10 | 89 |
} |
90 |
||
91 |
/** |
|
92 |
* Create a warning diagnostic that will not be hidden by the -nowarn or -Xlint:none options. |
|
93 |
* @param source The source of the compilation unit, if any, in which to report the warning. |
|
94 |
* @param pos The source position at which to report the warning. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
95 |
* @param key The key for the localized warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
96 |
* @param args Fields of the warning message. |
10 | 97 |
* @see MandatoryWarningHandler |
98 |
*/ |
|
99 |
public JCDiagnostic mandatoryWarning( |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
100 |
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
101 |
return create(WARNING, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
102 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
103 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
104 |
/** |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
105 |
* Create a warning diagnostic that will not be hidden by the -nowarn or -Xlint:none options. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
106 |
* @param lc The lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
107 |
* @param source The source of the compilation unit, if any, in which to report the warning. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
108 |
* @param pos The source position at which to report the warning. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
109 |
* @param key The key for the localized warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
110 |
* @param args Fields of the warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
111 |
* @see MandatoryWarningHandler |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
112 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
113 |
public JCDiagnostic mandatoryWarning( |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
114 |
LintCategory lc, |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
115 |
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
116 |
return create(WARNING, lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
117 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
118 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
119 |
/** |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
120 |
* Create a warning diagnostic. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
121 |
* @param lc The lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
122 |
* @param key The key for the localized error message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
123 |
* @param args Fields of the warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
124 |
* @see MandatoryWarningHandler |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
125 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
126 |
public JCDiagnostic warning( |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
127 |
LintCategory lc, String key, Object... args) { |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
128 |
return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args); |
10 | 129 |
} |
130 |
||
131 |
/** |
|
132 |
* Create a warning diagnostic. |
|
133 |
* @param source The source of the compilation unit, if any, in which to report the warning. |
|
134 |
* @param pos The source position at which to report the warning. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
135 |
* @param key The key for the localized warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
136 |
* @param args Fields of the warning message. |
10 | 137 |
*/ |
138 |
public JCDiagnostic warning( |
|
139 |
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
140 |
return create(WARNING, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
141 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
142 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
143 |
/** |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
144 |
* Create a warning diagnostic. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
145 |
* @param lc The lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
146 |
* @param source The source of the compilation unit, if any, in which to report the warning. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
147 |
* @param pos The source position at which to report the warning. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
148 |
* @param key The key for the localized warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
149 |
* @param args Fields of the warning message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
150 |
* @see MandatoryWarningHandler |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
151 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
152 |
public JCDiagnostic warning( |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
153 |
LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
154 |
return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args); |
10 | 155 |
} |
156 |
||
157 |
/** |
|
158 |
* Create a note diagnostic that will not be hidden by the -nowarn or -Xlint:none options. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
159 |
* @param key The key for the localized message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
160 |
* @param args Fields of the message. |
10 | 161 |
* @see MandatoryWarningHandler |
162 |
*/ |
|
163 |
public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
164 |
return create(NOTE, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, key, args); |
10 | 165 |
} |
166 |
||
167 |
/** |
|
168 |
* Create a note diagnostic. |
|
169 |
* @param key The key for the localized error message. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
170 |
* @param args Fields of the message. |
10 | 171 |
*/ |
172 |
public JCDiagnostic note(String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
173 |
return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args); |
10 | 174 |
} |
175 |
||
176 |
/** |
|
177 |
* Create a note diagnostic. |
|
178 |
* @param source The source of the compilation unit, if any, in which to report the note. |
|
179 |
* @param pos The source position at which to report the note. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
180 |
* @param key The key for the localized message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
181 |
* @param args Fields of the message. |
10 | 182 |
*/ |
183 |
public JCDiagnostic note( |
|
184 |
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
185 |
return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args); |
10 | 186 |
} |
187 |
||
188 |
/** |
|
189 |
* Create a fragment diagnostic, for use as an argument in other diagnostics |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
190 |
* @param key The key for the localized message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
191 |
* @param args Fields of the message. |
10 | 192 |
*/ |
193 |
public JCDiagnostic fragment(String key, Object... args) { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
194 |
return create(FRAGMENT, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args); |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
195 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
196 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
197 |
/** |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
198 |
* Create a new diagnostic of the given kind, which is not mandatory and which has |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
199 |
* no lint category. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
200 |
* @param kind The diagnostic kind |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
201 |
* @param ls The lint category, if applicable, or null |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
202 |
* @param source The source of the compilation unit, if any, in which to report the message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
203 |
* @param pos The source position at which to report the message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
204 |
* @param key The key for the localized message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
205 |
* @param args Fields of the message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
206 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
207 |
public JCDiagnostic create( |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
208 |
DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
209 |
return create(kind, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args); |
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
210 |
} |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
211 |
|
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
212 |
/** |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
213 |
* Create a new diagnostic of the given kind. |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
214 |
* @param kind The diagnostic kind |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
215 |
* @param lc The lint category, if applicable, or null |
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
216 |
* @param isMandatory is diagnostic mandatory? |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
217 |
* @param source The source of the compilation unit, if any, in which to report the message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
218 |
* @param pos The source position at which to report the message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
219 |
* @param key The key for the localized message. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
220 |
* @param args Fields of the message. |
3143
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
221 |
*/ |
0413d5b5b7fd
6822637: ResolveError hierarchy needs to be refactored
mcimadamore
parents:
1591
diff
changeset
|
222 |
public JCDiagnostic create( |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
223 |
DiagnosticType kind, LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) { |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
224 |
return new JCDiagnostic(formatter, kind, lc, flags, source, pos, qualify(kind, key), args); |
10 | 225 |
} |
226 |
||
227 |
protected String qualify(DiagnosticType t, String key) { |
|
228 |
return prefix + "." + t.key + "." + key; |
|
229 |
} |
|
230 |
} |
|
231 |
||
232 |
||
233 |
||
234 |
/** |
|
235 |
* Create a fragment diagnostic, for use as an argument in other diagnostics |
|
236 |
* @param key The key for the localized error message. |
|
237 |
* @param args Fields of the error message. |
|
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
238 |
* |
10 | 239 |
*/ |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
240 |
@Deprecated |
10 | 241 |
public static JCDiagnostic fragment(String key, Object... args) { |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
242 |
return new JCDiagnostic(getFragmentFormatter(), |
10 | 243 |
FRAGMENT, |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
244 |
null, |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
245 |
EnumSet.noneOf(DiagnosticFlag.class), |
10 | 246 |
null, |
247 |
null, |
|
248 |
"compiler." + FRAGMENT.key + "." + key, |
|
249 |
args); |
|
250 |
} |
|
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
251 |
//where |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
252 |
@Deprecated |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
253 |
public static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter() { |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
254 |
if (fragmentFormatter == null) { |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1109
diff
changeset
|
255 |
fragmentFormatter = new BasicDiagnosticFormatter(JavacMessages.getDefaultMessages()); |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
256 |
} |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
257 |
return fragmentFormatter; |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
258 |
} |
10 | 259 |
|
260 |
/** |
|
261 |
* A DiagnosticType defines the type of the diagnostic. |
|
262 |
**/ |
|
263 |
public enum DiagnosticType { |
|
264 |
/** A fragment of an enclosing diagnostic. */ |
|
265 |
FRAGMENT("misc"), |
|
266 |
/** A note: similar to, but less serious than, a warning. */ |
|
267 |
NOTE("note"), |
|
268 |
/** A warning. */ |
|
269 |
WARNING("warn"), |
|
270 |
/** An error. */ |
|
271 |
ERROR("err"); |
|
272 |
||
273 |
final String key; |
|
274 |
||
275 |
/** Create a DiagnosticType. |
|
276 |
* @param key A string used to create the resource key for the diagnostic. |
|
277 |
*/ |
|
278 |
DiagnosticType(String key) { |
|
279 |
this.key = key; |
|
280 |
} |
|
281 |
}; |
|
282 |
||
283 |
/** |
|
284 |
* A DiagnosticPosition provides information about the positions in a file |
|
285 |
* that gave rise to a diagnostic. It always defines a "preferred" position |
|
286 |
* that most accurately defines the location of the diagnostic, it may also |
|
287 |
* provide a related tree node that spans that location. |
|
288 |
*/ |
|
289 |
public static interface DiagnosticPosition { |
|
290 |
/** Gets the tree node, if any, to which the diagnostic applies. */ |
|
291 |
JCTree getTree(); |
|
292 |
/** If there is a tree node, get the start position of the tree node. |
|
293 |
* Otherwise, just returns the same as getPreferredPosition(). */ |
|
294 |
int getStartPosition(); |
|
295 |
/** Get the position within the file that most accurately defines the |
|
296 |
* location for the diagnostic. */ |
|
297 |
int getPreferredPosition(); |
|
298 |
/** If there is a tree node, and if endPositions are available, get |
|
299 |
* the end position of the tree node. Otherwise, just returns the |
|
300 |
* same as getPreferredPosition(). */ |
|
301 |
int getEndPosition(Map<JCTree, Integer> endPosTable); |
|
302 |
} |
|
303 |
||
304 |
/** |
|
305 |
* A DiagnosticPosition that simply identifies a position, but no related |
|
306 |
* tree node, as the location for a diagnostic. Used for scanner and parser |
|
307 |
* diagnostics. */ |
|
308 |
public static class SimpleDiagnosticPosition implements DiagnosticPosition { |
|
309 |
public SimpleDiagnosticPosition(int pos) { |
|
310 |
this.pos = pos; |
|
311 |
} |
|
312 |
||
313 |
public JCTree getTree() { |
|
314 |
return null; |
|
315 |
} |
|
316 |
||
317 |
public int getStartPosition() { |
|
318 |
return pos; |
|
319 |
} |
|
320 |
||
321 |
public int getPreferredPosition() { |
|
322 |
return pos; |
|
323 |
} |
|
324 |
||
325 |
public int getEndPosition(Map<JCTree, Integer> endPosTable) { |
|
326 |
return pos; |
|
327 |
} |
|
328 |
||
329 |
private final int pos; |
|
330 |
} |
|
331 |
||
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
332 |
public enum DiagnosticFlag { |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
333 |
MANDATORY, |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
334 |
RESOLVE_ERROR |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
335 |
} |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
336 |
|
10 | 337 |
private final DiagnosticType type; |
338 |
private final DiagnosticSource source; |
|
339 |
private final DiagnosticPosition position; |
|
340 |
private final int line; |
|
341 |
private final int column; |
|
342 |
private final String key; |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
343 |
protected final Object[] args; |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
344 |
private final Set<DiagnosticFlag> flags; |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
345 |
private final LintCategory lintCategory; |
10 | 346 |
|
347 |
/** |
|
348 |
* Create a diagnostic object. |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
349 |
* @param fomatter the formatter to use for the diagnostic |
10 | 350 |
* @param dt the type of diagnostic |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
351 |
* @param lc the lint category for the diagnostic |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
352 |
* @param source the name of the source file, or null if none. |
10 | 353 |
* @param pos the character offset within the source file, if given. |
354 |
* @param key a resource key to identify the text of the diagnostic |
|
355 |
* @param args arguments to be included in the text of the diagnostic |
|
356 |
*/ |
|
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
357 |
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter, |
10 | 358 |
DiagnosticType dt, |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
359 |
LintCategory lc, |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
360 |
Set<DiagnosticFlag> flags, |
10 | 361 |
DiagnosticSource source, |
362 |
DiagnosticPosition pos, |
|
363 |
String key, |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
364 |
Object... args) { |
10 | 365 |
if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS) |
366 |
throw new IllegalArgumentException(); |
|
367 |
||
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
368 |
this.defaultFormatter = formatter; |
10 | 369 |
this.type = dt; |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
370 |
this.lintCategory = lc; |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
371 |
this.flags = flags; |
10 | 372 |
this.source = source; |
373 |
this.position = pos; |
|
374 |
this.key = key; |
|
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
375 |
this.args = args; |
10 | 376 |
|
377 |
int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition()); |
|
378 |
if (n == Position.NOPOS || source == null) |
|
379 |
line = column = -1; |
|
380 |
else { |
|
381 |
line = source.getLineNumber(n); |
|
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
1040
diff
changeset
|
382 |
column = source.getColumnNumber(n, true); |
10 | 383 |
} |
384 |
} |
|
385 |
||
386 |
/** |
|
387 |
* Get the type of this diagnostic. |
|
388 |
* @return the type of this diagnostic |
|
389 |
*/ |
|
390 |
public DiagnosticType getType() { |
|
391 |
return type; |
|
392 |
} |
|
393 |
||
394 |
/** |
|
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
395 |
* Get the subdiagnostic list |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
396 |
* @return subdiagnostic list |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
397 |
*/ |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
398 |
public List<JCDiagnostic> getSubdiagnostics() { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
399 |
return List.nil(); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
400 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
401 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
402 |
public boolean isMultiline() { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
403 |
return false; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
404 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
405 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
406 |
/** |
10 | 407 |
* Check whether or not this diagnostic is required to be shown. |
408 |
* @return true if this diagnostic is required to be shown. |
|
409 |
*/ |
|
410 |
public boolean isMandatory() { |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
411 |
return flags.contains(DiagnosticFlag.MANDATORY); |
10 | 412 |
} |
413 |
||
414 |
/** |
|
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
415 |
* Check whether this diagnostic has an associated lint category. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
416 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
417 |
public boolean hasLintCategory() { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
418 |
return (lintCategory != null); |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
419 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
420 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
421 |
/** |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
422 |
* Get the associated lint category, or null if none. |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
423 |
*/ |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
424 |
public LintCategory getLintCategory() { |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
425 |
return lintCategory; |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
426 |
} |
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
427 |
|
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
428 |
/** |
10 | 429 |
* Get the name of the source file referred to by this diagnostic. |
430 |
* @return the name of the source referred to with this diagnostic, or null if none |
|
431 |
*/ |
|
432 |
public JavaFileObject getSource() { |
|
433 |
if (source == null) |
|
434 |
return null; |
|
435 |
else |
|
436 |
return source.getFile(); |
|
437 |
} |
|
438 |
||
439 |
/** |
|
440 |
* Get the source referred to by this diagnostic. |
|
441 |
* @return the source referred to with this diagnostic, or null if none |
|
442 |
*/ |
|
443 |
public DiagnosticSource getDiagnosticSource() { |
|
444 |
return source; |
|
445 |
} |
|
446 |
||
447 |
protected int getIntStartPosition() { |
|
448 |
return (position == null ? Position.NOPOS : position.getStartPosition()); |
|
449 |
} |
|
450 |
||
451 |
protected int getIntPosition() { |
|
452 |
return (position == null ? Position.NOPOS : position.getPreferredPosition()); |
|
453 |
} |
|
454 |
||
455 |
protected int getIntEndPosition() { |
|
456 |
return (position == null ? Position.NOPOS : position.getEndPosition(source.getEndPosTable())); |
|
457 |
} |
|
458 |
||
459 |
public long getStartPosition() { |
|
460 |
return getIntStartPosition(); |
|
461 |
} |
|
462 |
||
463 |
public long getPosition() { |
|
464 |
return getIntPosition(); |
|
465 |
} |
|
466 |
||
467 |
public long getEndPosition() { |
|
468 |
return getIntEndPosition(); |
|
469 |
} |
|
470 |
||
471 |
/** |
|
472 |
* Get the line number within the source referred to by this diagnostic. |
|
473 |
* @return the line number within the source referred to by this diagnostic |
|
474 |
*/ |
|
475 |
public long getLineNumber() { |
|
476 |
return line; |
|
477 |
} |
|
478 |
||
479 |
/** |
|
480 |
* Get the column number within the line of source referred to by this diagnostic. |
|
481 |
* @return the column number within the line of source referred to by this diagnostic |
|
482 |
*/ |
|
483 |
public long getColumnNumber() { |
|
484 |
return column; |
|
485 |
} |
|
486 |
||
487 |
/** |
|
488 |
* Get the arguments to be included in the text of the diagnostic. |
|
489 |
* @return the arguments to be included in the text of the diagnostic |
|
490 |
*/ |
|
491 |
public Object[] getArgs() { |
|
492 |
return args; |
|
493 |
} |
|
494 |
||
495 |
/** |
|
496 |
* Get the prefix string associated with this type of diagnostic. |
|
497 |
* @return the prefix string associated with this type of diagnostic |
|
498 |
*/ |
|
499 |
public String getPrefix() { |
|
500 |
return getPrefix(type); |
|
501 |
} |
|
502 |
||
503 |
/** |
|
504 |
* Get the prefix string associated with a particular type of diagnostic. |
|
505 |
* @return the prefix string associated with a particular type of diagnostic |
|
506 |
*/ |
|
507 |
public String getPrefix(DiagnosticType dt) { |
|
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
508 |
return defaultFormatter.formatKind(this, Locale.getDefault()); |
942 | 509 |
} |
510 |
||
10 | 511 |
/** |
512 |
* Return the standard presentation of this diagnostic. |
|
513 |
*/ |
|
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
3143
diff
changeset
|
514 |
@Override |
10 | 515 |
public String toString() { |
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
516 |
return defaultFormatter.format(this,Locale.getDefault()); |
10 | 517 |
} |
518 |
||
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
519 |
private DiagnosticFormatter<JCDiagnostic> defaultFormatter; |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
520 |
@Deprecated |
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
521 |
private static DiagnosticFormatter<JCDiagnostic> fragmentFormatter; |
10 | 522 |
|
523 |
// Methods for javax.tools.Diagnostic |
|
524 |
||
525 |
public Diagnostic.Kind getKind() { |
|
526 |
switch (type) { |
|
527 |
case NOTE: |
|
528 |
return Diagnostic.Kind.NOTE; |
|
529 |
case WARNING: |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
530 |
return flags.contains(DiagnosticFlag.MANDATORY) |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
531 |
? Diagnostic.Kind.MANDATORY_WARNING |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
532 |
: Diagnostic.Kind.WARNING; |
10 | 533 |
case ERROR: |
534 |
return Diagnostic.Kind.ERROR; |
|
535 |
default: |
|
536 |
return Diagnostic.Kind.OTHER; |
|
537 |
} |
|
538 |
} |
|
539 |
||
540 |
public String getCode() { |
|
541 |
return key; |
|
542 |
} |
|
543 |
||
544 |
public String getMessage(Locale locale) { |
|
1040
c0f5acfd9d15
6730423: Diagnostic formatter should be an instance field of JCDiagnostic
mcimadamore
parents:
942
diff
changeset
|
545 |
return defaultFormatter.formatMessage(this, locale); |
10 | 546 |
} |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
547 |
|
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
548 |
public void setFlag(DiagnosticFlag flag) { |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
549 |
flags.add(flag); |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
550 |
} |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
551 |
|
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
552 |
public boolean isFlagSet(DiagnosticFlag flag) { |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
553 |
return flags.contains(flag); |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
554 |
} |
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
555 |
|
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
556 |
public static class MultilineDiagnostic extends JCDiagnostic { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
557 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
558 |
private final List<JCDiagnostic> subdiagnostics; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
559 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
560 |
public MultilineDiagnostic(JCDiagnostic other, List<JCDiagnostic> subdiagnostics) { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
561 |
super(other.defaultFormatter, |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
562 |
other.getType(), |
6151
dd513881e71d
6957438: improve code for generating warning messages containing option names
jjg
parents:
5847
diff
changeset
|
563 |
other.getLintCategory(), |
6356
af24929939ca
6976747: JCDiagnostic: replace "boolean mandatory" with new "Set<JCDiagnostic.Flag>"
jjg
parents:
6151
diff
changeset
|
564 |
other.flags, |
1591
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
565 |
other.getDiagnosticSource(), |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
566 |
other.position, |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
567 |
other.getCode(), |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
568 |
other.getArgs()); |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
569 |
this.subdiagnostics = subdiagnostics; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
570 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
571 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
572 |
@Override |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
573 |
public List<JCDiagnostic> getSubdiagnostics() { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
574 |
return subdiagnostics; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
575 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
576 |
|
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
577 |
@Override |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
578 |
public boolean isMultiline() { |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
579 |
return true; |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
580 |
} |
e5a618442f5f
6768932: Add support for multiline diagnostics
mcimadamore
parents:
1471
diff
changeset
|
581 |
} |
10 | 582 |
} |