| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 writeln('{'); | 165 writeln('{'); |
| 166 indent(() { | 166 indent(() { |
| 167 bool commaNeeded = false; | 167 bool commaNeeded = false; |
| 168 for (TypeObjectField field in fields) { | 168 for (TypeObjectField field in fields) { |
| 169 if (commaNeeded) { | 169 if (commaNeeded) { |
| 170 writeln(','); | 170 writeln(','); |
| 171 } | 171 } |
| 172 write('${JSON.encode(field.name)}: '); | 172 write('${JSON.encode(field.name)}: '); |
| 173 visitTypeDecl(field.type); | 173 if (field.value != null) { |
| 174 write('equals(${JSON.encode(field.value)})'); |
| 175 } else { |
| 176 visitTypeDecl(field.type); |
| 177 } |
| 174 commaNeeded = true; | 178 commaNeeded = true; |
| 175 } | 179 } |
| 176 writeln(); | 180 writeln(); |
| 177 }); | 181 }); |
| 178 write('}'); | 182 write('}'); |
| 179 } | 183 } |
| 180 | 184 |
| 181 @override | 185 @override |
| 182 void visitTypeReference(TypeReference typeReference) { | 186 void visitTypeReference(TypeReference typeReference) { |
| 183 write(camelJoin(['is', typeReference.typeName])); | 187 write(camelJoin(['is', typeReference.typeName])); |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 | 190 |
| 187 /** | 191 /** |
| 188 * Translate spec_input.html into protocol_matchers.dart. | 192 * Translate spec_input.html into protocol_matchers.dart. |
| 189 */ | 193 */ |
| 190 main() { | 194 main() { |
| 191 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); | 195 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); |
| 192 String code = visitor.collectCode(visitor.visitApi); | 196 String code = visitor.collectCode(visitor.visitApi); |
| 193 File outputFile = new File('../../test/integration/protocol_matchers.dart'); | 197 File outputFile = new File('../../test/integration/protocol_matchers.dart'); |
| 194 outputFile.writeAsStringSync(code); | 198 outputFile.writeAsStringSync(code); |
| 195 } | 199 } |
| OLD | NEW |