| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 pub.asset.serialize; | 5 library pub.asset.serialize; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 | 9 |
| 10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
| 11 | 11 |
| 12 //# if source_maps >=0.9.0 <0.10.0 | |
| 13 //> import 'package:source_maps/span.dart'; | |
| 14 //# end | |
| 15 | |
| 16 //# if source_span | 12 //# if source_span |
| 17 import 'package:source_span/source_span.dart'; | 13 import 'package:source_span/source_span.dart'; |
| 18 //# end | 14 //# end |
| 19 | 15 |
| 20 import 'serialize/exception.dart'; | 16 import 'serialize/exception.dart'; |
| 21 import 'utils.dart'; | 17 import 'utils.dart'; |
| 22 | 18 |
| 23 export 'serialize/aggregate_transform.dart'; | 19 export 'serialize/aggregate_transform.dart'; |
| 24 export 'serialize/exception.dart'; | 20 export 'serialize/exception.dart'; |
| 25 export 'serialize/transform.dart'; | 21 export 'serialize/transform.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 return new SourceSpan( | 46 return new SourceSpan( |
| 51 deserializeLocation(span['start']), | 47 deserializeLocation(span['start']), |
| 52 deserializeLocation(span['end']), | 48 deserializeLocation(span['end']), |
| 53 span['text']); | 49 span['text']); |
| 54 } | 50 } |
| 55 | 51 |
| 56 /// Converts [location] into a serializable map. | 52 /// Converts [location] into a serializable map. |
| 57 /// | 53 /// |
| 58 /// [location] may be a [SourceLocation] or a [SourceLocation]. | 54 /// [location] may be a [SourceLocation] or a [SourceLocation]. |
| 59 Map serializeLocation(location) { | 55 Map serializeLocation(location) { |
| 60 //# if source_maps >=0.9.0 <0.10.0 | |
| 61 //> if (location is Location) { | |
| 62 //> return { | |
| 63 //> 'sourceUrl': location.sourceUrl, | |
| 64 //> 'offset': location.offset, | |
| 65 //> 'line': location.line, | |
| 66 //> 'column': location.column | |
| 67 //> }; | |
| 68 //> } | |
| 69 //# end | |
| 70 | |
| 71 //# if source_span | 56 //# if source_span |
| 72 // TODO(nweiz): convert FileLocations to FileLocations. | 57 // TODO(nweiz): convert FileLocations to FileLocations. |
| 73 if (location is SourceLocation) { | 58 if (location is SourceLocation) { |
| 74 return { | 59 return { |
| 75 'sourceUrl': location.sourceUrl.toString(), | 60 'sourceUrl': location.sourceUrl.toString(), |
| 76 'offset': location.offset, | 61 'offset': location.offset, |
| 77 'line': location.line, | 62 'line': location.line, |
| 78 'column': location.column | 63 'column': location.column |
| 79 }; | 64 }; |
| 80 } | 65 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 var replyTo = wrappedMessage['replyTo']; | 160 var replyTo = wrappedMessage['replyTo']; |
| 176 new Future.sync(() => callback(wrappedMessage['message'])) | 161 new Future.sync(() => callback(wrappedMessage['message'])) |
| 177 .then((result) => replyTo.send({'type': 'success', 'value': result})) | 162 .then((result) => replyTo.send({'type': 'success', 'value': result})) |
| 178 .catchError((error, stackTrace) { | 163 .catchError((error, stackTrace) { |
| 179 replyTo.send({ | 164 replyTo.send({ |
| 180 'type': 'error', | 165 'type': 'error', |
| 181 'error': serializeException(error, stackTrace) | 166 'error': serializeException(error, stackTrace) |
| 182 }); | 167 }); |
| 183 }); | 168 }); |
| 184 } | 169 } |
| OLD | NEW |