@babel/traverse 7.0.0-beta.43 → 7.0.0-beta.44
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/lib/cache.js +2 -2
- package/lib/context.js +75 -35
- package/lib/hub.js +3 -6
- package/lib/index.js +24 -12
- package/lib/path/ancestry.js +40 -26
- package/lib/path/comments.js +9 -9
- package/lib/path/context.js +45 -17
- package/lib/path/conversion.js +132 -124
- package/lib/path/evaluation.js +136 -97
- package/lib/path/family.js +40 -27
- package/lib/path/index.js +80 -60
- package/lib/path/inference/index.js +16 -12
- package/lib/path/inference/inferer-reference.js +41 -37
- package/lib/path/inference/inferers.js +16 -18
- package/lib/path/introspection.js +82 -49
- package/lib/path/lib/hoister.js +56 -48
- package/lib/path/lib/removal-hooks.js +2 -2
- package/lib/path/lib/virtual-types.js +46 -76
- package/lib/path/modification.js +53 -31
- package/lib/path/removal.js +10 -3
- package/lib/path/replacement.js +50 -32
- package/lib/scope/binding.js +22 -20
- package/lib/scope/index.js +400 -280
- package/lib/scope/lib/renamer.js +35 -37
- package/lib/visitors.js +120 -62
- package/package.json +8 -8
package/lib/cache.js
CHANGED
@@ -7,9 +7,9 @@ exports.clear = clear;
|
|
7
7
|
exports.clearPath = clearPath;
|
8
8
|
exports.clearScope = clearScope;
|
9
9
|
exports.scope = exports.path = void 0;
|
10
|
-
|
10
|
+
var path = new WeakMap();
|
11
11
|
exports.path = path;
|
12
|
-
|
12
|
+
var scope = new WeakMap();
|
13
13
|
exports.scope = scope;
|
14
14
|
|
15
15
|
function clear() {
|
package/lib/context.js
CHANGED
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _path2 = _interopRequireDefault(require("./path"));
|
9
9
|
|
10
10
|
function t() {
|
11
|
-
|
11
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
12
12
|
|
13
|
-
t = function () {
|
13
|
+
t = function t() {
|
14
14
|
return data;
|
15
15
|
};
|
16
16
|
|
@@ -21,10 +21,10 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
21
21
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
23
|
|
24
|
-
|
24
|
+
var testing = process.env.NODE_ENV === "test";
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
var TraversalContext = function () {
|
27
|
+
function TraversalContext(scope, opts, state, parentPath) {
|
28
28
|
this.queue = null;
|
29
29
|
this.parentPath = parentPath;
|
30
30
|
this.scope = scope;
|
@@ -32,31 +32,45 @@ class TraversalContext {
|
|
32
32
|
this.opts = opts;
|
33
33
|
}
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
var _proto = TraversalContext.prototype;
|
36
|
+
|
37
|
+
_proto.shouldVisit = function shouldVisit(node) {
|
38
|
+
var opts = this.opts;
|
37
39
|
if (opts.enter || opts.exit) return true;
|
38
40
|
if (opts[node.type]) return true;
|
39
|
-
|
41
|
+
var keys = t().VISITOR_KEYS[node.type];
|
40
42
|
if (!keys || !keys.length) return false;
|
41
43
|
|
42
|
-
for (
|
44
|
+
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
45
|
+
var _ref;
|
46
|
+
|
47
|
+
if (_isArray) {
|
48
|
+
if (_i >= _iterator.length) break;
|
49
|
+
_ref = _iterator[_i++];
|
50
|
+
} else {
|
51
|
+
_i = _iterator.next();
|
52
|
+
if (_i.done) break;
|
53
|
+
_ref = _i.value;
|
54
|
+
}
|
55
|
+
|
56
|
+
var key = _ref;
|
43
57
|
if (node[key]) return true;
|
44
58
|
}
|
45
59
|
|
46
60
|
return false;
|
47
|
-
}
|
61
|
+
};
|
48
62
|
|
49
|
-
create(node, obj, key, listKey) {
|
50
|
-
return
|
63
|
+
_proto.create = function create(node, obj, key, listKey) {
|
64
|
+
return _path2.default.get({
|
51
65
|
parentPath: this.parentPath,
|
52
66
|
parent: node,
|
53
67
|
container: obj,
|
54
68
|
key: key,
|
55
|
-
listKey
|
69
|
+
listKey: listKey
|
56
70
|
});
|
57
|
-
}
|
71
|
+
};
|
58
72
|
|
59
|
-
maybeQueue(path, notPriority) {
|
73
|
+
_proto.maybeQueue = function maybeQueue(path, notPriority) {
|
60
74
|
if (this.trap) {
|
61
75
|
throw new Error("Infinite cycle detected");
|
62
76
|
}
|
@@ -68,14 +82,14 @@ class TraversalContext {
|
|
68
82
|
this.priorityQueue.push(path);
|
69
83
|
}
|
70
84
|
}
|
71
|
-
}
|
85
|
+
};
|
72
86
|
|
73
|
-
visitMultiple(container, parent, listKey) {
|
87
|
+
_proto.visitMultiple = function visitMultiple(container, parent, listKey) {
|
74
88
|
if (container.length === 0) return false;
|
75
|
-
|
89
|
+
var queue = [];
|
76
90
|
|
77
|
-
for (
|
78
|
-
|
91
|
+
for (var key = 0; key < container.length; key++) {
|
92
|
+
var node = container[key];
|
79
93
|
|
80
94
|
if (node && this.shouldVisit(node)) {
|
81
95
|
queue.push(this.create(parent, container, key, listKey));
|
@@ -83,23 +97,35 @@ class TraversalContext {
|
|
83
97
|
}
|
84
98
|
|
85
99
|
return this.visitQueue(queue);
|
86
|
-
}
|
100
|
+
};
|
87
101
|
|
88
|
-
visitSingle(node, key) {
|
102
|
+
_proto.visitSingle = function visitSingle(node, key) {
|
89
103
|
if (this.shouldVisit(node[key])) {
|
90
104
|
return this.visitQueue([this.create(node, node, key)]);
|
91
105
|
} else {
|
92
106
|
return false;
|
93
107
|
}
|
94
|
-
}
|
108
|
+
};
|
95
109
|
|
96
|
-
visitQueue(queue) {
|
110
|
+
_proto.visitQueue = function visitQueue(queue) {
|
97
111
|
this.queue = queue;
|
98
112
|
this.priorityQueue = [];
|
99
|
-
|
100
|
-
|
113
|
+
var visited = [];
|
114
|
+
var stop = false;
|
101
115
|
|
102
|
-
for (
|
116
|
+
for (var _iterator2 = queue, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
117
|
+
var _ref2;
|
118
|
+
|
119
|
+
if (_isArray2) {
|
120
|
+
if (_i2 >= _iterator2.length) break;
|
121
|
+
_ref2 = _iterator2[_i2++];
|
122
|
+
} else {
|
123
|
+
_i2 = _iterator2.next();
|
124
|
+
if (_i2.done) break;
|
125
|
+
_ref2 = _i2.value;
|
126
|
+
}
|
127
|
+
|
128
|
+
var path = _ref2;
|
103
129
|
path.resync();
|
104
130
|
|
105
131
|
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
@@ -128,16 +154,29 @@ class TraversalContext {
|
|
128
154
|
}
|
129
155
|
}
|
130
156
|
|
131
|
-
for (
|
132
|
-
|
157
|
+
for (var _iterator3 = queue, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
|
158
|
+
var _ref3;
|
159
|
+
|
160
|
+
if (_isArray3) {
|
161
|
+
if (_i3 >= _iterator3.length) break;
|
162
|
+
_ref3 = _iterator3[_i3++];
|
163
|
+
} else {
|
164
|
+
_i3 = _iterator3.next();
|
165
|
+
if (_i3.done) break;
|
166
|
+
_ref3 = _i3.value;
|
167
|
+
}
|
168
|
+
|
169
|
+
var _path = _ref3;
|
170
|
+
|
171
|
+
_path.popContext();
|
133
172
|
}
|
134
173
|
|
135
174
|
this.queue = null;
|
136
175
|
return stop;
|
137
|
-
}
|
176
|
+
};
|
138
177
|
|
139
|
-
visit(node, key) {
|
140
|
-
|
178
|
+
_proto.visit = function visit(node, key) {
|
179
|
+
var nodes = node[key];
|
141
180
|
if (!nodes) return false;
|
142
181
|
|
143
182
|
if (Array.isArray(nodes)) {
|
@@ -145,8 +184,9 @@ class TraversalContext {
|
|
145
184
|
} else {
|
146
185
|
return this.visitSingle(node, key);
|
147
186
|
}
|
148
|
-
}
|
187
|
+
};
|
149
188
|
|
150
|
-
|
189
|
+
return TraversalContext;
|
190
|
+
}();
|
151
191
|
|
152
192
|
exports.default = TraversalContext;
|
package/lib/hub.js
CHANGED
package/lib/index.js
CHANGED
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = traverse;
|
7
7
|
Object.defineProperty(exports, "NodePath", {
|
8
8
|
enumerable: true,
|
9
|
-
get: function () {
|
9
|
+
get: function get() {
|
10
10
|
return _path.default;
|
11
11
|
}
|
12
12
|
});
|
13
13
|
Object.defineProperty(exports, "Scope", {
|
14
14
|
enumerable: true,
|
15
|
-
get: function () {
|
15
|
+
get: function get() {
|
16
16
|
return _scope.default;
|
17
17
|
}
|
18
18
|
});
|
19
19
|
Object.defineProperty(exports, "Hub", {
|
20
20
|
enumerable: true,
|
21
|
-
get: function () {
|
21
|
+
get: function get() {
|
22
22
|
return _hub.default;
|
23
23
|
}
|
24
24
|
});
|
@@ -31,9 +31,9 @@ var visitors = _interopRequireWildcard(require("./visitors"));
|
|
31
31
|
exports.visitors = visitors;
|
32
32
|
|
33
33
|
function _includes() {
|
34
|
-
|
34
|
+
var data = _interopRequireDefault(require("lodash/includes"));
|
35
35
|
|
36
|
-
_includes = function () {
|
36
|
+
_includes = function _includes() {
|
37
37
|
return data;
|
38
38
|
};
|
39
39
|
|
@@ -41,9 +41,9 @@ function _includes() {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
function t() {
|
44
|
-
|
44
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
45
45
|
|
46
|
-
t = function () {
|
46
|
+
t = function t() {
|
47
47
|
return data;
|
48
48
|
};
|
49
49
|
|
@@ -68,7 +68,7 @@ function traverse(parent, opts, scope, state, parentPath) {
|
|
68
68
|
|
69
69
|
if (!opts.noScope && !scope) {
|
70
70
|
if (parent.type !== "Program" && parent.type !== "File") {
|
71
|
-
throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " +
|
71
|
+
throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + ("Instead of that you tried to traverse a " + parent.type + " node without ") + "passing scope and parentPath.");
|
72
72
|
}
|
73
73
|
}
|
74
74
|
|
@@ -85,11 +85,23 @@ traverse.cheap = function (node, enter) {
|
|
85
85
|
};
|
86
86
|
|
87
87
|
traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
|
88
|
-
|
88
|
+
var keys = t().VISITOR_KEYS[node.type];
|
89
89
|
if (!keys) return;
|
90
|
-
|
90
|
+
var context = new _context.default(scope, opts, state, parentPath);
|
91
|
+
|
92
|
+
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
93
|
+
var _ref;
|
94
|
+
|
95
|
+
if (_isArray) {
|
96
|
+
if (_i >= _iterator.length) break;
|
97
|
+
_ref = _iterator[_i++];
|
98
|
+
} else {
|
99
|
+
_i = _iterator.next();
|
100
|
+
if (_i.done) break;
|
101
|
+
_ref = _i.value;
|
102
|
+
}
|
91
103
|
|
92
|
-
|
104
|
+
var key = _ref;
|
93
105
|
if (skipKeys && skipKeys[key]) continue;
|
94
106
|
if (context.visit(node, key)) return;
|
95
107
|
}
|
@@ -115,7 +127,7 @@ function hasBlacklistedType(path, state) {
|
|
115
127
|
traverse.hasType = function (tree, type, blacklistTypes) {
|
116
128
|
if ((0, _includes().default)(blacklistTypes, tree.type)) return false;
|
117
129
|
if (tree.type === type) return true;
|
118
|
-
|
130
|
+
var state = {
|
119
131
|
has: false,
|
120
132
|
type: type
|
121
133
|
};
|
package/lib/path/ancestry.js
CHANGED
@@ -15,9 +15,9 @@ exports.isDescendant = isDescendant;
|
|
15
15
|
exports.inType = inType;
|
16
16
|
|
17
17
|
function t() {
|
18
|
-
|
18
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
19
19
|
|
20
|
-
t = function () {
|
20
|
+
t = function t() {
|
21
21
|
return data;
|
22
22
|
};
|
23
23
|
|
@@ -31,7 +31,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
31
31
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
32
32
|
|
33
33
|
function findParent(callback) {
|
34
|
-
|
34
|
+
var path = this;
|
35
35
|
|
36
36
|
while (path = path.parentPath) {
|
37
37
|
if (callback(path)) return path;
|
@@ -41,7 +41,7 @@ function findParent(callback) {
|
|
41
41
|
}
|
42
42
|
|
43
43
|
function find(callback) {
|
44
|
-
|
44
|
+
var path = this;
|
45
45
|
|
46
46
|
do {
|
47
47
|
if (callback(path)) return path;
|
@@ -51,11 +51,13 @@ function find(callback) {
|
|
51
51
|
}
|
52
52
|
|
53
53
|
function getFunctionParent() {
|
54
|
-
return this.findParent(
|
54
|
+
return this.findParent(function (p) {
|
55
|
+
return p.isFunction();
|
56
|
+
});
|
55
57
|
}
|
56
58
|
|
57
59
|
function getStatementParent() {
|
58
|
-
|
60
|
+
var path = this;
|
59
61
|
|
60
62
|
do {
|
61
63
|
if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
|
@@ -74,11 +76,13 @@ function getStatementParent() {
|
|
74
76
|
|
75
77
|
function getEarliestCommonAncestorFrom(paths) {
|
76
78
|
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
|
77
|
-
|
78
|
-
|
79
|
+
var earliest;
|
80
|
+
var keys = t().VISITOR_KEYS[deepest.type];
|
81
|
+
var _arr = ancestries;
|
79
82
|
|
80
|
-
for (
|
81
|
-
|
83
|
+
for (var _i = 0; _i < _arr.length; _i++) {
|
84
|
+
var ancestry = _arr[_i];
|
85
|
+
var path = ancestry[i + 1];
|
82
86
|
|
83
87
|
if (!earliest) {
|
84
88
|
earliest = path;
|
@@ -92,8 +96,8 @@ function getEarliestCommonAncestorFrom(paths) {
|
|
92
96
|
}
|
93
97
|
}
|
94
98
|
|
95
|
-
|
96
|
-
|
99
|
+
var earliestKeyIndex = keys.indexOf(earliest.parentKey);
|
100
|
+
var currentKeyIndex = keys.indexOf(path.parentKey);
|
97
101
|
|
98
102
|
if (earliestKeyIndex > currentKeyIndex) {
|
99
103
|
earliest = path;
|
@@ -105,6 +109,8 @@ function getEarliestCommonAncestorFrom(paths) {
|
|
105
109
|
}
|
106
110
|
|
107
111
|
function getDeepestCommonAncestorFrom(paths, filter) {
|
112
|
+
var _this = this;
|
113
|
+
|
108
114
|
if (!paths.length) {
|
109
115
|
return this;
|
110
116
|
}
|
@@ -113,14 +119,14 @@ function getDeepestCommonAncestorFrom(paths, filter) {
|
|
113
119
|
return paths[0];
|
114
120
|
}
|
115
121
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
122
|
+
var minDepth = Infinity;
|
123
|
+
var lastCommonIndex, lastCommon;
|
124
|
+
var ancestries = paths.map(function (path) {
|
125
|
+
var ancestry = [];
|
120
126
|
|
121
127
|
do {
|
122
128
|
ancestry.unshift(path);
|
123
|
-
} while ((path = path.parentPath) && path !==
|
129
|
+
} while ((path = path.parentPath) && path !== _this);
|
124
130
|
|
125
131
|
if (ancestry.length < minDepth) {
|
126
132
|
minDepth = ancestry.length;
|
@@ -128,12 +134,15 @@ function getDeepestCommonAncestorFrom(paths, filter) {
|
|
128
134
|
|
129
135
|
return ancestry;
|
130
136
|
});
|
131
|
-
|
137
|
+
var first = ancestries[0];
|
138
|
+
|
139
|
+
depthLoop: for (var i = 0; i < minDepth; i++) {
|
140
|
+
var shouldMatch = first[i];
|
141
|
+
var _arr2 = ancestries;
|
132
142
|
|
133
|
-
|
134
|
-
|
143
|
+
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
144
|
+
var ancestry = _arr2[_i2];
|
135
145
|
|
136
|
-
for (const ancestry of ancestries) {
|
137
146
|
if (ancestry[i] !== shouldMatch) {
|
138
147
|
break depthLoop;
|
139
148
|
}
|
@@ -155,8 +164,8 @@ function getDeepestCommonAncestorFrom(paths, filter) {
|
|
155
164
|
}
|
156
165
|
|
157
166
|
function getAncestry() {
|
158
|
-
|
159
|
-
|
167
|
+
var path = this;
|
168
|
+
var paths = [];
|
160
169
|
|
161
170
|
do {
|
162
171
|
paths.push(path);
|
@@ -170,14 +179,19 @@ function isAncestor(maybeDescendant) {
|
|
170
179
|
}
|
171
180
|
|
172
181
|
function isDescendant(maybeAncestor) {
|
173
|
-
return !!this.findParent(
|
182
|
+
return !!this.findParent(function (parent) {
|
183
|
+
return parent === maybeAncestor;
|
184
|
+
});
|
174
185
|
}
|
175
186
|
|
176
187
|
function inType() {
|
177
|
-
|
188
|
+
var path = this;
|
178
189
|
|
179
190
|
while (path) {
|
180
|
-
|
191
|
+
var _arr3 = arguments;
|
192
|
+
|
193
|
+
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
|
194
|
+
var type = _arr3[_i3];
|
181
195
|
if (path.node.type === type) return true;
|
182
196
|
}
|
183
197
|
|
package/lib/path/comments.js
CHANGED
@@ -8,9 +8,9 @@ exports.addComment = addComment;
|
|
8
8
|
exports.addComments = addComments;
|
9
9
|
|
10
10
|
function t() {
|
11
|
-
|
11
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
12
12
|
|
13
|
-
t = function () {
|
13
|
+
t = function t() {
|
14
14
|
return data;
|
15
15
|
};
|
16
16
|
|
@@ -21,15 +21,15 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
21
21
|
|
22
22
|
function shareCommentsWithSiblings() {
|
23
23
|
if (typeof this.key === "string") return;
|
24
|
-
|
24
|
+
var node = this.node;
|
25
25
|
if (!node) return;
|
26
|
-
|
27
|
-
|
26
|
+
var trailing = node.trailingComments;
|
27
|
+
var leading = node.leadingComments;
|
28
28
|
if (!trailing && !leading) return;
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
var prev = this.getSibling(this.key - 1);
|
30
|
+
var next = this.getSibling(this.key + 1);
|
31
|
+
var hasPrev = Boolean(prev.node);
|
32
|
+
var hasNext = Boolean(next.node);
|
33
33
|
|
34
34
|
if (hasPrev && hasNext) {} else if (hasPrev) {
|
35
35
|
prev.addComments("trailing", trailing);
|
package/lib/path/context.js
CHANGED
@@ -29,7 +29,7 @@ var _index = _interopRequireDefault(require("../index"));
|
|
29
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
30
30
|
|
31
31
|
function call(key) {
|
32
|
-
|
32
|
+
var opts = this.opts;
|
33
33
|
this.debug(key);
|
34
34
|
|
35
35
|
if (this.node) {
|
@@ -46,18 +46,30 @@ function call(key) {
|
|
46
46
|
function _call(fns) {
|
47
47
|
if (!fns) return false;
|
48
48
|
|
49
|
-
for (
|
49
|
+
for (var _iterator = fns, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
50
|
+
var _ref;
|
51
|
+
|
52
|
+
if (_isArray) {
|
53
|
+
if (_i >= _iterator.length) break;
|
54
|
+
_ref = _iterator[_i++];
|
55
|
+
} else {
|
56
|
+
_i = _iterator.next();
|
57
|
+
if (_i.done) break;
|
58
|
+
_ref = _i.value;
|
59
|
+
}
|
60
|
+
|
61
|
+
var fn = _ref;
|
50
62
|
if (!fn) continue;
|
51
|
-
|
63
|
+
var node = this.node;
|
52
64
|
if (!node) return true;
|
53
|
-
|
65
|
+
var ret = fn.call(this.state, this, this.state);
|
54
66
|
|
55
67
|
if (ret && typeof ret === "object" && typeof ret.then === "function") {
|
56
|
-
throw new Error(
|
68
|
+
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
69
|
}
|
58
70
|
|
59
71
|
if (ret) {
|
60
|
-
throw new Error(
|
72
|
+
throw new Error("Unexpected return value from visitor method " + fn);
|
61
73
|
}
|
62
74
|
|
63
75
|
if (this.node !== node) return true;
|
@@ -68,7 +80,7 @@ function _call(fns) {
|
|
68
80
|
}
|
69
81
|
|
70
82
|
function isBlacklisted() {
|
71
|
-
|
83
|
+
var blacklist = this.opts.blacklist;
|
72
84
|
return blacklist && blacklist.indexOf(this.node.type) > -1;
|
73
85
|
}
|
74
86
|
|
@@ -113,8 +125,8 @@ function stop() {
|
|
113
125
|
|
114
126
|
function setScope() {
|
115
127
|
if (this.opts && this.opts.noScope) return;
|
116
|
-
|
117
|
-
|
128
|
+
var path = this.parentPath;
|
129
|
+
var target;
|
118
130
|
|
119
131
|
while (path && !target) {
|
120
132
|
if (path.opts && path.opts.noScope) return;
|
@@ -163,13 +175,13 @@ function _resyncKey() {
|
|
163
175
|
if (this.node === this.container[this.key]) return;
|
164
176
|
|
165
177
|
if (Array.isArray(this.container)) {
|
166
|
-
for (
|
178
|
+
for (var i = 0; i < this.container.length; i++) {
|
167
179
|
if (this.container[i] === this.node) {
|
168
180
|
return this.setKey(i);
|
169
181
|
}
|
170
182
|
}
|
171
183
|
} else {
|
172
|
-
for (
|
184
|
+
for (var key in this.container) {
|
173
185
|
if (this.container[key] === this.node) {
|
174
186
|
return this.setKey(key);
|
175
187
|
}
|
@@ -181,7 +193,7 @@ function _resyncKey() {
|
|
181
193
|
|
182
194
|
function _resyncList() {
|
183
195
|
if (!this.parent || !this.inList) return;
|
184
|
-
|
196
|
+
var newContainer = this.parent[this.listKey];
|
185
197
|
if (this.container === newContainer) return;
|
186
198
|
this.container = newContainer || null;
|
187
199
|
}
|
@@ -222,18 +234,34 @@ function setKey(key) {
|
|
222
234
|
this.type = this.node && this.node.type;
|
223
235
|
}
|
224
236
|
|
225
|
-
function requeue(pathToQueue
|
237
|
+
function requeue(pathToQueue) {
|
238
|
+
if (pathToQueue === void 0) {
|
239
|
+
pathToQueue = this;
|
240
|
+
}
|
241
|
+
|
226
242
|
if (pathToQueue.removed) return;
|
227
|
-
|
243
|
+
var contexts = this.contexts;
|
244
|
+
|
245
|
+
for (var _iterator2 = contexts, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
246
|
+
var _ref2;
|
247
|
+
|
248
|
+
if (_isArray2) {
|
249
|
+
if (_i2 >= _iterator2.length) break;
|
250
|
+
_ref2 = _iterator2[_i2++];
|
251
|
+
} else {
|
252
|
+
_i2 = _iterator2.next();
|
253
|
+
if (_i2.done) break;
|
254
|
+
_ref2 = _i2.value;
|
255
|
+
}
|
228
256
|
|
229
|
-
|
257
|
+
var context = _ref2;
|
230
258
|
context.maybeQueue(pathToQueue);
|
231
259
|
}
|
232
260
|
}
|
233
261
|
|
234
262
|
function _getQueueContexts() {
|
235
|
-
|
236
|
-
|
263
|
+
var path = this;
|
264
|
+
var contexts = this.contexts;
|
237
265
|
|
238
266
|
while (!contexts.length) {
|
239
267
|
path = path.parentPath;
|