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

Side by Side Diff: lib/src/source_visitor.dart

Issue 1255703002: Don't force for fully split if initializers or updaters do. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/0300/0375.stmt » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart_style.src.source_visitor; 5 library dart_style.src.source_visitor;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/src/generated/scanner.dart'; 8 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 10
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 builder.startRule(); 842 builder.startRule();
843 843
844 // The initialization clause. 844 // The initialization clause.
845 if (node.initialization != null) { 845 if (node.initialization != null) {
846 visit(node.initialization); 846 visit(node.initialization);
847 } else if (node.variables != null) { 847 } else if (node.variables != null) {
848 // Indent split variables more so they aren't at the same level 848 // Indent split variables more so they aren't at the same level
849 // as the rest of the loop clauses. 849 // as the rest of the loop clauses.
850 builder.indent(Indent.loopVariable); 850 builder.indent(Indent.loopVariable);
851 851
852 // Allow the variables to stay unsplit even if the clauses split.
853 builder.startRule();
854
852 var declaration = node.variables; 855 var declaration = node.variables;
853 visitDeclarationMetadata(declaration.metadata); 856 visitDeclarationMetadata(declaration.metadata);
854 modifier(declaration.keyword); 857 modifier(declaration.keyword);
855 visit(declaration.type, after: space); 858 visit(declaration.type, after: space);
856 859
857 visitCommaSeparatedNodes(declaration.variables, between: () { 860 visitCommaSeparatedNodes(declaration.variables, between: () {
858 split(); 861 split();
859 }); 862 });
860 863
864 builder.endRule();
861 builder.unindent(); 865 builder.unindent();
862 } 866 }
863 867
864 token(node.leftSeparator); 868 token(node.leftSeparator);
865 869
866 // The condition clause. 870 // The condition clause.
867 if (node.condition != null) split(); 871 if (node.condition != null) split();
868 visit(node.condition); 872 visit(node.condition);
869 token(node.rightSeparator); 873 token(node.rightSeparator);
870 874
871 // The update clause. 875 // The update clause.
872 if (node.updaters.isNotEmpty) { 876 if (node.updaters.isNotEmpty) {
873 split(); 877 split();
878
879 // Allow the updates to stay unsplit even if the clauses split.
880 builder.startRule();
881
874 visitCommaSeparatedNodes(node.updaters, between: split); 882 visitCommaSeparatedNodes(node.updaters, between: split);
883
884 builder.endRule();
875 } 885 }
876 886
877 token(node.rightParenthesis); 887 token(node.rightParenthesis);
878 builder.endRule(); 888 builder.endRule();
879 builder.unnest(); 889 builder.unnest();
880 890
881 // The body. 891 // The body.
882 if (node.body is! EmptyStatement) space(); 892 if (node.body is! EmptyStatement) space();
883 visit(node.body); 893 visit(node.body);
884 } 894 }
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 /// Gets the 1-based line number that the beginning of [token] lies on. 2146 /// Gets the 1-based line number that the beginning of [token] lies on.
2137 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; 2147 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber;
2138 2148
2139 /// Gets the 1-based line number that the end of [token] lies on. 2149 /// Gets the 1-based line number that the end of [token] lies on.
2140 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; 2150 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber;
2141 2151
2142 /// Gets the 1-based column number that the beginning of [token] lies on. 2152 /// Gets the 1-based column number that the beginning of [token] lies on.
2143 int _startColumn(Token token) => 2153 int _startColumn(Token token) =>
2144 _lineInfo.getLocation(token.offset).columnNumber; 2154 _lineInfo.getLocation(token.offset).columnNumber;
2145 } 2155 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/0300/0375.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698