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

Side by Side Diff: pkg/intl/lib/src/intl_message.dart

Issue 129813005: Add an examples getter for all Message objects in Intl (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 provides classes to represent the internal structure of the 6 * This provides classes to represent the internal structure of the
7 * arguments to `Intl.message`. It is used when parsing sources to extract 7 * arguments to `Intl.message`. It is used when parsing sources to extract
8 * messages or to generate code for message substitution. Normal programs 8 * messages or to generate code for message substitution. Normal programs
9 * using Intl would not import this library. 9 * using Intl would not import this library.
10 * 10 *
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Message parent; 54 Message parent;
55 55
56 Message(this.parent); 56 Message(this.parent);
57 57
58 /** 58 /**
59 * We find the arguments from the top-level [MainMessage] and use those to 59 * We find the arguments from the top-level [MainMessage] and use those to
60 * do variable substitutions. 60 * do variable substitutions.
61 */ 61 */
62 get arguments => parent == null ? const [] : parent.arguments; 62 get arguments => parent == null ? const [] : parent.arguments;
63 63
64 /**
65 * We find the examples from the top-level [MainMessage] and use those
Emily Fortuna 2014/01/09 23:10:32 does this comment make sense, because according to
Alan Knight 2014/01/10 18:44:28 But MainMessage has an examples field that overrid
66 * when writing out variables.
67 */
68 get examples => parent == null ? const [] : parent.examples;
69
64 String checkValidity(MethodInvocation node, List arguments, 70 String checkValidity(MethodInvocation node, List arguments,
65 String outerName, FormalParameterList outerArgs) { 71 String outerName, FormalParameterList outerArgs) {
66 var hasArgs = arguments.any( 72 var hasArgs = arguments.any(
67 (each) => each is NamedExpression && each.name.label.name == 'args'); 73 (each) => each is NamedExpression && each.name.label.name == 'args');
68 var hasParameters = !outerArgs.parameters.isEmpty; 74 var hasParameters = !outerArgs.parameters.isEmpty;
69 if (!hasArgs && hasParameters) { 75 if (!hasArgs && hasParameters) {
70 return "The 'args' argument for Intl.message must be specified"; 76 return "The 'args' argument for Intl.message must be specified";
71 } 77 }
72 78
73 var messageName = arguments.firstWhere( 79 var messageName = arguments.firstWhere(
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 out.write('('); 667 out.write('(');
662 out.write(mainArgument); 668 out.write(mainArgument);
663 var args = codeAttributeNames; 669 var args = codeAttributeNames;
664 out.write(", {"); 670 out.write(", {");
665 args.fold(out, (buffer, arg) => buffer..write( 671 args.fold(out, (buffer, arg) => buffer..write(
666 "'$arg': '${this[arg].toCode()}', ")); 672 "'$arg': '${this[arg].toCode()}', "));
667 out.write("})}"); 673 out.write("})}");
668 return out.toString(); 674 return out.toString();
669 } 675 }
670 } 676 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698