| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library yaml.null_span; |
| 6 |
| 7 import 'package:path/path.dart' as p; |
| 8 import 'package:source_maps/source_maps.dart'; |
| 9 |
| 10 /// A [Span] with no location information. |
| 11 /// |
| 12 /// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of |
| 13 /// accessing a non-YAML map that behaves transparently like a map parsed from |
| 14 /// YAML. |
| 15 class NullSpan extends Span { |
| 16 Location get end => start; |
| 17 final text = ""; |
| 18 |
| 19 NullSpan(String sourceUrl) |
| 20 : this._(new NullLocation(sourceUrl)); |
| 21 |
| 22 NullSpan._(Location location) |
| 23 : super(location, location, false); |
| 24 |
| 25 String formatLocationMessage(String message, {bool useColors: false, |
| 26 String color}) { |
| 27 var locationMessage = sourceUrl == null ? "in an unknown location" : |
| 28 "in ${p.prettyUri(sourceUrl)}"; |
| 29 return "$locationMessage: $message"; |
| 30 } |
| 31 } |
| 32 |
| 33 /// A [Location] with no location information. |
| 34 /// |
| 35 /// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of |
| 36 /// accessing a non-YAML map that behaves transparently like a map parsed from |
| 37 /// YAML. |
| 38 class NullLocation extends Location { |
| 39 final String sourceUrl; |
| 40 final line = 0; |
| 41 final column = 0; |
| 42 |
| 43 String get formatString => sourceUrl == null ? "unknown location" : sourceUrl; |
| 44 |
| 45 NullLocation(this.sourceUrl) |
| 46 : super(0); |
| 47 } |
| OLD | NEW |