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

Unified Diff: lib/src/debug.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/chunk_builder.dart ('k') | lib/src/line_splitting/line_splitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/debug.dart
diff --git a/lib/src/debug.dart b/lib/src/debug.dart
index 77590c03f43e9e4ae810e13d4e16adbc113b7a4b..60cb5f7f0965de7233f5c671edc42d66bc7f0a01 100644
--- a/lib/src/debug.dart
+++ b/lib/src/debug.dart
@@ -84,10 +84,8 @@ void dumpChunks(int start, List<Chunk> chunks) {
spans = spans.toList();
- var rules = chunks
- .map((chunk) => chunk.rule)
- .where((rule) => rule != null && rule is! HardSplitRule)
- .toSet();
+ var rules =
+ chunks.map((chunk) => chunk.rule).where((rule) => rule != null).toSet();
var rows = [];
@@ -132,13 +130,12 @@ void dumpChunks(int start, List<Chunk> chunks) {
row.add("");
row.add("(no rule)");
row.add("");
- } else if (chunk.isHardSplit) {
- row.add("");
- row.add("(hard)");
- row.add("");
- } else if (chunk.rule != null) {
+ } else {
writeIf(chunk.rule.cost != 0, () => "\$${chunk.rule.cost}");
- row.add(chunk.rule.toString());
+
+ var ruleString = chunk.rule.toString();
+ if (chunk.rule.isHardened) ruleString += "!";
+ row.add(ruleString);
var constrainedRules =
chunk.rule.constrainedRules.toSet().intersection(rules);
@@ -191,6 +188,33 @@ void dumpChunks(int start, List<Chunk> chunks) {
print(buffer.toString());
}
+/// Shows all of the constraints between the rules used by [chunks].
+void dumpConstraints(List<Chunk> chunks) {
+ var rules =
+ chunks.map((chunk) => chunk.rule).where((rule) => rule != null).toSet();
+
+ for (var rule in rules) {
+ var constrainedValues = [];
+ for (var value = 0; value < rule.numValues; value++) {
+ var constraints = [];
+ for (var other in rules) {
+ if (rule == other) continue;
+
+ var constraint = rule.constrain(value, other);
+ if (constraint != null) {
+ constraints.add("$other->$constraint");
+ }
+ }
+
+ if (constraints.isNotEmpty) {
+ constrainedValues.add("$value:(${constraints.join(' ')})");
+ }
+ }
+
+ log("$rule ${constrainedValues.join(' ')}");
+ }
+}
+
/// Convert the line to a [String] representation.
///
/// It will determine how best to split it into multiple lines of output and
« no previous file with comments | « lib/src/chunk_builder.dart ('k') | lib/src/line_splitting/line_splitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698