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

Unified Diff: pkg/analysis_server/tool/spec/codegen_dart_protocol.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
diff --git a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
index 4a422424fdcd024b526c2296edf537067b9cd9ef..38bbfb6d1003d4e55d932c90a95274c7a9544112 100644
--- a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
+++ b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
@@ -28,12 +28,14 @@ const Map<String, String> specialElementFlags = const {
'deprecated': '0x20'
};
-final GeneratedFile target =
- new GeneratedFile('lib/protocol/protocol_generated.dart', (String pkgPath) {
- CodegenProtocolVisitor visitor =
- new CodegenProtocolVisitor(path.basename(pkgPath), readApi(pkgPath));
- return visitor.collectCode(visitor.visitApi);
-});
+GeneratedFile target(bool responseRequiresRequestTime) {
+ return new GeneratedFile('lib/protocol/protocol_generated.dart',
+ (String pkgPath) {
+ CodegenProtocolVisitor visitor = new CodegenProtocolVisitor(
+ path.basename(pkgPath), responseRequiresRequestTime, readApi(pkgPath));
+ return visitor.collectCode(visitor.visitApi);
+ });
+}
/**
* Callback type used to represent arbitrary code generation.
@@ -73,6 +75,12 @@ class CodegenProtocolVisitor extends DartCodegenVisitor with CodeGenerator {
final String packageName;
/**
+ * A flag indicating whether the class [Response] requires a `requestTime`
+ * parameter.
+ */
+ final bool responseRequiresRequestTime;
+
+ /**
* Visitor used to produce doc comments.
*/
final ToHtmlVisitor toHtmlVisitor;
@@ -84,7 +92,8 @@ class CodegenProtocolVisitor extends DartCodegenVisitor with CodeGenerator {
*/
final Map<String, ImpliedType> impliedTypes;
- CodegenProtocolVisitor(this.packageName, Api api)
+ CodegenProtocolVisitor(
+ this.packageName, this.responseRequiresRequestTime, Api api)
: toHtmlVisitor = new ToHtmlVisitor(api),
impliedTypes = computeImpliedTypes(api),
super(api) {
@@ -955,10 +964,18 @@ class CodegenProtocolVisitor extends DartCodegenVisitor with CodeGenerator {
bool emitToResponseMember(ImpliedType impliedType) {
if (impliedType.kind == 'requestResult') {
writeln('@override');
- writeln('Response toResponse(String id) {');
+ if (responseRequiresRequestTime) {
+ writeln('Response toResponse(String id, int requestTime) {');
+ } else {
+ writeln('Response toResponse(String id) {');
+ }
indent(() {
String jsonPart = impliedType.type != null ? 'toJson()' : 'null';
- writeln('return new Response(id, result: $jsonPart);');
+ if (responseRequiresRequestTime) {
+ writeln('return new Response(id, requestTime, result: $jsonPart);');
+ } else {
+ writeln('return new Response(id, result: $jsonPart);');
+ }
});
writeln('}');
return true;
« no previous file with comments | « pkg/analysis_server/test/src/plugin/plugin_manager_test.dart ('k') | pkg/analysis_server/tool/spec/generate_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698