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

Side by Side Diff: pkg/intl/lib/extract_messages.dart

Issue 28193004: Attempt to fix build. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** 5 /**
6 * This is for use in extracting messages from a Dart program 6 * This is for use in extracting messages from a Dart program
7 * using the Intl.message() mechanism and writing them to a file for 7 * using the Intl.message() mechanism and writing them to a file for
8 * translation. This provides only the stub of a mechanism, because it 8 * translation. This provides only the stub of a mechanism, because it
9 * doesn't define how the file should be written. It provides an 9 * doesn't define how the file should be written. It provides an
10 * [IntlMessage] class that holds the extracted data and [parseString] 10 * [IntlMessage] class that holds the extracted data and [parseString]
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 * Create a MainMessage from [node] using the name and 210 * Create a MainMessage from [node] using the name and
211 * parameters of the last function/method declaration we encountered, 211 * parameters of the last function/method declaration we encountered,
212 * and the values we get by calling [extract]. We set those values 212 * and the values we get by calling [extract]. We set those values
213 * by calling [setAttribute]. This is the common parts between 213 * by calling [setAttribute]. This is the common parts between
214 * [messageFromIntlMessageCall] and [messageFromDirectPluralOrGenderCall]. 214 * [messageFromIntlMessageCall] and [messageFromDirectPluralOrGenderCall].
215 */ 215 */
216 MainMessage _messageFromNode(MethodInvocation node, Function extract, 216 MainMessage _messageFromNode(MethodInvocation node, Function extract,
217 Function setAttribute) { 217 Function setAttribute) {
218 var message = new MainMessage(); 218 var message = new MainMessage();
219 message.name = name; 219 message.name = name;
220 message.arguments = parameters.parameters.elements.map( 220 message.arguments = parameters.parameters.map(
221 (x) => x.identifier.name).toList(); 221 (x) => x.identifier.name).toList();
222 var arguments = node.argumentList.arguments.elements; 222 var arguments = node.argumentList.arguments;
223 extract(message, arguments); 223 extract(message, arguments);
224 224
225 for (var namedArgument in arguments.where((x) => x is NamedExpression)) { 225 for (var namedArgument in arguments.where((x) => x is NamedExpression)) {
226 var name = namedArgument.name.label.name; 226 var name = namedArgument.name.label.name;
227 var exp = namedArgument.expression; 227 var exp = namedArgument.expression;
228 var string = exp is SimpleStringLiteral ? exp.value : exp.toString(); 228 var string = exp is SimpleStringLiteral ? exp.value : exp.toString();
229 setAttribute(message, name, string); 229 setAttribute(message, name, string);
230 } 230 }
231 return message; 231 return message;
232 } 232 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } on IntlMessageExtractionException catch (e) { 439 } on IntlMessageExtractionException catch (e) {
440 message = null; 440 message = null;
441 var err = new StringBuffer(); 441 var err = new StringBuffer();
442 err.write("Error $e"); 442 err.write("Error $e");
443 err.write("Processing <$node>"); 443 err.write("Processing <$node>");
444 err.write(_reportErrorLocation(node)); 444 err.write(_reportErrorLocation(node));
445 print(err); 445 print(err);
446 warnings.add(err); 446 warnings.add(err);
447 } 447 }
448 }); 448 });
449 var mainArg = node.argumentList.arguments.elements.firstWhere( 449 var mainArg = node.argumentList.arguments.firstWhere(
450 (each) => each is! NamedExpression); 450 (each) => each is! NamedExpression);
451 if (mainArg is SimpleStringLiteral) { 451 if (mainArg is SimpleStringLiteral) {
452 message.mainArgument = mainArg.toString(); 452 message.mainArgument = mainArg.toString();
453 } else { 453 } else {
454 message.mainArgument = mainArg.name; 454 message.mainArgument = mainArg.name;
455 } 455 }
456 return message; 456 return message;
457 } 457 }
458 } 458 }
459 459
460 /** 460 /**
461 * Exception thrown when we cannot process a message properly. 461 * Exception thrown when we cannot process a message properly.
462 */ 462 */
463 class IntlMessageExtractionException implements Exception { 463 class IntlMessageExtractionException implements Exception {
464 /** 464 /**
465 * A message describing the error. 465 * A message describing the error.
466 */ 466 */
467 final String message; 467 final String message;
468 468
469 /** 469 /**
470 * Creates a new exception with an optional error [message]. 470 * Creates a new exception with an optional error [message].
471 */ 471 */
472 const IntlMessageExtractionException([this.message = ""]); 472 const IntlMessageExtractionException([this.message = ""]);
473 473
474 String toString() => "IntlMessageExtractionException: $message"; 474 String toString() => "IntlMessageExtractionException: $message";
475 } 475 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/engine.dart ('k') | pkg/intl/lib/src/intl_message.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698