OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 protoc.const_generator; | 5 library protoc.const_generator; |
6 | 6 |
7 import "indenting_writer.dart"; | 7 import "indenting_writer.dart"; |
8 | 8 |
9 /// Writes JSON data as a Dart constant expression. | 9 /// Writes JSON data as a Dart constant expression. |
10 /// Accepts null, bool, num, String, and maps and lists. | 10 /// Accepts null, bool, num, String, and maps and lists. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 out.print(", "); | 85 out.print(", "); |
86 } | 86 } |
87 writeJsonConst(out, item); | 87 writeJsonConst(out, item); |
88 if (vertical) { | 88 if (vertical) { |
89 out.println(","); | 89 out.println(","); |
90 } | 90 } |
91 first = false; | 91 first = false; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void _writeMapItems(IndentingWriter out, Map<String, dynamic> val, | 95 void _writeMapItems(IndentingWriter out, Map<dynamic, dynamic> val, |
96 {bool vertical: false}) { | 96 {bool vertical: false}) { |
97 bool first = true; | 97 bool first = true; |
98 for (String key in val.keys) { | 98 for (var key in val.keys) { |
99 if (!first && !vertical) out.print(", "); | 99 if (!first && !vertical) out.print(", "); |
100 _writeString(out, key); | 100 _writeString(out, key); |
101 out.print(": "); | 101 out.print(": "); |
102 writeJsonConst(out, val[key]); | 102 writeJsonConst(out, val[key]); |
103 if (vertical) { | 103 if (vertical) { |
104 out.println(","); | 104 out.println(","); |
105 } | 105 } |
106 first = false; | 106 first = false; |
107 } | 107 } |
108 } | 108 } |
OLD | NEW |