| OLD | NEW |
| 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 messages; | 5 library messages; |
| 6 | 6 |
| 7 import 'dart:json' as json; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:barback/barback.dart' show TransformLogger; | 9 import 'package:barback/barback.dart' show TransformLogger; |
| 10 import 'package:source_maps/span.dart' show Span; | 10 import 'package:source_maps/span.dart' show Span; |
| 11 import 'package:logging/logging.dart' show Level; | 11 import 'package:logging/logging.dart' show Level; |
| 12 | 12 |
| 13 import 'compiler_options.dart'; | 13 import 'compiler_options.dart'; |
| 14 import 'utils.dart'; | 14 import 'utils.dart'; |
| 15 | 15 |
| 16 /** Map between error levels and their display color. */ | 16 /** Map between error levels and their display color. */ |
| 17 final Map<Level, String> _ERROR_COLORS = (() { | 17 final Map<Level, String> _ERROR_COLORS = (() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 47 } else { | 47 } else { |
| 48 output.write(span.getLocationMessage(message, useColors: colors, | 48 output.write(span.getLocationMessage(message, useColors: colors, |
| 49 color: levelColor)); | 49 color: levelColor)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 return output.toString(); | 52 return output.toString(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 String toJson() { | 55 String toJson() { |
| 56 if (span == null) return toString(); | 56 if (span == null) return toString(); |
| 57 return json.stringify([{ | 57 return JSON.encode([{ |
| 58 'method': kind, | 58 'method': kind, |
| 59 'params': { | 59 'params': { |
| 60 'file': span.sourceUrl, | 60 'file': span.sourceUrl, |
| 61 'message': message, | 61 'message': message, |
| 62 'line': span.start.line + 1, | 62 'line': span.start.line + 1, |
| 63 'charStart': span.start.offset, | 63 'charStart': span.start.offset, |
| 64 'charEnd': span.end.offset, | 64 'charEnd': span.end.offset, |
| 65 } | 65 } |
| 66 }]); | 66 }]); |
| 67 } | 67 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 useColors: options.useColors); | 140 useColors: options.useColors); |
| 141 | 141 |
| 142 messages.add(msg); | 142 messages.add(msg); |
| 143 if (options.verbose) printMessage(msg); | 143 if (options.verbose) printMessage(msg); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void printMessage(msg) { | 146 void printMessage(msg) { |
| 147 if (shouldPrint) print(options.jsonFormat ? msg.toJson() : msg); | 147 if (shouldPrint) print(options.jsonFormat ? msg.toJson() : msg); |
| 148 } | 148 } |
| 149 } | 149 } |
| OLD | NEW |