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

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

Issue 109153006: Fix and test for leading comment handling (dartbug.com/15876). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | 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/java_core.dart' show CharSequence; 10 import 'package:analyzer/src/generated/java_core.dart' show CharSequence;
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 int emitPrecedingCommentsAndNewlines(Token token, {min: 0}) { 1490 int emitPrecedingCommentsAndNewlines(Token token, {min: 0}) {
1491 1491
1492 var comment = token.precedingComments; 1492 var comment = token.precedingComments;
1493 var currentToken = comment != null ? comment : token; 1493 var currentToken = comment != null ? comment : token;
1494 1494
1495 //Handle EOLs before newlines 1495 //Handle EOLs before newlines
1496 if (isAtEOL(comment)) { 1496 if (isAtEOL(comment)) {
1497 emitComment(comment, previousToken); 1497 emitComment(comment, previousToken);
1498 comment = comment.next; 1498 comment = comment.next;
1499 currentToken = comment != null ? comment : token; 1499 currentToken = comment != null ? comment : token;
1500 // Ensure EOL comments force a linebreak
1501 needsNewline = true;
1500 } 1502 }
1501 1503
1502 var lines = 0; 1504 var lines = 0;
1503 if (needsNewline || preserveNewlines) { 1505 if (needsNewline || preserveNewlines) {
1504 lines = max(min, countNewlinesBetween(previousToken, currentToken)); 1506 lines = max(min, countNewlinesBetween(previousToken, currentToken));
1505 preserveNewlines = false; 1507 preserveNewlines = false;
1506 } 1508 }
1507 emitNewlines(lines); 1509 emitNewlines(lines);
1508 1510
1509 previousToken = 1511 previousToken =
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 var lastLine = 1628 var lastLine =
1627 lineInfo.getLocation(lastOffset).lineNumber; 1629 lineInfo.getLocation(lastOffset).lineNumber;
1628 var currentLine = 1630 var currentLine =
1629 lineInfo.getLocation(currentOffset).lineNumber; 1631 lineInfo.getLocation(currentOffset).lineNumber;
1630 return currentLine - lastLine; 1632 return currentLine - lastLine;
1631 } 1633 }
1632 1634
1633 String toString() => writer.toString(); 1635 String toString() => writer.toString();
1634 1636
1635 } 1637 }
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