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

Side by Side Diff: lib/src/barback/cycle_exception.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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 | « lib/src/barback/barback_server.dart ('k') | lib/src/barback/dart2js_transformer.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 d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 '../exceptions.dart'; 5 import '../exceptions.dart';
6 6
7 /// An exception thrown when a transformer dependency cycle is detected. 7 /// An exception thrown when a transformer dependency cycle is detected.
8 /// 8 ///
9 /// A cycle exception is usually produced within a deeply-nested series of 9 /// A cycle exception is usually produced within a deeply-nested series of
10 /// calls. The API is designed to make it easy for each of these calls to add to 10 /// calls. The API is designed to make it easy for each of these calls to add to
11 /// the message so that the full reasoning for the cycle is made visible to the 11 /// the message so that the full reasoning for the cycle is made visible to the
12 /// user. 12 /// user.
13 /// 13 ///
14 /// Each call's individual message is called a "step". A [CycleException] is 14 /// Each call's individual message is called a "step". A [CycleException] is
15 /// represented internally as a linked list of steps. 15 /// represented internally as a linked list of steps.
16 class CycleException implements ApplicationException { 16 class CycleException implements ApplicationException {
17 /// The step for this exception. 17 /// The step for this exception.
18 final String _step; 18 final String _step;
19 19
20 /// The next exception in the linked list. 20 /// The next exception in the linked list.
21 /// 21 ///
22 /// [_next]'s steps come after [_step]. 22 /// [_next]'s steps come after [_step].
23 final CycleException _next; 23 final CycleException _next;
24 24
25 /// A list of all steps in the cycle. 25 /// A list of all steps in the cycle.
26 List<String> get steps { 26 List<String> get steps {
27 if (_step == null) return []; 27 if (_step == null) return [];
28 28
29 var exception = this; 29 var exception = this;
30 var steps = []; 30 var steps = <String>[];
31 while (exception != null) { 31 while (exception != null) {
32 steps.add(exception._step); 32 steps.add(exception._step);
33 exception = exception._next; 33 exception = exception._next;
34 } 34 }
35 return steps; 35 return steps;
36 } 36 }
37 37
38 String get message { 38 String get message {
39 var steps = this.steps; 39 var steps = this.steps;
40 if (steps.isEmpty) return "Transformer cycle detected."; 40 if (steps.isEmpty) return "Transformer cycle detected.";
41 return "Transformer cycle detected:\n" + 41 return "Transformer cycle detected:\n" +
42 steps.map((step) => " $step").join("\n"); 42 steps.map((step) => " $step").join("\n");
43 } 43 }
44 44
45 /// Creates a new [CycleException] with zero or one steps. 45 /// Creates a new [CycleException] with zero or one steps.
46 CycleException([this._step]) 46 CycleException([this._step])
47 : _next = null; 47 : _next = null;
48 48
49 CycleException._(this._step, this._next); 49 CycleException._(this._step, this._next);
50 50
51 /// Returns a copy of [this] with [step] added to the beginning of [steps]. 51 /// Returns a copy of [this] with [step] added to the beginning of [steps].
52 CycleException prependStep(String step) { 52 CycleException prependStep(String step) {
53 if (_step == null) return new CycleException(step); 53 if (_step == null) return new CycleException(step);
54 return new CycleException._(step, this); 54 return new CycleException._(step, this);
55 } 55 }
56 56
57 String toString() => message; 57 String toString() => message;
58 } 58 }
OLDNEW
« no previous file with comments | « lib/src/barback/barback_server.dart ('k') | lib/src/barback/dart2js_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698