Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 12082024: Use named arguments for messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 class MessageKind { 7 class MessageKind {
8 final String template; 8 final String template;
9 const MessageKind(this.template); 9 const MessageKind(this.template);
10 10
11 static const GENERIC = const MessageKind('#{1}'); 11 static const GENERIC = const MessageKind('#{text}');
12 12
13 static const NOT_ASSIGNABLE = const MessageKind( 13 static const NOT_ASSIGNABLE = const MessageKind(
14 '#{2} is not assignable to #{1}'); 14 '#{fromType} is not assignable to #{toType}');
15 static const VOID_EXPRESSION = const MessageKind( 15 static const VOID_EXPRESSION = const MessageKind(
16 'expression does not yield a value'); 16 'expression does not yield a value');
17 static const VOID_VARIABLE = const MessageKind( 17 static const VOID_VARIABLE = const MessageKind(
18 'variable cannot be of type void'); 18 'variable cannot be of type void');
19 static const RETURN_VALUE_IN_VOID = const MessageKind( 19 static const RETURN_VALUE_IN_VOID = const MessageKind(
20 'cannot return value from void function'); 20 'cannot return value from void function');
21 static const RETURN_NOTHING = const MessageKind( 21 static const RETURN_NOTHING = const MessageKind(
22 'value of type #{1} expected'); 22 'value of type #{returnType} expected');
23 static const MISSING_ARGUMENT = const MessageKind( 23 static const MISSING_ARGUMENT = const MessageKind(
24 'missing argument of type #{1}'); 24 'missing argument of type #{argumentType}');
25 static const ADDITIONAL_ARGUMENT = const MessageKind( 25 static const ADDITIONAL_ARGUMENT = const MessageKind(
26 'additional argument'); 26 'additional argument');
27 static const METHOD_NOT_FOUND = const MessageKind( 27 static const METHOD_NOT_FOUND = const MessageKind(
28 'no method named #{2} in class #{1}'); 28 'no method named #{methodName} in class #{className}');
29 static const MEMBER_NOT_STATIC = const MessageKind( 29 static const MEMBER_NOT_STATIC = const MessageKind(
30 '#{1}.#{2} is not static'); 30 '#{className}.#{memberName} is not static');
31 static const NO_INSTANCE_AVAILABLE = const MessageKind( 31 static const NO_INSTANCE_AVAILABLE = const MessageKind(
32 '#{1} is only available in instance methods'); 32 '#{name} is only available in instance methods');
33 33
34 static const UNREACHABLE_CODE = const MessageKind( 34 static const UNREACHABLE_CODE = const MessageKind(
35 'unreachable code'); 35 'unreachable code');
36 static const MISSING_RETURN = const MessageKind( 36 static const MISSING_RETURN = const MessageKind(
37 'missing return'); 37 'missing return');
38 static const MAYBE_MISSING_RETURN = const MessageKind( 38 static const MAYBE_MISSING_RETURN = const MessageKind(
39 'not all paths lead to a return or throw statement'); 39 'not all paths lead to a return or throw statement');
40 40
41 static const CANNOT_RESOLVE = const MessageKind( 41 static const CANNOT_RESOLVE = const MessageKind(
42 'cannot resolve #{1}'); 42 'cannot resolve #{name}');
43 static const CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind( 43 static const CANNOT_RESOLVE_CONSTRUCTOR = const MessageKind(
44 'cannot resolve constructor #{1}'); 44 'cannot resolve constructor #{constructorName}');
45 static const CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind( 45 static const CANNOT_RESOLVE_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind(
46 'cannot resolve constructor #{1} for implicit super call'); 46 'cannot resolve constructor #{constructorName} for implicit super call');
47 static const CANNOT_RESOLVE_TYPE = const MessageKind( 47 static const CANNOT_RESOLVE_TYPE = const MessageKind(
48 'cannot resolve type #{1}'); 48 'cannot resolve type #{typeName}');
49 static const DUPLICATE_DEFINITION = const MessageKind( 49 static const DUPLICATE_DEFINITION = const MessageKind(
50 'duplicate definition of #{1}'); 50 'duplicate definition of #{name}');
51 static const DUPLICATE_IMPORT = const MessageKind( 51 static const DUPLICATE_IMPORT = const MessageKind(
52 'duplicate import of #{1}'); 52 'duplicate import of #{name}');
53 static const DUPLICATE_EXPORT = const MessageKind( 53 static const DUPLICATE_EXPORT = const MessageKind(
54 'duplicate export of #{1}'); 54 'duplicate export of #{name}');
55 static const NOT_A_TYPE = const MessageKind( 55 static const NOT_A_TYPE = const MessageKind(
56 '#{1} is not a type'); 56 '#{node} is not a type');
57 static const NOT_A_PREFIX = const MessageKind( 57 static const NOT_A_PREFIX = const MessageKind(
58 '#{1} is not a prefix'); 58 '#{node} is not a prefix');
59 static const NO_SUPER_IN_OBJECT = const MessageKind( 59 static const NO_SUPER_IN_OBJECT = const MessageKind(
60 "'Object' does not have a superclass"); 60 "'Object' does not have a superclass");
61 static const CANNOT_FIND_CONSTRUCTOR = const MessageKind( 61 static const CANNOT_FIND_CONSTRUCTOR = const MessageKind(
62 'cannot find constructor #{1}'); 62 'cannot find constructor #{constructorName}');
63 static const CANNOT_FIND_CONSTRUCTOR2 = const MessageKind( 63 static const CANNOT_FIND_CONSTRUCTOR2 = const MessageKind(
64 'cannot find constructor #{1} in #{2}'); 64 'cannot find constructor #{constructorName} in #{className}');
65 static const CYCLIC_CLASS_HIERARCHY = const MessageKind( 65 static const CYCLIC_CLASS_HIERARCHY = const MessageKind(
66 '#{1} creates a cycle in the class hierarchy'); 66 '#{className} creates a cycle in the class hierarchy');
67 static const INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( 67 static const INVALID_RECEIVER_IN_INITIALIZER = const MessageKind(
68 'field initializer expected'); 68 'field initializer expected');
69 static const NO_SUPER_IN_STATIC = const MessageKind( 69 static const NO_SUPER_IN_STATIC = const MessageKind(
70 "'super' is only available in instance methods"); 70 "'super' is only available in instance methods");
71 static const DUPLICATE_INITIALIZER = const MessageKind( 71 static const DUPLICATE_INITIALIZER = const MessageKind(
72 'field #{1} is initialized more than once'); 72 'field #{fieldName} is initialized more than once');
73 static const ALREADY_INITIALIZED = const MessageKind( 73 static const ALREADY_INITIALIZED = const MessageKind(
74 '#{1} was already initialized here'); 74 '#{fieldName} was already initialized here');
75 static const INIT_STATIC_FIELD = const MessageKind( 75 static const INIT_STATIC_FIELD = const MessageKind(
76 'cannot initialize static field #{1}'); 76 'cannot initialize static field #{fieldName}');
77 static const NOT_A_FIELD = const MessageKind( 77 static const NOT_A_FIELD = const MessageKind(
78 '#{1} is not a field'); 78 '#{fieldName} is not a field');
79 static const CONSTRUCTOR_CALL_EXPECTED = const MessageKind( 79 static const CONSTRUCTOR_CALL_EXPECTED = const MessageKind(
80 "only call to 'this' or 'super' constructor allowed"); 80 "only call to 'this' or 'super' constructor allowed");
81 static const INVALID_FOR_IN = const MessageKind( 81 static const INVALID_FOR_IN = const MessageKind(
82 'invalid for-in variable declaration.'); 82 'invalid for-in variable declaration.');
83 static const INVALID_INITIALIZER = const MessageKind( 83 static const INVALID_INITIALIZER = const MessageKind(
84 'invalid initializer'); 84 'invalid initializer');
85 static const FUNCTION_WITH_INITIALIZER = const MessageKind( 85 static const FUNCTION_WITH_INITIALIZER = const MessageKind(
86 'only constructors can have initializers'); 86 'only constructors can have initializers');
87 static const REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind( 87 static const REDIRECTING_CONSTRUCTOR_CYCLE = const MessageKind(
88 'cyclic constructor redirection'); 88 'cyclic constructor redirection');
89 static const REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind( 89 static const REDIRECTING_CONSTRUCTOR_HAS_BODY = const MessageKind(
90 'redirecting constructor cannot have a body'); 90 'redirecting constructor cannot have a body');
91 static const REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = const MessageKind( 91 static const REDIRECTING_CONSTRUCTOR_HAS_INITIALIZER = const MessageKind(
92 'redirecting constructor cannot have other initializers'); 92 'redirecting constructor cannot have other initializers');
93 static const SUPER_INITIALIZER_IN_OBJECT = const MessageKind( 93 static const SUPER_INITIALIZER_IN_OBJECT = const MessageKind(
94 "'Object' cannot have a super initializer"); 94 "'Object' cannot have a super initializer");
95 static const DUPLICATE_SUPER_INITIALIZER = const MessageKind( 95 static const DUPLICATE_SUPER_INITIALIZER = const MessageKind(
96 'cannot have more than one super initializer'); 96 'cannot have more than one super initializer');
97 static const INVALID_ARGUMENTS = const MessageKind( 97 static const INVALID_ARGUMENTS = const MessageKind(
98 "arguments do not match the expected parameters of #{1}"); 98 "arguments do not match the expected parameters of #{methodName}");
99 static const NO_MATCHING_CONSTRUCTOR = const MessageKind( 99 static const NO_MATCHING_CONSTRUCTOR = const MessageKind(
100 "super call arguments and constructor parameters don't match"); 100 "super call arguments and constructor parameters don't match");
101 static const NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind( 101 static const NO_MATCHING_CONSTRUCTOR_FOR_IMPLICIT = const MessageKind(
102 "implicit super call arguments and constructor parameters don't match"); 102 "implicit super call arguments and constructor parameters don't match");
103 static const NO_CONSTRUCTOR = const MessageKind(
104 '#{1} is a #{2}, not a constructor');
105 static const FIELD_PARAMETER_NOT_ALLOWED = const MessageKind( 103 static const FIELD_PARAMETER_NOT_ALLOWED = const MessageKind(
106 'a field parameter is only allowed in generative constructors'); 104 'a field parameter is only allowed in generative constructors');
107 static const INVALID_PARAMETER = const MessageKind( 105 static const INVALID_PARAMETER = const MessageKind(
108 "cannot resolve parameter"); 106 "cannot resolve parameter");
109 static const NOT_INSTANCE_FIELD = const MessageKind( 107 static const NOT_INSTANCE_FIELD = const MessageKind(
110 '#{1} is not an instance field'); 108 '#{fieldName} is not an instance field');
111 static const NO_CATCH_NOR_FINALLY = const MessageKind( 109 static const NO_CATCH_NOR_FINALLY = const MessageKind(
112 "expected 'catch' or 'finally'"); 110 "expected 'catch' or 'finally'");
113 static const EMPTY_CATCH_DECLARATION = const MessageKind( 111 static const EMPTY_CATCH_DECLARATION = const MessageKind(
114 'expected an identifier in catch declaration'); 112 'expected an identifier in catch declaration');
115 static const EXTRA_CATCH_DECLARATION = const MessageKind( 113 static const EXTRA_CATCH_DECLARATION = const MessageKind(
116 'extra parameter in catch declaration'); 114 'extra parameter in catch declaration');
117 static const PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind( 115 static const PARAMETER_WITH_TYPE_IN_CATCH = const MessageKind(
118 'cannot use type annotations in catch'); 116 'cannot use type annotations in catch');
119 static const PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind( 117 static const PARAMETER_WITH_MODIFIER_IN_CATCH = const MessageKind(
120 'cannot use modifiers in catch'); 118 'cannot use modifiers in catch');
121 static const OPTIONAL_PARAMETER_IN_CATCH = const MessageKind( 119 static const OPTIONAL_PARAMETER_IN_CATCH = const MessageKind(
122 'cannot use optional parameters in catch'); 120 'cannot use optional parameters in catch');
123 static const THROW_WITHOUT_EXPRESSION = const MessageKind( 121 static const THROW_WITHOUT_EXPRESSION = const MessageKind(
124 'cannot use re-throw outside of catch block (expression expected after ' 122 'cannot use re-throw outside of catch block (expression expected after '
125 '"throw")'); 123 '"throw")');
126 static const UNBOUND_LABEL = const MessageKind( 124 static const UNBOUND_LABEL = const MessageKind(
127 'cannot resolve label #{1}'); 125 'cannot resolve label #{labelName}');
128 static const NO_BREAK_TARGET = const MessageKind( 126 static const NO_BREAK_TARGET = const MessageKind(
129 'break statement not inside switch or loop'); 127 'break statement not inside switch or loop');
130 static const NO_CONTINUE_TARGET = const MessageKind( 128 static const NO_CONTINUE_TARGET = const MessageKind(
131 'continue statement not inside loop'); 129 'continue statement not inside loop');
132 static const EXISTING_LABEL = const MessageKind( 130 static const EXISTING_LABEL = const MessageKind(
133 'original declaration of duplicate label #{1}'); 131 'original declaration of duplicate label #{labelName}');
134 static const DUPLICATE_LABEL = const MessageKind( 132 static const DUPLICATE_LABEL = const MessageKind(
135 'duplicate declaration of label #{1}'); 133 'duplicate declaration of label #{labelName}');
136 static const UNUSED_LABEL = const MessageKind( 134 static const UNUSED_LABEL = const MessageKind(
137 'unused label #{1}'); 135 'unused label #{labelName}');
138 static const INVALID_CONTINUE = const MessageKind( 136 static const INVALID_CONTINUE = const MessageKind(
139 'target of continue is not a loop or switch case'); 137 'target of continue is not a loop or switch case');
138 static const INVALID_BREAK = const MessageKind(
139 'target of break is not a statement');
140
140 static const TYPE_VARIABLE_AS_CONSTRUCTOR = const MessageKind( 141 static const TYPE_VARIABLE_AS_CONSTRUCTOR = const MessageKind(
141 'cannot use type variable as constructor'); 142 'cannot use type variable as constructor');
142 static const DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind( 143 static const DUPLICATE_TYPE_VARIABLE_NAME = const MessageKind(
143 'type variable #{1} already declared'); 144 'type variable #{typeVariableName} already declared');
144 static const TYPE_VARIABLE_WITHIN_STATIC_MEMBER = const MessageKind( 145 static const TYPE_VARIABLE_WITHIN_STATIC_MEMBER = const MessageKind(
145 'cannot refer to type variable #{1} within a static member'); 146 'cannot refer to type variable #{typeVariableName} '
146 static const INVALID_BREAK = const MessageKind( 147 'within a static member');
147 'target of break is not a statement'); 148
148 static const INVALID_USE_OF_SUPER = const MessageKind( 149 static const INVALID_USE_OF_SUPER = const MessageKind(
149 'super not allowed here'); 150 'super not allowed here');
150 static const INVALID_CASE_DEFAULT = const MessageKind( 151 static const INVALID_CASE_DEFAULT = const MessageKind(
151 'default only allowed on last case of a switch'); 152 'default only allowed on last case of a switch');
152 153
153 static const SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind( 154 static const SWITCH_CASE_TYPES_NOT_EQUAL = const MessageKind(
154 "case expressions don't all have the same type."); 155 "case expressions don't all have the same type.");
155 static const SWITCH_CASE_VALUE_OVERRIDES_EQUALS = const MessageKind( 156 static const SWITCH_CASE_VALUE_OVERRIDES_EQUALS = const MessageKind(
156 "case expression value overrides 'operator=='."); 157 "case expression value overrides 'operator=='.");
157 static const SWITCH_INVALID = const MessageKind( 158 static const SWITCH_INVALID = const MessageKind(
158 "switch cases contain invalid expressions."); 159 "switch cases contain invalid expressions.");
159 160
160 static const INVALID_ARGUMENT_AFTER_NAMED = const MessageKind( 161 static const INVALID_ARGUMENT_AFTER_NAMED = const MessageKind(
161 'non-named argument after named argument'); 162 'non-named argument after named argument');
162 163
163 static const NOT_A_COMPILE_TIME_CONSTANT = const MessageKind( 164 static const NOT_A_COMPILE_TIME_CONSTANT = const MessageKind(
164 'not a compile-time constant'); 165 'not a compile-time constant');
165 static const CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind( 166 static const CYCLIC_COMPILE_TIME_CONSTANTS = const MessageKind(
166 'cycle in the compile-time constant computation'); 167 'cycle in the compile-time constant computation');
167 static const CONSTRUCTOR_IS_NOT_CONST = const MessageKind( 168 static const CONSTRUCTOR_IS_NOT_CONST = const MessageKind(
168 'constructor is not a const constructor'); 169 'constructor is not a const constructor');
169 170
170 static const KEY_NOT_A_STRING_LITERAL = const MessageKind( 171 static const KEY_NOT_A_STRING_LITERAL = const MessageKind(
171 'map-literal key not a string literal'); 172 'map-literal key not a string literal');
172 173
173 static const NO_SUCH_LIBRARY_MEMBER = const MessageKind( 174 static const NO_SUCH_LIBRARY_MEMBER = const MessageKind(
174 '#{1} has no member named #{2}'); 175 '#{libraryName} has no member named #{memberName}');
175 176
176 static const CANNOT_INSTANTIATE_INTERFACE = const MessageKind( 177 static const CANNOT_INSTANTIATE_INTERFACE = const MessageKind(
177 "cannot instantiate interface '#{1}'"); 178 "cannot instantiate interface '#{interfaceName}'");
178 179
179 static const CANNOT_INSTANTIATE_TYPEDEF = const MessageKind( 180 static const CANNOT_INSTANTIATE_TYPEDEF = const MessageKind(
180 "cannot instantiate typedef '#{1}'"); 181 "cannot instantiate typedef '#{typedefName}'");
181 182
182 static const CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind( 183 static const CANNOT_INSTANTIATE_TYPE_VARIABLE = const MessageKind(
183 "cannot instantiate type variable '#{1}'"); 184 "cannot instantiate type variable '#{typeVariableName}'");
184 185
185 static const NO_DEFAULT_CLASS = const MessageKind( 186 static const NO_DEFAULT_CLASS = const MessageKind(
186 "no default class on enclosing interface '#{1}'"); 187 "no default class on enclosing interface '#{interfaceName}'");
187 188
188 static const CYCLIC_TYPE_VARIABLE = const MessageKind( 189 static const CYCLIC_TYPE_VARIABLE = const MessageKind(
189 "cyclic reference to type variable #{1}"); 190 "cyclic reference to type variable #{typeVariableName}");
190 191
191 static const CLASS_NAME_EXPECTED = const MessageKind( 192 static const CLASS_NAME_EXPECTED = const MessageKind(
192 "class name expected"); 193 "class name expected");
193 194
194 static const INTERFACE_TYPE_EXPECTED = const MessageKind( 195 static const INTERFACE_TYPE_EXPECTED = const MessageKind(
195 "interface type expected"); 196 "interface type expected");
196 197
197 static const CANNOT_EXTEND = const MessageKind( 198 static const CANNOT_EXTEND = const MessageKind(
198 "#{1} cannot be extended"); 199 "#{type} cannot be extended");
199 200
200 static const CANNOT_IMPLEMENT = const MessageKind( 201 static const CANNOT_IMPLEMENT = const MessageKind(
201 "#{1} cannot be implemented"); 202 "#{type} cannot be implemented");
202 203
203 static const DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind( 204 static const DUPLICATE_EXTENDS_IMPLEMENTS = const MessageKind(
204 "Error: #{1} can not be both extended and implemented."); 205 "Error: #{type} can not be both extended and implemented.");
205 206
206 static const DUPLICATE_IMPLEMENTS = const MessageKind( 207 static const DUPLICATE_IMPLEMENTS = const MessageKind(
207 "Error: #{1} must not occur more than once in the implements clause."); 208 "Error: #{type} must not occur more than once "
209 "in the implements clause.");
208 210
209 static const ILLEGAL_SUPER_SEND = const MessageKind( 211 static const ILLEGAL_SUPER_SEND = const MessageKind(
210 "#{1} cannot be called on super"); 212 "#{name} cannot be called on super");
211 213
212 static const ADDITIONAL_TYPE_ARGUMENT = const MessageKind( 214 static const ADDITIONAL_TYPE_ARGUMENT = const MessageKind(
213 "additional type argument"); 215 "additional type argument");
214 216
215 static const MISSING_TYPE_ARGUMENT = const MessageKind( 217 static const MISSING_TYPE_ARGUMENT = const MessageKind(
216 "missing type argument"); 218 "missing type argument");
217 219
218 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT 220 // TODO(johnniwinther): Use ADDITIONAL_TYPE_ARGUMENT or MISSING_TYPE_ARGUMENT
219 // instead. 221 // instead.
220 static const TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind( 222 static const TYPE_ARGUMENT_COUNT_MISMATCH = const MessageKind(
221 "incorrect number of type arguments on #{1}"); 223 "incorrect number of type arguments on #{type}");
222 224
223 static const MISSING_ARGUMENTS_TO_ASSERT = const MessageKind( 225 static const MISSING_ARGUMENTS_TO_ASSERT = const MessageKind(
224 "missing arguments to assert"); 226 "missing arguments to assert");
225 227
226 static const GETTER_MISMATCH = const MessageKind( 228 static const GETTER_MISMATCH = const MessageKind(
227 "Error: setter disagrees on: #{1}."); 229 "Error: setter disagrees on: #{modifiers}.");
228 230
229 static const SETTER_MISMATCH = const MessageKind( 231 static const SETTER_MISMATCH = const MessageKind(
230 "Error: getter disagrees on: #{1}."); 232 "Error: getter disagrees on: #{modifiers}.");
231 233
232 static const ILLEGAL_SETTER_FORMALS = const MessageKind( 234 static const ILLEGAL_SETTER_FORMALS = const MessageKind(
233 "Error: a setter must have exactly one argument."); 235 "Error: a setter must have exactly one argument.");
234 236
235 static const NO_STATIC_OVERRIDE = const MessageKind( 237 static const NO_STATIC_OVERRIDE = const MessageKind(
236 "Error: static member cannot override instance member '#{1}' of '#{2}'."); 238 "Error: static member cannot override instance member '#{memberName}' of "
239 "'#{className}'.");
237 240
238 static const NO_STATIC_OVERRIDE_CONT = const MessageKind( 241 static const NO_STATIC_OVERRIDE_CONT = const MessageKind(
239 "Info: this is the instance member that cannot be overridden " 242 "Info: this is the instance member that cannot be overridden "
240 "by a static member."); 243 "by a static member.");
241 244
242 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD = const MessageKind( 245 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD = const MessageKind(
243 "Error: method cannot override field '#{1}' of '#{2}'."); 246 "Error: method cannot override field '#{memberName}' of '#{className}'.");
244 247
245 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = const MessageKind( 248 static const CANNOT_OVERRIDE_FIELD_WITH_METHOD_CONT = const MessageKind(
246 "Info: this is the field that cannot be overridden by a method."); 249 "Info: this is the field that cannot be overridden by a method.");
247 250
248 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD = const MessageKind( 251 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD = const MessageKind(
249 "Error: field cannot override method '#{1}' of '#{2}'."); 252 "Error: field cannot override method '#{memberName}' of '#{className}'.");
250 253
251 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = const MessageKind( 254 static const CANNOT_OVERRIDE_METHOD_WITH_FIELD_CONT = const MessageKind(
252 "Info: this is the method that cannot be overridden by a field."); 255 "Info: this is the method that cannot be overridden by a field.");
253 256
254 static const BAD_ARITY_OVERRIDE = const MessageKind( 257 static const BAD_ARITY_OVERRIDE = const MessageKind(
255 "Error: cannot override method '#{1}' in '#{2}'; " 258 "Error: cannot override method '#{memberName}' in '#{className}'; "
256 "the parameters do not match."); 259 "the parameters do not match.");
257 260
258 static const BAD_ARITY_OVERRIDE_CONT = const MessageKind( 261 static const BAD_ARITY_OVERRIDE_CONT = const MessageKind(
259 "Info: this is the method whose parameters do not match."); 262 "Info: this is the method whose parameters do not match.");
260 263
261 static const MISSING_FORMALS = const MessageKind( 264 static const MISSING_FORMALS = const MessageKind(
262 "Error: Formal parameters are missing."); 265 "Error: Formal parameters are missing.");
263 266
264 static const EXTRA_FORMALS = const MessageKind( 267 static const EXTRA_FORMALS = const MessageKind(
265 "Error: Formal parameters are not allowed here."); 268 "Error: Formal parameters are not allowed here.");
266 269
267 static const UNARY_OPERATOR_BAD_ARITY = const MessageKind( 270 static const UNARY_OPERATOR_BAD_ARITY = const MessageKind(
268 "Error: Operator #{1} must have no parameters."); 271 "Error: Operator #{operatorName} must have no parameters.");
269 272
270 static const MINUS_OPERATOR_BAD_ARITY = const MessageKind( 273 static const MINUS_OPERATOR_BAD_ARITY = const MessageKind(
271 "Error: Operator - must have 0 or 1 parameters."); 274 "Error: Operator - must have 0 or 1 parameters.");
272 275
273 static const BINARY_OPERATOR_BAD_ARITY = const MessageKind( 276 static const BINARY_OPERATOR_BAD_ARITY = const MessageKind(
274 "Error: Operator #{1} must have exactly 1 parameter."); 277 "Error: Operator #{operatorName} must have exactly 1 parameter.");
275 278
276 static const TERNARY_OPERATOR_BAD_ARITY = const MessageKind( 279 static const TERNARY_OPERATOR_BAD_ARITY = const MessageKind(
277 "Error: Operator #{1} must have exactly 2 parameters."); 280 "Error: Operator #{operatorName} must have exactly 2 parameters.");
278 281
279 static const OPERATOR_OPTIONAL_PARAMETERS = const MessageKind( 282 static const OPERATOR_OPTIONAL_PARAMETERS = const MessageKind(
280 "Error: Operator #{1} cannot have optional parameters."); 283 "Error: Operator #{operatorName} cannot have optional parameters.");
281 284
282 static const OPERATOR_NAMED_PARAMETERS = const MessageKind( 285 static const OPERATOR_NAMED_PARAMETERS = const MessageKind(
283 "Error: Operator #{1} cannot have named parameters."); 286 "Error: Operator #{operatorName} cannot have named parameters.");
284 287
285 // TODO(ahe): This message is hard to localize. This is acceptable, 288 // TODO(ahe): This message is hard to localize. This is acceptable,
286 // as it will be removed when we ship Dart version 1.0. 289 // as it will be removed when we ship Dart version 1.0.
287 static const DEPRECATED_FEATURE_WARNING = const MessageKind( 290 static const DEPRECATED_FEATURE_WARNING = const MessageKind(
288 "Warning: deprecated language feature, #{1}, " 291 "Warning: deprecated language feature, #{featureName}, "
289 "will be removed in a future Dart milestone."); 292 "will be removed in a future Dart milestone.");
290 293
291 // TODO(ahe): This message is hard to localize. This is acceptable, 294 // TODO(ahe): This message is hard to localize. This is acceptable,
292 // as it will be removed when we ship Dart version 1.0. 295 // as it will be removed when we ship Dart version 1.0.
293 static const DEPRECATED_FEATURE_ERROR = const MessageKind( 296 static const DEPRECATED_FEATURE_ERROR = const MessageKind(
294 "Error: #{1} are not legal " 297 "Error: #{featureName} are not legal "
295 "due to option --reject-deprecated-language-features."); 298 "due to option --reject-deprecated-language-features.");
296 299
297 static const CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind( 300 static const CONSTRUCTOR_WITH_RETURN_TYPE = const MessageKind(
298 "Error: cannot have return type for constructor."); 301 "Error: cannot have return type for constructor.");
299 302
300 static const ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind( 303 static const ILLEGAL_FINAL_METHOD_MODIFIER = const MessageKind(
301 "Error: cannot have final modifier on method."); 304 "Error: cannot have final modifier on method.");
302 305
303 static const ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind( 306 static const ILLEGAL_CONSTRUCTOR_MODIFIERS = const MessageKind(
304 "Error: illegal constructor modifiers: #{1}."); 307 "Error: illegal constructor modifiers: #{modifiers}.");
305 308
306 static const ILLEGAL_MIXIN_APPLICATION_MODIFIERS = const MessageKind( 309 static const ILLEGAL_MIXIN_APPLICATION_MODIFIERS = const MessageKind(
307 "Error: illegal mixin application modifiers: #{1}."); 310 "Error: illegal mixin application modifiers: #{modifiers}.");
308 311
309 static const ILLEGAL_MIXIN_SUPERCLASS = const MessageKind( 312 static const ILLEGAL_MIXIN_SUPERCLASS = const MessageKind(
310 "Error: class used as mixin must have Object as superclass."); 313 "Error: class used as mixin must have Object as superclass.");
311 314
312 static const ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind( 315 static const ILLEGAL_MIXIN_CONSTRUCTOR = const MessageKind(
313 "Error: class used as mixin cannot have non-factory constructor."); 316 "Error: class used as mixin cannot have non-factory constructor.");
314 317
315 static const ILLEGAL_MIXIN_CYCLE = const MessageKind( 318 static const ILLEGAL_MIXIN_CYCLE = const MessageKind(
316 "Error: class used as mixin introduces mixin cycle: #{1} <-> #{2}."); 319 "Error: class used as mixin introduces mixin cycle: "
320 "#{mixinName1} <-> #{mixinName2}.");
317 321
318 static const ILLEGAL_MIXIN_WITH_SUPER = const MessageKind( 322 static const ILLEGAL_MIXIN_WITH_SUPER = const MessageKind(
319 "Error: cannot use class #{1} as a mixin because it uses super."); 323 "Error: cannot use class #{className} as a mixin because it uses super.");
320 324
321 static const ILLEGAL_MIXIN_SUPER_USE = const MessageKind( 325 static const ILLEGAL_MIXIN_SUPER_USE = const MessageKind(
322 "Use of super in class used as mixin."); 326 "Use of super in class used as mixin.");
323 327
324 static const PARAMETER_NAME_EXPECTED = const MessageKind( 328 static const PARAMETER_NAME_EXPECTED = const MessageKind(
325 "Error: parameter name expected."); 329 "Error: parameter name expected.");
326 330
327 static const CANNOT_RESOLVE_GETTER = const MessageKind( 331 static const CANNOT_RESOLVE_GETTER = const MessageKind(
328 'cannot resolve getter.'); 332 'cannot resolve getter.');
329 333
330 static const CANNOT_RESOLVE_SETTER = const MessageKind( 334 static const CANNOT_RESOLVE_SETTER = const MessageKind(
331 'cannot resolve setter.'); 335 'cannot resolve setter.');
332 336
333 static const VOID_NOT_ALLOWED = const MessageKind( 337 static const VOID_NOT_ALLOWED = const MessageKind(
334 'type void is only allowed in a return type.'); 338 'type void is only allowed in a return type.');
335 339
336 static const BEFORE_TOP_LEVEL = const MessageKind( 340 static const BEFORE_TOP_LEVEL = const MessageKind(
337 'Error: part header must come before top-level definitions.'); 341 'Error: part header must come before top-level definitions.');
338 342
339 static const LIBRARY_NAME_MISMATCH = const MessageKind( 343 static const LIBRARY_NAME_MISMATCH = const MessageKind(
340 'Warning: expected part of library name "#{1}".'); 344 'Warning: expected part of library name "#{libraryName}".');
341 345
342 static const MISSING_PART_OF_TAG = const MessageKind( 346 static const MISSING_PART_OF_TAG = const MessageKind(
343 'Note: This file has no part-of tag, but it is being used as a part.'); 347 'Note: This file has no part-of tag, but it is being used as a part.');
344 348
345 static const DUPLICATED_PART_OF = const MessageKind( 349 static const DUPLICATED_PART_OF = const MessageKind(
346 'Error: duplicated part-of directive.'); 350 'Error: duplicated part-of directive.');
347 351
348 static const ILLEGAL_DIRECTIVE = const MessageKind( 352 static const ILLEGAL_DIRECTIVE = const MessageKind(
349 'Error: directive not allowed here.'); 353 'Error: directive not allowed here.');
350 354
351 static const DUPLICATED_LIBRARY_NAME = const MessageKind( 355 static const DUPLICATED_LIBRARY_NAME = const MessageKind(
352 'Warning: duplicated library name "#{1}".'); 356 'Warning: duplicated library name "#{libraryName}".');
353 357
354 static const INVALID_SOURCE_FILE_LOCATION = const MessageKind(''' 358 static const INVALID_SOURCE_FILE_LOCATION = const MessageKind('''
355 Invalid offset (#{1}) in source map. 359 Invalid offset (#{offset}) in source map.
356 File: #{2} 360 File: #{fileName}
357 Length: #{3}'''); 361 Length: #{length}''');
358 362
359 static const PATCH_RETURN_TYPE_MISMATCH = const MessageKind( 363 static const PATCH_RETURN_TYPE_MISMATCH = const MessageKind(
360 "Patch return type '#{3}' doesn't match '#{2}' on origin method '#{1}'."); 364 "Patch return type '#{patchReturnType}' doesn't match "
365 "'#{originReturnType}' on origin method '#{methodName}'.");
361 366
362 static const PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = const MessageKind( 367 static const PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = const MessageKind(
363 "Required parameter count of patch method (#{3}) doesn't match parameter " 368 "Required parameter count of patch method (#{patchParameterCount}) "
364 "count on origin method '#{1}' (#{2})."); 369 "doesn't match parameter count on origin method '#{methodName}' "
370 "(#{originParameterCount}).");
365 371
366 static const PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = const MessageKind( 372 static const PATCH_OPTIONAL_PARAMETER_COUNT_MISMATCH = const MessageKind(
367 "Optional parameter count of patch method (#{3}) doesn't match parameter " 373 "Optional parameter count of patch method (#{patchParameterCount}) "
368 "count on origin method '#{1}' (#{2})."); 374 "doesn't match parameter count on origin method '#{methodName}' "
375 "(#{originParameterCount}).");
369 376
370 static const PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = const MessageKind( 377 static const PATCH_OPTIONAL_PARAMETER_NAMED_MISMATCH = const MessageKind(
371 "Optional parameters of origin and patch method '#{1}' must " 378 "Optional parameters of origin and patch method '#{methodName}' must "
372 "both be either named or positional."); 379 "both be either named or positional.");
373 380
374 static const PATCH_PARAMETER_MISMATCH = const MessageKind( 381 static const PATCH_PARAMETER_MISMATCH = const MessageKind(
375 "Patch method parameter '#{3}' doesn't match '#{2}' on origin method " 382 "Patch method parameter '#{patchParameter}' doesn't match "
376 "#{1}."); 383 "'#{originParameter}' on origin method #{methodName}.");
377 384
378 static const EXTERNAL_WITHOUT_IMPLEMENTATION = const MessageKind( 385 static const EXTERNAL_WITHOUT_IMPLEMENTATION = const MessageKind(
379 "External method without an implementation."); 386 "External method without an implementation.");
380 387
381 static const TOP_LEVEL_VARIABLE_DECLARED_STATIC = const MessageKind( 388 static const TOP_LEVEL_VARIABLE_DECLARED_STATIC = const MessageKind(
382 "Top-level variable cannot be declared static."); 389 "Top-level variable cannot be declared static.");
383 390
384 static const WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = const MessageKind( 391 static const WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT = const MessageKind(
385 "Wrong number of arguments to assert. Should be 1, but given #{1}."); 392 "Wrong number of arguments to assert. Should be 1, but given "
393 "#{argumentCount}.");
386 394
387 static const ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind( 395 static const ASSERT_IS_GIVEN_NAMED_ARGUMENTS = const MessageKind(
388 "assert takes no named arguments, but given #{1}."); 396 "assert takes no named arguments, but given #{argumentCount}.");
389
390 static const MALFORMED_TYPE_REFERENCE = const MessageKind(
391 "Malformed type reference encountered in #{1}.");
392 397
393 static const FACTORY_REDIRECTION_IN_NON_FACTORY = const MessageKind( 398 static const FACTORY_REDIRECTION_IN_NON_FACTORY = const MessageKind(
394 "Error: Factory redirection only allowed in factories."); 399 "Error: Factory redirection only allowed in factories.");
395 400
396 static const MISSING_FACTORY_KEYWORD = const MessageKind( 401 static const MISSING_FACTORY_KEYWORD = const MessageKind(
397 "Did you forget a factory keyword here?"); 402 "Did you forget a factory keyword here?");
398 403
399 static const COMPILER_CRASHED = const MessageKind( 404 static const COMPILER_CRASHED = const MessageKind(
400 "Error: The compiler crashed when compiling this element."); 405 "Error: The compiler crashed when compiling this element.");
401 406
402 static const PLEASE_REPORT_THE_CRASH = const MessageKind(''' 407 static const PLEASE_REPORT_THE_CRASH = const MessageKind('''
403 The compiler is broken. 408 The compiler is broken.
404 409
405 When compiling the above element, the compiler crashed. It is not 410 When compiling the above element, the compiler crashed. It is not
406 possible to tell if this is caused by a problem in your program or 411 possible to tell if this is caused by a problem in your program or
407 not. Regardless, the compiler should not crash. 412 not. Regardless, the compiler should not crash.
408 413
409 The Dart team would greatly appreciate if you would take a moment to 414 The Dart team would greatly appreciate if you would take a moment to
410 report this problem at http://dartbug.com/new. 415 report this problem at http://dartbug.com/new.
411 416
412 Please include the following information: 417 Please include the following information:
413 418
414 * the name and version of your operating system, 419 * the name and version of your operating system,
415 420
416 * the Dart SDK build number (#{1}), and 421 * the Dart SDK build number (#{buildId}), and
417 422
418 * the entire message you see here (including the full stack trace 423 * the entire message you see here (including the full stack trace
419 below as well as the source location above). 424 below as well as the source location above).
420 '''); 425 ''');
421 426
422 toString() => template; 427 toString() => template;
423 428
424 Message message([List arguments = const []]) { 429 Message message([Map arguments = const {}]) {
425 return new Message(this, arguments); 430 return new Message(this, arguments);
426 } 431 }
427 432
428 CompilationError error([List arguments = const []]) { 433 CompilationError error([Map arguments = const {}]) {
429 return new CompilationError(this, arguments); 434 return new CompilationError(this, arguments);
430 } 435 }
431 } 436 }
432 437
433 class Message { 438 class Message {
434 final kind; 439 final kind;
435 final List arguments; 440 final Map arguments;
436 String message; 441 String message;
437 442
438 Message(this.kind, this.arguments); 443 Message(this.kind, this.arguments) {
444 assert(() { computeMessage(); return true; });
445 }
446
447 String computeMessage() {
448 if (message == null) {
449 message = kind.template;
450 arguments.forEach((key, value) {
451 String string = slowToString(value);
452 message = message.replaceAll('#{${key}}', string);
453 });
454 assert(invariant(
455 CURRENT_ELEMENT_SPANNABLE,
456 !message.contains(new RegExp(r"#\{.+\}")),
457 message: 'Missing arguments in error message: "$message"'));
458 }
459 return message;
460 }
439 461
440 String toString() { 462 String toString() {
441 if (message == null) { 463 return computeMessage();
442 message = kind.template;
443 int position = 1;
444 for (var argument in arguments) {
445 String string = slowToString(argument);
446 message = message.replaceAll('#{${position++}}', string);
447 }
448 }
449 return message;
450 } 464 }
451 465
452 bool operator==(other) { 466 bool operator==(other) {
453 if (other is !Message) return false; 467 if (other is !Message) return false;
454 return (kind == other.kind) && (toString() == other.toString()); 468 return (kind == other.kind) && (toString() == other.toString());
455 } 469 }
456 470
457 String slowToString(object) { 471 String slowToString(object) {
458 if (object is SourceString) { 472 if (object is SourceString) {
459 return object.slowToString(); 473 return object.slowToString();
460 } else { 474 } else {
461 return object.toString(); 475 return object.toString();
462 } 476 }
463 } 477 }
464 } 478 }
465 479
466 class Diagnostic { 480 class Diagnostic {
467 final Message message; 481 final Message message;
468 Diagnostic(MessageKind kind, List arguments) 482 Diagnostic(MessageKind kind, [Map arguments = const {}])
469 : message = new Message(kind, arguments); 483 : message = new Message(kind, arguments);
470 String toString() => message.toString(); 484 String toString() => message.toString();
471 } 485 }
472 486
473 class TypeWarning extends Diagnostic { 487 class TypeWarning extends Diagnostic {
474 TypeWarning(MessageKind kind, List arguments) 488 TypeWarning(MessageKind kind, [Map arguments = const {}])
475 : super(kind, arguments); 489 : super(kind, arguments);
476 } 490 }
477 491
478 class ResolutionError extends Diagnostic { 492 class ResolutionError extends Diagnostic {
479 ResolutionError(MessageKind kind, List arguments) 493 ResolutionError(MessageKind kind, [Map arguments = const {}])
480 : super(kind, arguments); 494 : super(kind, arguments);
481 } 495 }
482 496
483 class ResolutionWarning extends Diagnostic { 497 class ResolutionWarning extends Diagnostic {
484 ResolutionWarning(MessageKind kind, List arguments) 498 ResolutionWarning(MessageKind kind, [Map arguments = const {}])
485 : super(kind, arguments); 499 : super(kind, arguments);
486 } 500 }
487 501
488 class CompileTimeConstantError extends Diagnostic { 502 class CompileTimeConstantError extends Diagnostic {
489 CompileTimeConstantError(MessageKind kind, List arguments) 503 CompileTimeConstantError(MessageKind kind, [Map arguments = const {}])
490 : super(kind, arguments); 504 : super(kind, arguments);
491 } 505 }
492 506
493 class CompilationError extends Diagnostic { 507 class CompilationError extends Diagnostic {
494 CompilationError(MessageKind kind, List arguments) 508 CompilationError(MessageKind kind, [Map arguments = const {}])
495 : super(kind, arguments); 509 : super(kind, arguments);
496 } 510 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/util/util.dart ('k') | tests/compiler/dart2js/erroneous_element_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698