Chromium Code Reviews| Index: lib/src/file.dart |
| diff --git a/lib/src/file.dart b/lib/src/file.dart |
| index ed5f6a8371226ed65065789a6ec8ee043701426f..953a6afdbfce86b2aaf23eb2f21052a801f71280 100644 |
| --- a/lib/src/file.dart |
| +++ b/lib/src/file.dart |
| @@ -12,6 +12,7 @@ import 'package:path/path.dart' as p; |
| import 'colors.dart' as colors; |
| import 'location.dart'; |
| import 'span.dart'; |
| +import 'span_context.dart'; |
| import 'span_mixin.dart'; |
| import 'utils.dart'; |
| @@ -183,7 +184,7 @@ class FileLocation extends SourceLocation { |
| /// [FileSpan.union] will return a [FileSpan] if possible. |
| /// |
| /// A [FileSpan] can be created using [SourceFile.span]. |
| -class FileSpan extends SourceSpanMixin { |
| +class FileSpan extends SourceSpanMixin implements SourceSpanContext { |
| /// The [file] that [this] belongs to. |
| final SourceFile file; |
| @@ -262,40 +263,9 @@ class FileSpan extends SourceSpanMixin { |
| return new FileSpan._(file, start, end); |
| } |
| - String message(String message, {color}) { |
|
Siggi Cherem (dart-lang)
2015/03/21 00:19:59
the old logic basically is now shared with the def
|
| - if (color == true) color = colors.RED; |
| - if (color == false) color = null; |
| - |
| + String get contextLine { |
|
nweiz
2015/03/24 23:01:17
Nit: put getters above the constructor.
Siggi Cherem (dart-lang)
2015/03/25 00:33:25
Done.
|
| var line = start.line; |
| - var column = start.column; |
| - |
| - var buffer = new StringBuffer(); |
| - buffer.write('line ${start.line + 1}, column ${start.column + 1}'); |
| - if (sourceUrl != null) buffer.write(' of ${p.prettyUri(sourceUrl)}'); |
| - buffer.write(': $message\n'); |
| - |
| - var textLine = file.getText(file.getOffset(line), |
| + return file.getText(file.getOffset(line), |
| line == file.lines - 1 ? null : file.getOffset(line + 1)); |
| - |
| - column = math.min(column, textLine.length - 1); |
| - var toColumn = |
| - math.min(column + end.offset - start.offset, textLine.length); |
| - |
| - if (color != null) { |
| - buffer.write(textLine.substring(0, column)); |
| - buffer.write(color); |
| - buffer.write(textLine.substring(column, toColumn)); |
| - buffer.write(colors.NONE); |
| - buffer.write(textLine.substring(toColumn)); |
| - } else { |
| - buffer.write(textLine); |
| - } |
| - if (!textLine.endsWith('\n')) buffer.write('\n'); |
| - |
| - buffer.write(' ' * column); |
| - if (color != null) buffer.write(color); |
| - buffer.write('^' * math.max(toColumn - column, 1)); |
| - if (color != null) buffer.write(colors.NONE); |
| - return buffer.toString(); |
| } |
| } |