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

Side by Side Diff: pkg/dart_messages/lib/shared_messages.dart

Issue 1770703002: Use error-names for 'specializationOf'. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | pkg/dart_messages/test/dart_messages_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // An update to this file must be followed by regenerating the corresponding 5 // An update to this file must be followed by regenerating the corresponding
6 // json, dart2js and analyzer file. Use `publish.dart` in the bin directory. 6 // json, dart2js and analyzer file. Use `publish.dart` in the bin directory.
7 // 7 //
8 // Every message in this file must have an id. Use `message_id.dart` in the 8 // Every message in this file must have an id. Use `message_id.dart` in the
9 // bin directory to generate a fresh one. 9 // bin directory to generate a fresh one.
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 /// In particular, we want errors of the same category to share the same 93 /// In particular, we want errors of the same category to share the same
94 /// explanation page, and want to disable warnings of the same category 94 /// explanation page, and want to disable warnings of the same category
95 /// with just one line. 95 /// with just one line.
96 final String id; 96 final String id;
97 97
98 /// The sub-id of the error. 98 /// The sub-id of the error.
99 /// 99 ///
100 /// This id just needs to be unique within the same [id]. 100 /// This id just needs to be unique within the same [id].
101 final int subId; 101 final int subId;
102 102
103 /// The error sub-id of which this message is a specialization. 103 /// The error of which this message is a specialization.
104 /// 104 ///
105 /// For example, "Const is not allowed on getters" may be a specialization of 105 /// For example, "Const is not allowed on getters" may be a specialization of
106 /// "The 'const' keyword is not allowed here". 106 /// "The 'const' keyword is not allowed here".
107 /// 107 ///
108 /// Examples of the specialized message, should trigger for the more generic 108 /// Examples of the specialized message, should trigger for the more generic
109 /// message, when the platform doesn't support the more specialized message. 109 /// message, when the platform doesn't support the more specialized message.
110 final int specializationOf; 110 ///
111 /// Specializations must have the same error-id (but not sub-id) as the more
112 /// generic message.
113 final String specializationOf;
111 114
112 final Category category; 115 final Category category;
113 final String template; 116 final String template;
114 // The analyzer fills holes positionally (and not named). The following field 117 // The analyzer fills holes positionally (and not named). The following field
115 // overrides the order of the holes. 118 // overrides the order of the holes.
116 // For example the template "The argument #field in #cls is bad", could have 119 // For example the template "The argument #field in #cls is bad", could have
117 // the order `["cls", "field"]', which means that the analyzer would first 120 // the order `["cls", "field"]', which means that the analyzer would first
118 // provide the class `cls` and then only `field`. 121 // provide the class `cls` and then only `field`.
119 // This list is generally `null`, but when it is provided it must contain all 122 // This list is generally `null`, but when it is provided it must contain all
120 // holes. 123 // holes.
121 final List<String> templateHoleOrder; 124 final List<String> templateHoleOrder;
122 final String howToFix; 125 final String howToFix;
123 final List<String> options; 126 final List<String> options;
124 final List examples; 127 final List examples;
125 final List<Platform> usedBy; 128 final List<Platform> usedBy;
126 129
127 Message( 130 Message(
128 {this.id, 131 {this.id,
129 this.subId: 0, 132 this.subId: 0,
130 this.specializationOf: -1, 133 this.specializationOf: null,
131 this.category, 134 this.category,
132 this.template, 135 this.template,
133 this.templateHoleOrder, 136 this.templateHoleOrder,
134 this.howToFix, 137 this.howToFix,
135 this.options, 138 this.options,
136 this.usedBy: const [], 139 this.usedBy: const [],
137 this.examples}); 140 this.examples});
138 } 141 }
139 142
140 String get messagesAsJson { 143 String get messagesAsJson {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 class C { 200 class C {
198 const factory C() {} 201 const factory C() {}
199 } 202 }
200 203
201 main() => new C();""" 204 main() => new C();"""
202 ]), 205 ]),
203 // Const constructors may not have a body. 206 // Const constructors may not have a body.
204 'CONST_CONSTRUCTOR_WITH_BODY': new Message( 207 'CONST_CONSTRUCTOR_WITH_BODY': new Message(
205 id: 'LGJGHW', 208 id: 'LGJGHW',
206 subId: 1, 209 subId: 1,
207 specializationOf: 0, 210 specializationOf: "CONST_CONSTRUCTOR_OR_FACTORY_WITH_BODY",
208 category: Category.parserError, 211 category: Category.parserError,
209 template: "Const constructor can't have a body.", 212 template: "Const constructor can't have a body.",
210 howToFix: "Try removing the 'const' keyword or the body.", 213 howToFix: "Try removing the 'const' keyword or the body.",
211 usedBy: [ 214 usedBy: [
212 analyzer 215 analyzer
213 ], 216 ],
214 examples: const [ 217 examples: const [
215 r""" 218 r"""
216 class C { 219 class C {
217 const C() {} 220 const C() {}
218 } 221 }
219 222
220 main() => new C();""" 223 main() => new C();"""
221 ]), 224 ]),
222 // Const constructor factories may only redirect (and must not have a body). 225 // Const constructor factories may only redirect (and must not have a body).
223 'CONST_FACTORY': new Message( 226 'CONST_FACTORY': new Message(
224 id: 'LGJGHW', 227 id: 'LGJGHW',
225 subId: 2, 228 subId: 2,
226 specializationOf: 0, 229 specializationOf: "CONST_CONSTRUCTOR_OR_FACTORY_WITH_BODY",
227 category: Category.parserError, 230 category: Category.parserError,
228 template: "Only redirecting factory constructors can be declared to " 231 template: "Only redirecting factory constructors can be declared to "
229 "be 'const'.", 232 "be 'const'.",
230 howToFix: "Try removing the 'const' keyword or replacing the body with " 233 howToFix: "Try removing the 'const' keyword or replacing the body with "
231 "'=' followed by a valid target.", 234 "'=' followed by a valid target.",
232 usedBy: [ 235 usedBy: [
233 analyzer 236 analyzer
234 ], 237 ],
235 examples: const [ 238 examples: const [
236 r""" 239 r"""
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // "get foo; main(){}", 287 // "get foo; main(){}",
285 "set foo; main(){}", 288 "set foo; main(){}",
286 "abstract foo; main(){}", 289 "abstract foo; main(){}",
287 "static foo; main(){}", 290 "static foo; main(){}",
288 "external foo; main(){}" 291 "external foo; main(){}"
289 ]), 292 ]),
290 293
291 'CONST_CLASS': new Message( 294 'CONST_CLASS': new Message(
292 id: 'GRKIQE', 295 id: 'GRKIQE',
293 subId: 2, 296 subId: 2,
294 // The specialization could also be 1, but the example below triggers 0. 297 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
295 specializationOf: 0, 298 // example below triggers 'EXTRANEOUS_MODIFIER'.
299 specializationOf: 'EXTRANEOUS_MODIFIER',
296 category: Category.parserError, 300 category: Category.parserError,
297 template: "Classes can't be declared to be 'const'", 301 template: "Classes can't be declared to be 'const'",
298 howToFix: "Try removing the 'const' keyword or moving to the class'" 302 howToFix: "Try removing the 'const' keyword or moving to the class'"
299 " constructor(s).", 303 " constructor(s).",
300 usedBy: [ 304 usedBy: [
301 analyzer 305 analyzer
302 ], 306 ],
303 examples: const [ 307 examples: const [
304 r""" 308 r"""
305 const class C {} 309 const class C {}
306 310
307 main() => new C(); 311 main() => new C();
308 """ 312 """
309 ]), 313 ]),
310 314
311 'CONST_METHOD': new Message( 315 'CONST_METHOD': new Message(
312 id: 'GRKIQE', 316 id: 'GRKIQE',
313 subId: 3, 317 subId: 3,
314 // The specialization could also be 1, but the example below triggers 0. 318 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
315 specializationOf: 0, 319 // example below triggers 'EXTRANEOUS_MODIFIER'.
320 specializationOf: 'EXTRANEOUS_MODIFIER',
316 category: Category.parserError, 321 category: Category.parserError,
317 template: "Getters, setters and methods can't be declared to be 'const'", 322 template: "Getters, setters and methods can't be declared to be 'const'",
318 howToFix: "Try removing the 'const' keyword.", 323 howToFix: "Try removing the 'const' keyword.",
319 usedBy: [ 324 usedBy: [
320 analyzer 325 analyzer
321 ], 326 ],
322 examples: const [ 327 examples: const [
323 "const int foo() => 499; main() {}", 328 "const int foo() => 499; main() {}",
324 "const int get foo => 499; main() {}", 329 "const int get foo => 499; main() {}",
325 "const set foo(v) => 499; main() {}", 330 "const set foo(v) => 499; main() {}",
326 "class A { const int foo() => 499; } main() { new A(); }", 331 "class A { const int foo() => 499; } main() { new A(); }",
327 "class A { const int get foo => 499; } main() { new A(); }", 332 "class A { const int get foo => 499; } main() { new A(); }",
328 "class A { const set foo(v) => 499; } main() { new A(); }", 333 "class A { const set foo(v) => 499; } main() { new A(); }",
329 ]), 334 ]),
330 335
331 'CONST_ENUM': new Message( 336 'CONST_ENUM': new Message(
332 id: 'GRKIQE', 337 id: 'GRKIQE',
333 subId: 4, 338 subId: 4,
334 // The specialization could also be 1, but the example below triggers 0. 339 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
335 specializationOf: 0, 340 // example below triggers 'EXTRANEOUS_MODIFIER'.
341 specializationOf: 'EXTRANEOUS_MODIFIER',
336 category: Category.parserError, 342 category: Category.parserError,
337 template: "Enums can't be declared to be 'const'", 343 template: "Enums can't be declared to be 'const'",
338 howToFix: "Try removing the 'const' keyword.", 344 howToFix: "Try removing the 'const' keyword.",
339 usedBy: [analyzer], 345 usedBy: [analyzer],
340 examples: const ["const enum Foo { x } main() {}",]), 346 examples: const ["const enum Foo { x } main() {}",]),
341 347
342 'CONST_TYPEDEF': new Message( 348 'CONST_TYPEDEF': new Message(
343 id: 'GRKIQE', 349 id: 'GRKIQE',
344 subId: 5, 350 subId: 5,
345 // The specialization could also be 1, but the example below triggers 0. 351 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
346 specializationOf: 0, 352 // example below triggers 'EXTRANEOUS_MODIFIER'.
353 specializationOf: 'EXTRANEOUS_MODIFIER',
347 category: Category.parserError, 354 category: Category.parserError,
348 template: "Type aliases can't be declared to be 'const'", 355 template: "Type aliases can't be declared to be 'const'",
349 howToFix: "Try removing the 'const' keyword.", 356 howToFix: "Try removing the 'const' keyword.",
350 usedBy: [analyzer], 357 usedBy: [analyzer],
351 examples: const ["const typedef void Foo(); main() {}",]), 358 examples: const ["const typedef void Foo(); main() {}",]),
352 359
353 'CONST_AND_FINAL': new Message( 360 'CONST_AND_FINAL': new Message(
354 id: 'GRKIQE', 361 id: 'GRKIQE',
355 subId: 6, 362 subId: 6,
356 // The specialization could also be 1, but the example below triggers 0. 363 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
357 specializationOf: 0, 364 // example below triggers 'EXTRANEOUS_MODIFIER'.
365 specializationOf: 'EXTRANEOUS_MODIFIER',
358 category: Category.parserError, 366 category: Category.parserError,
359 template: "Members can't be declared to be both 'const' and 'final'", 367 template: "Members can't be declared to be both 'const' and 'final'",
360 howToFix: "Try removing either the 'const' or 'final' keyword.", 368 howToFix: "Try removing either the 'const' or 'final' keyword.",
361 usedBy: [ 369 usedBy: [
362 analyzer 370 analyzer
363 ], 371 ],
364 examples: const [ 372 examples: const [
365 "final const int x = 499; main() {}", 373 "final const int x = 499; main() {}",
366 "const final int x = 499; main() {}", 374 "const final int x = 499; main() {}",
367 "class A { static final const int x = 499; } main() {}", 375 "class A { static final const int x = 499; } main() {}",
368 "class A { static const final int x = 499; } main() {}", 376 "class A { static const final int x = 499; } main() {}",
369 ]), 377 ]),
370 378
371 'CONST_AND_VAR': new Message( 379 'CONST_AND_VAR': new Message(
372 id: 'GRKIQE', 380 id: 'GRKIQE',
373 subId: 7, 381 subId: 7,
374 // The specialization could also be 1, but the example below triggers 0. 382 // The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
375 specializationOf: 0, 383 // example below triggers 'EXTRANEOUS_MODIFIER'.
384 specializationOf: 'EXTRANEOUS_MODIFIER',
376 category: Category.parserError, 385 category: Category.parserError,
377 template: "Members can't be declared to be both 'const' and 'var'", 386 template: "Members can't be declared to be both 'const' and 'var'",
378 howToFix: "Try removing either the 'const' or 'var' keyword.", 387 howToFix: "Try removing either the 'const' or 'var' keyword.",
379 usedBy: [ 388 usedBy: [
380 analyzer 389 analyzer
381 ], 390 ],
382 examples: const [ 391 examples: const [
383 "var const x = 499; main() {}", 392 "var const x = 499; main() {}",
384 "const var x = 499; main() {}", 393 "const var x = 499; main() {}",
385 "class A { var const x = 499; } main() {}", 394 "class A { var const x = 499; } main() {}",
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 """ 486 """
478 foo() async* { return 0; } 487 foo() async* { return 0; }
479 main() => foo(); 488 main() => foo();
480 """, 489 """,
481 """ 490 """
482 foo() sync* { return 0; } 491 foo() sync* { return 0; }
483 main() => foo(); 492 main() => foo();
484 """ 493 """
485 ]), 494 ]),
486 }; 495 };
OLDNEW
« no previous file with comments | « no previous file | pkg/dart_messages/test/dart_messages_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698