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

Unified Diff: lib/src/js/printer.dart

Issue 1677863002: Use default params when --destructure-named-params + fix renaming of reserved destructured params (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 10 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/src/js/nodes.dart ('k') | lib/src/js/template.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/js/printer.dart
diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
index bd8de3b40aa49c9bae41dc8051df78f5f84e9465..02bf379a74871a8b82bd27ef89827c59c42b1c54 100644
--- a/lib/src/js/printer.dart
+++ b/lib/src/js/printer.dart
@@ -621,8 +621,17 @@ class Printer implements NodeVisitor {
}
visitDestructuredVariable(DestructuredVariable node) {
- var hasName = node.name != null;
- if (hasName) visit(node.name);
+ var name = node.name;
+ var hasName = name != null;
+ if (hasName) {
+ if (name is LiteralString) {
+ out("[");
+ out(name.value);
+ out("]");
+ } else {
+ visit(name);
+ }
+ }
if (node.structure != null) {
if (hasName) {
out(":");
@@ -639,6 +648,10 @@ class Printer implements NodeVisitor {
}
}
+ visitSimpleBindingPattern(SimpleBindingPattern node) {
+ visit(node.name);
+ }
+
visitAssignment(Assignment assignment) {
visitNestedExpression(assignment.leftHandSide, LEFT_HAND_SIDE,
newInForInit: inForInit,
@@ -1585,13 +1598,23 @@ abstract class VariableDeclarationVisitor<T> extends BaseVisitor<T> {
_scanVariableBinding(VariableBinding d) {
if (d is Identifier) declare(d);
- if (d is RestParameter) _scanVariableBinding(d.parameter);
- else if (d is BindingPattern) {
- for (var v in d.variables) {
- if (v.name != null) declare(v.name);
- if (v.structure != null) _scanVariableBinding(v.structure);
- }
- }
+ else d.accept(this);
+ }
+
+ visitRestParameter(RestParameter node) {
+ _scanVariableBinding(node.parameter);
+ super.visitRestParameter(node);
+ }
+
+ visitDestructuredVariable(DestructuredVariable node) {
+ var name = node.name;
+ if (name is Identifier) _scanVariableBinding(name);
+ super.visitDestructuredVariable(node);
+ }
+
+ visitSimpleBindingPattern(SimpleBindingPattern node) {
+ _scanVariableBinding(node.name);
+ super.visitSimpleBindingPattern(node);
}
visitVariableInitialization(VariableInitialization node) {
« no previous file with comments | « lib/src/js/nodes.dart ('k') | lib/src/js/template.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698