| 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 |
| 56 /// Function signature of [traceAndReport]. | 62 /// Function signature of [traceAndReport]. |
| 57 typedef void TraceAndReport(Compiler compiler, Spannable node, String message, | 63 typedef void TraceAndReport(Compiler compiler, Spannable node, String message, |
| 58 {bool condition(String stackTrace), int limit, | 64 {bool condition(String stackTrace), int limit, |
| 59 bool throwOnPrint}); | 65 bool throwOnPrint}); |
| 60 | 66 |
| 61 /// Calls [reportHere] and [trace] with the same message. | 67 /// Calls [reportHere] and [trace] with the same message. |
| 62 TraceAndReport get traceAndReport { | 68 TraceAndReport get traceAndReport { |
| 63 enableDebugMode(); | 69 enableDebugMode(); |
| 64 return _traceAndReport; | 70 return _traceAndReport; |
| 65 } | 71 } |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 330 } |
| 325 for (int index = text.length ; index < intendedLength ; index ++) { | 331 for (int index = text.length ; index < intendedLength ; index ++) { |
| 326 int dotsIndex = index % dotsLength; | 332 int dotsIndex = index % dotsLength; |
| 327 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); | 333 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); |
| 328 } | 334 } |
| 329 if (padLeft) { | 335 if (padLeft) { |
| 330 sb.write(text); | 336 sb.write(text); |
| 331 } | 337 } |
| 332 return sb.toString(); | 338 return sb.toString(); |
| 333 } | 339 } |
| OLD | NEW |