rename t.getIds to t.getDeclarations and remove dead code
This commit is contained in:
parent
f325d3b065
commit
0fea437536
@ -45,7 +45,7 @@ var exportsVisitor = {
|
||||
formatter.hasLocalImports = true;
|
||||
|
||||
if (declar && t.isStatement(declar)) {
|
||||
extend(formatter.localExports, t.getIds(declar, true));
|
||||
extend(formatter.localExports, t.getDeclarations(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.getIds(node, true));
|
||||
extend(formatter.localImports, t.getDeclarations(node));
|
||||
formatter.bumpImportOccurences(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ LetScoping.prototype.getLetReferences = function () {
|
||||
//
|
||||
for (var i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
extend(this.outsideLetReferences, t.getIds(declar, true));
|
||||
extend(this.outsideLetReferences, t.getDeclarations(declar));
|
||||
}
|
||||
|
||||
//
|
||||
@ -275,7 +275,7 @@ LetScoping.prototype.getLetReferences = function () {
|
||||
//
|
||||
for (i = 0; i < declarators.length; i++) {
|
||||
declar = declarators[i];
|
||||
var keys = t.getIds(declar, true);
|
||||
var keys = t.getDeclarations(declar);
|
||||
extend(this.letReferences, keys);
|
||||
this.hasLetReferences = true;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ var t = require("../../../types");
|
||||
var visitor = {
|
||||
enter: function (node, parent, scope, context, state) {
|
||||
if (t.isDeclaration(node) || t.isAssignmentExpression(node)) {
|
||||
var ids = t.getIds(node, true);
|
||||
var ids = t.getDeclarations(node);
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
|
||||
@ -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.getIds(node, true);
|
||||
var ids = t.getDeclarations(node);
|
||||
|
||||
for (var key in ids) {
|
||||
var id = ids[key];
|
||||
|
||||
@ -502,12 +502,10 @@ t.toBlock = function (node, parent) {
|
||||
* declaration then it's assumed to be an assignable.
|
||||
*
|
||||
* @param {Object} node
|
||||
* @param {Boolean} [map]
|
||||
* @param {Array} [ignoreTypes]
|
||||
* @returns {Array|Object}
|
||||
*/
|
||||
|
||||
t.getIds = function (node, map, ignoreTypes) {
|
||||
t.getDeclarations = function (node) {
|
||||
var search = [].concat(node);
|
||||
var ids = object();
|
||||
|
||||
@ -515,11 +513,8 @@ t.getIds = function (node, map, ignoreTypes) {
|
||||
var id = search.shift();
|
||||
if (!id) continue;
|
||||
|
||||
// blacklist types
|
||||
if (ignoreTypes && ignoreTypes.indexOf(id.type) >= 0) continue;
|
||||
|
||||
var nodeKeys = t.getIds.nodes[id.type];
|
||||
var arrKeys = t.getIds.arrays[id.type];
|
||||
var nodeKeys = t.getDeclarations.nodes[id.type];
|
||||
var arrKeys = t.getDeclarations.arrays[id.type];
|
||||
|
||||
var i, key;
|
||||
|
||||
@ -545,11 +540,10 @@ t.getIds = function (node, map, ignoreTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!map) ids = keys(ids);
|
||||
return ids;
|
||||
};
|
||||
|
||||
t.getIds.nodes = {
|
||||
t.getDeclarations.nodes = {
|
||||
AssignmentExpression: ["left"],
|
||||
ImportBatchSpecifier: ["name"],
|
||||
ImportSpecifier: ["name", "id"],
|
||||
@ -565,7 +559,7 @@ t.getIds.nodes = {
|
||||
AssignmentPattern: ["left"]
|
||||
};
|
||||
|
||||
t.getIds.arrays = {
|
||||
t.getDeclarations.arrays = {
|
||||
PrivateDeclaration: ["declarations"],
|
||||
ComprehensionExpression: ["blocks"],
|
||||
ImportDeclaration: ["specifiers"],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user