| 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 808 } |
| 809 token(node.rightParenthesis); | 809 token(node.rightParenthesis); |
| 810 if (node.body is! EmptyStatement) { | 810 if (node.body is! EmptyStatement) { |
| 811 space(); | 811 space(); |
| 812 } | 812 } |
| 813 visit(node.body); | 813 visit(node.body); |
| 814 } | 814 } |
| 815 | 815 |
| 816 visitFunctionDeclaration(FunctionDeclaration node) { | 816 visitFunctionDeclaration(FunctionDeclaration node) { |
| 817 preserveLeadingNewlines(); | 817 preserveLeadingNewlines(); |
| 818 visitNode(node.returnType, followedBy: space); | 818 modifier(node.externalKeyword); |
| 819 token(node.propertyKeyword, followedBy: space); | 819 //TODO(pquitslund): remove this workaround once setter functions |
| 820 //have their return types properly set (dartbug.com/15914) |
| 821 if (node.returnType == null && node.propertyKeyword != null) { |
| 822 modifier(node.propertyKeyword.previous); |
| 823 } else { |
| 824 visitNode(node.returnType, followedBy: space); |
| 825 } |
| 826 modifier(node.propertyKeyword); |
| 820 visit(node.name); | 827 visit(node.name); |
| 821 visit(node.functionExpression); | 828 visit(node.functionExpression); |
| 822 } | 829 } |
| 823 | 830 |
| 824 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | 831 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 825 visit(node.functionDeclaration); | 832 visit(node.functionDeclaration); |
| 826 } | 833 } |
| 827 | 834 |
| 828 visitFunctionExpression(FunctionExpression node) { | 835 visitFunctionExpression(FunctionExpression node) { |
| 829 visit(node.parameters); | 836 visit(node.parameters); |
| 830 space(); | 837 if (node.body is! EmptyFunctionBody) { |
| 838 space(); |
| 839 } |
| 831 visit(node.body); | 840 visit(node.body); |
| 832 } | 841 } |
| 833 | 842 |
| 834 visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 843 visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 835 visit(node.function); | 844 visit(node.function); |
| 836 visit(node.argumentList); | 845 visit(node.argumentList); |
| 837 } | 846 } |
| 838 | 847 |
| 839 visitFunctionTypeAlias(FunctionTypeAlias node) { | 848 visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 840 token(node.keyword); | 849 token(node.keyword); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 var lastLine = | 1642 var lastLine = |
| 1634 lineInfo.getLocation(lastOffset).lineNumber; | 1643 lineInfo.getLocation(lastOffset).lineNumber; |
| 1635 var currentLine = | 1644 var currentLine = |
| 1636 lineInfo.getLocation(currentOffset).lineNumber; | 1645 lineInfo.getLocation(currentOffset).lineNumber; |
| 1637 return currentLine - lastLine; | 1646 return currentLine - lastLine; |
| 1638 } | 1647 } |
| 1639 | 1648 |
| 1640 String toString() => writer.toString(); | 1649 String toString() => writer.toString(); |
| 1641 | 1650 |
| 1642 } | 1651 } |
| OLD | NEW |