| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class Printer implements NodeVisitor { | 5 class Printer implements NodeVisitor { |
| 6 final bool shouldCompressOutput; | 6 final bool shouldCompressOutput; |
| 7 leg.Compiler compiler; | 7 leg.Compiler compiler; |
| 8 var positionElement; | 8 var positionElement; |
| 9 leg.CodeBuffer outBuffer; | 9 leg.CodeBuffer outBuffer; |
| 10 int indentLevel = 0; | 10 int indentLevel = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void recordSourcePosition(var position) { | 55 void recordSourcePosition(var position) { |
| 56 if (position != null) { | 56 if (position != null) { |
| 57 outBuffer.setSourceLocation(positionElement, position); | 57 outBuffer.setSourceLocation(positionElement, position); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 visit(Node node) { | 61 visit(Node node) { |
| 62 if (node.sourcePosition != null) outBuffer.beginMappedRange(); |
| 62 recordSourcePosition(node.sourcePosition); | 63 recordSourcePosition(node.sourcePosition); |
| 63 node.accept(this); | 64 node.accept(this); |
| 64 recordSourcePosition(node.endSourcePosition); | 65 recordSourcePosition(node.endSourcePosition); |
| 66 if (node.sourcePosition != null) outBuffer.endMappedRange(); |
| 65 } | 67 } |
| 66 | 68 |
| 67 visitCommaSeparated(List<Node> nodes, int hasRequiredType, | 69 visitCommaSeparated(List<Node> nodes, int hasRequiredType, |
| 68 [bool newInForInit, bool newAtStatementBegin]) { | 70 [bool newInForInit, bool newAtStatementBegin]) { |
| 69 for (int i = 0; i < nodes.length; i++) { | 71 for (int i = 0; i < nodes.length; i++) { |
| 70 if (i != 0) { | 72 if (i != 0) { |
| 71 atStatementBegin = false; | 73 atStatementBegin = false; |
| 72 out(","); | 74 out(","); |
| 73 spaceOut(); | 75 spaceOut(); |
| 74 } | 76 } |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 820 } |
| 819 | 821 |
| 820 | 822 |
| 821 leg.CodeBuffer prettyPrint(Node node, | 823 leg.CodeBuffer prettyPrint(Node node, |
| 822 leg.Compiler compiler, | 824 leg.Compiler compiler, |
| 823 Dynamic positionElement) { | 825 Dynamic positionElement) { |
| 824 Printer printer = new Printer(compiler, positionElement); | 826 Printer printer = new Printer(compiler, positionElement); |
| 825 printer.visit(node); | 827 printer.visit(node); |
| 826 return printer.outBuffer; | 828 return printer.outBuffer; |
| 827 } | 829 } |
| OLD | NEW |