| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 makeMatcher(camelKind, 'options', refactoring.options); | 96 makeMatcher(camelKind, 'options', refactoring.options); |
| 97 } | 97 } |
| 98 | 98 |
| 99 @override | 99 @override |
| 100 visitTypeDefinition(TypeDefinition typeDefinition) { | 100 visitTypeDefinition(TypeDefinition typeDefinition) { |
| 101 makeMatcher(typeDefinition.name, null, typeDefinition.type); | 101 makeMatcher(typeDefinition.name, null, typeDefinition.type); |
| 102 } | 102 } |
| 103 | 103 |
| 104 @override | 104 @override |
| 105 visitTypeEnum(TypeEnum typeEnum) { | 105 visitTypeEnum(TypeEnum typeEnum) { |
| 106 writeln('isIn(['); | 106 writeln('new MatchesEnum(${JSON.encode(context)}, ['); |
| 107 indent(() { | 107 indent(() { |
| 108 bool commaNeeded = false; | 108 bool commaNeeded = false; |
| 109 for (TypeEnumValue value in typeEnum.values) { | 109 for (TypeEnumValue value in typeEnum.values) { |
| 110 if (commaNeeded) { | 110 if (commaNeeded) { |
| 111 writeln(','); | 111 writeln(','); |
| 112 } | 112 } |
| 113 write('${JSON.encode(value.value)}'); | 113 write('${JSON.encode(value.value)}'); |
| 114 commaNeeded = true; | 114 commaNeeded = true; |
| 115 } | 115 } |
| 116 writeln(); | 116 writeln(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * Translate spec_input.html into protocol_matchers.dart. | 192 * Translate spec_input.html into protocol_matchers.dart. |
| 193 */ | 193 */ |
| 194 main() { | 194 main() { |
| 195 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); | 195 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); |
| 196 String code = visitor.collectCode(visitor.visitApi); | 196 String code = visitor.collectCode(visitor.visitApi); |
| 197 File outputFile = new File('../../test/integration/protocol_matchers.dart'); | 197 File outputFile = new File('../../test/integration/protocol_matchers.dart'); |
| 198 outputFile.writeAsStringSync(code); | 198 outputFile.writeAsStringSync(code); |
| 199 } | 199 } |
| OLD | NEW |