| 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 yaml.null_span; |   5 library yaml.null_span; | 
|   6  |   6  | 
|   7 import 'package:path/path.dart' as p; |   7 import 'package:source_span/source_span.dart'; | 
|   8 import 'package:source_maps/source_maps.dart'; |  | 
|   9  |   8  | 
|  10 /// A [Span] with no location information. |   9 /// A [Span] with no location information. | 
|  11 /// |  10 /// | 
|  12 /// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of |  11 /// 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 |  12 /// accessing a non-YAML map that behaves transparently like a map parsed from | 
|  14 /// YAML. |  13 /// YAML. | 
|  15 class NullSpan extends Span { |  14 class NullSpan extends SourceSpanMixin { | 
|  16   Location get end => start; |  15   final SourceLocation start; | 
 |  16   SourceLocation get end => start; | 
|  17   final text = ""; |  17   final text = ""; | 
|  18  |  18  | 
|  19   NullSpan(String sourceUrl) |  19   NullSpan(sourceUrl) | 
|  20       : this._(new NullLocation(sourceUrl)); |  20       : start = new SourceLocation(0, sourceUrl: 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 } |  21 } | 
|  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 |