| 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/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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 final bool codeTransforms; | 375 final bool codeTransforms; |
| 376 | 376 |
| 377 /// Post format selection information. | 377 /// Post format selection information. |
| 378 Selection selection; | 378 Selection selection; |
| 379 | 379 |
| 380 | 380 |
| 381 /// Initialize a newly created visitor to write source code representing | 381 /// Initialize a newly created visitor to write source code representing |
| 382 /// the visited nodes to the given [writer]. | 382 /// the visited nodes to the given [writer]. |
| 383 SourceVisitor(FormatterOptions options, this.lineInfo, this.preSelection): | 383 SourceVisitor(FormatterOptions options, this.lineInfo, this.preSelection): |
| 384 writer = new SourceWriter(indentCount: options.initialIndentationLevel, | 384 writer = new SourceWriter(indentCount: options.initialIndentationLevel, |
| 385 lineSeparator: options.lineSeparator), | 385 lineSeparator: options.lineSeparator, |
| 386 useTabs: options.tabsForIndent, |
| 387 spacesPerIndent: options.spacesPerIndent), |
| 386 codeTransforms = options.codeTransforms; | 388 codeTransforms = options.codeTransforms; |
| 387 | 389 |
| 388 visitAdjacentStrings(AdjacentStrings node) { | 390 visitAdjacentStrings(AdjacentStrings node) { |
| 389 visitNodes(node.strings, separatedBy: space); | 391 visitNodes(node.strings, separatedBy: space); |
| 390 } | 392 } |
| 391 | 393 |
| 392 visitAnnotation(Annotation node) { | 394 visitAnnotation(Annotation node) { |
| 393 token(node.atSign); | 395 token(node.atSign); |
| 394 visit(node.name); | 396 visit(node.name); |
| 395 token(node.period); | 397 token(node.period); |
| (...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 var lastLine = | 1680 var lastLine = |
| 1679 lineInfo.getLocation(lastOffset).lineNumber; | 1681 lineInfo.getLocation(lastOffset).lineNumber; |
| 1680 var currentLine = | 1682 var currentLine = |
| 1681 lineInfo.getLocation(currentOffset).lineNumber; | 1683 lineInfo.getLocation(currentOffset).lineNumber; |
| 1682 return currentLine - lastLine; | 1684 return currentLine - lastLine; |
| 1683 } | 1685 } |
| 1684 | 1686 |
| 1685 String toString() => writer.toString(); | 1687 String toString() => writer.toString(); |
| 1686 | 1688 |
| 1687 } | 1689 } |
| OLD | NEW |