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

Unified Diff: pkg/analyzer/lib/src/services/formatter_impl.dart

Issue 156033002: Fix to ensure no breaks after new and general zero-length space support (dartbug.com/16379). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 months 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 | « no previous file | pkg/analyzer/lib/src/services/writer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/services/formatter_impl.dart
===================================================================
--- pkg/analyzer/lib/src/services/formatter_impl.dart (revision 32331)
+++ pkg/analyzer/lib/src/services/formatter_impl.dart (working copy)
@@ -363,6 +363,9 @@
/// addded to the indent level).
bool allowLineLeadingSpaces;
+ /// A flag to specify whether zero-length spaces should be emmitted.
+ bool emitEmptySpaces = false;
+
/// Used for matching EOL comments
final twoSlashes = new RegExp(r'//[^/]');
@@ -412,7 +415,9 @@
visitArgumentList(ArgumentList node) {
token(node.leftParenthesis);
+ breakableNonSpace();
visitCommaSeparatedNodes(node.arguments);
+ breakableNonSpace();
token(node.rightParenthesis);
}
@@ -930,7 +935,7 @@
visitInstanceCreationExpression(InstanceCreationExpression node) {
token(node.keyword);
- space();
+ nonBreakingSpace();
visit(node.constructorName);
visit(node.argumentList);
}
@@ -1466,12 +1471,13 @@
}
emitSpaces() {
- if (leadingSpaces > 0) {
+ if (leadingSpaces > 0 || emitEmptySpaces) {
if (allowLineLeadingSpaces || !writer.currentLine.isWhitespace()) {
writer.spaces(leadingSpaces, breakWeight: currentBreakWeight);
}
leadingSpaces = 0;
allowLineLeadingSpaces = false;
+ emitEmptySpaces = false;
currentBreakWeight = DEFAULT_SPACE_WEIGHT;
}
}
@@ -1490,6 +1496,12 @@
}
}
+ /// Emit a breakable 'non' (zero-length) space
+ breakableNonSpace() {
+ space(n: 0);
+ emitEmptySpaces = true;
+ }
+
/// Emit a non-breakable space.
nonBreakingSpace() {
space(breakWeight: UNBREAKABLE_SPACE_WEIGHT);
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/services/writer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698