Chromium Code Reviews| Index: pkg/compiler/lib/src/io/source_file.dart |
| diff --git a/pkg/compiler/lib/src/io/source_file.dart b/pkg/compiler/lib/src/io/source_file.dart |
| index d799a9bfaba0048f0420919e5e3ad5d6db3a934a..a4c48a609f237718ed6a51a1fcc5cb51e15c2417 100644 |
| --- a/pkg/compiler/lib/src/io/source_file.dart |
| +++ b/pkg/compiler/lib/src/io/source_file.dart |
| @@ -137,31 +137,48 @@ abstract class SourceFile implements LineColumnProvider { |
| if (colorize == null) { |
| colorize = (text) => text; |
| } |
| - var line = getLine(start); |
| - var column = getColumn(line, start); |
| + var lineStart = getLine(start); |
| + var columnStart = getColumn(lineStart, start); |
| + var lineEnd = getLine(end); |
| + var columnEnd = getColumn(lineEnd, end); |
|
ahe
2015/10/30 13:13:14
Take this opportunity to add types?
Johnni Winther
2015/11/02 10:45:53
Done.
|
| var buf = new StringBuffer('${filename}:'); |
| if (start != end || start != 0) { |
| // Line/column info is relevant. |
| - buf.write('${line + 1}:${column + 1}:'); |
| + buf.write('${lineStart + 1}:${columnStart + 1}:'); |
| } |
| buf.write('\n$message\n'); |
| if (start != end && includeSourceLine) { |
| - String textLine = getLineText(line); |
| - |
| - int toColumn = min(column + (end-start), textLine.length); |
| - buf.write(textLine.substring(0, column)); |
| - buf.write(colorize(textLine.substring(column, toColumn))); |
| - buf.write(textLine.substring(toColumn)); |
| - |
| - int i = 0; |
| - for (; i < column; i++) { |
| - buf.write(' '); |
| - } |
| - |
| - for (; i < toColumn; i++) { |
| - buf.write(colorize('^')); |
| + if (lineStart == lineEnd) { |
| + String textLine = getLineText(lineStart); |
| + |
| + int toColumn = min(columnStart + (end-start), textLine.length); |
| + buf.write(textLine.substring(0, columnStart)); |
| + buf.write(colorize(textLine.substring(columnStart, toColumn))); |
| + buf.write(textLine.substring(toColumn)); |
| + |
| + int i = 0; |
| + for (; i < columnStart; i++) { |
| + buf.write(' '); |
| + } |
| + |
| + for (; i < toColumn; i++) { |
| + buf.write(colorize('^')); |
| + } |
| + } else { |
| + for (int line = lineStart; line <= lineEnd; line++) { |
| + String textLine = getLineText(line); |
| + if (line == lineStart) { |
| + buf.write(textLine.substring(0, columnStart)); |
| + buf.write(colorize(textLine.substring(columnStart))); |
| + } else if (line == lineEnd) { |
| + buf.write(colorize(textLine.substring(0, columnEnd))); |
| + buf.write(textLine.substring(columnEnd)); |
| + } else { |
| + buf.write(colorize(textLine)); |
| + } |
| + } |
| } |
| } |