Chromium Code Reviews| 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 e8bccf0bdea0606b0846e2ad3ab10a08ce58dcf3..498686a7284807f23ca919f61d0e68e8807a01b6 100644 |
| --- a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart |
| +++ b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart |
| @@ -283,6 +283,7 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| */ |
| void emitObjectClass(String className, TypeObject type, |
| ImpliedType impliedType) { |
| + print(impliedType.kind); |
|
Paul Berry
2014/09/03 21:23:55
Was this temporary debug code? It looks like it s
scheglov
2014/09/04 01:37:17
Fixed.
|
| docComment(toHtmlVisitor.collectHtml(() { |
| toHtmlVisitor.p(() { |
| toHtmlVisitor.write(impliedType.humanReadableName); |
| @@ -291,7 +292,11 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| toHtmlVisitor.showType(null, impliedType.type); |
| } |
| })); |
| - writeln('class $className implements HasToJson {'); |
| + write('class $className'); |
| + if (impliedType.kind == 'refactoringOptions') { |
| + write(' extends RefactoringOptions'); |
| + } |
| + writeln(' implements HasToJson {'); |
| indent(() { |
| if (emitSpecialStaticMembers(className)) { |
| writeln(); |
| @@ -964,6 +969,16 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| ImpliedType impliedType) { |
| String humanReadableNameString = |
| literalString(impliedType.humanReadableName); |
| + if (className == 'RefactoringOptions') { |
| + writeln('factory RefactoringOptions.fromJson(JsonDecoder jsonDecoder, ' |
| + 'String jsonPath, Object json, RefactoringKind kind) {'); |
| + indent(() { |
| + writeln('return _refactoringOptionsFromJson(jsonDecoder, jsonPath, ' |
| + 'json, kind);'); |
| + }); |
| + writeln('}'); |
| + return; |
| + } |
| writeln( |
| 'factory $className.fromJson(JsonDecoder jsonDecoder, String jsonPath, Object json) {'); |
| indent(() { |
| @@ -1000,9 +1015,9 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| writeln('$fieldDartType ${field.name};'); |
| writeln('if (json.containsKey($fieldNameString)) {'); |
| indent(() { |
| - String toJson = |
| + String fromJson = |
|
Paul Berry
2014/09/03 21:23:55
Oops. Thanks for fixing this.
|
| fromJsonCode(fieldType).asSnippet(jsonPath, fieldAccessor); |
| - writeln('${field.name} = $toJson;'); |
| + writeln('${field.name} = $fromJson;'); |
| }); |
| write('}'); |
| if (!field.optional) { |
| @@ -1074,8 +1089,14 @@ class CodegenProtocolVisitor extends HierarchicalApiVisitor with CodeGenerator { |
| TypeDecl referencedType = referencedDefinition.type; |
| if (referencedType is TypeObject || referencedType is TypeEnum) { |
| return new FromJsonSnippet( |
| - (String jsonPath, String json) => |
| - 'new ${dartType(type)}.fromJson(jsonDecoder, $jsonPath, $json)'); |
| + (String jsonPath, String json) { |
| + String typeName = dartType(type); |
| + if (typeName == 'RefactoringOptions') { |
| + return 'new $typeName.fromJson(jsonDecoder, $jsonPath, $json, kind)'; |
| + } else { |
| + return 'new $typeName.fromJson(jsonDecoder, $jsonPath, $json)'; |
| + } |
| + }); |
| } else { |
| return fromJsonCode(referencedType); |
| } |