Chromium Code Reviews| Index: pkg/yaml/lib/src/dummy_span.dart |
| diff --git a/pkg/yaml/lib/src/dummy_span.dart b/pkg/yaml/lib/src/dummy_span.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..075d74aa00122cd2bfcfc3c933efc4204acc3bdc |
| --- /dev/null |
| +++ b/pkg/yaml/lib/src/dummy_span.dart |
| @@ -0,0 +1,47 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library yaml.dummy_span; |
| + |
| +import 'package:path/path.dart' as p; |
| +import 'package:source_maps/source_maps.dart'; |
| + |
| +/// A [Span] with no location information. |
| +/// |
| +/// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of |
| +/// accessing a non-YAML map that behaves transparently like a map parsed from |
| +/// YAML. |
| +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.
|
| + Location get end => start; |
| + final text = ""; |
| + |
| + DummySpan(String sourceUrl) |
| + : this._(new DummyLocation(sourceUrl)); |
| + |
| + 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.
|
| + : super(location, location, false); |
| + |
| + String formatLocationMessage(String message, {bool useColors: false, |
| + String color}) { |
| + var locationMessage = sourceUrl == null ? "in an unknown location" : |
| + "in ${p.prettyUri(sourceUrl)}"; |
| + return "$locationMessage: $message"; |
| + } |
| +} |
| + |
| +/// A [Location] with no location information. |
| +/// |
| +/// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of |
| +/// accessing a non-YAML map that behaves transparently like a map parsed from |
| +/// YAML. |
| +class DummyLocation extends Location { |
| + final String sourceUrl; |
| + final line = 0; |
| + final column = 0; |
| + |
| + String get formatString => sourceUrl == null ? "unknown location" : sourceUrl; |
| + |
| + DummyLocation(this.sourceUrl) |
| + : super(0); |
| +} |