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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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.null_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 NullSpan extends Span {
16 Location get end => start;
17 final text = "";
18
19 NullSpan(String sourceUrl)
20 : this._(new NullLocation(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 }
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 }
OLDNEW
« 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