| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Definitions used to run the polymer linter and deploy tools without using | 5 /// Definitions used to run the polymer linter and deploy tools without using |
| 6 /// pub serve or pub deploy. | 6 /// pub serve or pub deploy. |
| 7 library polymer.src.build.runner; | 7 library polymer.src.build.runner; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:convert'; | 10 import 'dart:convert'; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 /// Formatter that generates messages using a format that can be parsed | 340 /// Formatter that generates messages using a format that can be parsed |
| 341 /// by tools, such as the Dart Editor, for reporting error messages. | 341 /// by tools, such as the Dart Editor, for reporting error messages. |
| 342 String _jsonFormatter(LogEntry entry) { | 342 String _jsonFormatter(LogEntry entry) { |
| 343 var kind = _kindFromEntry(entry); | 343 var kind = _kindFromEntry(entry); |
| 344 var span = entry.span; | 344 var span = entry.span; |
| 345 return JSON.encode((span == null) | 345 return JSON.encode((span == null) |
| 346 ? [{'method': kind, 'params': {'message': entry.message}}] | 346 ? [{'method': kind, 'params': {'message': entry.message}}] |
| 347 : [{'method': kind, | 347 : [{'method': kind, |
| 348 'params': { | 348 'params': { |
| 349 'file': span.sourceUrl, | 349 'file': span.sourceUrl.toString(), |
| 350 'message': entry.message, | 350 'message': entry.message, |
| 351 'line': span.start.line + 1, | 351 'line': span.start.line + 1, |
| 352 'charStart': span.start.offset, | 352 'charStart': span.start.offset, |
| 353 'charEnd': span.end.offset, | 353 'charEnd': span.end.offset, |
| 354 }}]); | 354 }}]); |
| 355 } | 355 } |
| 356 | 356 |
| 357 /// Formatter that generates messages that are easy to read on the console (used | 357 /// Formatter that generates messages that are easy to read on the console (used |
| 358 /// by default). | 358 /// by default). |
| 359 String _consoleFormatter(LogEntry entry) { | 359 String _consoleFormatter(LogEntry entry) { |
| 360 var kind = _kindFromEntry(entry); | 360 var kind = _kindFromEntry(entry); |
| 361 var useColors = stdioType(stdout) == StdioType.TERMINAL; | 361 var useColors = stdioType(stdout) == StdioType.TERMINAL; |
| 362 var levelColor = (kind == 'error') ? _RED_COLOR : _MAGENTA_COLOR; | 362 var levelColor = (kind == 'error') ? _RED_COLOR : _MAGENTA_COLOR; |
| 363 var output = new StringBuffer(); | 363 var output = new StringBuffer(); |
| 364 if (useColors) output.write(levelColor); | 364 if (useColors) output.write(levelColor); |
| 365 output..write(kind)..write(' '); | 365 output..write(kind)..write(' '); |
| 366 if (useColors) output.write(_NO_COLOR); | 366 if (useColors) output.write(_NO_COLOR); |
| 367 if (entry.span == null) { | 367 if (entry.span == null) { |
| 368 output.write(entry.message); | 368 output.write(entry.message); |
| 369 } else { | 369 } else { |
| 370 output.write(entry.span.message(entry.message, | 370 output.write(entry.span.message(entry.message, |
| 371 color: useColors ? levelColor : null)); | 371 color: useColors ? levelColor : null)); |
| 372 } | 372 } |
| 373 return output.toString(); | 373 return output.toString(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 const String _RED_COLOR = '\u001b[31m'; | 376 const String _RED_COLOR = '\u001b[31m'; |
| 377 const String _MAGENTA_COLOR = '\u001b[35m'; | 377 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 378 const String _NO_COLOR = '\u001b[0m'; | 378 const String _NO_COLOR = '\u001b[0m'; |
| OLD | NEW |