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

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

Issue 149743002: Fix to allow single method cascades to fit on one line (dartbug.com/16384). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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/stmt_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/java_core.dart' show CharSequence; 10 import 'package:analyzer/src/generated/java_core.dart' show CharSequence;
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 visitBreakStatement(BreakStatement node) { 470 visitBreakStatement(BreakStatement node) {
471 token(node.keyword); 471 token(node.keyword);
472 visitNode(node.label, precededBy: space); 472 visitNode(node.label, precededBy: space);
473 token(node.semicolon); 473 token(node.semicolon);
474 } 474 }
475 475
476 visitCascadeExpression(CascadeExpression node) { 476 visitCascadeExpression(CascadeExpression node) {
477 visit(node.target); 477 visit(node.target);
478 indent(2); 478 indent(2);
479 newlines(); 479 // Single cascades do not force a linebreak (dartbug.com/16384)
480 if (node.cascadeSections.length > 1) {
481 newlines();
482 }
480 visitNodes(node.cascadeSections, separatedBy: newlines); 483 visitNodes(node.cascadeSections, separatedBy: newlines);
481 unindent(2); 484 unindent(2);
482 } 485 }
483 486
484 visitCatchClause(CatchClause node) { 487 visitCatchClause(CatchClause node) {
485 488
486 token(node.onKeyword, followedBy: space); 489 token(node.onKeyword, followedBy: space);
487 visit(node.exceptionType); 490 visit(node.exceptionType);
488 491
489 if (node.catchKeyword != null) { 492 if (node.catchKeyword != null) {
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 var lastLine = 1684 var lastLine =
1682 lineInfo.getLocation(lastOffset).lineNumber; 1685 lineInfo.getLocation(lastOffset).lineNumber;
1683 var currentLine = 1686 var currentLine =
1684 lineInfo.getLocation(currentOffset).lineNumber; 1687 lineInfo.getLocation(currentOffset).lineNumber;
1685 return currentLine - lastLine; 1688 return currentLine - lastLine;
1686 } 1689 }
1687 1690
1688 String toString() => writer.toString(); 1691 String toString() => writer.toString();
1689 1692
1690 } 1693 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/services/data/stmt_tests.data » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698