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

Side by Side Diff: pkg/source_span/lib/src/file.dart

Issue 712473002: Fix source_span tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | 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 source_span.file; 5 library source_span.file;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 import 'dart:typed_data'; 8 import 'dart:typed_data';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 final int _end; 200 final int _end;
201 201
202 FileLocation get start => new FileLocation._(file, _start); 202 FileLocation get start => new FileLocation._(file, _start);
203 FileLocation get end => new FileLocation._(file, _end); 203 FileLocation get end => new FileLocation._(file, _end);
204 204
205 String get text => file.getText(start.offset, end.offset); 205 String get text => file.getText(start.offset, end.offset);
206 206
207 FileSpan._(this.file, this._start, this._end) { 207 FileSpan._(this.file, this._start, this._end) {
208 if (_end < _start) { 208 if (_end < _start) {
209 throw new ArgumentError('End $_end must come after start $_start.'); 209 throw new ArgumentError('End $_end must come after start $_start.');
210 } else if (_end > file.length) {
211 throw new RangeError("End $_end must not be greater than the number "
212 "of characters in the file, ${file.length}.");
213 } else if (_start < 0) {
214 throw new RangeError("Start may not be negative, was $_start.");
210 } 215 }
211 } 216 }
212 217
213 SourceSpan union(SourceSpan other) { 218 SourceSpan union(SourceSpan other) {
214 if (other is! FileSpan) return super.union(other); 219 if (other is! FileSpan) return super.union(other);
215 220
216 var span = expand(other); 221 var span = expand(other);
217 var beginSpan = span.start == this.start ? this : other; 222 var beginSpan = span.start == this.start ? this : other;
218 var endSpan = span.end == this.end ? this : other; 223 var endSpan = span.end == this.end ? this : other;
219 224
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 274 }
270 if (!textLine.endsWith('\n')) buffer.write('\n'); 275 if (!textLine.endsWith('\n')) buffer.write('\n');
271 276
272 buffer.write(' ' * column); 277 buffer.write(' ' * column);
273 if (color != null) buffer.write(color); 278 if (color != null) buffer.write(color);
274 buffer.write('^' * math.max(toColumn - column, 1)); 279 buffer.write('^' * math.max(toColumn - column, 1));
275 if (color != null) buffer.write(colors.NONE); 280 if (color != null) buffer.write(colors.NONE);
276 return buffer.toString(); 281 return buffer.toString();
277 } 282 }
278 } 283 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698