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 utils; | 5 library utils; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'path.dart'; | 10 import 'path.dart'; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 currentIndentation += shiftWidth; | 108 currentIndentation += shiftWidth; |
109 prettifyJsonInternal(obj[key], indentation: false); | 109 prettifyJsonInternal(obj[key], indentation: false); |
110 currentIndentation -= shiftWidth; | 110 currentIndentation -= shiftWidth; |
111 } | 111 } |
112 currentIndentation -= shiftWidth; | 112 currentIndentation -= shiftWidth; |
113 addString("}", indentation: indentation, newLine: newLine); | 113 addString("}", indentation: indentation, newLine: newLine); |
114 } else { | 114 } else { |
115 addString("$obj", indentation: indentation, newLine: newLine); | 115 addString("$obj", indentation: indentation, newLine: newLine); |
116 } | 116 } |
117 } | 117 } |
| 118 |
118 prettifyJsonInternal(json); | 119 prettifyJsonInternal(json); |
119 return buffer.toString(); | 120 return buffer.toString(); |
120 } | 121 } |
121 | 122 |
122 /** | 123 /** |
123 * [areByteArraysEqual] compares a range of bytes from [buffer1] with a | 124 * [areByteArraysEqual] compares a range of bytes from [buffer1] with a |
124 * range of bytes from [buffer2]. | 125 * range of bytes from [buffer2]. |
125 * | 126 * |
126 * Returns [true] if the [count] bytes in [buffer1] (starting at | 127 * Returns [true] if the [count] bytes in [buffer1] (starting at |
127 * [offset1]) match the [count] bytes in [buffer2] (starting at | 128 * [offset1]) match the [count] bytes in [buffer2] (starting at |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 303 |
303 class UniqueObject { | 304 class UniqueObject { |
304 static int _nextId = 1; | 305 static int _nextId = 1; |
305 final int _hashCode; | 306 final int _hashCode; |
306 | 307 |
307 int get hashCode => _hashCode; | 308 int get hashCode => _hashCode; |
308 operator ==(other) => other is UniqueObject && _hashCode == other._hashCode; | 309 operator ==(other) => other is UniqueObject && _hashCode == other._hashCode; |
309 | 310 |
310 UniqueObject() : _hashCode = ++_nextId; | 311 UniqueObject() : _hashCode = ++_nextId; |
311 } | 312 } |
OLD | NEW |