Chromium Code Reviews| Index: pkg/barback/lib/src/transform.dart |
| diff --git a/pkg/barback/lib/src/transform.dart b/pkg/barback/lib/src/transform.dart |
| index 77800dbcca92d7e07c3ef6ceb1ecab95045fa815..42d2fd5e4dc87c87f9ba08708a36aad5bb4011e6 100644 |
| --- a/pkg/barback/lib/src/transform.dart |
| +++ b/pkg/barback/lib/src/transform.dart |
| @@ -5,6 +5,7 @@ |
| library barback.transform; |
| import 'dart:async'; |
| +import 'package:source_maps/span.dart' show Span; |
|
nweiz
2013/08/08 23:34:57
Style nit: blank line between core library imports
Siggi Cherem (dart-lang)
2013/08/09 00:29:54
Done.
Funny, I usually like using show if the lis
Jennifer Messerly
2013/08/09 05:44:03
Moreover, it's the only style (along with "as") wh
Bob Nystrom
2013/08/09 15:42:38
Since this is a "package:" import, that doesn't wo
|
| import 'asset.dart'; |
| import 'asset_id.dart'; |
| @@ -45,6 +46,8 @@ class Transform { |
| /// would be secondary inputs. |
| AssetId get primaryId => _node.primary.id; |
| + Log get log => _log; |
|
Bob Nystrom
2013/08/08 22:47:09
Document:
"A logger so that the [Transformer] can
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done.
|
| + |
| /// Gets the asset for the primary input. |
| Future<Asset> get primaryInput => getInput(primaryId); |
| @@ -65,3 +68,38 @@ class Transform { |
| _outputs.add(output); |
| } |
| } |
| + |
| +final Log _log = new Log(true); |
|
Bob Nystrom
2013/08/08 22:47:09
Add a TODO to create a separate one for each Trans
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done.
|
| + |
| +/// Log object used to report warnings and errors encountered while running a |
|
Bob Nystrom
2013/08/08 22:47:09
Add a TODO to move this into its own file.
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done. I'm happy to move it out too (if we know wha
nweiz
2013/08/08 23:34:57
Or just move it now.
Siggi Cherem (dart-lang)
2013/08/09 00:29:54
now that it's just TransformLogger, it feels like
nweiz
2013/08/09 00:53:48
I'd still prefer it to be separate.
Siggi Cherem (dart-lang)
2013/08/09 01:17:30
Done.
|
| +/// transform. |
| +class Log { |
| + |
| + bool _shouldPrint; |
| + |
| + Log(this._shouldPrint); |
| + |
| + /// Logs a warning message. If present, [span] indicates the location in an |
|
Bob Nystrom
2013/08/08 22:47:09
"an asset that generated" -> "the input asset that
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done.
nweiz
2013/08/08 23:34:57
Style nit: the first paragraph of a doc comment sh
Siggi Cherem (dart-lang)
2013/08/09 00:29:54
Done.
|
| + /// asset that generated the warning. |
| + void warning(String message, [Span span]) { |
| + _printMessage('warning', message, span); |
| + } |
| + |
| + /// Logs an error message. If present, [span] indicates the location in an |
| + /// asset that generated the error. |
|
Bob Nystrom
2013/08/08 22:47:09
Ditto above change here.
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done.
|
| + void error(String message, [Span span]) { |
|
nweiz
2013/08/08 23:34:57
Add a TODO to clarify when an error message should
Siggi Cherem (dart-lang)
2013/08/09 00:29:54
Done.
|
| + _printMessage('error', message, span); |
| + } |
| + |
| + // TODO(sigmund,rnystrom): do something better than printing. |
| + _printMessage(String prefix, String message, Span span) { |
| + if (!_shouldPrint) return; |
| + var sb = new StringBuffer()..write(prefix)..write(' '); |
|
Bob Nystrom
2013/08/08 22:47:09
sb -> buffer
Siggi Cherem (dart-lang)
2013/08/08 23:10:41
Done. We all have different preferences on this on
|
| + if (span == null) { |
| + sb.write(message); |
| + } else { |
| + sb.write(span.getLocationMessage(message)); |
| + } |
| + print(sb.toString()); |
|
nweiz
2013/08/08 23:34:57
Is it worth the extra complexity here to use a Str
Siggi Cherem (dart-lang)
2013/08/09 00:29:54
good point. I used to have color printing and remv
|
| + } |
| +} |