| OLD | NEW |
| 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_experimental/analyzer.dart'; | 9 import 'package:analyzer_experimental/analyzer.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/parser.dart'; | 10 import 'package:analyzer_experimental/src/generated/parser.dart'; |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 //Handle EOLs before newlines | 1287 //Handle EOLs before newlines |
| 1288 if (isAtEOL(comment)) { | 1288 if (isAtEOL(comment)) { |
| 1289 emitComment(comment, previousToken); | 1289 emitComment(comment, previousToken); |
| 1290 comment = comment.next; | 1290 comment = comment.next; |
| 1291 currentToken = comment != null ? comment : token; | 1291 currentToken = comment != null ? comment : token; |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 var lines = max(min, countNewlinesBetween(previousToken, currentToken)); | 1294 var lines = max(min, countNewlinesBetween(previousToken, currentToken)); |
| 1295 writer.newlines(lines); | 1295 writer.newlines(lines); |
| 1296 | 1296 |
| 1297 var previousToken = currentToken.previous; | 1297 previousToken = currentToken.previous; |
| 1298 | 1298 |
| 1299 while (comment != null) { | 1299 while (comment != null) { |
| 1300 | 1300 |
| 1301 emitComment(comment, previousToken); | 1301 emitComment(comment, previousToken); |
| 1302 | 1302 |
| 1303 var nextToken = comment.next != null ? comment.next : token; | 1303 var nextToken = comment.next != null ? comment.next : token; |
| 1304 var newlines = calculateNewlinesBetweenComments(comment, nextToken); | 1304 var newlines = calculateNewlinesBetweenComments(comment, nextToken); |
| 1305 if (newlines > 0) { | 1305 if (newlines > 0) { |
| 1306 writer.newlines(newlines); | 1306 writer.newlines(newlines); |
| 1307 lines += newlines; | 1307 lines += newlines; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 var lastLine = | 1407 var lastLine = |
| 1408 lineInfo.getLocation(lastOffset).lineNumber; | 1408 lineInfo.getLocation(lastOffset).lineNumber; |
| 1409 var currentLine = | 1409 var currentLine = |
| 1410 lineInfo.getLocation(currentOffset).lineNumber; | 1410 lineInfo.getLocation(currentOffset).lineNumber; |
| 1411 return currentLine - lastLine; | 1411 return currentLine - lastLine; |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 String toString() => writer.toString(); | 1414 String toString() => writer.toString(); |
| 1415 | 1415 |
| 1416 } | 1416 } |
| OLD | NEW |