| 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 library codegen.protocol; | 5 library codegen.protocol; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'api.dart'; | 9 import 'api.dart'; |
| 10 import 'codegen_tools.dart'; | 10 import 'codegen_tools.dart'; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 static const Map<String, String> _typeRenames = const { | 192 static const Map<String, String> _typeRenames = const { |
| 193 'object': 'Map', | 193 'object': 'Map', |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * Class members for which the constructor argument should be optional, even | 197 * Class members for which the constructor argument should be optional, even |
| 198 * if the member is not an optional part of the protocol. For list types, | 198 * if the member is not an optional part of the protocol. For list types, |
| 199 * the constructor will default the member to the empty list. | 199 * the constructor will default the member to the empty list. |
| 200 */ | 200 */ |
| 201 static const Map<String, List<String>> _optionalConstructorArguments = const { | 201 static const Map<String, List<String>> _optionalConstructorArguments = const { |
| 202 'ErrorFixes': const ['fixes'], | 202 'AnalysisErrorFixes': const ['fixes'], |
| 203 'SourceChange': const ['edits', 'linkedEditGroups'], | 203 'SourceChange': const ['edits', 'linkedEditGroups'], |
| 204 'SourceFileEdit': const ['edits'], | 204 'SourceFileEdit': const ['edits'], |
| 205 'TypeHierarchyItem': const ['interfaces', 'mixins', 'subclasses'], | 205 'TypeHierarchyItem': const ['interfaces', 'mixins', 'subclasses'], |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * Visitor used to produce doc comments. | 209 * Visitor used to produce doc comments. |
| 210 */ | 210 */ |
| 211 final ToHtmlVisitor toHtmlVisitor; | 211 final ToHtmlVisitor toHtmlVisitor; |
| 212 | 212 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 return false; | 518 return false; |
| 519 } | 519 } |
| 520 } | 520 } |
| 521 | 521 |
| 522 /** | 522 /** |
| 523 * If the class named [className] requires special methods, emit them and | 523 * If the class named [className] requires special methods, emit them and |
| 524 * return true. | 524 * return true. |
| 525 */ | 525 */ |
| 526 bool emitSpecialMethods(String className) { | 526 bool emitSpecialMethods(String className) { |
| 527 switch (className) { | 527 switch (className) { |
| 528 case 'ErrorFixes': | 528 case 'AnalysisErrorFixes': |
| 529 docComment([new dom.Text('Add a [Fix]')]); | 529 docComment([new dom.Text('Add a [Fix]')]); |
| 530 writeln('void addFix(Fix fix) {'); | 530 writeln('void addFix(Fix fix) {'); |
| 531 indent(() { | 531 indent(() { |
| 532 writeln('fixes.add(fix.change);'); | 532 writeln('fixes.add(fix.change);'); |
| 533 }); | 533 }); |
| 534 writeln('}'); | 534 writeln('}'); |
| 535 return true; | 535 return true; |
| 536 case 'LinkedEditGroup': | 536 case 'LinkedEditGroup': |
| 537 docComment([new dom.Text('Add a new position and change the length.')]); | 537 docComment([new dom.Text('Add a new position and change the length.')]); |
| 538 writeln('void addPosition(Position position, int length) {'); | 538 writeln('void addPosition(Position position, int length) {'); |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); | 1266 CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(readApi()); |
| 1267 return visitor.collectCode(visitor.visitApi); | 1267 return visitor.collectCode(visitor.visitApi); |
| 1268 }); | 1268 }); |
| 1269 | 1269 |
| 1270 /** | 1270 /** |
| 1271 * Translate spec_input.html into protocol_matchers.dart. | 1271 * Translate spec_input.html into protocol_matchers.dart. |
| 1272 */ | 1272 */ |
| 1273 main() { | 1273 main() { |
| 1274 target.generate(); | 1274 target.generate(); |
| 1275 } | 1275 } |
| OLD | NEW |