| 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 a1ef9f83f04ef3eeea776ffb91c6bd53ded896a0..cf0388cfe1a5c777fa80feab6b69c88f40fb18b1 100644
|
| --- a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
|
| +++ b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
|
| @@ -230,7 +230,7 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
|
| toHtmlVisitor.showType(null, impliedType.type);
|
| }
|
| }));
|
| - writeln('class $className {');
|
| + writeln('class $className implements HasToJson {');
|
| indent(() {
|
| for (TypeObjectField field in type.fields) {
|
| if (field.value != null) {
|
| @@ -251,6 +251,9 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
|
| }
|
| emitToJsonMember(type);
|
| writeln();
|
| + if (emitToRequestMember(impliedType)) {
|
| + writeln();
|
| + }
|
| writeln('@override');
|
| writeln('String toString() => JSON.encode(toJson());');
|
| writeln();
|
| @@ -315,6 +318,24 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
|
| }
|
|
|
| /**
|
| + * Emit the toRequest() code for a class, if appropriate. Returns true if
|
| + * code was emitted.
|
| + */
|
| + bool emitToRequestMember(ImpliedType impliedType) {
|
| + if (impliedType.kind == 'requestParams') {
|
| + writeln('Request toRequest(String id) {');
|
| + indent(() {
|
| + String methodString = literalString((impliedType.apiNode as
|
| + Request).longMethod);
|
| + writeln('return new Request(id, $methodString, toJson());');
|
| + });
|
| + writeln('}');
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| * Emit the operator== code for an object class.
|
| */
|
| void emitObjectEqualsMember(TypeObject type, String className) {
|
| @@ -440,7 +461,7 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator {
|
| return new ToJsonIdentity(dartType(type));
|
| } else {
|
| return new ToJsonSnippet(dartType(type), (String value) =>
|
| - '$value.map(${itemCode.asClosure})');
|
| + '$value.map(${itemCode.asClosure}).toList()');
|
| }
|
| } else if (resolvedType is TypeMap) {
|
| ToJsonCode keyCode;
|
|
|