| 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/java_core.dart' show CharSequence; | 10 import 'package:analyzer/src/generated/java_core.dart' show CharSequence; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 | 469 |
| 470 visitBreakStatement(BreakStatement node) { | 470 visitBreakStatement(BreakStatement node) { |
| 471 token(node.keyword); | 471 token(node.keyword); |
| 472 visitNode(node.label, precededBy: space); | 472 visitNode(node.label, precededBy: space); |
| 473 token(node.semicolon); | 473 token(node.semicolon); |
| 474 } | 474 } |
| 475 | 475 |
| 476 visitCascadeExpression(CascadeExpression node) { | 476 visitCascadeExpression(CascadeExpression node) { |
| 477 visit(node.target); | 477 visit(node.target); |
| 478 indent(2); | 478 indent(2); |
| 479 newlines(); | 479 // Single cascades do not force a linebreak (dartbug.com/16384) |
| 480 if (node.cascadeSections.length > 1) { |
| 481 newlines(); |
| 482 } |
| 480 visitNodes(node.cascadeSections, separatedBy: newlines); | 483 visitNodes(node.cascadeSections, separatedBy: newlines); |
| 481 unindent(2); | 484 unindent(2); |
| 482 } | 485 } |
| 483 | 486 |
| 484 visitCatchClause(CatchClause node) { | 487 visitCatchClause(CatchClause node) { |
| 485 | 488 |
| 486 token(node.onKeyword, followedBy: space); | 489 token(node.onKeyword, followedBy: space); |
| 487 visit(node.exceptionType); | 490 visit(node.exceptionType); |
| 488 | 491 |
| 489 if (node.catchKeyword != null) { | 492 if (node.catchKeyword != null) { |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 var lastLine = | 1684 var lastLine = |
| 1682 lineInfo.getLocation(lastOffset).lineNumber; | 1685 lineInfo.getLocation(lastOffset).lineNumber; |
| 1683 var currentLine = | 1686 var currentLine = |
| 1684 lineInfo.getLocation(currentOffset).lineNumber; | 1687 lineInfo.getLocation(currentOffset).lineNumber; |
| 1685 return currentLine - lastLine; | 1688 return currentLine - lastLine; |
| 1686 } | 1689 } |
| 1687 | 1690 |
| 1688 String toString() => writer.toString(); | 1691 String toString() => writer.toString(); |
| 1689 | 1692 |
| 1690 } | 1693 } |
| OLD | NEW |