| OLD | NEW |
| 1 // Copyright (c) 2017, 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 "integration_test_methods.dart". | 6 * Code generation for the file "integration_test_methods.dart". |
| 7 */ | 7 */ |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/codegen/tools.dart'; | 10 import 'package:analyzer/src/codegen/tools.dart'; |
| 11 import 'package:front_end/src/codegen/tools.dart'; | 11 import 'package:front_end/src/codegen/tools.dart'; |
| 12 import 'package:path/path.dart' as path; |
| 12 | 13 |
| 13 import 'api.dart'; | 14 import 'api.dart'; |
| 14 import 'codegen_dart.dart'; | 15 import 'codegen_dart.dart'; |
| 15 import 'from_html.dart'; | 16 import 'from_html.dart'; |
| 16 import 'to_html.dart'; | 17 import 'to_html.dart'; |
| 17 | 18 |
| 18 final GeneratedFile target = new GeneratedFile( | 19 final GeneratedFile target = new GeneratedFile( |
| 19 'test/integration/support/integration_test_methods.dart', (String pkgPath) { | 20 'test/integration/support/integration_test_methods.dart', (String pkgPath) { |
| 20 CodegenInttestMethodsVisitor visitor = | 21 CodegenInttestMethodsVisitor visitor = new CodegenInttestMethodsVisitor( |
| 21 new CodegenInttestMethodsVisitor(readApi(pkgPath)); | 22 path.basename(pkgPath), readApi(pkgPath)); |
| 22 return visitor.collectCode(visitor.visitApi); | 23 return visitor.collectCode(visitor.visitApi); |
| 23 }); | 24 }); |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * Visitor that generates the code for integration_test_methods.dart | 27 * Visitor that generates the code for integration_test_methods.dart |
| 27 */ | 28 */ |
| 28 class CodegenInttestMethodsVisitor extends DartCodegenVisitor | 29 class CodegenInttestMethodsVisitor extends DartCodegenVisitor |
| 29 with CodeGenerator { | 30 with CodeGenerator { |
| 30 /** | 31 /** |
| 32 * The name of the package into which code is being generated. |
| 33 */ |
| 34 final String packageName; |
| 35 |
| 36 /** |
| 31 * Visitor used to produce doc comments. | 37 * Visitor used to produce doc comments. |
| 32 */ | 38 */ |
| 33 final ToHtmlVisitor toHtmlVisitor; | 39 final ToHtmlVisitor toHtmlVisitor; |
| 34 | 40 |
| 35 /** | 41 /** |
| 36 * Code snippets concatenated to initialize all of the class fields. | 42 * Code snippets concatenated to initialize all of the class fields. |
| 37 */ | 43 */ |
| 38 List<String> fieldInitializationCode = <String>[]; | 44 List<String> fieldInitializationCode = <String>[]; |
| 39 | 45 |
| 40 /** | 46 /** |
| 41 * Code snippets concatenated to produce the contents of the switch statement | 47 * Code snippets concatenated to produce the contents of the switch statement |
| 42 * for dispatching notifications. | 48 * for dispatching notifications. |
| 43 */ | 49 */ |
| 44 List<String> notificationSwitchContents = <String>[]; | 50 List<String> notificationSwitchContents = <String>[]; |
| 45 | 51 |
| 46 CodegenInttestMethodsVisitor(Api api) | 52 CodegenInttestMethodsVisitor(this.packageName, Api api) |
| 47 : toHtmlVisitor = new ToHtmlVisitor(api), | 53 : toHtmlVisitor = new ToHtmlVisitor(api), |
| 48 super(api) { | 54 super(api) { |
| 49 codeGeneratorSettings.commentLineLength = 79; | 55 codeGeneratorSettings.commentLineLength = 79; |
| 50 codeGeneratorSettings.languageName = 'dart'; | 56 codeGeneratorSettings.languageName = 'dart'; |
| 51 } | 57 } |
| 52 | 58 |
| 53 /** | 59 /** |
| 54 * Generate a function argument for the given parameter field. | 60 * Generate a function argument for the given parameter field. |
| 55 */ | 61 */ |
| 56 String formatArgument(TypeObjectField field) => | 62 String formatArgument(TypeObjectField field) => |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 97 |
| 92 @override | 98 @override |
| 93 visitApi() { | 99 visitApi() { |
| 94 outputHeader(year: '2017'); | 100 outputHeader(year: '2017'); |
| 95 writeln(); | 101 writeln(); |
| 96 writeln('/**'); | 102 writeln('/**'); |
| 97 writeln(' * Convenience methods for running integration tests'); | 103 writeln(' * Convenience methods for running integration tests'); |
| 98 writeln(' */'); | 104 writeln(' */'); |
| 99 writeln("import 'dart:async';"); | 105 writeln("import 'dart:async';"); |
| 100 writeln(); | 106 writeln(); |
| 107 writeln("import 'package:$packageName/protocol/protocol_generated.dart';"); |
| 101 writeln( | 108 writeln( |
| 102 "import 'package:analyzer_plugin/protocol/protocol_generated.dart';"); | 109 "import 'package:$packageName/src/protocol/protocol_internal.dart';"); |
| 103 writeln( | |
| 104 "import 'package:analyzer_plugin/src/protocol/protocol_internal.dart';")
; | |
| 105 writeln("import 'package:test/test.dart';"); | 110 writeln("import 'package:test/test.dart';"); |
| 106 writeln(); | 111 writeln(); |
| 107 writeln("import 'integration_tests.dart';"); | 112 writeln("import 'integration_tests.dart';"); |
| 108 writeln("import 'protocol_matchers.dart';"); | 113 writeln("import 'protocol_matchers.dart';"); |
| 109 writeln(); | 114 writeln(); |
| 110 writeln('/**'); | 115 writeln('/**'); |
| 111 writeln(' * Convenience methods for running integration tests'); | 116 writeln(' * Convenience methods for running integration tests'); |
| 112 writeln(' */'); | 117 writeln(' */'); |
| 113 writeln('abstract class IntegrationTestMixin {'); | 118 writeln('abstract class IntegrationTestMixin {'); |
| 114 indent(() { | 119 indent(() { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 writeln('ResponseDecoder decoder = new ResponseDecoder($kind);'); | 260 writeln('ResponseDecoder decoder = new ResponseDecoder($kind);'); |
| 256 writeln("return new $resultClass.fromJson(decoder, 'result', result);"); | 261 writeln("return new $resultClass.fromJson(decoder, 'result', result);"); |
| 257 } else { | 262 } else { |
| 258 writeln('outOfTestExpect(result, isNull);'); | 263 writeln('outOfTestExpect(result, isNull);'); |
| 259 writeln('return null;'); | 264 writeln('return null;'); |
| 260 } | 265 } |
| 261 }); | 266 }); |
| 262 writeln('}'); | 267 writeln('}'); |
| 263 } | 268 } |
| 264 } | 269 } |
| OLD | NEW |