| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 String get dartMessageName; | 206 String get dartMessageName; |
| 207 } | 207 } |
| 208 | 208 |
| 209 /** | 209 /** |
| 210 * This represents a message chunk that is a list of multiple sub-pieces, | 210 * This represents a message chunk that is a list of multiple sub-pieces, |
| 211 * each of which is in turn a [Message]. | 211 * each of which is in turn a [Message]. |
| 212 */ | 212 */ |
| 213 class CompositeMessage extends Message { | 213 class CompositeMessage extends Message { |
| 214 List<Message> pieces; | 214 List<Message> pieces; |
| 215 | 215 |
| 216 CompositeMessage.parent(parent) : super(parent); | 216 CompositeMessage.withParent(parent) : super(parent); |
| 217 CompositeMessage(this.pieces, ComplexMessage parent) : super(parent) { | 217 CompositeMessage(this.pieces, ComplexMessage parent) : super(parent) { |
| 218 pieces.forEach((x) => x.parent = this); | 218 pieces.forEach((x) => x.parent = this); |
| 219 } | 219 } |
| 220 toCode() => pieces.map((each) => each.toCode()).join(''); | 220 toCode() => pieces.map((each) => each.toCode()).join(''); |
| 221 toString() => "CompositeMessage(" + pieces.toString() + ")"; | 221 toString() => "CompositeMessage(" + pieces.toString() + ")"; |
| 222 String expanded([Function f = _nullTransform]) => | 222 String expanded([Function f = _nullTransform]) => |
| 223 pieces.map((chunk) => f(this, chunk)).join(""); | 223 pieces.map((chunk) => f(this, chunk)).join(""); |
| 224 } | 224 } |
| 225 | 225 |
| 226 /** Represents a simple constant string with no dynamic elements. */ | 226 /** Represents a simple constant string with no dynamic elements. */ |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 out.write(dartMessageName); | 634 out.write(dartMessageName); |
| 635 out.write('('); | 635 out.write('('); |
| 636 out.write(mainArgument); | 636 out.write(mainArgument); |
| 637 var args = codeAttributeNames; | 637 var args = codeAttributeNames; |
| 638 out.write(", {"); | 638 out.write(", {"); |
| 639 args.fold(out, (buffer, arg) => buffer..write( | 639 args.fold(out, (buffer, arg) => buffer..write( |
| 640 "'$arg': '${this[arg].toCode()}', ")); | 640 "'$arg': '${this[arg].toCode()}', ")); |
| 641 out.write("})}"); | 641 out.write("})}"); |
| 642 return out.toString(); | 642 return out.toString(); |
| 643 } | 643 } |
| 644 } | 644 } |
| OLD | NEW |