Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Unified Diff: pkg/yaml/lib/src/null_span.dart

Issue 343063002: Add new constructors to YamlNode subclasses. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/yaml/lib/src/constructor.dart ('k') | pkg/yaml/lib/src/yaml_node.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « pkg/yaml/lib/src/constructor.dart ('k') | pkg/yaml/lib/src/yaml_node.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698