@babel/traverse 7.0.0-beta.45 → 7.0.0-beta.49
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/.npmignore +3 -0
- package/README.md +3 -3
- package/lib/cache.js +2 -2
- package/lib/context.js +35 -75
- package/lib/hub.js +6 -3
- package/lib/index.js +12 -24
- package/lib/path/ancestry.js +26 -40
- package/lib/path/comments.js +9 -9
- package/lib/path/context.js +17 -45
- package/lib/path/conversion.js +122 -128
- package/lib/path/evaluation.js +97 -136
- package/lib/path/family.js +27 -40
- package/lib/path/index.js +61 -81
- package/lib/path/inference/index.js +12 -16
- package/lib/path/inference/inferer-reference.js +37 -41
- package/lib/path/inference/inferers.js +18 -16
- package/lib/path/introspection.js +55 -99
- package/lib/path/lib/hoister.js +48 -56
- package/lib/path/lib/removal-hooks.js +2 -2
- package/lib/path/lib/virtual-types.js +76 -46
- package/lib/path/modification.js +40 -56
- package/lib/path/removal.js +3 -10
- package/lib/path/replacement.js +34 -52
- package/lib/scope/binding.js +20 -22
- package/lib/scope/index.js +280 -402
- package/lib/scope/lib/renamer.js +37 -35
- package/lib/visitors.js +62 -120
- package/package.json +9 -9
package/lib/path/conversion.js
CHANGED
@@ -10,9 +10,9 @@ exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
|
|
10
10
|
exports.arrowFunctionToExpression = arrowFunctionToExpression;
|
11
11
|
|
12
12
|
function t() {
|
13
|
-
|
13
|
+
const data = _interopRequireWildcard(require("@babel/types"));
|
14
14
|
|
15
|
-
t = function
|
15
|
+
t = function () {
|
16
16
|
return data;
|
17
17
|
};
|
18
18
|
|
@@ -20,9 +20,9 @@ function t() {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
function _helperFunctionName() {
|
23
|
-
|
23
|
+
const data = _interopRequireDefault(require("@babel/helper-function-name"));
|
24
24
|
|
25
|
-
_helperFunctionName = function
|
25
|
+
_helperFunctionName = function () {
|
26
26
|
return data;
|
27
27
|
};
|
28
28
|
|
@@ -34,8 +34,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
34
34
|
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; } }
|
35
35
|
|
36
36
|
function toComputedKey() {
|
37
|
-
|
38
|
-
|
37
|
+
const node = this.node;
|
38
|
+
let key;
|
39
39
|
|
40
40
|
if (this.isMemberExpression()) {
|
41
41
|
key = node.property;
|
@@ -53,8 +53,8 @@ function toComputedKey() {
|
|
53
53
|
}
|
54
54
|
|
55
55
|
function ensureBlock() {
|
56
|
-
|
57
|
-
|
56
|
+
const body = this.get("body");
|
57
|
+
const bodyNode = body.node;
|
58
58
|
|
59
59
|
if (Array.isArray(body)) {
|
60
60
|
throw new Error("Can't convert array path to a block statement");
|
@@ -68,10 +68,10 @@ function ensureBlock() {
|
|
68
68
|
return bodyNode;
|
69
69
|
}
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
const statements = [];
|
72
|
+
let stringPath = "body";
|
73
|
+
let key;
|
74
|
+
let listKey;
|
75
75
|
|
76
76
|
if (body.isStatement()) {
|
77
77
|
listKey = "body";
|
@@ -90,7 +90,7 @@ function ensureBlock() {
|
|
90
90
|
}
|
91
91
|
|
92
92
|
this.node.body = t().blockStatement(statements);
|
93
|
-
|
93
|
+
const parentPath = this.get(stringPath);
|
94
94
|
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
|
95
95
|
return this.node;
|
96
96
|
}
|
@@ -108,23 +108,20 @@ function unwrapFunctionEnvironment() {
|
|
108
108
|
hoistFunctionEnvironment(this);
|
109
109
|
}
|
110
110
|
|
111
|
-
function arrowFunctionToExpression(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
_ref$specCompliant = _ref.specCompliant,
|
116
|
-
specCompliant = _ref$specCompliant === void 0 ? false : _ref$specCompliant;
|
117
|
-
|
111
|
+
function arrowFunctionToExpression({
|
112
|
+
allowInsertArrow = true,
|
113
|
+
specCompliant = false
|
114
|
+
} = {}) {
|
118
115
|
if (!this.isArrowFunctionExpression()) {
|
119
116
|
throw this.buildCodeFrameError("Cannot convert non-arrow function to a function expression.");
|
120
117
|
}
|
121
118
|
|
122
|
-
|
119
|
+
const thisBinding = hoistFunctionEnvironment(this, specCompliant, allowInsertArrow);
|
123
120
|
this.ensureBlock();
|
124
121
|
this.node.type = "FunctionExpression";
|
125
122
|
|
126
123
|
if (specCompliant) {
|
127
|
-
|
124
|
+
const checkBinding = thisBinding ? null : this.parentPath.scope.generateUidIdentifier("arrowCheckId");
|
128
125
|
|
129
126
|
if (checkBinding) {
|
130
127
|
this.parentPath.scope.push({
|
@@ -138,69 +135,65 @@ function arrowFunctionToExpression(_temp) {
|
|
138
135
|
}
|
139
136
|
}
|
140
137
|
|
141
|
-
function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
142
|
-
|
143
|
-
specCompliant = false;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (allowInsertArrow === void 0) {
|
147
|
-
allowInsertArrow = true;
|
148
|
-
}
|
149
|
-
|
150
|
-
var thisEnvFn = fnPath.findParent(function (p) {
|
138
|
+
function hoistFunctionEnvironment(fnPath, specCompliant = false, allowInsertArrow = true) {
|
139
|
+
const thisEnvFn = fnPath.findParent(p => {
|
151
140
|
return p.isFunction() && !p.isArrowFunctionExpression() || p.isProgram() || p.isClassProperty({
|
152
141
|
static: false
|
153
142
|
});
|
154
143
|
});
|
155
|
-
|
144
|
+
const inConstructor = thisEnvFn && thisEnvFn.node.kind === "constructor";
|
156
145
|
|
157
146
|
if (thisEnvFn.isClassProperty()) {
|
158
147
|
throw fnPath.buildCodeFrameError("Unable to transform arrow inside class property");
|
159
148
|
}
|
160
149
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
150
|
+
const {
|
151
|
+
thisPaths,
|
152
|
+
argumentsPaths,
|
153
|
+
newTargetPaths,
|
154
|
+
superProps,
|
155
|
+
superCalls
|
156
|
+
} = getScopeInformation(fnPath);
|
167
157
|
|
168
158
|
if (inConstructor && superCalls.length > 0) {
|
169
159
|
if (!allowInsertArrow) {
|
170
160
|
throw superCalls[0].buildCodeFrameError("Unable to handle nested super() usage in arrow");
|
171
161
|
}
|
172
162
|
|
173
|
-
|
163
|
+
const allSuperCalls = [];
|
174
164
|
thisEnvFn.traverse({
|
175
|
-
Function
|
165
|
+
Function(child) {
|
176
166
|
if (child.isArrowFunctionExpression()) return;
|
177
167
|
child.skip();
|
178
168
|
},
|
179
|
-
|
169
|
+
|
170
|
+
ClassProperty(child) {
|
180
171
|
if (child.node.static) return;
|
181
172
|
child.skip();
|
182
173
|
},
|
183
|
-
|
174
|
+
|
175
|
+
CallExpression(child) {
|
184
176
|
if (!child.get("callee").isSuper()) return;
|
185
177
|
allSuperCalls.push(child);
|
186
178
|
}
|
179
|
+
|
187
180
|
});
|
188
|
-
|
189
|
-
allSuperCalls.forEach(
|
190
|
-
|
181
|
+
const superBinding = getSuperBinding(thisEnvFn);
|
182
|
+
allSuperCalls.forEach(superCall => {
|
183
|
+
const callee = t().identifier(superBinding);
|
191
184
|
callee.loc = superCall.node.callee.loc;
|
192
185
|
superCall.get("callee").replaceWith(callee);
|
193
186
|
});
|
194
187
|
}
|
195
188
|
|
196
|
-
|
189
|
+
let thisBinding;
|
197
190
|
|
198
191
|
if (thisPaths.length > 0 || specCompliant) {
|
199
192
|
thisBinding = getThisBinding(thisEnvFn, inConstructor);
|
200
193
|
|
201
194
|
if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
|
202
|
-
thisPaths.forEach(
|
203
|
-
|
195
|
+
thisPaths.forEach(thisChild => {
|
196
|
+
const thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding);
|
204
197
|
thisRef.loc = thisChild.node.loc;
|
205
198
|
thisChild.replaceWith(thisRef);
|
206
199
|
});
|
@@ -209,22 +202,18 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
209
202
|
}
|
210
203
|
|
211
204
|
if (argumentsPaths.length > 0) {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
argumentsPaths.forEach(function (argumentsChild) {
|
216
|
-
var argsRef = t().identifier(argumentsBinding);
|
205
|
+
const argumentsBinding = getBinding(thisEnvFn, "arguments", () => t().identifier("arguments"));
|
206
|
+
argumentsPaths.forEach(argumentsChild => {
|
207
|
+
const argsRef = t().identifier(argumentsBinding);
|
217
208
|
argsRef.loc = argumentsChild.node.loc;
|
218
209
|
argumentsChild.replaceWith(argsRef);
|
219
210
|
});
|
220
211
|
}
|
221
212
|
|
222
213
|
if (newTargetPaths.length > 0) {
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
newTargetPaths.forEach(function (targetChild) {
|
227
|
-
var targetRef = t().identifier(newTargetBinding);
|
214
|
+
const newTargetBinding = getBinding(thisEnvFn, "newtarget", () => t().metaProperty(t().identifier("new"), t().identifier("target")));
|
215
|
+
newTargetPaths.forEach(targetChild => {
|
216
|
+
const targetRef = t().identifier(newTargetBinding);
|
228
217
|
targetRef.loc = targetChild.node.loc;
|
229
218
|
targetChild.replaceWith(targetRef);
|
230
219
|
});
|
@@ -235,43 +224,39 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
235
224
|
throw superProps[0].buildCodeFrameError("Unable to handle nested super.prop usage");
|
236
225
|
}
|
237
226
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
flatSuperProps.forEach(function (superProp) {
|
242
|
-
var key = superProp.node.computed ? "" : superProp.get("property").node.name;
|
227
|
+
const flatSuperProps = superProps.reduce((acc, superProp) => acc.concat(standardizeSuperProperty(superProp)), []);
|
228
|
+
flatSuperProps.forEach(superProp => {
|
229
|
+
const key = superProp.node.computed ? "" : superProp.get("property").node.name;
|
243
230
|
|
244
231
|
if (superProp.parentPath.isCallExpression({
|
245
232
|
callee: superProp.node
|
246
233
|
})) {
|
247
|
-
|
234
|
+
const superBinding = getSuperPropCallBinding(thisEnvFn, key);
|
248
235
|
|
249
236
|
if (superProp.node.computed) {
|
250
|
-
|
251
|
-
superProp.replaceWith(t().identifier(
|
237
|
+
const prop = superProp.get("property").node;
|
238
|
+
superProp.replaceWith(t().identifier(superBinding));
|
252
239
|
superProp.parentPath.node.arguments.unshift(prop);
|
253
240
|
} else {
|
254
|
-
superProp.replaceWith(t().identifier(
|
241
|
+
superProp.replaceWith(t().identifier(superBinding));
|
255
242
|
}
|
256
243
|
} else {
|
257
|
-
|
244
|
+
const isAssignment = superProp.parentPath.isAssignmentExpression({
|
258
245
|
left: superProp.node
|
259
246
|
});
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
var args = [];
|
247
|
+
const superBinding = getSuperPropBinding(thisEnvFn, isAssignment, key);
|
248
|
+
const args = [];
|
264
249
|
|
265
250
|
if (superProp.node.computed) {
|
266
251
|
args.push(superProp.get("property").node);
|
267
252
|
}
|
268
253
|
|
269
254
|
if (isAssignment) {
|
270
|
-
|
255
|
+
const value = superProp.parentPath.node.right;
|
271
256
|
args.push(value);
|
272
|
-
superProp.parentPath.replaceWith(t().callExpression(t().identifier(
|
257
|
+
superProp.parentPath.replaceWith(t().callExpression(t().identifier(superBinding), args));
|
273
258
|
} else {
|
274
|
-
superProp.replaceWith(t().callExpression(t().identifier(
|
259
|
+
superProp.replaceWith(t().callExpression(t().identifier(superBinding), args));
|
275
260
|
}
|
276
261
|
}
|
277
262
|
});
|
@@ -282,13 +267,13 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
282
267
|
|
283
268
|
function standardizeSuperProperty(superProp) {
|
284
269
|
if (superProp.parentPath.isAssignmentExpression() && superProp.parentPath.node.operator !== "=") {
|
285
|
-
|
286
|
-
|
287
|
-
|
270
|
+
const assignmentPath = superProp.parentPath;
|
271
|
+
const op = assignmentPath.node.operator.slice(0, -1);
|
272
|
+
const value = assignmentPath.node.right;
|
288
273
|
assignmentPath.node.operator = "=";
|
289
274
|
|
290
275
|
if (superProp.node.computed) {
|
291
|
-
|
276
|
+
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
292
277
|
assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true));
|
293
278
|
assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value));
|
294
279
|
} else {
|
@@ -298,20 +283,18 @@ function standardizeSuperProperty(superProp) {
|
|
298
283
|
|
299
284
|
return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
|
300
285
|
} else if (superProp.parentPath.isUpdateExpression()) {
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
var computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
|
306
|
-
var parts = [t().assignmentExpression("=", _tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(_tmp.name), t().numericLiteral(1)))];
|
286
|
+
const updateExpr = superProp.parentPath;
|
287
|
+
const tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
288
|
+
const computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
|
289
|
+
const parts = [t().assignmentExpression("=", tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(tmp.name), t().numericLiteral(1)))];
|
307
290
|
|
308
291
|
if (!superProp.parentPath.node.prefix) {
|
309
|
-
parts.push(t().identifier(
|
292
|
+
parts.push(t().identifier(tmp.name));
|
310
293
|
}
|
311
294
|
|
312
295
|
updateExpr.replaceWith(t().sequenceExpression(parts));
|
313
|
-
|
314
|
-
|
296
|
+
const left = updateExpr.get("expressions.0.right");
|
297
|
+
const right = updateExpr.get("expressions.1.left");
|
315
298
|
return [left, right];
|
316
299
|
}
|
317
300
|
|
@@ -323,45 +306,48 @@ function hasSuperClass(thisEnvFn) {
|
|
323
306
|
}
|
324
307
|
|
325
308
|
function getThisBinding(thisEnvFn, inConstructor) {
|
326
|
-
return getBinding(thisEnvFn, "this",
|
309
|
+
return getBinding(thisEnvFn, "this", thisBinding => {
|
327
310
|
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression();
|
328
|
-
|
311
|
+
const supers = new WeakSet();
|
329
312
|
thisEnvFn.traverse({
|
330
|
-
Function
|
313
|
+
Function(child) {
|
331
314
|
if (child.isArrowFunctionExpression()) return;
|
332
315
|
child.skip();
|
333
316
|
},
|
334
|
-
|
317
|
+
|
318
|
+
ClassProperty(child) {
|
335
319
|
if (child.node.static) return;
|
336
320
|
child.skip();
|
337
321
|
},
|
338
|
-
|
322
|
+
|
323
|
+
CallExpression(child) {
|
339
324
|
if (!child.get("callee").isSuper()) return;
|
340
325
|
if (supers.has(child.node)) return;
|
341
326
|
supers.add(child.node);
|
342
327
|
child.replaceWith(t().assignmentExpression("=", t().identifier(thisBinding), child.node));
|
343
328
|
}
|
329
|
+
|
344
330
|
});
|
345
331
|
});
|
346
332
|
}
|
347
333
|
|
348
334
|
function getSuperBinding(thisEnvFn) {
|
349
|
-
return getBinding(thisEnvFn, "supercall",
|
350
|
-
|
335
|
+
return getBinding(thisEnvFn, "supercall", () => {
|
336
|
+
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
|
351
337
|
return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))]));
|
352
338
|
});
|
353
339
|
}
|
354
340
|
|
355
341
|
function getSuperPropCallBinding(thisEnvFn, propName) {
|
356
|
-
return getBinding(thisEnvFn,
|
357
|
-
|
358
|
-
|
359
|
-
|
342
|
+
return getBinding(thisEnvFn, `superprop_call:${propName || ""}`, () => {
|
343
|
+
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
|
344
|
+
const argsList = [t().restElement(argsBinding)];
|
345
|
+
let fnBody;
|
360
346
|
|
361
347
|
if (propName) {
|
362
348
|
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]);
|
363
349
|
} else {
|
364
|
-
|
350
|
+
const method = thisEnvFn.scope.generateUidIdentifier("prop");
|
365
351
|
argsList.unshift(method);
|
366
352
|
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]);
|
367
353
|
}
|
@@ -371,21 +357,21 @@ function getSuperPropCallBinding(thisEnvFn, propName) {
|
|
371
357
|
}
|
372
358
|
|
373
359
|
function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
|
374
|
-
|
375
|
-
return getBinding(thisEnvFn,
|
376
|
-
|
377
|
-
|
360
|
+
const op = isAssignment ? "set" : "get";
|
361
|
+
return getBinding(thisEnvFn, `superprop_${op}:${propName || ""}`, () => {
|
362
|
+
const argsList = [];
|
363
|
+
let fnBody;
|
378
364
|
|
379
365
|
if (propName) {
|
380
366
|
fnBody = t().memberExpression(t().super(), t().identifier(propName));
|
381
367
|
} else {
|
382
|
-
|
368
|
+
const method = thisEnvFn.scope.generateUidIdentifier("prop");
|
383
369
|
argsList.unshift(method);
|
384
370
|
fnBody = t().memberExpression(t().super(), t().identifier(method.name), true);
|
385
371
|
}
|
386
372
|
|
387
373
|
if (isAssignment) {
|
388
|
-
|
374
|
+
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
|
389
375
|
argsList.push(valueIdent);
|
390
376
|
fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name));
|
391
377
|
}
|
@@ -395,11 +381,11 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
|
|
395
381
|
}
|
396
382
|
|
397
383
|
function getBinding(thisEnvFn, key, init) {
|
398
|
-
|
399
|
-
|
384
|
+
const cacheKey = "binding:" + key;
|
385
|
+
let data = thisEnvFn.getData(cacheKey);
|
400
386
|
|
401
387
|
if (!data) {
|
402
|
-
|
388
|
+
const id = thisEnvFn.scope.generateUidIdentifier(key);
|
403
389
|
data = id.name;
|
404
390
|
thisEnvFn.setData(cacheKey, data);
|
405
391
|
thisEnvFn.scope.push({
|
@@ -412,24 +398,27 @@ function getBinding(thisEnvFn, key, init) {
|
|
412
398
|
}
|
413
399
|
|
414
400
|
function getScopeInformation(fnPath) {
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
401
|
+
const thisPaths = [];
|
402
|
+
const argumentsPaths = [];
|
403
|
+
const newTargetPaths = [];
|
404
|
+
const superProps = [];
|
405
|
+
const superCalls = [];
|
420
406
|
fnPath.traverse({
|
421
|
-
ClassProperty
|
407
|
+
ClassProperty(child) {
|
422
408
|
if (child.node.static) return;
|
423
409
|
child.skip();
|
424
410
|
},
|
425
|
-
|
411
|
+
|
412
|
+
Function(child) {
|
426
413
|
if (child.isArrowFunctionExpression()) return;
|
427
414
|
child.skip();
|
428
415
|
},
|
429
|
-
|
416
|
+
|
417
|
+
ThisExpression(child) {
|
430
418
|
thisPaths.push(child);
|
431
419
|
},
|
432
|
-
|
420
|
+
|
421
|
+
JSXIdentifier(child) {
|
433
422
|
if (child.node.name !== "this") return;
|
434
423
|
|
435
424
|
if (!child.parentPath.isJSXMemberExpression({
|
@@ -442,17 +431,21 @@ function getScopeInformation(fnPath) {
|
|
442
431
|
|
443
432
|
thisPaths.push(child);
|
444
433
|
},
|
445
|
-
|
434
|
+
|
435
|
+
CallExpression(child) {
|
446
436
|
if (child.get("callee").isSuper()) superCalls.push(child);
|
447
437
|
},
|
448
|
-
|
438
|
+
|
439
|
+
MemberExpression(child) {
|
449
440
|
if (child.get("object").isSuper()) superProps.push(child);
|
450
441
|
},
|
451
|
-
|
442
|
+
|
443
|
+
ReferencedIdentifier(child) {
|
452
444
|
if (child.node.name !== "arguments") return;
|
453
445
|
argumentsPaths.push(child);
|
454
446
|
},
|
455
|
-
|
447
|
+
|
448
|
+
MetaProperty(child) {
|
456
449
|
if (!child.get("meta").isIdentifier({
|
457
450
|
name: "new"
|
458
451
|
})) return;
|
@@ -461,12 +454,13 @@ function getScopeInformation(fnPath) {
|
|
461
454
|
})) return;
|
462
455
|
newTargetPaths.push(child);
|
463
456
|
}
|
457
|
+
|
464
458
|
});
|
465
459
|
return {
|
466
|
-
thisPaths
|
467
|
-
argumentsPaths
|
468
|
-
newTargetPaths
|
469
|
-
superProps
|
470
|
-
superCalls
|
460
|
+
thisPaths,
|
461
|
+
argumentsPaths,
|
462
|
+
newTargetPaths,
|
463
|
+
superProps,
|
464
|
+
superCalls
|
471
465
|
};
|
472
466
|
}
|