Chromium Code Reviews| Index: frog/source.dart |
| diff --git a/frog/source.dart b/frog/source.dart |
| index ab62a2fe3a43592c14adba3e54dc23484e70d16c..c73fa118133171c07d6a71d8c6176ec82a5cb147 100644 |
| --- a/frog/source.dart |
| +++ b/frog/source.dart |
| @@ -72,12 +72,12 @@ class SourceFile implements Comparable { |
| * Create a pretty string representation from a character position |
| * in the file. |
| */ |
| - String getLocationMessage(String message, int start, [int end, bool includeText=false]) { |
| + String getLocationMessage(String message, int start, |
| + [int end, bool includeText=false]) { |
| var line = getLine(start); |
| var column = getColumn(line, start); |
| - var buf = new StringBuffer( |
| - '${filename}:${line + 1}:${column + 1}: $message'); |
| + var buf = new StringBuffer('${filename}:${line + 1}:${column + 1}: $message'); |
|
Jennifer Messerly
2011/12/06 22:50:03
long line
Siggi Cherem (dart-lang)
2011/12/06 23:37:38
Done.
|
| if (includeText) { |
| buf.add('\n'); |
| var textLine; |
| @@ -87,16 +87,24 @@ class SourceFile implements Comparable { |
| } else { |
| textLine = text.substring(_lineStarts[line]) + '\n'; |
| } |
| - buf.add(textLine); |
| - int i = 0; |
| - for (; i < column; i++) { |
| - buf.add(' '); |
| - } |
| int toColumn = Math.min(column + (end-start), textLine.length); |
| - |
| - for (; i < toColumn; i++) { |
| - buf.add('^'); |
| + if (options.useColors) { |
| + buf.add(textLine.substring(0, column)); |
| + buf.add(_RED_COLOR); |
| + buf.add(textLine.substring(column, toColumn)); |
| + buf.add(_NO_COLOR); |
| + buf.add(textLine.substring(toColumn)); |
| + } else { |
| + buf.add(textLine); |
| + int i = 0; |
| + for (; i < column; i++) { |
| + buf.add(' '); |
| + } |
| + |
| + for (; i < toColumn; i++) { |
|
Jennifer Messerly
2011/12/06 22:50:03
Would it be nice to display the arrows even in col
Bob Nystrom
2011/12/06 23:12:46
+1 for always showing ^^^^
Siggi Cherem (dart-lang)
2011/12/06 23:37:38
I added them back, but with colors too.
I was no
|
| + buf.add('^'); |
| + } |
| } |
| } |
| @@ -138,7 +146,7 @@ class SourceSpan implements Comparable { |
| } |
| toMessageString(String message) { |
| - return file.getLocationMessage(message, start, end, true); |
| + return file.getLocationMessage(message, start, end: end, includeText: true); |
| } |
| String get locationText() { |