Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: pkg/analyzer_plugin/tool/spec/codegen_protocol_common.dart

Issue 2890163004: Add requestTime to responses (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/src/codegen/tools.dart'; 5 import 'package:analyzer/src/codegen/tools.dart';
6 import 'package:front_end/src/codegen/tools.dart'; 6 import 'package:front_end/src/codegen/tools.dart';
7 import 'package:path/path.dart' as path; 7 import 'package:path/path.dart' as path;
8 8
9 import 'api.dart'; 9 import 'api.dart';
10 import 'codegen_dart_protocol.dart'; 10 import 'codegen_dart_protocol.dart';
11 import 'from_html.dart'; 11 import 'from_html.dart';
12 import 'implied_types.dart'; 12 import 'implied_types.dart';
13 13
14 final GeneratedFile target = 14 GeneratedFile target(bool responseRequiresRequestTime) =>
15 new GeneratedFile('lib/protocol/protocol_common.dart', (String pkgPath) { 15 new GeneratedFile('lib/protocol/protocol_common.dart', (String pkgPath) {
16 CodegenCommonVisitor visitor = 16 CodegenCommonVisitor visitor = new CodegenCommonVisitor(
17 new CodegenCommonVisitor(path.basename(pkgPath), readApi(pkgPath)); 17 path.basename(pkgPath),
18 return visitor.collectCode(visitor.visitApi); 18 responseRequiresRequestTime,
19 }); 19 readApi(pkgPath));
20 return visitor.collectCode(visitor.visitApi);
21 });
20 22
21 /** 23 /**
22 * A visitor that produces Dart code defining the common types associated with 24 * A visitor that produces Dart code defining the common types associated with
23 * the API. 25 * the API.
24 */ 26 */
25 class CodegenCommonVisitor extends CodegenProtocolVisitor { 27 class CodegenCommonVisitor extends CodegenProtocolVisitor {
26 /** 28 /**
27 * Initialize a newly created visitor to generate code in the package with the 29 * Initialize a newly created visitor to generate code in the package with the
28 * given [packageName] corresponding to the types in the given [api] that are 30 * given [packageName] corresponding to the types in the given [api] that are
29 * common to multiple protocols. 31 * common to multiple protocols.
30 */ 32 */
31 CodegenCommonVisitor(String packageName, Api api) : super(packageName, api); 33 CodegenCommonVisitor(
34 String packageName, bool responseRequiresRequestTime, Api api)
35 : super(packageName, responseRequiresRequestTime, api);
32 36
33 @override 37 @override
34 void emitImports() { 38 void emitImports() {
35 writeln("import 'dart:convert' hide JsonDecoder;"); 39 writeln("import 'dart:convert' hide JsonDecoder;");
36 writeln(); 40 writeln();
37 writeln("import 'package:analyzer/src/generated/utilities_general.dart';"); 41 writeln("import 'package:analyzer/src/generated/utilities_general.dart';");
38 writeln("import 'package:$packageName/protocol/protocol.dart';"); 42 writeln("import 'package:$packageName/protocol/protocol.dart';");
39 writeln( 43 writeln(
40 "import 'package:$packageName/src/protocol/protocol_internal.dart';"); 44 "import 'package:$packageName/src/protocol/protocol_internal.dart';");
41 } 45 }
42 46
43 @override 47 @override
44 List<ImpliedType> getClassesToEmit() { 48 List<ImpliedType> getClassesToEmit() {
45 List<ImpliedType> types = impliedTypes.values.where((ImpliedType type) { 49 List<ImpliedType> types = impliedTypes.values.where((ImpliedType type) {
46 ApiNode node = type.apiNode; 50 ApiNode node = type.apiNode;
47 return node is TypeDefinition && node.isExternal; 51 return node is TypeDefinition && node.isExternal;
48 }).toList(); 52 }).toList();
49 types.sort((first, second) => 53 types.sort((first, second) =>
50 capitalize(first.camelName).compareTo(capitalize(second.camelName))); 54 capitalize(first.camelName).compareTo(capitalize(second.camelName)));
51 return types; 55 return types;
52 } 56 }
53 } 57 }
OLDNEW
« no previous file with comments | « pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart ('k') | pkg/analyzer_plugin/tool/spec/generate_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698