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

Side by Side Diff: packages/source_span/lib/src/span.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
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 source_span.span;
6
7 import 'location.dart'; 5 import 'location.dart';
8 import 'span_mixin.dart'; 6 import 'span_mixin.dart';
9 7
10 /// A class that describes a segment of source text. 8 /// A class that describes a segment of source text.
11 abstract class SourceSpan implements Comparable<SourceSpan> { 9 abstract class SourceSpan implements Comparable<SourceSpan> {
12 /// The start location of this span. 10 /// The start location of this span.
13 final SourceLocation start; 11 final SourceLocation start;
14 12
15 /// The end location of this span, exclusive. 13 /// The end location of this span, exclusive.
16 final SourceLocation end; 14 final SourceLocation end;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 int compareTo(SourceSpan other); 46 int compareTo(SourceSpan other);
49 47
50 /// Formats [message] in a human-friendly way associated with this span. 48 /// Formats [message] in a human-friendly way associated with this span.
51 /// 49 ///
52 /// [color] may either be a [String], a [bool], or `null`. If it's a string, 50 /// [color] may either be a [String], a [bool], or `null`. If it's a string,
53 /// it indicates an ANSII terminal color escape that should be used to 51 /// it indicates an ANSII terminal color escape that should be used to
54 /// highlight the span's text. If it's `true`, it indicates that the text 52 /// highlight the span's text. If it's `true`, it indicates that the text
55 /// should be highlighted using the default color. If it's `false` or `null`, 53 /// should be highlighted using the default color. If it's `false` or `null`,
56 /// it indicates that the text shouldn't be highlighted. 54 /// it indicates that the text shouldn't be highlighted.
57 String message(String message, {color}); 55 String message(String message, {color});
56
57 /// Prints the text associated with this span in a user-friendly way.
58 ///
59 /// This is identical to [message], except that it doesn't print the file
60 /// name, line number, column number, or message. If [length] is 0 and this
61 /// isn't a [SourceSpanWithContext], returns an empty string.
62 ///
63 /// [color] may either be a [String], a [bool], or `null`. If it's a string,
64 /// it indicates an ANSII terminal color escape that should be used to
65 /// highlight the span's text. If it's `true`, it indicates that the text
66 /// should be highlighted using the default color. If it's `false` or `null`,
67 /// it indicates that the text shouldn't be highlighted.
68 String highlight({color});
58 } 69 }
59 70
60 /// A base class for source spans with [start], [end], and [text] known at 71 /// A base class for source spans with [start], [end], and [text] known at
61 /// construction time. 72 /// construction time.
62 class SourceSpanBase extends SourceSpanMixin { 73 class SourceSpanBase extends SourceSpanMixin {
63 final SourceLocation start; 74 final SourceLocation start;
64 final SourceLocation end; 75 final SourceLocation end;
65 final String text; 76 final String text;
66 77
67 SourceSpanBase(this.start, this.end, this.text) { 78 SourceSpanBase(this.start, this.end, this.text) {
68 if (end.sourceUrl != start.sourceUrl) { 79 if (end.sourceUrl != start.sourceUrl) {
69 throw new ArgumentError("Source URLs \"${start.sourceUrl}\" and " 80 throw new ArgumentError("Source URLs \"${start.sourceUrl}\" and "
70 " \"${end.sourceUrl}\" don't match."); 81 " \"${end.sourceUrl}\" don't match.");
71 } else if (end.offset < start.offset) { 82 } else if (end.offset < start.offset) {
72 throw new ArgumentError('End $end must come after start $start.'); 83 throw new ArgumentError('End $end must come after start $start.');
73 } else if (text.length != start.distance(end)) { 84 } else if (text.length != start.distance(end)) {
74 throw new ArgumentError('Text "$text" must be ${start.distance(end)} ' 85 throw new ArgumentError('Text "$text" must be ${start.distance(end)} '
75 'characters long.'); 86 'characters long.');
76 } 87 }
77 } 88 }
78 } 89 }
OLDNEW
« no previous file with comments | « packages/source_span/lib/src/location_mixin.dart ('k') | packages/source_span/lib/src/span_exception.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698