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

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

Issue 2979623002: Use messages for (some) public API errors (Closed)
Patch Set: 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 Uri.parse('package:front_end/src/fasta/fasta_codes_generated.dart')); 44 Uri.parse('package:front_end/src/fasta/fasta_codes_generated.dart'));
45 await new File.fromUri(problemsFile) 45 await new File.fromUri(problemsFile)
46 .writeAsString(dartfmtedText, flush: true); 46 .writeAsString(dartfmtedText, flush: true);
47 port.close(); 47 port.close();
48 } 48 }
49 49
50 final RegExp placeholderPattern = new RegExp("#[a-zA-Z0-9_]+"); 50 final RegExp placeholderPattern = new RegExp("#[a-zA-Z0-9_]+");
51 51
52 String compileTemplate(String name, String template, String tip, 52 String compileTemplate(String name, String template, String tip,
53 String analyzerCode, String dart2jsCode) { 53 String analyzerCode, String dart2jsCode) {
54 if (template == null) {
55 print('missing template for message: $name');
56 return '';
Paul Berry 2017/07/11 16:00:59 Would it be better to throw an exception here, to
Siggi Cherem (dart-lang) 2017/07/12 00:29:46 Done.
57 }
54 var parameters = new Set<String>(); 58 var parameters = new Set<String>();
55 var conversions = new Set<String>(); 59 var conversions = new Set<String>();
56 var arguments = new Set<String>(); 60 var arguments = new Set<String>();
57 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) { 61 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) {
58 switch (match[0]) { 62 switch (match[0]) {
59 case "#character": 63 case "#character":
60 parameters.add("String character"); 64 parameters.add("String character");
61 arguments.add("'character': character"); 65 arguments.add("'character': character");
62 break; 66 break;
63 67
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 154
151 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. 155 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
152 Message _withArguments$name(${parameters.join(', ')}) { 156 Message _withArguments$name(${parameters.join(', ')}) {
153 ${conversions.join('\n ')} 157 ${conversions.join('\n ')}
154 return new Message( 158 return new Message(
155 code$name, 159 code$name,
156 ${messageArguments.join(', ')}); 160 ${messageArguments.join(', ')});
157 } 161 }
158 """; 162 """;
159 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698