Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: lib/src/chain.dart

Issue 1940453003: pkg/stack_trace: use List.unmodifiable when possible (Closed) Base URL: https://github.com/dart-lang/stack_trace.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/trace.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection';
7 import 'dart:math' as math; 6 import 'dart:math' as math;
8 7
9 import 'frame.dart'; 8 import 'frame.dart';
10 import 'stack_zone_specification.dart'; 9 import 'stack_zone_specification.dart';
11 import 'trace.dart'; 10 import 'trace.dart';
12 import 'utils.dart'; 11 import 'utils.dart';
13 12
14 /// A function that handles errors in the zone wrapped by [Chain.capture]. 13 /// A function that handles errors in the zone wrapped by [Chain.capture].
15 @Deprecated("Will be removed in stack_trace 2.0.0.") 14 @Deprecated("Will be removed in stack_trace 2.0.0.")
16 typedef void ChainHandler(error, Chain chain); 15 typedef void ChainHandler(error, Chain chain);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 factory Chain.parse(String chain) { 138 factory Chain.parse(String chain) {
140 if (chain.isEmpty) return new Chain([]); 139 if (chain.isEmpty) return new Chain([]);
141 if (!chain.contains(chainGap)) return new Chain([new Trace.parse(chain)]); 140 if (!chain.contains(chainGap)) return new Chain([new Trace.parse(chain)]);
142 141
143 return new Chain( 142 return new Chain(
144 chain.split(chainGap).map((trace) => new Trace.parseFriendly(trace))); 143 chain.split(chainGap).map((trace) => new Trace.parseFriendly(trace)));
145 } 144 }
146 145
147 /// Returns a new [Chain] comprised of [traces]. 146 /// Returns a new [Chain] comprised of [traces].
148 Chain(Iterable<Trace> traces) 147 Chain(Iterable<Trace> traces)
149 : traces = new UnmodifiableListView<Trace>(traces.toList()); 148 : traces = new List<Trace>.unmodifiable(traces);
150 149
151 /// Returns a terser version of [this]. 150 /// Returns a terser version of [this].
152 /// 151 ///
153 /// This calls [Trace.terse] on every trace in [traces], and discards any 152 /// This calls [Trace.terse] on every trace in [traces], and discards any
154 /// trace that contain only internal frames. 153 /// trace that contain only internal frames.
155 Chain get terse => foldFrames((_) => false, terse: true); 154 Chain get terse => foldFrames((_) => false, terse: true);
156 155
157 /// Returns a new [Chain] based on [this] where multiple stack frames matching 156 /// Returns a new [Chain] based on [this] where multiple stack frames matching
158 /// [predicate] are folded together. 157 /// [predicate] are folded together.
159 /// 158 ///
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 205
207 // Don't call out to [Trace.toString] here because that doesn't ensure that 206 // Don't call out to [Trace.toString] here because that doesn't ensure that
208 // padding is consistent across all traces. 207 // padding is consistent across all traces.
209 return traces.map((trace) { 208 return traces.map((trace) {
210 return trace.frames.map((frame) { 209 return trace.frames.map((frame) {
211 return '${padRight(frame.location, longest)} ${frame.member}\n'; 210 return '${padRight(frame.location, longest)} ${frame.member}\n';
212 }).join(); 211 }).join();
213 }).join(chainGap); 212 }).join(chainGap);
214 } 213 }
215 } 214 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/trace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698