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_level.dart'; | 8 import 'nesting_level.dart'; |
9 import 'rule/rule.dart'; | 9 import 'rule/rule.dart'; |
10 | 10 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 if (_isDouble) parts.add("double"); | 247 if (_isDouble) parts.add("double"); |
248 if (_flushLeft) parts.add("flush"); | 248 if (_flushLeft) parts.add("flush"); |
249 | 249 |
250 if (_rule == null) { | 250 if (_rule == null) { |
251 parts.add("(no split)"); | 251 parts.add("(no split)"); |
252 } else if (isHardSplit) { | 252 } else if (isHardSplit) { |
253 parts.add("hard"); | 253 parts.add("hard"); |
254 } else { | 254 } else { |
255 parts.add(rule.toString()); | 255 parts.add(rule.toString()); |
256 | 256 |
257 if (_rule.outerRules.isNotEmpty) { | 257 if (_rule.constrainedRules.isNotEmpty) { |
258 parts.add("-> ${_rule.outerRules.join(' ')}"); | 258 parts.add("-> ${_rule.constrainedRules.join(' ')}"); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 return parts.join(" "); | 262 return parts.join(" "); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 /// Constants for the cost heuristics used to determine which set of splits is | 266 /// Constants for the cost heuristics used to determine which set of splits is |
267 /// most desirable. | 267 /// most desirable. |
268 class Cost { | 268 class Cost { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 /// output. This way, commented out chunks of code do not get erroneously | 362 /// output. This way, commented out chunks of code do not get erroneously |
363 /// re-indented. | 363 /// re-indented. |
364 final bool flushLeft; | 364 final bool flushLeft; |
365 | 365 |
366 /// Whether this comment is an inline block comment. | 366 /// Whether this comment is an inline block comment. |
367 bool get isInline => linesBefore == 0 && !isLineComment; | 367 bool get isInline => linesBefore == 0 && !isLineComment; |
368 | 368 |
369 SourceComment(this.text, this.linesBefore, | 369 SourceComment(this.text, this.linesBefore, |
370 {this.isLineComment, this.flushLeft}); | 370 {this.isLineComment, this.flushLeft}); |
371 } | 371 } |
OLD | NEW |