OLD | NEW |
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.chunk; | 5 library dart_style.src.chunk; |
6 | 6 |
7 import 'fast_hash.dart'; | 7 import 'fast_hash.dart'; |
8 import 'nesting.dart'; | 8 import 'nesting.dart'; |
9 import 'rule/rule.dart'; | 9 import 'rule/rule.dart'; |
10 | 10 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 bool get spaceWhenUnsplit => _spaceWhenUnsplit; | 139 bool get spaceWhenUnsplit => _spaceWhenUnsplit; |
140 bool _spaceWhenUnsplit = false; | 140 bool _spaceWhenUnsplit = false; |
141 | 141 |
142 /// Whether this chunk marks the end of a range of chunks that can be line | 142 /// Whether this chunk marks the end of a range of chunks that can be line |
143 /// split independently of the following chunks. | 143 /// split independently of the following chunks. |
144 bool get canDivide { | 144 bool get canDivide { |
145 // Have to call markDivide() before accessing this. | 145 // Have to call markDivide() before accessing this. |
146 assert(_canDivide != null); | 146 assert(_canDivide != null); |
147 return _canDivide; | 147 return _canDivide; |
148 } | 148 } |
| 149 |
149 bool _canDivide; | 150 bool _canDivide; |
150 | 151 |
151 /// The number of characters in this chunk when unsplit. | 152 /// The number of characters in this chunk when unsplit. |
152 int get length => _text.length + (spaceWhenUnsplit ? 1 : 0); | 153 int get length => _text.length + (spaceWhenUnsplit ? 1 : 0); |
153 | 154 |
154 /// The unsplit length of all of this chunk's block contents. | 155 /// The unsplit length of all of this chunk's block contents. |
155 /// | 156 /// |
156 /// Does not include this chunk's own length, just the length of its child | 157 /// Does not include this chunk's own length, just the length of its child |
157 /// block chunks (recursively). | 158 /// block chunks (recursively). |
158 int get unsplitBlockLength { | 159 int get unsplitBlockLength { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 /// output. This way, commented out chunks of code do not get erroneously | 351 /// output. This way, commented out chunks of code do not get erroneously |
351 /// re-indented. | 352 /// re-indented. |
352 final bool flushLeft; | 353 final bool flushLeft; |
353 | 354 |
354 /// Whether this comment is an inline block comment. | 355 /// Whether this comment is an inline block comment. |
355 bool get isInline => linesBefore == 0 && !isLineComment; | 356 bool get isInline => linesBefore == 0 && !isLineComment; |
356 | 357 |
357 SourceComment(this.text, this.linesBefore, | 358 SourceComment(this.text, this.linesBefore, |
358 {this.isLineComment, this.flushLeft}); | 359 {this.isLineComment, this.flushLeft}); |
359 } | 360 } |
OLD | NEW |