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

Side by Side Diff: pkg/stack_trace/lib/src/trace.dart

Issue 14394003: Use UnmodifiableListView to expose read-only lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review change. Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « pkg/scheduled_test/lib/src/task.dart ('k') | no next file » | 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 library trace; 5 library trace;
6 6
7 import 'dart:collection';
7 import 'dart:uri'; 8 import 'dart:uri';
8 import 'dart:math' as math; 9 import 'dart:math' as math;
9 10
10 import 'frame.dart'; 11 import 'frame.dart';
11 12
12 final _patchRegExp = new RegExp(r"-patch$"); 13 final _patchRegExp = new RegExp(r"-patch$");
13 14
14 /// A stack trace, comprised of a list of stack frames. 15 /// A stack trace, comprised of a list of stack frames.
15 class Trace implements StackTrace { 16 class Trace implements StackTrace {
16 // TODO(nweiz): make this read-only once issue 8321 is fixed.
17 /// The stack frames that comprise this stack trace. 17 /// The stack frames that comprise this stack trace.
18 final List<Frame> frames; 18 final List<Frame> frames;
19 19
20 /// Returns a human-readable representation of [stackTrace]. If [terse] is 20 /// Returns a human-readable representation of [stackTrace]. If [terse] is
21 /// set, this folds together multiple stack frames from the Dart core 21 /// set, this folds together multiple stack frames from the Dart core
22 /// libraries, so that only the core library method directly called from user 22 /// libraries, so that only the core library method directly called from user
23 /// code is visible (see [Trace.terse]). 23 /// code is visible (see [Trace.terse]).
24 static String format(StackTrace stackTrace, {bool terse: true}) { 24 static String format(StackTrace stackTrace, {bool terse: true}) {
25 var trace = new Trace.from(stackTrace); 25 var trace = new Trace.from(stackTrace);
26 if (terse) trace = trace.terse; 26 if (terse) trace = trace.terse;
(...skipping 29 matching lines...) Expand all
56 } 56 }
57 57
58 /// Parses a string representation of a stack trace. 58 /// Parses a string representation of a stack trace.
59 /// 59 ///
60 /// [trace] should be formatted in the same way as native stack traces. 60 /// [trace] should be formatted in the same way as native stack traces.
61 Trace.parse(String trace) 61 Trace.parse(String trace)
62 : this(trace.trim().split("\n").map((line) => new Frame.parse(line))); 62 : this(trace.trim().split("\n").map((line) => new Frame.parse(line)));
63 63
64 /// Returns a new [Trace] comprised of [frames]. 64 /// Returns a new [Trace] comprised of [frames].
65 Trace(Iterable<Frame> frames) 65 Trace(Iterable<Frame> frames)
66 : frames = frames.toList(); 66 : frames = new UnmodifiableListView<Frame>(frames.toList());
67 67
68 // TODO(nweiz): Keep track of which [Frame]s are part of the partial stack 68 // TODO(nweiz): Keep track of which [Frame]s are part of the partial stack
69 // trace and only print them. 69 // trace and only print them.
70 /// Returns a string representation of this stack trace. 70 /// Returns a string representation of this stack trace.
71 /// 71 ///
72 /// This is identical to [toString]. It will not be formatted in the manner of 72 /// This is identical to [toString]. It will not be formatted in the manner of
73 /// native stack traces. 73 /// native stack traces.
74 String get stackTrace => toString(); 74 String get stackTrace => toString();
75 75
76 /// Returns a string representation of this stack trace. 76 /// Returns a string representation of this stack trace.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (string.length >= length) return string; 132 if (string.length >= length) return string;
133 133
134 var result = new StringBuffer(); 134 var result = new StringBuffer();
135 result.write(string); 135 result.write(string);
136 for (var i = 0; i < length - string.length; i++) { 136 for (var i = 0; i < length - string.length; i++) {
137 result.write(' '); 137 result.write(' ');
138 } 138 }
139 139
140 return result.toString(); 140 return result.toString();
141 } 141 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/task.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698