| 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 if (node.body is! EmptyStatement) { | 824 if (node.body is! EmptyStatement) { |
| 825 space(); | 825 space(); |
| 826 } | 826 } |
| 827 visit(node.body); | 827 visit(node.body); |
| 828 } | 828 } |
| 829 | 829 |
| 830 visitFunctionDeclaration(FunctionDeclaration node) { | 830 visitFunctionDeclaration(FunctionDeclaration node) { |
| 831 preserveLeadingNewlines(); | 831 preserveLeadingNewlines(); |
| 832 visitNodes(node.metadata, followedBy: newlines); | 832 visitNodes(node.metadata, followedBy: newlines); |
| 833 modifier(node.externalKeyword); | 833 modifier(node.externalKeyword); |
| 834 //TODO(pquitslund): remove this workaround once setter functions | 834 visitNode(node.returnType, followedBy: space); |
| 835 //have their return types properly set (dartbug.com/15914) | |
| 836 if (node.returnType == null && node.propertyKeyword != null) { | |
| 837 var previous = node.propertyKeyword.previous; | |
| 838 if (previous is KeywordToken && previous.keyword == Keyword.VOID) { | |
| 839 modifier(previous); | |
| 840 } | |
| 841 } else { | |
| 842 visitNode(node.returnType, followedBy: space); | |
| 843 } | |
| 844 modifier(node.propertyKeyword); | 835 modifier(node.propertyKeyword); |
| 845 visit(node.name); | 836 visit(node.name); |
| 846 visit(node.functionExpression); | 837 visit(node.functionExpression); |
| 847 } | 838 } |
| 848 | 839 |
| 849 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | 840 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 850 visit(node.functionDeclaration); | 841 visit(node.functionDeclaration); |
| 851 } | 842 } |
| 852 | 843 |
| 853 visitFunctionExpression(FunctionExpression node) { | 844 visitFunctionExpression(FunctionExpression node) { |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 var lastLine = | 1682 var lastLine = |
| 1692 lineInfo.getLocation(lastOffset).lineNumber; | 1683 lineInfo.getLocation(lastOffset).lineNumber; |
| 1693 var currentLine = | 1684 var currentLine = |
| 1694 lineInfo.getLocation(currentOffset).lineNumber; | 1685 lineInfo.getLocation(currentOffset).lineNumber; |
| 1695 return currentLine - lastLine; | 1686 return currentLine - lastLine; |
| 1696 } | 1687 } |
| 1697 | 1688 |
| 1698 String toString() => writer.toString(); | 1689 String toString() => writer.toString(); |
| 1699 | 1690 |
| 1700 } | 1691 } |
| OLD | NEW |