| 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(null, [], null,
null, null); | 150 if (parameters == null) { |
| 151 parameters = new FormalParameterList(null, [], null, null, null); |
| 152 } |
| 151 name = node.name.name; | 153 name = node.name.name; |
| 152 super.visitMethodDeclaration(node); | 154 super.visitMethodDeclaration(node); |
| 153 } | 155 } |
| 154 | 156 |
| 155 /** | 157 /** |
| 156 * Record the parameters of the function or method declaration we last | 158 * Record the parameters of the function or method declaration we last |
| 157 * encountered before seeing the Intl.message call. | 159 * encountered before seeing the Intl.message call. |
| 158 */ | 160 */ |
| 159 void visitFunctionDeclaration(FunctionDeclaration node) { | 161 void visitFunctionDeclaration(FunctionDeclaration node) { |
| 160 parameters = node.functionExpression.parameters; | 162 parameters = node.functionExpression.parameters; |
| 161 if (parameters == null) parameters = new FormalParameterList(null, [], null,
null, null); | 163 if (parameters == null) { |
| 164 parameters = new FormalParameterList(null, [], null, null, null); |
| 165 } |
| 162 name = node.name.name; | 166 name = node.name.name; |
| 163 super.visitFunctionDeclaration(node); | 167 super.visitFunctionDeclaration(node); |
| 164 } | 168 } |
| 165 | 169 |
| 166 /** | 170 /** |
| 167 * Examine method invocations to see if they look like calls to Intl.message. | 171 * Examine method invocations to see if they look like calls to Intl.message. |
| 168 * If we've found one, stop recursing. This is important because we can have | 172 * If we've found one, stop recursing. This is important because we can have |
| 169 * Intl.message(...Intl.plural...) and we don't want to treat the inner | 173 * Intl.message(...Intl.plural...) and we don't want to treat the inner |
| 170 * plural as if it was an outermost message. | 174 * plural as if it was an outermost message. |
| 171 */ | 175 */ |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 */ | 470 */ |
| 467 final String message; | 471 final String message; |
| 468 | 472 |
| 469 /** | 473 /** |
| 470 * Creates a new exception with an optional error [message]. | 474 * Creates a new exception with an optional error [message]. |
| 471 */ | 475 */ |
| 472 const IntlMessageExtractionException([this.message = ""]); | 476 const IntlMessageExtractionException([this.message = ""]); |
| 473 | 477 |
| 474 String toString() => "IntlMessageExtractionException: $message"; | 478 String toString() => "IntlMessageExtractionException: $message"; |
| 475 } | 479 } |
| OLD | NEW |