| 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_builder; | 5 library dart_style.src.chunk_builder; |
| 6 | 6 |
| 7 import 'chunk.dart'; | 7 import 'chunk.dart'; |
| 8 import 'dart_formatter.dart'; | 8 import 'dart_formatter.dart'; |
| 9 import 'debug.dart' as debug; | 9 import 'debug.dart' as debug; |
| 10 import 'line_writer.dart'; | 10 import 'line_writer.dart'; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 /// | 377 /// |
| 378 /// If [rule] is omitted, defaults to a new [Rule]. | 378 /// If [rule] is omitted, defaults to a new [Rule]. |
| 379 void startLazyRule([Rule rule]) { | 379 void startLazyRule([Rule rule]) { |
| 380 if (rule == null) rule = new Rule(); | 380 if (rule == null) rule = new Rule(); |
| 381 | 381 |
| 382 _lazyRules.add(rule); | 382 _lazyRules.add(rule); |
| 383 } | 383 } |
| 384 | 384 |
| 385 /// Ends the innermost rule. | 385 /// Ends the innermost rule. |
| 386 void endRule() { | 386 void endRule() { |
| 387 _rules.removeLast(); | 387 if (_lazyRules.isNotEmpty) { |
| 388 _lazyRules.removeLast(); |
| 389 } else { |
| 390 _rules.removeLast(); |
| 391 } |
| 388 } | 392 } |
| 389 | 393 |
| 390 /// Pre-emptively forces all of the current rules to become hard splits. | 394 /// Pre-emptively forces all of the current rules to become hard splits. |
| 391 /// | 395 /// |
| 392 /// This is called by [SourceVisitor] when it can determine that a rule will | 396 /// This is called by [SourceVisitor] when it can determine that a rule will |
| 393 /// will always be split. Turning it (and the surrounding rules) into hard | 397 /// will always be split. Turning it (and the surrounding rules) into hard |
| 394 /// splits lets the writer break the output into smaller pieces for the line | 398 /// splits lets the writer break the output into smaller pieces for the line |
| 395 /// splitter, which helps performance and avoids failing on very large input. | 399 /// splitter, which helps performance and avoids failing on very large input. |
| 396 /// | 400 /// |
| 397 /// In particular, it's easy for the visitor to know that collections with a | 401 /// In particular, it's easy for the visitor to know that collections with a |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 | 806 |
| 803 // Discard spans in hardened chunks since we know for certain they will | 807 // Discard spans in hardened chunks since we know for certain they will |
| 804 // split anyway. | 808 // split anyway. |
| 805 for (var chunk in _chunks) { | 809 for (var chunk in _chunks) { |
| 806 if (chunk.rule != null && chunk.rule.isHardened) { | 810 if (chunk.rule != null && chunk.rule.isHardened) { |
| 807 chunk.spans.clear(); | 811 chunk.spans.clear(); |
| 808 } | 812 } |
| 809 } | 813 } |
| 810 } | 814 } |
| 811 } | 815 } |
| OLD | NEW |