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

Side by Side Diff: pkg/yaml/lib/src/null_span.dart

Issue 401753002: Move a number of packages and some of pub over to using source_span. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 5 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/model.dart ('k') | pkg/yaml/lib/src/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library yaml.null_span; 5 library yaml.null_span;
6 6
7 import 'package:path/path.dart' as p; 7 import 'package:source_span/source_span.dart';
8 import 'package:source_maps/source_maps.dart';
9 8
10 /// A [Span] with no location information. 9 /// A [Span] with no location information.
11 /// 10 ///
12 /// This is used with [YamlMap.wrap] and [YamlList.wrap] to provide means of 11 /// 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 12 /// accessing a non-YAML map that behaves transparently like a map parsed from
14 /// YAML. 13 /// YAML.
15 class NullSpan extends Span { 14 class NullSpan extends SourceSpanMixin {
16 Location get end => start; 15 final SourceLocation start;
16 SourceLocation get end => start;
17 final text = ""; 17 final text = "";
18 18
19 NullSpan(String sourceUrl) 19 NullSpan(sourceUrl)
20 : this._(new NullLocation(sourceUrl)); 20 : start = new SourceLocation(0, sourceUrl: 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 } 21 }
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/model.dart ('k') | pkg/yaml/lib/src/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698