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..e5e0ac5a4445634b4da756282dcaeed4b5a51e78 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,74 @@ 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_OR_FACTORY_WITH_BODY': new Message( |
| + id: 'LGJGHW', |
| + subId: 0, |
| + category: Category.parserError, |
| + template: "Const constructor or factory cannot have a body.", |
|
Johnni Winther
2016/02/04 08:40:11
`cannot` -> `can't` ? (cf. item 6 in the dartdoc)
floitsch
2016/02/04 10:44:41
Done.
|
| + howToFix: "Remove the 'const' keyword or the body.", |
|
Johnni Winther
2016/02/04 08:40:11
I think the [howToFix] should be a suggestion and
floitsch
2016/02/04 10:44:41
Done.
|
| + 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 cannot have a body.", |
| + 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'", |
|
Johnni Winther
2016/02/04 08:40:11
Add period to finish the sentence.
floitsch
2016/02/04 10:44:41
Done.
|
| + howToFix: "Remove the 'const' keyword or replace the body with '=' " |
| + "followed by a valid target", |
|
Johnni Winther
2016/02/04 08:40:11
Ditto.
floitsch
2016/02/04 10:44:41
Done.
|
| + usedBy: [analyzer], |
| + examples: const [ |
| + r""" |
| + class C { |
| + const factory C() {} |
| + } |
| + |
| + main() => new C();""" |
| + ]), |
| }; |