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

Side by Side Diff: pkg/source_maps/lib/span.dart

Issue 346983002: Improve the readability of some human-consumed strings in source_maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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/source_maps/CHANGELOG.md ('k') | pkg/source_maps/pubspec.yaml » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// Dart classes representing the souce spans and source files. 5 /// Dart classes representing the souce spans and source files.
6 library source_maps.span; 6 library source_maps.span;
7 7
8 import 'dart:math' show min, max; 8 import 'dart:math' show min, max;
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 int d = start.compareTo(other.start); 57 int d = start.compareTo(other.start);
58 return d == 0 ? end.compareTo(other.end) : d; 58 return d == 0 ? end.compareTo(other.end) : d;
59 } 59 }
60 60
61 /// Gets the location in standard printed form `filename:line:column`, where 61 /// Gets the location in standard printed form `filename:line:column`, where
62 /// line and column are adjusted by 1 to match the convention in editors. 62 /// line and column are adjusted by 1 to match the convention in editors.
63 String get formatLocation => start.formatString; 63 String get formatLocation => start.formatString;
64 64
65 String getLocationMessage(String message, 65 String getLocationMessage(String message,
66 {bool useColors: false, String color}) { 66 {bool useColors: false, String color}) {
67 return '$formatLocation: $message'; 67 var source = url == null ? '' : ' of ${p.prettyUri(url)}';
68 return 'line ${start.line + 1}, column ${start.column + 1}$source: ' +
69 message;
68 } 70 }
69 71
70 bool operator ==(Span other) => 72 bool operator ==(Span other) =>
71 sourceUrl == other.sourceUrl && start == other.start && end == other.end; 73 sourceUrl == other.sourceUrl && start == other.start && end == other.end;
72 74
73 int get hashCode => sourceUrl.hashCode + start.offset + (31 * length); 75 int get hashCode => sourceUrl.hashCode + start.offset + (31 * length);
74 76
75 String toString() => '<$runtimeType: $start $end $formatLocation $text>'; 77 String toString() => '<$runtimeType: $start $end $formatLocation $text>';
76 } 78 }
77 79
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 370
369 /// The span associated with this exception. 371 /// The span associated with this exception.
370 /// 372 ///
371 /// This may be `null` if the source location can't be determined. 373 /// This may be `null` if the source location can't be determined.
372 final Span span; 374 final Span span;
373 375
374 SpanException(this.message, this.span); 376 SpanException(this.message, this.span);
375 377
376 String toString({bool useColors: false, String color}) { 378 String toString({bool useColors: false, String color}) {
377 if (span == null) return message; 379 if (span == null) return message;
378 return span.getLocationMessage(message, useColors: useColors, color: color); 380 return "Error on " + span.getLocationMessage(message,
381 useColors: useColors, color: color);
379 } 382 }
380 } 383 }
381 384
382 /// A [SpanException] that's also a [FormatException]. 385 /// A [SpanException] that's also a [FormatException].
383 class SpanFormatException extends SpanException implements FormatException { 386 class SpanFormatException extends SpanException implements FormatException {
384 SpanFormatException(String message, Span span) 387 SpanFormatException(String message, Span span)
385 : super(message, span); 388 : super(message, span);
386 } 389 }
OLDNEW
« no previous file with comments | « pkg/source_maps/CHANGELOG.md ('k') | pkg/source_maps/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698