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

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

Issue 151243003: Fixes for empty class and method bodies. (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/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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 visit(node.leftOperand); 450 visit(node.leftOperand);
451 space(); 451 space();
452 token(node.operator); 452 token(node.operator);
453 space(); 453 space();
454 visit(node.rightOperand); 454 visit(node.rightOperand);
455 } 455 }
456 456
457 visitBlock(Block node) { 457 visitBlock(Block node) {
458 token(node.leftBracket); 458 token(node.leftBracket);
459 indent(); 459 indent();
460 visitNodes(node.statements, precededBy: newlines, separatedBy: newlines); 460 if (!node.statements.isEmpty) {
461 newlines(); 461 visitNodes(node.statements, precededBy: newlines, separatedBy: newlines);
462 newlines();
463 } else {
464 preserveLeadingNewlines();
465 }
462 token(node.rightBracket, precededBy: unindent); 466 token(node.rightBracket, precededBy: unindent);
463 } 467 }
464 468
465 visitBlockFunctionBody(BlockFunctionBody node) { 469 visitBlockFunctionBody(BlockFunctionBody node) {
466 visit(node.block); 470 visit(node.block);
467 } 471 }
468 472
469 visitBooleanLiteral(BooleanLiteral node) { 473 visitBooleanLiteral(BooleanLiteral node) {
470 token(node.literal); 474 token(node.literal);
471 } 475 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 allowContinuedLines((){ 524 allowContinuedLines((){
521 visit(node.typeParameters); 525 visit(node.typeParameters);
522 visitNode(node.extendsClause, precededBy: space); 526 visitNode(node.extendsClause, precededBy: space);
523 visitNode(node.withClause, precededBy: space); 527 visitNode(node.withClause, precededBy: space);
524 visitNode(node.implementsClause, precededBy: space); 528 visitNode(node.implementsClause, precededBy: space);
525 visitNode(node.nativeClause, precededBy: space); 529 visitNode(node.nativeClause, precededBy: space);
526 space(); 530 space();
527 }); 531 });
528 token(node.leftBracket); 532 token(node.leftBracket);
529 indent(); 533 indent();
530 visitNodes(node.members, precededBy: newlines, separatedBy: newlines); 534 if (!node.members.isEmpty) {
531 newlines(); 535 visitNodes(node.members, precededBy: newlines, separatedBy: newlines);
536 newlines();
537 } else {
538 preserveLeadingNewlines();
539 }
532 token(node.rightBracket, precededBy: unindent); 540 token(node.rightBracket, precededBy: unindent);
533 } 541 }
534 542
535 visitClassTypeAlias(ClassTypeAlias node) { 543 visitClassTypeAlias(ClassTypeAlias node) {
536 preserveLeadingNewlines(); 544 preserveLeadingNewlines();
537 visitNodes(node.metadata, followedBy: newlines); 545 visitNodes(node.metadata, followedBy: newlines);
538 modifier(node.abstractKeyword); 546 modifier(node.abstractKeyword);
539 token(node.keyword); 547 token(node.keyword);
540 space(); 548 space();
541 visit(node.name); 549 visit(node.name);
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 var lastLine = 1704 var lastLine =
1697 lineInfo.getLocation(lastOffset).lineNumber; 1705 lineInfo.getLocation(lastOffset).lineNumber;
1698 var currentLine = 1706 var currentLine =
1699 lineInfo.getLocation(currentOffset).lineNumber; 1707 lineInfo.getLocation(currentOffset).lineNumber;
1700 return currentLine - lastLine; 1708 return currentLine - lastLine;
1701 } 1709 }
1702 1710
1703 String toString() => writer.toString(); 1711 String toString() => writer.toString();
1704 1712
1705 } 1713 }
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