| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 formatter_impl; | 5 library formatter_impl; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 token(SEMI_COLON); | 625 token(SEMI_COLON); |
| 626 newlines(); | 626 newlines(); |
| 627 return; | 627 return; |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 | 630 |
| 631 visitPrefixedBody(space, body); | 631 visitPrefixedBody(space, body); |
| 632 } | 632 } |
| 633 | 633 |
| 634 visitConstructorInitializers(ConstructorDeclaration node) { | 634 visitConstructorInitializers(ConstructorDeclaration node) { |
| 635 newlines(); | 635 if (node.initializers.length > 1) { |
| 636 newlines(); |
| 637 } else { |
| 638 preserveLeadingNewlines(); |
| 639 } |
| 636 indent(2); | 640 indent(2); |
| 637 token(node.separator /* : */); | 641 token(node.separator /* : */); |
| 638 space(); | 642 space(); |
| 639 for (var i = 0; i < node.initializers.length; i++) { | 643 for (var i = 0; i < node.initializers.length; i++) { |
| 640 if (i > 0) { | 644 if (i > 0) { |
| 641 // preceding comma | 645 // preceding comma |
| 642 token(node.initializers[i].beginToken.previous); | 646 token(node.initializers[i].beginToken.previous); |
| 643 newlines(); | 647 newlines(); |
| 644 space(n: 2, allowLineLeading: true); | 648 space(n: 2, allowLineLeading: true); |
| 645 } | 649 } |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 var lastLine = | 1708 var lastLine = |
| 1705 lineInfo.getLocation(lastOffset).lineNumber; | 1709 lineInfo.getLocation(lastOffset).lineNumber; |
| 1706 var currentLine = | 1710 var currentLine = |
| 1707 lineInfo.getLocation(currentOffset).lineNumber; | 1711 lineInfo.getLocation(currentOffset).lineNumber; |
| 1708 return currentLine - lastLine; | 1712 return currentLine - lastLine; |
| 1709 } | 1713 } |
| 1710 | 1714 |
| 1711 String toString() => writer.toString(); | 1715 String toString() => writer.toString(); |
| 1712 | 1716 |
| 1713 } | 1717 } |
| OLD | NEW |