From b2ad79cf885c0d55349adf10eb79fd0be20b7422 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 3 Feb 2015 12:03:21 +1100 Subject: [PATCH] rename t.getDeclarations to the WAY more reflective t.getBindingIdentifiers --- lib/6to5/transformation/modules/_default.js | 4 ++-- .../transformers/es6/block-scoping.js | 4 ++-- lib/6to5/traverse/scope.js | 2 +- lib/6to5/types/index.js | 13 +++++-------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/6to5/transformation/modules/_default.js b/lib/6to5/transformation/modules/_default.js index 591a78ee8f..495ffd60c5 100644 --- a/lib/6to5/transformation/modules/_default.js +++ b/lib/6to5/transformation/modules/_default.js @@ -45,7 +45,7 @@ var exportsVisitor = { formatter.hasLocalImports = true; if (declar && t.isStatement(declar)) { - extend(formatter.localExports, t.getDeclarations(declar)); + extend(formatter.localExports, t.getBindingIdentifiers(declar)); } if (!node.default) { @@ -67,7 +67,7 @@ var importsVisitor = { enter: function (node, parent, scope, context, formatter) { if (t.isImportDeclaration(node)) { formatter.hasLocalImports = true; - extend(formatter.localImports, t.getDeclarations(node)); + extend(formatter.localImports, t.getBindingIdentifiers(node)); formatter.bumpImportOccurences(node); } } diff --git a/lib/6to5/transformation/transformers/es6/block-scoping.js b/lib/6to5/transformation/transformers/es6/block-scoping.js index e36fb9ed69..dc5dad4020 100644 --- a/lib/6to5/transformation/transformers/es6/block-scoping.js +++ b/lib/6to5/transformation/transformers/es6/block-scoping.js @@ -258,7 +258,7 @@ BlockScoping.prototype.getLetReferences = function () { // for (var i = 0; i < declarators.length; i++) { declar = declarators[i]; - extend(this.outsideLetReferences, t.getDeclarations(declar)); + extend(this.outsideLetReferences, t.getBindingIdentifiers(declar)); } // @@ -274,7 +274,7 @@ BlockScoping.prototype.getLetReferences = function () { // for (i = 0; i < declarators.length; i++) { declar = declarators[i]; - var keys = t.getDeclarations(declar); + var keys = t.getBindingIdentifiers(declar); extend(this.letReferences, keys); this.hasLetReferences = true; } diff --git a/lib/6to5/traverse/scope.js b/lib/6to5/traverse/scope.js index cfa859fb78..b3eeb649e4 100644 --- a/lib/6to5/traverse/scope.js +++ b/lib/6to5/traverse/scope.js @@ -42,7 +42,7 @@ Scope.defaultDeclarations = flatten([globals.builtin, globals.browser, globals.n Scope.prototype._add = function (node, references, throwOnDuplicate) { if (!node) return; - var ids = t.getDeclarations(node); + var ids = t.getBindingIdentifiers(node); for (var key in ids) { var id = ids[key]; diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 68a2937b68..878b8f5424 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -560,17 +560,14 @@ t.toBlock = function (node, parent) { }; /** - * Return a list of identifiers that will be assigned - * as a result of runtime evaluation. - * - * If an identifier is passed as `node` instead of a - * declaration then it's assumed to be an assignable. + * Return a list of binding identifiers associated with + * the input `node`. * * @param {Object} node * @returns {Array|Object} */ -t.getDeclarations = function (node) { +t.getBindingIdentifiers = function (node) { var search = [].concat(node); var ids = object(); @@ -578,7 +575,7 @@ t.getDeclarations = function (node) { var id = search.shift(); if (!id) continue; - var keys = t.getDeclarations.keys[id.type]; + var keys = t.getBindingIdentifiers.keys[id.type]; if (t.isIdentifier(id)) { ids[id.name] = id; @@ -597,7 +594,7 @@ t.getDeclarations = function (node) { return ids; }; -t.getDeclarations.keys = { +t.getBindingIdentifiers.keys = { AssignmentExpression: ["left"], ImportBatchSpecifier: ["name"], ImportSpecifier: ["name", "id"],