| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.serialization.json; | 5 library dart2js.serialization.json; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'keys.dart'; | 9 import 'keys.dart'; |
| 10 import 'serialization.dart'; | 10 import 'serialization.dart'; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 String visitString(StringValue value, arg) => value.value; | 101 String visitString(StringValue value, arg) => value.value; |
| 102 | 102 |
| 103 @override | 103 @override |
| 104 visitType(TypeValue value, arg) => visit(value.id); | 104 visitType(TypeValue value, arg) => visit(value.id); |
| 105 | 105 |
| 106 @override | 106 @override |
| 107 visitUri(UriValue value, arg) => '${value.value}'; | 107 visitUri(UriValue value, arg) => '${value.value}'; |
| 108 } | 108 } |
| 109 | 109 |
| 110 /// [ValueVisitor] that generates a verbose JSON-like output. | 110 /// [ValueVisitor] that generates a verbose JSON-like output. |
| 111 class PrettyPrintEncoder implements ValueVisitor { | 111 class PrettyPrintEncoder implements ValueVisitor<dynamic, String> { |
| 112 StringBuffer buffer; | 112 StringBuffer buffer; |
| 113 | 113 |
| 114 String toText(Value value) { | 114 String toText(Value value) { |
| 115 buffer = new StringBuffer(); | 115 buffer = new StringBuffer(); |
| 116 visit(value, ''); | 116 visit(value, ''); |
| 117 String text = buffer.toString(); | 117 String text = buffer.toString(); |
| 118 buffer = null; | 118 buffer = null; |
| 119 return text; | 119 return text; |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 @override | 222 @override |
| 223 void visitType(TypeValue value, String indentation) { | 223 void visitType(TypeValue value, String indentation) { |
| 224 buffer.write('Type(${value.id}):${value.type}'); | 224 buffer.write('Type(${value.id}):${value.type}'); |
| 225 } | 225 } |
| 226 | 226 |
| 227 @override | 227 @override |
| 228 void visitUri(UriValue value, String indentation) { | 228 void visitUri(UriValue value, String indentation) { |
| 229 buffer.write('Uri(${value.value})'); | 229 buffer.write('Uri(${value.value})'); |
| 230 } | 230 } |
| 231 } | 231 } |
| OLD | NEW |