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 library command_line_config; | 5 library command_line_config; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:math'; | 8 import 'dart:math' as math; |
9 | 9 |
10 import 'package:pathos/path.dart' as path; | 10 import 'package:pathos/path.dart' as path; |
11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
12 import '../../pub/utils.dart'; | 12 import '../../pub/utils.dart'; |
13 | 13 |
14 /// Gets a "special" string (ANSI escape or Unicode). On Windows, returns | 14 /// Gets a "special" string (ANSI escape or Unicode). On Windows, returns |
15 /// something else since those aren't supported. | 15 /// something else since those aren't supported. |
16 String _getSpecial(String color, [String onWindows = '']) { | 16 String _getSpecial(String color, [String onWindows = '']) { |
17 // No ANSI escapes on windows. | 17 // No ANSI escapes on windows. |
18 if (Platform.operatingSystem == 'windows') return onWindows; | 18 if (Platform.operatingSystem == 'windows') return onWindows; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Parse out each stack entry. | 85 // Parse out each stack entry. |
86 var stack = []; | 86 var stack = []; |
87 for (var line in stackTrace.split('\n')) { | 87 for (var line in stackTrace.split('\n')) { |
88 if (line.trim() == '') continue; | 88 if (line.trim() == '') continue; |
89 stack.add(new _StackFrame(line)); | 89 stack.add(new _StackFrame(line)); |
90 } | 90 } |
91 | 91 |
92 if (stack.length == 0) return; | 92 if (stack.length == 0) return; |
93 | 93 |
94 // Figure out the longest path so we know how much to pad. | 94 // Figure out the longest path so we know how much to pad. |
95 int longest = stack.map((frame) => frame.location.length).reduce(max); | 95 int longest = stack.map((frame) => frame.location.length).reduce(math.max); |
96 | 96 |
97 // Print out the stack trace nicely formatted. | 97 // Print out the stack trace nicely formatted. |
98 for (var frame in stack) { | 98 for (var frame in stack) { |
99 print(' ${_padLeft(frame.location, longest)} ${frame.member}'); | 99 print(' ${_padLeft(frame.location, longest)} ${frame.member}'); |
100 } | 100 } |
101 | 101 |
102 print(''); | 102 print(''); |
103 } | 103 } |
104 | 104 |
105 String _padLeft(String string, int length) { | 105 String _padLeft(String string, int length) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 var library = match[2]; | 160 var library = match[2]; |
161 if (!isCore) { | 161 if (!isCore) { |
162 // Make the library path relative to the entrypoint. | 162 // Make the library path relative to the entrypoint. |
163 library = path.relative(library); | 163 library = path.relative(library); |
164 } | 164 } |
165 | 165 |
166 var member = match[1].replaceAll("<anonymous closure>", _lambda); | 166 var member = match[1].replaceAll("<anonymous closure>", _lambda); |
167 return new _StackFrame._(isCore, library, match[3], match[4], member); | 167 return new _StackFrame._(isCore, library, match[3], match[4], member); |
168 } | 168 } |
169 } | 169 } |
OLD | NEW |