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 import '../common.dart'; | 5 import '../common.dart'; |
6 import '../util/util.dart'; | 6 import '../util/util.dart'; |
7 | 7 |
8 /// Function signature for [trace]. | 8 /// Function signature for [trace]. |
9 typedef void Trace(String message, | 9 typedef void Trace(String message, |
10 {bool condition(String stackTrace), int limit, bool throwOnPrint}); | 10 {bool condition(String stackTrace), int limit, bool throwOnPrint}); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 int rangeStart = offset; | 95 int rangeStart = offset; |
96 int rangeEnd = limit == null ? null : rangeStart + limit; | 96 int rangeEnd = limit == null ? null : rangeStart + limit; |
97 try { | 97 try { |
98 throw ''; | 98 throw ''; |
99 } catch (_, stackTrace) { | 99 } catch (_, stackTrace) { |
100 return new StackTraceLines.fromTrace(stackTrace, | 100 return new StackTraceLines.fromTrace(stackTrace, |
101 rangeStart: offset, | 101 rangeStart: offset, |
102 rangeEnd: rangeEnd, | 102 rangeEnd: rangeEnd, |
103 filePrefix: stackTraceFilePrefix); | 103 filePrefix: stackTraceFilePrefix); |
104 } | 104 } |
105 return null; | |
106 } | 105 } |
107 | 106 |
108 /// A stack trace as a sequence of [StackTraceLine]s. | 107 /// A stack trace as a sequence of [StackTraceLine]s. |
109 class StackTraceLines { | 108 class StackTraceLines { |
110 final List<StackTraceLine> lines; | 109 final List<StackTraceLine> lines; |
111 final int maxFileLength; | 110 final int maxFileLength; |
112 final int maxLineNoLength; | 111 final int maxLineNoLength; |
113 final int maxColumnNoLength; | 112 final int maxColumnNoLength; |
114 | 113 |
115 factory StackTraceLines.fromTrace(StackTrace s, | 114 factory StackTraceLines.fromTrace(StackTrace s, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 338 } |
340 for (int index = text.length; index < intendedLength; index++) { | 339 for (int index = text.length; index < intendedLength; index++) { |
341 int dotsIndex = index % dotsLength; | 340 int dotsIndex = index % dotsLength; |
342 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); | 341 sb.write(dots.substring(dotsIndex, dotsIndex + 1)); |
343 } | 342 } |
344 if (padLeft) { | 343 if (padLeft) { |
345 sb.write(text); | 344 sb.write(text); |
346 } | 345 } |
347 return sb.toString(); | 346 return sb.toString(); |
348 } | 347 } |
OLD | NEW |