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

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: Clarified comment 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 * All [Message]s except a [MainMessage] are contained inside some parent, 50 * All [Message]s except a [MainMessage] are contained inside some parent,
51 * terminating at an Intl.message call which supplies the arguments we 51 * terminating at an Intl.message call which supplies the arguments we
52 * use for variable substitutions. 52 * use for variable substitutions.
53 */ 53 */
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. [MainMessage] overrides this to return
61 * the actual arguments.
61 */ 62 */
62 get arguments => parent == null ? const [] : parent.arguments; 63 get arguments => parent == null ? const [] : parent.arguments;
63 64
65 /**
66 * We find the examples from the top-level [MainMessage] and use those
67 * when writing out variables. [MainMessage] overrides this to return
68 * the actual examples.
69 */
70 get examples => parent == null ? const [] : parent.examples;
71
64 String checkValidity(MethodInvocation node, List arguments, 72 String checkValidity(MethodInvocation node, List arguments,
65 String outerName, FormalParameterList outerArgs) { 73 String outerName, FormalParameterList outerArgs) {
66 var hasArgs = arguments.any( 74 var hasArgs = arguments.any(
67 (each) => each is NamedExpression && each.name.label.name == 'args'); 75 (each) => each is NamedExpression && each.name.label.name == 'args');
68 var hasParameters = !outerArgs.parameters.isEmpty; 76 var hasParameters = !outerArgs.parameters.isEmpty;
69 if (!hasArgs && hasParameters) { 77 if (!hasArgs && hasParameters) {
70 return "The 'args' argument for Intl.message must be specified"; 78 return "The 'args' argument for Intl.message must be specified";
71 } 79 }
72 80
73 var messageName = arguments.firstWhere( 81 var messageName = arguments.firstWhere(
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 out.write('('); 669 out.write('(');
662 out.write(mainArgument); 670 out.write(mainArgument);
663 var args = codeAttributeNames; 671 var args = codeAttributeNames;
664 out.write(", {"); 672 out.write(", {");
665 args.fold(out, (buffer, arg) => buffer..write( 673 args.fold(out, (buffer, arg) => buffer..write(
666 "'$arg': '${this[arg].toCode()}', ")); 674 "'$arg': '${this[arg].toCode()}', "));
667 out.write("})}"); 675 out.write("})}");
668 return out.toString(); 676 return out.toString();
669 } 677 }
670 } 678 }
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