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

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

Issue 815423003: Don't put spaces in empty for loop clauses. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 11 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/132.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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 _writer.nestExpression(); 746 _writer.nestExpression();
747 token(node.forKeyword); 747 token(node.forKeyword);
748 space(); 748 space();
749 token(node.leftParenthesis); 749 token(node.leftParenthesis);
750 750
751 _writer.startMultisplit(); 751 _writer.startMultisplit();
752 752
753 // The initialization clause. 753 // The initialization clause.
754 if (node.initialization != null) { 754 if (node.initialization != null) {
755 visit(node.initialization); 755 visit(node.initialization);
756 } else { 756 } else if (node.variables != null) {
757 if (node.variables == null) { 757 // Indent split variables more so they aren't at the same level
758 space(); 758 // as the rest of the loop clauses.
759 } else { 759 _writer.indent(4);
760 // Indent split variables more so they aren't at the same level
761 // as the rest of the loop clauses.
762 _writer.indent(4);
763 760
764 var declaration = node.variables; 761 var declaration = node.variables;
765 visitDeclarationMetadata(declaration.metadata); 762 visitDeclarationMetadata(declaration.metadata);
766 modifier(declaration.keyword); 763 modifier(declaration.keyword);
767 visit(declaration.type, after: space); 764 visit(declaration.type, after: space);
768 765
769 visitCommaSeparatedNodes(declaration.variables, between: () { 766 visitCommaSeparatedNodes(declaration.variables, between: () {
770 _writer.multisplit(space: true, nest: true); 767 _writer.multisplit(space: true, nest: true);
771 }); 768 });
772 769
773 _writer.unindent(4); 770 _writer.unindent(4);
774 }
775 } 771 }
776 772
777 token(node.leftSeparator); 773 token(node.leftSeparator);
778 _writer.multisplit(nest: true, space: true);
779 774
780 // The condition clause. 775 // The condition clause.
776 if (node.condition != null) _writer.multisplit(nest: true, space: true);
781 visit(node.condition); 777 visit(node.condition);
782 token(node.rightSeparator); 778 token(node.rightSeparator);
783 779
784 // The update clause. 780 // The update clause.
785 if (node.updaters != null) { 781 if (node.updaters.isNotEmpty) {
786 _writer.multisplit(nest: true, space: true); 782 _writer.multisplit(nest: true, space: true);
787 visitCommaSeparatedNodes(node.updaters, 783 visitCommaSeparatedNodes(node.updaters,
788 between: () => _writer.multisplit(nest: true, space: true)); 784 between: () => _writer.multisplit(nest: true, space: true));
789 } 785 }
790 786
791 token(node.rightParenthesis); 787 token(node.rightParenthesis);
792 _writer.endMultisplit(); 788 _writer.endMultisplit();
793 _writer.unnest(); 789 _writer.unnest();
794 790
795 // The body. 791 // The body.
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 /// Gets the 1-based line number that the beginning of [token] lies on. 1853 /// Gets the 1-based line number that the beginning of [token] lies on.
1858 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; 1854 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber;
1859 1855
1860 /// Gets the 1-based line number that the end of [token] lies on. 1856 /// Gets the 1-based line number that the end of [token] lies on.
1861 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; 1857 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber;
1862 1858
1863 /// Gets the 1-based column number that the beginning of [token] lies on. 1859 /// Gets the 1-based column number that the beginning of [token] lies on.
1864 int _startColumn(Token token) => 1860 int _startColumn(Token token) =>
1865 _lineInfo.getLocation(token.offset).columnNumber; 1861 _lineInfo.getLocation(token.offset).columnNumber;
1866 } 1862 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/132.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698