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

Side by Side Diff: pkg/front_end/lib/src/fasta/errors.dart

Issue 2664593002: Port parser and scanner fixes from rasta branch. (Closed)
Patch Set: Rebased on ef8ec26cf36d1f07b4fdf5d605003210826ae1c2. Created 3 years, 10 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.errors; 5 library fasta.errors;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:convert' show 10 import 'dart:convert' show
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 InputError(this.uri, int charOffset, this.error) 49 InputError(this.uri, int charOffset, this.error)
50 : this.charOffset = charOffset ?? -1; 50 : this.charOffset = charOffset ?? -1;
51 51
52 toString() => "InputError: $error"; 52 toString() => "InputError: $error";
53 53
54 String format() { 54 String format() {
55 // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on 55 // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
56 // Windows. 56 // Windows.
57 String message = red("Error: ${safeToString(error)}"); 57 String message = red("Error: ${safeToString(error)}");
58 if (uri != null) { 58 if (uri != null) {
59 String uri = "${this.uri}";
60 String base = "${Uri.base}";
61 if (uri.startsWith(base)) {
62 uri = uri.substring(base.length);
63 }
59 String position = charOffset == -1 ? "" : "$charOffset:"; 64 String position = charOffset == -1 ? "" : "$charOffset:";
60 return "${uri}:$position $message"; 65 return "${uri}:$position $message";
61 } else { 66 } else {
62 return message; 67 return message;
63 } 68 }
64 } 69 }
65 } 70 }
66 71
67 class Crash { 72 class Crash {
68 final Uri uri; 73 final Uri uri;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return new Future.error(error, trace); 149 return new Future.error(error, trace);
145 } 150 }
146 151
147 String safeToString(Object object) { 152 String safeToString(Object object) {
148 try { 153 try {
149 return "$object"; 154 return "$object";
150 } catch (e) { 155 } catch (e) {
151 return "Error when converting ${object.runtimeType} to string."; 156 return "Error when converting ${object.runtimeType} to string.";
152 } 157 }
153 } 158 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/element_listener.dart ('k') | pkg/front_end/lib/src/fasta/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698