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

Side by Side Diff: pkg/front_end/tool/_fasta/generate_messages.dart

Issue 2979623002: Use messages for (some) public API errors (Closed)
Patch Set: cl comments Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 8
9 import 'package:yaml/yaml.dart' show loadYaml; 9 import 'package:yaml/yaml.dart' show loadYaml;
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 Uri.parse('package:front_end/src/fasta/fasta_codes_generated.dart')); 46 Uri.parse('package:front_end/src/fasta/fasta_codes_generated.dart'));
47 await new File.fromUri(problemsFile) 47 await new File.fromUri(problemsFile)
48 .writeAsString(dartfmtedText, flush: true); 48 .writeAsString(dartfmtedText, flush: true);
49 port.close(); 49 port.close();
50 } 50 }
51 51
52 final RegExp placeholderPattern = new RegExp("#[a-zA-Z0-9_]+"); 52 final RegExp placeholderPattern = new RegExp("#[a-zA-Z0-9_]+");
53 53
54 String compileTemplate(String name, String template, String tip, 54 String compileTemplate(String name, String template, String tip,
55 String analyzerCode, String dart2jsCode) { 55 String analyzerCode, String dart2jsCode) {
56 if (template == null) {
57 print('Error: missing template for message: $name');
58 exit(1);
ahe 2017/07/13 00:03:38 How about: exitCode = 1;
Siggi Cherem (dart-lang) 2017/07/18 00:32:57 Done.
59 return '';
60 }
56 var parameters = new Set<String>(); 61 var parameters = new Set<String>();
57 var conversions = new Set<String>(); 62 var conversions = new Set<String>();
58 var arguments = new Set<String>(); 63 var arguments = new Set<String>();
59 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) { 64 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) {
60 switch (match[0]) { 65 switch (match[0]) {
61 case "#character": 66 case "#character":
62 parameters.add("String character"); 67 parameters.add("String character");
63 arguments.add("'character': character"); 68 arguments.add("'character': character");
64 break; 69 break;
65 70
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 179
175 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. 180 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
176 Message _withArguments$name(${parameters.join(', ')}) { 181 Message _withArguments$name(${parameters.join(', ')}) {
177 ${conversions.join('\n ')} 182 ${conversions.join('\n ')}
178 return new Message( 183 return new Message(
179 code$name, 184 code$name,
180 ${messageArguments.join(', ')}); 185 ${messageArguments.join(', ')});
181 } 186 }
182 """; 187 """;
183 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698