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

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

Issue 181383009: Relax string literal requirements on arguments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | pkg/intl/test/message_extraction/part_of_sample_with_messages.dart » ('j') | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (outerName != null && outerName != messageName.expression.value) { 92 if (outerName != null && outerName != messageName.expression.value) {
93 return "The 'name' argument for Intl.message must match " 93 return "The 'name' argument for Intl.message must match "
94 "the name of the containing function (" 94 "the name of the containing function ("
95 "'${messageName.expression.value}' vs. '$outerName')"; 95 "'${messageName.expression.value}' vs. '$outerName')";
96 } 96 }
97 var simpleArguments = arguments.where( 97 var simpleArguments = arguments.where(
98 (each) => each is NamedExpression 98 (each) => each is NamedExpression
99 && ["desc", "name"].contains(each.name.label.name)); 99 && ["desc", "name"].contains(each.name.label.name));
100 var values = simpleArguments.map((each) => each.expression).toList(); 100 var values = simpleArguments.map((each) => each.expression).toList();
101 for (var arg in values) { 101 for (var arg in values) {
102 if (arg is! SimpleStringLiteral) { 102 if (arg is! StringLiteral) {
103 return "Intl.message argument '$arg' must be " 103 return( "Intl.message arguments must be string literals: $arg");
104 "a simple string literal";
105 } 104 }
106 } 105 }
107 return null; 106 return null;
108 } 107 }
109 108
110 /** 109 /**
111 * Turn a value, typically read from a translation file or created out of an 110 * Turn a value, typically read from a translation file or created out of an
112 * AST for a source program, into the appropriate 111 * AST for a source program, into the appropriate
113 * subclass. We expect to get literal Strings, variable substitutions 112 * subclass. We expect to get literal Strings, variable substitutions
114 * represented by integers, things that are already MessageChunks and 113 * represented by integers, things that are already MessageChunks and
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 out.write('('); 674 out.write('(');
676 out.write(mainArgument); 675 out.write(mainArgument);
677 var args = codeAttributeNames; 676 var args = codeAttributeNames;
678 out.write(", {"); 677 out.write(", {");
679 args.fold(out, (buffer, arg) => buffer..write( 678 args.fold(out, (buffer, arg) => buffer..write(
680 "'$arg': '${this[arg].toCode()}', ")); 679 "'$arg': '${this[arg].toCode()}', "));
681 out.write("})}"); 680 out.write("})}");
682 return out.toString(); 681 return out.toString();
683 } 682 }
684 } 683 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/test/message_extraction/part_of_sample_with_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698