Chromium Code Reviews| 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.dummy_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 DummySpan extends Span { | |
|
Bob Nystrom
2014/06/21 00:14:15
How about "Dummy" -> "Null"?
It's effectively the
nweiz
2014/06/23 22:23:06
Done.
| |
| 16 Location get end => start; | |
| 17 final text = ""; | |
| 18 | |
| 19 DummySpan(String sourceUrl) | |
| 20 : this._(new DummyLocation(sourceUrl)); | |
| 21 | |
| 22 DummySpan._(Location location) | |
|
Bob Nystrom
2014/06/21 00:14:15
What's this constructor for?
nweiz
2014/06/23 22:23:06
The superclass constructor requires two locations,
Bob Nystrom
2014/06/23 23:11:44
Oh, I see it now. Thanks.
| |
| 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 DummyLocation 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 DummyLocation(this.sourceUrl) | |
| 46 : super(0); | |
| 47 } | |
| OLD | NEW |