| 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 is for use in extracting messages from a Dart program | 6 * This is for use in extracting messages from a Dart program |
| 7 * using the Intl.message() mechanism and writing them to a file for | 7 * using the Intl.message() mechanism and writing them to a file for |
| 8 * translation. This provides only the stub of a mechanism, because it | 8 * translation. This provides only the stub of a mechanism, because it |
| 9 * doesn't define how the file should be written. It provides an | 9 * doesn't define how the file should be written. It provides an |
| 10 * [IntlMessage] class that holds the extracted data and [parseString] | 10 * [IntlMessage] class that holds the extracted data and [parseString] |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 var instance = _expectedInstance(node.methodName.name); | 140 var instance = _expectedInstance(node.methodName.name); |
| 141 return instance.checkValidity(node, arguments, name, parameters); | 141 return instance.checkValidity(node, arguments, name, parameters); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * Record the parameters of the function or method declaration we last | 145 * Record the parameters of the function or method declaration we last |
| 146 * encountered before seeing the Intl.message call. | 146 * encountered before seeing the Intl.message call. |
| 147 */ | 147 */ |
| 148 void visitMethodDeclaration(MethodDeclaration node) { | 148 void visitMethodDeclaration(MethodDeclaration node) { |
| 149 parameters = node.parameters; | 149 parameters = node.parameters; |
| 150 if (parameters == null) parameters = new FormalParameterList(); |
| 150 name = node.name.name; | 151 name = node.name.name; |
| 151 super.visitMethodDeclaration(node); | 152 super.visitMethodDeclaration(node); |
| 152 } | 153 } |
| 153 | 154 |
| 154 /** | 155 /** |
| 155 * Record the parameters of the function or method declaration we last | 156 * Record the parameters of the function or method declaration we last |
| 156 * encountered before seeing the Intl.message call. | 157 * encountered before seeing the Intl.message call. |
| 157 */ | 158 */ |
| 158 void visitFunctionDeclaration(FunctionDeclaration node) { | 159 void visitFunctionDeclaration(FunctionDeclaration node) { |
| 159 parameters = node.functionExpression.parameters; | 160 parameters = node.functionExpression.parameters; |
| 161 if (parameters == null) parameters = new FormalParameterList(); |
| 160 name = node.name.name; | 162 name = node.name.name; |
| 161 super.visitFunctionDeclaration(node); | 163 super.visitFunctionDeclaration(node); |
| 162 } | 164 } |
| 163 | 165 |
| 164 /** | 166 /** |
| 165 * Examine method invocations to see if they look like calls to Intl.message. | 167 * Examine method invocations to see if they look like calls to Intl.message. |
| 166 * If we've found one, stop recursing. This is important because we can have | 168 * If we've found one, stop recursing. This is important because we can have |
| 167 * Intl.message(...Intl.plural...) and we don't want to treat the inner | 169 * Intl.message(...Intl.plural...) and we don't want to treat the inner |
| 168 * plural as if it was an outermost message. | 170 * plural as if it was an outermost message. |
| 169 */ | 171 */ |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 */ | 466 */ |
| 465 final String message; | 467 final String message; |
| 466 | 468 |
| 467 /** | 469 /** |
| 468 * Creates a new exception with an optional error [message]. | 470 * Creates a new exception with an optional error [message]. |
| 469 */ | 471 */ |
| 470 const IntlMessageExtractionException([this.message = ""]); | 472 const IntlMessageExtractionException([this.message = ""]); |
| 471 | 473 |
| 472 String toString() => "IntlMessageExtractionException: $message"; | 474 String toString() => "IntlMessageExtractionException: $message"; |
| 473 } | 475 } |
| OLD | NEW |