| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 * Code generation for the file "matchers.dart". | 6 * Code generation for the file "matchers.dart". |
| 7 */ | 7 */ |
| 8 library codegen.matchers; | 8 library codegen.matchers; |
| 9 | 9 |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 180 } |
| 181 writeln(); | 181 writeln(); |
| 182 }); | 182 }); |
| 183 write('}'); | 183 write('}'); |
| 184 } | 184 } |
| 185 | 185 |
| 186 @override | 186 @override |
| 187 void visitTypeReference(TypeReference typeReference) { | 187 void visitTypeReference(TypeReference typeReference) { |
| 188 write(camelJoin(['is', typeReference.typeName])); | 188 write(camelJoin(['is', typeReference.typeName])); |
| 189 } | 189 } |
| 190 |
| 191 @override |
| 192 void visitTypeUnion(TypeUnion typeUnion) { |
| 193 bool commaNeeded = false; |
| 194 write('isOneOf(['); |
| 195 for (TypeDecl choice in typeUnion.choices) { |
| 196 if (commaNeeded) { |
| 197 write(', '); |
| 198 } |
| 199 visitTypeDecl(choice); |
| 200 commaNeeded = true; |
| 201 } |
| 202 write('])'); |
| 203 } |
| 190 } | 204 } |
| 191 | 205 |
| 192 /** | 206 /** |
| 193 * Translate spec_input.html into protocol_matchers.dart. | 207 * Translate spec_input.html into protocol_matchers.dart. |
| 194 */ | 208 */ |
| 195 main() { | 209 main() { |
| 196 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); | 210 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); |
| 197 String code = visitor.collectCode(visitor.visitApi); | 211 String code = visitor.collectCode(visitor.visitApi); |
| 198 File outputFile = new File('../../test/integration/protocol_matchers.dart'); | 212 File outputFile = new File('../../test/integration/protocol_matchers.dart'); |
| 199 outputFile.writeAsStringSync(code); | 213 outputFile.writeAsStringSync(code); |
| 200 } | 214 } |
| OLD | NEW |