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

Side by Side Diff: pkg/compiler/lib/src/io/source_file.dart

Issue 1415883011: Don't crash on error at end-of-file. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 dart2js.io.source_file; 5 library dart2js.io.source_file;
6 6
7 import 'dart:math'; 7 import 'dart:math';
8 import 'dart:convert' show UTF8; 8 import 'dart:convert' show UTF8;
9 import 'dart:typed_data' show Uint8List; 9 import 'dart:typed_data' show Uint8List;
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * 130 *
131 * Use [colorize] to wrap source code text and marker characters in color 131 * Use [colorize] to wrap source code text and marker characters in color
132 * escape codes. 132 * escape codes.
133 */ 133 */
134 String getLocationMessage(String message, int start, int end, 134 String getLocationMessage(String message, int start, int end,
135 {bool includeSourceLine: true, 135 {bool includeSourceLine: true,
136 String colorize(String text)}) { 136 String colorize(String text)}) {
137 if (colorize == null) { 137 if (colorize == null) {
138 colorize = (text) => text; 138 colorize = (text) => text;
139 } 139 }
140 if (end > length) {
ahe 2015/11/02 16:55:31 Add a TODO to turn this into an assertion. If you
ahe 2015/11/02 16:56:02 I meant to say: "consider adding a TODO..."
141 start = length - 1;
142 end = length;
143 }
144
140 int lineStart = getLine(start); 145 int lineStart = getLine(start);
141 int columnStart = getColumn(lineStart, start); 146 int columnStart = getColumn(lineStart, start);
142 int lineEnd = getLine(end); 147 int lineEnd = getLine(end);
143 int columnEnd = getColumn(lineEnd, end); 148 int columnEnd = getColumn(lineEnd, end);
144 149
145 StringBuffer buf = new StringBuffer('${filename}:'); 150 StringBuffer buf = new StringBuffer('${filename}:');
146 if (start != end || start != 0) { 151 if (start != end || start != 0) {
147 // Line/column info is relevant. 152 // Line/column info is relevant.
148 buf.write('${lineStart + 1}:${columnStart + 1}:'); 153 buf.write('${lineStart + 1}:${columnStart + 1}:');
149 } 154 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 set length(int v) { } 285 set length(int v) { }
281 286
282 String slowText() => text; 287 String slowText() => text;
283 288
284 List<int> slowUtf8ZeroTerminatedBytes() { 289 List<int> slowUtf8ZeroTerminatedBytes() {
285 return _zeroTerminateIfNecessary(UTF8.encode(text)); 290 return _zeroTerminateIfNecessary(UTF8.encode(text));
286 } 291 }
287 292
288 String slowSubstring(int start, int end) => text.substring(start, end); 293 String slowSubstring(int start, int end) => text.substring(start, end);
289 } 294 }
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