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

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

Issue 1000513002: Tweak formatting rules. Fix #211. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Update changelog. Created 5 years, 9 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/line_writer.dart ('k') | lib/src/source_visitor.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) 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 library dart_style.src.multisplit; 5 library dart_style.src.multisplit;
6 6
7 import 'chunk.dart'; 7 import 'chunk.dart';
8 8
9 /// Handles a series of [Chunks] that all either split or don't split together. 9 /// Handles a series of [Chunks] that all either split or don't split together.
10 /// 10 ///
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 /// The trailing calls are short enough to not split. 46 /// The trailing calls are short enough to not split.
47 class Multisplit { 47 class Multisplit {
48 /// The index of the first chunk contained by the multisplit. 48 /// The index of the first chunk contained by the multisplit.
49 /// 49 ///
50 /// This is used to determine which chunk range needs to be scanned to look 50 /// This is used to determine which chunk range needs to be scanned to look
51 /// for hard newlines to see if the multisplit gets forced. 51 /// for hard newlines to see if the multisplit gets forced.
52 final int startChunk; 52 final int startChunk;
53 53
54 /// The [SplitParam] that controls all of the split chunks. 54 /// The [SplitParam] that controls all of the split chunks.
55 SplitParam get param => _param; 55 SplitParam get param => _param;
56 SplitParam _param = new SplitParam(); 56 SplitParam _param;
57 57
58 /// `true` if a hard newline has forced this multisplit to be split. 58 /// `true` if a hard newline has forced this multisplit to be split.
59 bool _isSplit = false; 59 bool _isSplit = false;
60 60
61 final bool _separable; 61 final bool _separable;
62 62
63 Multisplit(this.startChunk, {bool separable}) 63 Multisplit(this.startChunk, {bool separable, int cost})
64 : _separable = separable != null ? separable : false; 64 : _separable = separable != null ? separable : false,
65 _param = new SplitParam(cost);
65 66
66 /// Handles a hard split occurring in the middle of this multisplit. 67 /// Handles a hard split occurring in the middle of this multisplit.
67 /// 68 ///
68 /// If the multisplit is separable, this creates a new param so the previous 69 /// If the multisplit is separable, this creates a new param so the previous
69 /// split chunks can vary independently of later ones. Otherwise, it just 70 /// split chunks can vary independently of later ones. Otherwise, it just
70 /// marks this multisplit as being split. 71 /// marks this multisplit as being split.
71 /// 72 ///
72 /// Returns a [SplitParam] for existing splits that should be hardened if this 73 /// Returns a [SplitParam] for existing splits that should be hardened if this
73 /// splits a non-separable multisplit for the first time. Otherwise, returns 74 /// splits a non-separable multisplit for the first time. Otherwise, returns
74 /// `null`. 75 /// `null`.
75 SplitParam harden() { 76 SplitParam harden() {
76 if (_isSplit) return null; 77 if (_isSplit) return null;
77 78
78 _isSplit = true; 79 _isSplit = true;
79 80
80 if (_separable) { 81 if (_separable) {
81 _param = new SplitParam(param.cost); 82 _param = new SplitParam(_param.cost);
82 83
83 // Previous splits may still remain unsplit. 84 // Previous splits may still remain unsplit.
84 return null; 85 return null;
85 } else { 86 } else {
86 // Any other splits created from this multisplit should be hardened now. 87 // Any other splits created from this multisplit should be hardened now.
87 var oldParam = _param; 88 var oldParam = _param;
88 _param = null; 89 _param = null;
89 return oldParam; 90 return oldParam;
90 } 91 }
91 } 92 }
92 } 93 }
OLDNEW
« no previous file with comments | « lib/src/line_writer.dart ('k') | lib/src/source_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698