Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: pkg/analyzer/lib/src/services/formatter_impl.dart

Issue 320503002: Tweaks for long formal parameters and method body '{' formatting. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/services/data/cu_tests.data » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 } 801 }
802 802
803 visitFormalParameterList(FormalParameterList node) { 803 visitFormalParameterList(FormalParameterList node) {
804 var groupEnd = null; 804 var groupEnd = null;
805 token(node.leftParenthesis); 805 token(node.leftParenthesis);
806 var parameters = node.parameters; 806 var parameters = node.parameters;
807 var size = parameters.length; 807 var size = parameters.length;
808 for (var i = 0; i < size; i++) { 808 for (var i = 0; i < size; i++) {
809 var parameter = parameters[i]; 809 var parameter = parameters[i];
810 if (i > 0) { 810 if (i > 0) {
811 append(', '); 811 append(',');
812 space();
812 } 813 }
813 if (groupEnd == null && parameter is DefaultFormalParameter) { 814 if (groupEnd == null && parameter is DefaultFormalParameter) {
814 if (identical(parameter.kind, ParameterKind.NAMED)) { 815 if (identical(parameter.kind, ParameterKind.NAMED)) {
815 groupEnd = '}'; 816 groupEnd = '}';
816 append('{'); 817 append('{');
817 } else { 818 } else {
818 groupEnd = ']'; 819 groupEnd = ']';
819 append('['); 820 append('[');
820 } 821 }
821 } 822 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 visitMemberMetadata(node.metadata); 1055 visitMemberMetadata(node.metadata);
1055 modifier(node.externalKeyword); 1056 modifier(node.externalKeyword);
1056 modifier(node.modifierKeyword); 1057 modifier(node.modifierKeyword);
1057 visitNode(node.returnType, followedBy: space); 1058 visitNode(node.returnType, followedBy: space);
1058 modifier(node.propertyKeyword); 1059 modifier(node.propertyKeyword);
1059 modifier(node.operatorKeyword); 1060 modifier(node.operatorKeyword);
1060 visit(node.name); 1061 visit(node.name);
1061 if (!node.isGetter) { 1062 if (!node.isGetter) {
1062 visit(node.parameters); 1063 visit(node.parameters);
1063 } 1064 }
1064 visitPrefixedBody(space, node.body); 1065 visitPrefixedBody(nonBreakingSpace, node.body);
1065 } 1066 }
1066 1067
1067 visitMethodInvocation(MethodInvocation node) { 1068 visitMethodInvocation(MethodInvocation node) {
1068 visit(node.target); 1069 visit(node.target);
1069 token(node.period); 1070 token(node.period);
1070 visit(node.methodName); 1071 visit(node.methodName);
1071 visit(node.argumentList); 1072 visit(node.argumentList);
1072 } 1073 }
1073 1074
1074 visitNamedExpression(NamedExpression node) { 1075 visitNamedExpression(NamedExpression node) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1174
1174 visitShowCombinator(ShowCombinator node) { 1175 visitShowCombinator(ShowCombinator node) {
1175 token(node.keyword); 1176 token(node.keyword);
1176 space(); 1177 space();
1177 visitCommaSeparatedNodes(node.shownNames); 1178 visitCommaSeparatedNodes(node.shownNames);
1178 } 1179 }
1179 1180
1180 visitSimpleFormalParameter(SimpleFormalParameter node) { 1181 visitSimpleFormalParameter(SimpleFormalParameter node) {
1181 visitMemberMetadata(node.metadata); 1182 visitMemberMetadata(node.metadata);
1182 modifier(node.keyword); 1183 modifier(node.keyword);
1183 visitNode(node.type, followedBy: space); 1184 visitNode(node.type, followedBy: nonBreakingSpace);
1184 visit(node.identifier); 1185 visit(node.identifier);
1185 } 1186 }
1186 1187
1187 visitSimpleIdentifier(SimpleIdentifier node) { 1188 visitSimpleIdentifier(SimpleIdentifier node) {
1188 token(node.token); 1189 token(node.token);
1189 } 1190 }
1190 1191
1191 visitSimpleStringLiteral(SimpleStringLiteral node) { 1192 visitSimpleStringLiteral(SimpleStringLiteral node) {
1192 token(node.literal); 1193 token(node.literal);
1193 } 1194 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 var lastLine = 1769 var lastLine =
1769 lineInfo.getLocation(lastOffset).lineNumber; 1770 lineInfo.getLocation(lastOffset).lineNumber;
1770 var currentLine = 1771 var currentLine =
1771 lineInfo.getLocation(currentOffset).lineNumber; 1772 lineInfo.getLocation(currentOffset).lineNumber;
1772 return currentLine - lastLine; 1773 return currentLine - lastLine;
1773 } 1774 }
1774 1775
1775 String toString() => writer.toString(); 1776 String toString() => writer.toString();
1776 1777
1777 } 1778 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/services/data/cu_tests.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698