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 bd51f581934a31c2f75267c359de6f5ba33f490e..3c66dd1b51250584c42d3cda357447d7804f4c0e 100644 |
| --- a/pkg/dart_messages/lib/shared_messages.dart |
| +++ b/pkg/dart_messages/lib/shared_messages.dart |
| @@ -3,7 +3,7 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| // An update to this file must be followed by regenerating the corresponding |
| -// json file. Use `json_converter.dart` in the bin directory. |
| +// json, dart2js and analyzer file. Use `publish.dart` in the bin directory. |
| // |
| // Every message in this file must have an id. Use `message_id.dart` in the |
| // bin directory to generate a fresh one. |
| @@ -58,5 +58,56 @@ |
| // 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we |
| // combine the first two in [template] and the last in [howToFix]. |
| -final Map<String, Map> MESSAGES = { |
| +import 'dart:convert'; |
| + |
| +class Message { |
| + final String id; |
| + final String template; |
| + // The analyzer fills holes positionally (and not named). The following field |
| + // overrides the order of the holes. |
| + // For example the template "The argument #field in #cls is bad", could have |
| + // the order `["cls", "field"]', which means that the analyzer would first |
| + // 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 String howToFix; |
| + final List<String> options; |
| + final List examples; |
| + |
| + Message({this.id, this.template, this.templateHoleOrder, this.howToFix, |
| + this.options, this.examples}); |
| +} |
| + |
| +String get messagesAsJson { |
| + var jsonified = {}; |
| + MESSAGES.forEach((String name, Message message) { |
| + jsonified[name] = { |
| + 'id': message.id, |
| + 'template': message.template, |
| + 'howToFix': message.howToFix |
| + }; |
| + }); |
| + return JSON.encode(jsonified); |
| +} |
| + |
| +final Map<String, Message> MESSAGES = { |
| + 'exampleMessage': new Message( |
| + id: 'use an Id generated by bin/message_id.dart', |
| + template: "#use #named #arguments", |
| + templateHoleOrder: ["arguments", "named", "use"], |
| + howToFix: "an explanation on how to fix things", |
| + examples: [r''' |
| +Some multiline example; |
|
Siggi Cherem (dart-lang)
2016/01/14 17:57:40
consider indenting this if the extra space is not
floitsch
2016/01/15 17:20:39
Done.
|
| +That generates the bug.''', |
| + { |
| +'fileA.dart': ''' |
| +or a map from file to content. |
| +again multiline''', |
| +'fileB.dart': ''' |
| +with possibly multiple files. |
| +muliline too''' |
| + } |
| + ] |
| + ), |
| }; |