| Index: pkg/yaml/lib/src/null_span.dart
|
| diff --git a/pkg/yaml/lib/src/null_span.dart b/pkg/yaml/lib/src/null_span.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b3e32549951be3259886a034f0fa3eed7f9530e2
|
| --- /dev/null
|
| +++ b/pkg/yaml/lib/src/null_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.null_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 NullSpan extends Span {
|
| + Location get end => start;
|
| + final text = "";
|
| +
|
| + NullSpan(String sourceUrl)
|
| + : this._(new NullLocation(sourceUrl));
|
| +
|
| + NullSpan._(Location location)
|
| + : 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 NullLocation extends Location {
|
| + final String sourceUrl;
|
| + final line = 0;
|
| + final column = 0;
|
| +
|
| + String get formatString => sourceUrl == null ? "unknown location" : sourceUrl;
|
| +
|
| + NullLocation(this.sourceUrl)
|
| + : super(0);
|
| +}
|
|
|