| Index: pkg/analyzer/lib/src/services/formatter_impl.dart
|
| ===================================================================
|
| --- pkg/analyzer/lib/src/services/formatter_impl.dart (revision 32082)
|
| +++ pkg/analyzer/lib/src/services/formatter_impl.dart (working copy)
|
| @@ -367,7 +367,7 @@
|
| final twoSlashes = new RegExp(r'//[^/]');
|
|
|
| /// A weight for potential breakpoints.
|
| - int breakWeight = DEFAULT_SPACE_WEIGHT;
|
| + int currentBreakWeight = DEFAULT_SPACE_WEIGHT;
|
|
|
| /// Original pre-format selection information (may be null).
|
| final Selection preSelection;
|
| @@ -923,7 +923,7 @@
|
| visitImportDirective(ImportDirective node) {
|
| visitNodes(node.metadata, followedBy: newlines);
|
| token(node.keyword);
|
| - space();
|
| + nonBreakingSpace();
|
| visit(node.uri);
|
| token(node.asToken, precededBy: space, followedBy: space);
|
| allowContinuedLines((){
|
| @@ -1481,11 +1481,11 @@
|
| emitSpaces() {
|
| if (leadingSpaces > 0) {
|
| if (allowLineLeadingSpaces || !writer.currentLine.isWhitespace()) {
|
| - writer.spaces(leadingSpaces, breakWeight: breakWeight);
|
| + writer.spaces(leadingSpaces, breakWeight: currentBreakWeight);
|
| }
|
| leadingSpaces = 0;
|
| allowLineLeadingSpaces = false;
|
| - breakWeight = DEFAULT_SPACE_WEIGHT;
|
| + currentBreakWeight = DEFAULT_SPACE_WEIGHT;
|
| }
|
| }
|
|
|
| @@ -1503,22 +1503,21 @@
|
| }
|
| }
|
|
|
| - /// Emit a non-breakable space. If [allowLineLeading] is specified, spaces
|
| + /// Emit a non-breakable space.
|
| + nonBreakingSpace() {
|
| + space(breakWeight: UNBREAKABLE_SPACE_WEIGHT);
|
| + }
|
| +
|
| + /// Emit a space. If [allowLineLeading] is specified, spaces
|
| /// will be preserved at the start of a line (in addition to the
|
| /// indent-level), otherwise line-leading spaces will be ignored.
|
| - space({n: 1, allowLineLeading: false}) {
|
| + space({n: 1, allowLineLeading: false, breakWeight: DEFAULT_SPACE_WEIGHT}) {
|
| //TODO(pquitslund): replace with a proper space token
|
| leadingSpaces+=n;
|
| allowLineLeadingSpaces = allowLineLeading;
|
| + currentBreakWeight = breakWeight;
|
| }
|
|
|
| - /// Mark a breakable space
|
| - breakableSpace() {
|
| - space();
|
| - breakWeight =
|
| - countNewlinesBetween(previousToken, previousToken.next) > 0 ? 1 : 0;
|
| - }
|
| -
|
| /// Append the given [string] to the source writer if it's non-null.
|
| append(String string) {
|
| if (string != null && !string.isEmpty) {
|
|
|