| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of dart2js.helpers; | 5 part of dart2js.helpers; |
| 6 | 6 |
| 7 /// Function signature for [trace]. | 7 /// Function signature for [trace]. |
| 8 typedef void Trace(String message, | 8 typedef void Trace(String message, |
| 9 {bool condition(String stackTrace), | 9 {bool condition(String stackTrace), |
| 10 int limit, | 10 int limit, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 stackTrace = '$s'; | 46 stackTrace = '$s'; |
| 47 } | 47 } |
| 48 if (condition != null) { | 48 if (condition != null) { |
| 49 if (!condition(stackTrace)) return; | 49 if (!condition(stackTrace)) return; |
| 50 } | 50 } |
| 51 print('$message\n$stackTrace'); | 51 print('$message\n$stackTrace'); |
| 52 if (throwOnPrint) throw message; | 52 if (throwOnPrint) throw message; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 /// Creates a function to use as an `condition` argument in [trace] that filters | |
| 57 /// stack traces that contains any of the [exceptions]. | |
| 58 traceExceptions(List<String> exceptions) { | |
| 59 return (String stackTrace) => !exceptions.any(stackTrace.contains); | |
| 60 } | |
| 61 | |
| 62 /// Function signature of [traceAndReport]. | 56 /// Function signature of [traceAndReport]. |
| 63 typedef void TraceAndReport(Compiler compiler, Spannable node, String message, | 57 typedef void TraceAndReport(Compiler compiler, Spannable node, String message, |
| 64 {bool condition(String stackTrace), int limit, | 58 {bool condition(String stackTrace), int limit, |
| 65 bool throwOnPrint}); | 59 bool throwOnPrint}); |
| 66 | 60 |
| 67 /// Calls [reportHere] and [trace] with the same message. | 61 /// Calls [reportHere] and [trace] with the same message. |
| 68 TraceAndReport get traceAndReport { | 62 TraceAndReport get traceAndReport { |
| 69 enableDebugMode(); | 63 enableDebugMode(); |
| 70 return _traceAndReport; | 64 return _traceAndReport; |
| 71 } | 65 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 324 } |
| 331 for (int index = text.length ; index < intendedLength ; index ++) { | 325 for (int index = text.length ; index < intendedLength ; index ++) { |
| 332 int dotsIndex = index % dotsLength; | 326 int dotsIndex = index % dotsLength; |
| 333 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); | 327 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); |
| 334 } | 328 } |
| 335 if (padLeft) { | 329 if (padLeft) { |
| 336 sb.write(text); | 330 sb.write(text); |
| 337 } | 331 } |
| 338 return sb.toString(); | 332 return sb.toString(); |
| 339 } | 333 } |
| OLD | NEW |