@babel/traverse 7.0.0-beta.5 → 7.0.0-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/README.md +9 -23
- package/lib/cache.js +5 -3
- package/lib/context.js +55 -91
- package/lib/hub.js +9 -4
- package/lib/index.js +36 -33
- package/lib/path/ancestry.js +37 -41
- package/lib/path/comments.js +22 -12
- package/lib/path/context.js +24 -48
- package/lib/path/conversion.js +170 -150
- package/lib/path/evaluation.js +108 -150
- package/lib/path/family.js +40 -43
- package/lib/path/index.js +99 -80
- package/lib/path/inference/index.js +39 -33
- package/lib/path/inference/inferer-reference.js +55 -49
- package/lib/path/inference/inferers.js +61 -49
- package/lib/path/introspection.js +105 -96
- package/lib/path/lib/hoister.js +63 -61
- package/lib/path/lib/removal-hooks.js +5 -3
- package/lib/path/lib/virtual-types.js +106 -66
- package/lib/path/modification.js +70 -68
- package/lib/path/removal.js +12 -5
- package/lib/path/replacement.js +76 -69
- package/lib/scope/binding.js +23 -23
- package/lib/scope/index.js +389 -487
- package/lib/scope/lib/renamer.js +71 -61
- package/lib/visitors.js +84 -124
- package/package.json +11 -10
package/lib/path/context.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.call = call;
|
5
7
|
exports._call = _call;
|
6
8
|
exports.isBlacklisted = isBlacklisted;
|
@@ -27,7 +29,7 @@ var _index = _interopRequireDefault(require("../index"));
|
|
27
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
28
30
|
|
29
31
|
function call(key) {
|
30
|
-
|
32
|
+
const opts = this.opts;
|
31
33
|
this.debug(key);
|
32
34
|
|
33
35
|
if (this.node) {
|
@@ -44,27 +46,18 @@ function call(key) {
|
|
44
46
|
function _call(fns) {
|
45
47
|
if (!fns) return false;
|
46
48
|
|
47
|
-
for (
|
48
|
-
|
49
|
-
|
50
|
-
if (_isArray) {
|
51
|
-
if (_i >= _iterator.length) break;
|
52
|
-
_ref = _iterator[_i++];
|
53
|
-
} else {
|
54
|
-
_i = _iterator.next();
|
55
|
-
if (_i.done) break;
|
56
|
-
_ref = _i.value;
|
57
|
-
}
|
58
|
-
|
59
|
-
var _fn = _ref;
|
60
|
-
if (!_fn) continue;
|
61
|
-
var node = this.node;
|
49
|
+
for (const fn of fns) {
|
50
|
+
if (!fn) continue;
|
51
|
+
const node = this.node;
|
62
52
|
if (!node) return true;
|
53
|
+
const ret = fn.call(this.state, this, this.state);
|
63
54
|
|
64
|
-
|
55
|
+
if (ret && typeof ret === "object" && typeof ret.then === "function") {
|
56
|
+
throw new Error(`You appear to be using a plugin with an async traversal visitor, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
|
57
|
+
}
|
65
58
|
|
66
59
|
if (ret) {
|
67
|
-
throw new Error(
|
60
|
+
throw new Error(`Unexpected return value from visitor method ${fn}`);
|
68
61
|
}
|
69
62
|
|
70
63
|
if (this.node !== node) return true;
|
@@ -75,7 +68,7 @@ function _call(fns) {
|
|
75
68
|
}
|
76
69
|
|
77
70
|
function isBlacklisted() {
|
78
|
-
|
71
|
+
const blacklist = this.opts.blacklist;
|
79
72
|
return blacklist && blacklist.indexOf(this.node.type) > -1;
|
80
73
|
}
|
81
74
|
|
@@ -120,8 +113,8 @@ function stop() {
|
|
120
113
|
|
121
114
|
function setScope() {
|
122
115
|
if (this.opts && this.opts.noScope) return;
|
123
|
-
|
124
|
-
|
116
|
+
let path = this.parentPath;
|
117
|
+
let target;
|
125
118
|
|
126
119
|
while (path && !target) {
|
127
120
|
if (path.opts && path.opts.noScope) return;
|
@@ -170,13 +163,13 @@ function _resyncKey() {
|
|
170
163
|
if (this.node === this.container[this.key]) return;
|
171
164
|
|
172
165
|
if (Array.isArray(this.container)) {
|
173
|
-
for (
|
166
|
+
for (let i = 0; i < this.container.length; i++) {
|
174
167
|
if (this.container[i] === this.node) {
|
175
168
|
return this.setKey(i);
|
176
169
|
}
|
177
170
|
}
|
178
171
|
} else {
|
179
|
-
for (
|
172
|
+
for (const key in this.container) {
|
180
173
|
if (this.container[key] === this.node) {
|
181
174
|
return this.setKey(key);
|
182
175
|
}
|
@@ -188,7 +181,7 @@ function _resyncKey() {
|
|
188
181
|
|
189
182
|
function _resyncList() {
|
190
183
|
if (!this.parent || !this.inList) return;
|
191
|
-
|
184
|
+
const newContainer = this.parent[this.listKey];
|
192
185
|
if (this.container === newContainer) return;
|
193
186
|
this.container = newContainer || null;
|
194
187
|
}
|
@@ -229,35 +222,18 @@ function setKey(key) {
|
|
229
222
|
this.type = this.node && this.node.type;
|
230
223
|
}
|
231
224
|
|
232
|
-
function requeue(pathToQueue) {
|
233
|
-
if (pathToQueue === void 0) {
|
234
|
-
pathToQueue = this;
|
235
|
-
}
|
236
|
-
|
225
|
+
function requeue(pathToQueue = this) {
|
237
226
|
if (pathToQueue.removed) return;
|
238
|
-
|
239
|
-
|
240
|
-
for (var _iterator2 = contexts, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
241
|
-
var _ref2;
|
242
|
-
|
243
|
-
if (_isArray2) {
|
244
|
-
if (_i2 >= _iterator2.length) break;
|
245
|
-
_ref2 = _iterator2[_i2++];
|
246
|
-
} else {
|
247
|
-
_i2 = _iterator2.next();
|
248
|
-
if (_i2.done) break;
|
249
|
-
_ref2 = _i2.value;
|
250
|
-
}
|
251
|
-
|
252
|
-
var _context = _ref2;
|
227
|
+
const contexts = this.contexts;
|
253
228
|
|
254
|
-
|
229
|
+
for (const context of contexts) {
|
230
|
+
context.maybeQueue(pathToQueue);
|
255
231
|
}
|
256
232
|
}
|
257
233
|
|
258
234
|
function _getQueueContexts() {
|
259
|
-
|
260
|
-
|
235
|
+
let path = this;
|
236
|
+
let contexts = this.contexts;
|
261
237
|
|
262
238
|
while (!contexts.length) {
|
263
239
|
path = path.parentPath;
|