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

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

Issue 2979623002: Use messages for (some) public API errors (Closed)
Patch Set: wrap - verification error still pending 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('Error: missing template for message: $name');
56 exit(1);
57 return '';
58 }
54 var parameters = new Set<String>(); 59 var parameters = new Set<String>();
55 var conversions = new Set<String>(); 60 var conversions = new Set<String>();
56 var arguments = new Set<String>(); 61 var arguments = new Set<String>();
57 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) { 62 for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) {
58 switch (match[0]) { 63 switch (match[0]) {
59 case "#character": 64 case "#character":
60 parameters.add("String character"); 65 parameters.add("String character");
61 arguments.add("'character': character"); 66 arguments.add("'character': character");
62 break; 67 break;
63 68
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 155
151 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. 156 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
152 Message _withArguments$name(${parameters.join(', ')}) { 157 Message _withArguments$name(${parameters.join(', ')}) {
153 ${conversions.join('\n ')} 158 ${conversions.join('\n ')}
154 return new Message( 159 return new Message(
155 code$name, 160 code$name,
156 ${messageArguments.join(', ')}); 161 ${messageArguments.join(', ')});
157 } 162 }
158 """; 163 """;
159 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698