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

Side by Side Diff: lib/src/line_splitting/line_splitter.dart

Issue 1492683002: Change the way hard splits are handled. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years 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/debug.dart ('k') | lib/src/line_splitting/rule_set.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.line_splitting.line_splitter; 5 library dart_style.src.line_splitting.line_splitter;
6 6
7 import '../chunk.dart'; 7 import '../chunk.dart';
8 import '../debug.dart' as debug; 8 import '../debug.dart' as debug;
9 import '../line_writer.dart'; 9 import '../line_writer.dart';
10 import '../rule/rule.dart'; 10 import '../rule/rule.dart';
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 /// The lowest cost solution found so far. 124 /// The lowest cost solution found so far.
125 SolveState _bestSolution; 125 SolveState _bestSolution;
126 126
127 /// Creates a new splitter for [_writer] that tries to fit [chunks] into the 127 /// Creates a new splitter for [_writer] that tries to fit [chunks] into the
128 /// page width. 128 /// page width.
129 LineSplitter(this.writer, List<Chunk> chunks, int blockIndentation, 129 LineSplitter(this.writer, List<Chunk> chunks, int blockIndentation,
130 int firstLineIndent, 130 int firstLineIndent,
131 {bool flushLeft: false}) 131 {bool flushLeft: false})
132 : chunks = chunks, 132 : chunks = chunks,
133 // Collect the set of soft rules that we need to select values for. 133 // Collect the set of rules that we need to select values for.
134 rules = chunks 134 rules = chunks
135 .map((chunk) => chunk.rule) 135 .map((chunk) => chunk.rule)
136 .where((rule) => rule != null && rule is! HardSplitRule) 136 .where((rule) => rule != null)
137 .toSet() 137 .toSet()
138 .toList(growable: false), 138 .toList(growable: false),
139 blockIndentation = blockIndentation, 139 blockIndentation = blockIndentation,
140 firstLineIndent = flushLeft ? 0 : firstLineIndent + blockIndentation { 140 firstLineIndent = flushLeft ? 0 : firstLineIndent + blockIndentation {
141 _queue.bindSplitter(this); 141 _queue.bindSplitter(this);
142 142
143 // Store the rule's index in the rule so we can get from a chunk to a rule 143 // Store the rule's index in the rule so we can get from a chunk to a rule
144 // index quickly. 144 // index quickly.
145 for (var i = 0; i < rules.length; i++) { 145 for (var i = 0; i < rules.length; i++) {
146 rules[i].index = i; 146 rules[i].index = i;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 debug.log(); 196 debug.log();
197 } 197 }
198 198
199 return _bestSolution.splits; 199 return _bestSolution.splits;
200 } 200 }
201 201
202 void enqueue(SolveState state) { 202 void enqueue(SolveState state) {
203 _queue.add(state); 203 _queue.add(state);
204 } 204 }
205 } 205 }
OLDNEW
« no previous file with comments | « lib/src/debug.dart ('k') | lib/src/line_splitting/rule_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698