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

Side by Side Diff: pkg/yaml/lib/model.dart

Issue 12295014: Remove deprecated Strings class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/lib/src/config.dart ('k') | pkg/yaml/test/yaml_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of yaml; 5 part of yaml;
6 6
7 // This file contains the node classes for the internal representations of YAML 7 // This file contains the node classes for the internal representations of YAML
8 // documents. These nodes are used for both the serialization tree and the 8 // documents. These nodes are used for both the serialization tree and the
9 // representation graph. 9 // representation graph.
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool operator ==(other) { 83 bool operator ==(other) {
84 // Should be super != other; bug 2554 84 // Should be super != other; bug 2554
85 if (!(super == other) || other is! _SequenceNode) return false; 85 if (!(super == other) || other is! _SequenceNode) return false;
86 if (content.length != other.content.length) return false; 86 if (content.length != other.content.length) return false;
87 for (var i = 0; i < content.length; i++) { 87 for (var i = 0; i < content.length; i++) {
88 if (content[i] != other.content[i]) return false; 88 if (content[i] != other.content[i]) return false;
89 } 89 }
90 return true; 90 return true;
91 } 91 }
92 92
93 String toString() => 93 String toString() => '$tag [${content.map((e) => '$e').join(', ')}]';
94 '$tag [${Strings.join(content.map((e) => '$e'), ', ')}]';
95 94
96 int get hashCode => super.hashCode ^ _hashCode(content); 95 int get hashCode => super.hashCode ^ _hashCode(content);
97 96
98 visit(_Visitor v) => v.visitSequence(this); 97 visit(_Visitor v) => v.visitSequence(this);
99 } 98 }
100 99
101 /// An alias node is a reference to an anchor. 100 /// An alias node is a reference to an anchor.
102 class _AliasNode extends _Node { 101 class _AliasNode extends _Node {
103 _AliasNode(String anchor) : super(new _Tag.scalar(_Tag.yaml("str")), anchor); 102 _AliasNode(String anchor) : super(new _Tag.scalar(_Tag.yaml("str")), anchor);
104 103
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return "\\x${zeroPad(c.toRadixString(16).toUpperCase(), 2)}"; 171 return "\\x${zeroPad(c.toRadixString(16).toUpperCase(), 2)}";
173 } else if (c >= 0x100 && c < 0x10000) { 172 } else if (c >= 0x100 && c < 0x10000) {
174 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 4)}"; 173 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 4)}";
175 } else if (c >= 0x10000) { 174 } else if (c >= 0x10000) {
176 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 8)}"; 175 return "\\u${zeroPad(c.toRadixString(16).toUpperCase(), 8)}";
177 } else { 176 } else {
178 return new String.fromCharCodes([c]); 177 return new String.fromCharCodes([c]);
179 } 178 }
180 } 179 }
181 }); 180 });
182 return '"${Strings.join(escapedValue, '')}"'; 181 return '"${escapedValue.join()}"';
183 } 182 }
184 183
185 throw new YamlException("unknown scalar value: $value"); 184 throw new YamlException("unknown scalar value: $value");
186 } 185 }
187 186
188 String toString() => '$tag "$content"'; 187 String toString() => '$tag "$content"';
189 188
190 /// Left-pads [str] with zeros so that it's at least [length] characters 189 /// Left-pads [str] with zeros so that it's at least [length] characters
191 /// long. 190 /// long.
192 String zeroPad(String str, int length) { 191 String zeroPad(String str, int length) {
193 assert(length >= str.length); 192 assert(length >= str.length);
194 var prefix = []; 193 var prefix = [];
195 prefix.insertRange(0, length - str.length, '0'); 194 prefix.insertRange(0, length - str.length, '0');
196 return '${Strings.join(prefix, '')}$str'; 195 return '${prefix.join()}$str';
197 } 196 }
198 197
199 int get hashCode => super.hashCode ^ content.hashCode; 198 int get hashCode => super.hashCode ^ content.hashCode;
200 199
201 visit(_Visitor v) => v.visitScalar(this); 200 visit(_Visitor v) => v.visitScalar(this);
202 } 201 }
203 202
204 /// A mapping node represents an unordered map of nodes to nodes. 203 /// A mapping node represents an unordered map of nodes to nodes.
205 class _MappingNode extends _Node { 204 class _MappingNode extends _Node {
206 /// The node map. 205 /// The node map.
(...skipping 18 matching lines...) Expand all
225 var strContent = content.keys 224 var strContent = content.keys
226 .map((k) => '${k}: ${content[k]}') 225 .map((k) => '${k}: ${content[k]}')
227 .join(', '); 226 .join(', ');
228 return '$tag {$strContent}'; 227 return '$tag {$strContent}';
229 } 228 }
230 229
231 int get hashCode => super.hashCode ^ _hashCode(content); 230 int get hashCode => super.hashCode ^ _hashCode(content);
232 231
233 visit(_Visitor v) => v.visitMapping(this); 232 visit(_Visitor v) => v.visitMapping(this);
234 } 233 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/config.dart ('k') | pkg/yaml/test/yaml_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698