Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |