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

Unified Diff: pkg/intl/lib/src/intl_message.dart

Issue 175543003: Add a validation for the name parameter not matching the function name (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/lib/src/intl_message.dart
diff --git a/pkg/intl/lib/src/intl_message.dart b/pkg/intl/lib/src/intl_message.dart
index a502326280b3b06184870adb3bf7841438994b39..b21c0b85812c0ee5472a83c126334befd61e2ca0 100644
--- a/pkg/intl/lib/src/intl_message.dart
+++ b/pkg/intl/lib/src/intl_message.dart
@@ -89,6 +89,11 @@ abstract class Message {
return "The 'name' argument for Intl.message must be a simple string "
"literal.";
}
+ if (outerName != null && outerName != messageName.expression.value) {
+ return "The 'name' argument for Intl.message must match "
+ "the name of the containing function ("
+ "'${messageName.expression.value}' vs. '$outerName')";
+ }
var simpleArguments = arguments.where(
(each) => each is NamedExpression
&& ["desc", "name"].contains(each.name.label.name));
@@ -99,6 +104,7 @@ abstract class Message {
"a simple string literal";
}
}
+ return null;
}
/**
@@ -351,7 +357,7 @@ class MainMessage extends ComplexMessage {
* the name.
*/
String get name => _name == null ? computeName() : _name;
- void set name(x) {_name = x;}
+ set name(String newName) { _name = newName; }
Emily Fortuna 2014/02/24 18:38:23 I'd be inclined to leave the "void" in this line,
Alan Knight 2014/02/24 18:46:44 I got dinged before in a review for having that, s
String computeName() => name = expanded((msg, chunk) => "");
@@ -369,7 +375,7 @@ class MainMessage extends ComplexMessage {
* Record the translation for this message in the given locale, after
* suitably escaping it.
*/
- String addTranslation(String locale, Message translated) {
+ void addTranslation(String locale, Message translated) {
translated.parent = this;
translations[locale] = translated.toCode();
}
« 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