Chromium Code Reviews| Index: pkg/dart_messages/lib/shared_messages.dart |
| diff --git a/pkg/dart_messages/lib/shared_messages.dart b/pkg/dart_messages/lib/shared_messages.dart |
| index 896f52ad546ca0ba5ac6e68adc638515fe891263..5967b13ab6bd09bc4e269e3a3e422e2d9cf29e8a 100644 |
| --- a/pkg/dart_messages/lib/shared_messages.dart |
| +++ b/pkg/dart_messages/lib/shared_messages.dart |
| @@ -70,17 +70,25 @@ class Category { |
| static final analysisOptionsWarning = new Category("AnalysisOptionsWarning"); |
| - static final checkedModeCompileTimeError = new Category( |
| - "CheckedModeCompileTimeError"); |
| + static final checkedModeCompileTimeError = |
| + new Category("CheckedModeCompileTimeError"); |
| + |
| + static final parserError = new Category("ParserError"); |
| final String name; |
| Category(this.name); |
| } |
| +enum Platform { |
| + dart2js, analyzer, |
| +} |
| +const dart2js = Platform.dart2js; |
| +const analyzer = Platform.analyzer; |
| class Message { |
| final String id; |
| + final int subId; |
| final Category category; |
| final String template; |
| // The analyzer fills holes positionally (and not named). The following field |
| @@ -90,23 +98,37 @@ class Message { |
| // provide the class `cls` and then only `field`. |
| // This list is generally `null`, but when it is provided it must contain all |
| // holes. |
| - final List templateHoleOrder; |
| + final List<String> templateHoleOrder; |
| final String howToFix; |
| final List<String> options; |
| final List examples; |
| + final List<Platform> usedBy; |
| - Message({this.id, this.category, this.template, this.templateHoleOrder, |
| - this.howToFix, this.options, this.examples}); |
| + Message( |
| + {this.id, |
| + this.subId: 0, |
| + this.category, |
| + this.template, |
| + this.templateHoleOrder, |
| + this.howToFix, |
| + this.options, |
| + this.usedBy: const [], |
| + this.examples}); |
| } |
| String get messagesAsJson { |
| var jsonified = {}; |
| MESSAGES.forEach((String name, Message message) { |
| - jsonified[name] = { |
| + jsonified[name] = { |
| 'id': message.id, |
| + 'subId': message.subId, |
| 'category': message.category.name, |
| 'template': message.template, |
| - 'howToFix': message.howToFix |
| + 'templateHoleOrder': message.templateHoleOrder, |
| + 'howToFix': message.howToFix, |
| + 'options': message.options, |
| + 'usedBy': message.usedBy.map((platform) => platform.toString()).toList(), |
| + 'examples': message.examples, |
| }; |
| }); |
| return JSON.encode(jsonified); |
| @@ -119,17 +141,73 @@ final Map<String, Message> MESSAGES = { |
| template: "#use #named #arguments", |
| templateHoleOrder: ["arguments", "named", "use"], |
| howToFix: "an explanation on how to fix things", |
| - examples: [r''' |
| + examples: [ |
| + r''' |
| Some multiline example; |
| That generates the bug.''', |
| - { |
| - 'fileA.dart': ''' |
| + { |
| + 'fileA.dart': ''' |
| or a map from file to content. |
| again multiline''', |
| - 'fileB.dart': ''' |
| + 'fileB.dart': ''' |
| with possibly multiple files. |
| muliline too''' |
| - } |
| - ] |
| - ), |
| + } |
| + ]), |
| + |
| + // Const constructors (factory or not) may not have a body. |
| + 'CONST_CONSTRUCTOR_HAS_BODY': new Message( |
| + id: 'LGJGHW', |
| + category: Category.parserError, |
|
Brian Wilkerson
2016/02/03 00:27:12
Missing subId?
floitsch
2016/02/03 17:50:25
Missing subid implies 0, but I added it.
Brian Wilkerson
2016/02/03 20:37:22
Good to know.
|
| + template: "Const constructor or factory can't have a body.", |
| + howToFix: "Remove the 'const' keyword or the body.", |
| + usedBy: [dart2js], |
| + examples: const [ |
| + r""" |
| + class C { |
| + const C() {} |
| + } |
| + |
| + main() => new C();""", |
| + r""" |
| + class C { |
| + const factory C() {} |
| + } |
| + |
| + main() => new C();""" |
| + ]), |
| + // Const constructors may not have a body. |
| + 'CONST_CONSTRUCTOR_WITH_BODY': new Message( |
| + id: 'LGJGHW', |
| + subId: 1, |
| + category: Category.parserError, |
| + template: "Const constructor or factory can't have a body.", |
|
Brian Wilkerson
2016/02/03 00:27:12
The "or factory" is confusing. If the constructor
floitsch
2016/02/03 17:50:25
My mistake. Removed the factory part.
I don't want
Brian Wilkerson
2016/02/03 20:37:22
Like I said, every time we change a message we ris
floitsch
2016/02/03 21:15:39
The latest version is "Const constructor cannot ha
Brian Wilkerson
2016/02/03 21:30:59
Sounds good.
|
| + howToFix: "Remove the 'const' keyword or the body.", |
| + usedBy: [analyzer], |
| + examples: const [ |
| + r""" |
| + class C { |
| + const C() {} |
| + } |
| + |
| + main() => new C();""" |
| + ]), |
| + // Const constructor factories may only redirect (and must not have a body). |
| + 'CONST_FACTORY': new Message( |
| + id: 'LGJGHW', |
| + subId: 2, |
| + category: Category.parserError, |
| + template: |
| + "Only redirecting factory constructors can be declared to be 'const'", |
| + howToFix: "Remove the 'const' keyword or replace the body with '=' " |
| + "followed by a valid target", |
| + usedBy: [analyzer], |
| + examples: const [ |
| + r""" |
| + class C { |
| + const factory C() {} |
| + } |
| + |
| + main() => new C();""" |
| + ]), |
| }; |