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

Unified Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10913067: Simplify Unparser.unparseClassWithBody. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/dart_backend/emitter.dart ('k') | tests/compiler/dart2js/unparser2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index aabd65f369178d9c71f5494c63510c495f878723..e16c57b9a9f33c232acab4d84c5bc44b77465b21 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -61,7 +61,7 @@ class Unparser implements Visitor {
visit(node.expression);
}
- unparseClassWithBody(ClassNode node, void classBodyEmitter()) {
+ unparseClassWithBody(ClassNode node, Iterable<Node> members) {
Roman 2012/09/04 17:12:15 thank you for specifying type :)
Anton Muhin 2012/09/04 18:00:40 My pleasure
addToken(node.beginToken);
if (node.beginToken.stringValue == 'abstract') {
addToken(node.beginToken.next);
@@ -84,24 +84,14 @@ class Unparser implements Visitor {
visit(node.defaultClause);
}
sb.add('{');
- classBodyEmitter();
+ for (final member in members) {
+ visit(member);
+ }
sb.add('}');
}
visitClassNode(ClassNode node) {
- unparseClassWithBody(node, () {
- NodeList body = node.body;
- if (body !== null) {
- sb.add('\n');
- Link nodes = body.nodes;
- if (!nodes.isEmpty()) {
- sb.add(' ');
- nodes.printOn(sb, '\n ');
- sb.add('\n');
- }
- }
- });
- sb.add('\n');
+ unparseClassWithBody(node, node.body.nodes);
Roman 2012/09/04 17:12:15 original code performed null check on body. Are yo
Anton Muhin 2012/09/04 18:00:40 Not quite, but so far tests revealed no such cases
}
visitConditional(Conditional node) {
« no previous file with comments | « lib/compiler/implementation/dart_backend/emitter.dart ('k') | tests/compiler/dart2js/unparser2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698