| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 bool _firstFlushLeft = false; | 91 bool _firstFlushLeft = false; |
| 92 | 92 |
| 93 /// Whether there is pending whitespace that depends on the number of | 93 /// Whether there is pending whitespace that depends on the number of |
| 94 /// newlines in the source. | 94 /// newlines in the source. |
| 95 /// | 95 /// |
| 96 /// This is used to avoid calculating the newlines between tokens unless | 96 /// This is used to avoid calculating the newlines between tokens unless |
| 97 /// actually needed since doing so is slow when done between every single | 97 /// actually needed since doing so is slow when done between every single |
| 98 /// token pair. | 98 /// token pair. |
| 99 bool get needsToPreserveNewlines => | 99 bool get needsToPreserveNewlines => |
| 100 _pendingWhitespace == Whitespace.oneOrTwoNewlines || | 100 _pendingWhitespace == Whitespace.oneOrTwoNewlines || |
| 101 _pendingWhitespace == Whitespace.spaceOrNewline || | 101 _pendingWhitespace == Whitespace.spaceOrNewline || |
| 102 _pendingWhitespace == Whitespace.splitOrNewline; | 102 _pendingWhitespace == Whitespace.splitOrNewline; |
| 103 | 103 |
| 104 /// The number of characters of code that can fit in a single line. | 104 /// The number of characters of code that can fit in a single line. |
| 105 int get pageWidth => _formatter.pageWidth; | 105 int get pageWidth => _formatter.pageWidth; |
| 106 | 106 |
| 107 /// The current innermost rule. | 107 /// The current innermost rule. |
| 108 Rule get rule => _rules.last; | 108 Rule get rule => _rules.last; |
| 109 | 109 |
| 110 ChunkBuilder(this._formatter, this._source) | 110 ChunkBuilder(this._formatter, this._source) |
| 111 : _parent = null, | 111 : _parent = null, |
| 112 _chunks = [] { | 112 _chunks = [] { |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 788 |
| 789 // Discard spans in hardened chunks since we know for certain they will | 789 // Discard spans in hardened chunks since we know for certain they will |
| 790 // split anyway. | 790 // split anyway. |
| 791 for (var chunk in _chunks) { | 791 for (var chunk in _chunks) { |
| 792 if (chunk.rule != null && chunk.rule.isHardened) { | 792 if (chunk.rule != null && chunk.rule.isHardened) { |
| 793 chunk.spans.clear(); | 793 chunk.spans.clear(); |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 } | 796 } |
| 797 } | 797 } |
| OLD | NEW |