@babel/traverse 8.0.0-alpha.12 → 8.0.0-alpha.13

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.
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import * as _t from '@babel/types';
2
1
  import buildDebug from 'debug';
3
- import globals from 'globals';
4
- import generator from '@babel/generator';
5
2
  import { codeFrameColumns } from '@babel/code-frame';
3
+ import * as _t from '@babel/types';
6
4
  import { parse } from '@babel/parser';
5
+ import globals from 'globals';
6
+ import generator from '@babel/generator';
7
7
  import template from '@babel/template';
8
8
 
9
9
  const ReferencedIdentifier = ["Identifier", "JSXIdentifier"];
@@ -67,12 +67,12 @@ const {
67
67
  isStatement: nodeIsStatement,
68
68
  isVar: nodeIsVar,
69
69
  isVariableDeclaration: isVariableDeclaration$2,
70
- react: react$1,
70
+ react,
71
71
  isForOfStatement
72
72
  } = _t;
73
73
  const {
74
74
  isCompatTag
75
- } = react$1;
75
+ } = react;
76
76
  function isReferencedIdentifier(opts) {
77
77
  const {
78
78
  node,
@@ -289,7 +289,7 @@ function verify$1(visitor) {
289
289
  }
290
290
  if (shouldIgnoreKey(nodeType)) continue;
291
291
  if (!TYPES.includes(nodeType)) {
292
- throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type`);
292
+ throw new Error(`You gave us a visitor for the node type ${nodeType} but it's not a valid type in @babel/traverse ${"8.0.0-alpha.13"}`);
293
293
  }
294
294
  const visitors = visitor[nodeType];
295
295
  if (typeof visitors === "object") {
@@ -313,7 +313,10 @@ function validateVisitorMethods(path, val) {
313
313
  }
314
314
  }
315
315
  function merge(visitors, states = [], wrapper) {
316
- const mergedVisitor = {};
316
+ const mergedVisitor = {
317
+ _verified: true,
318
+ _exploded: true
319
+ };
317
320
  for (let i = 0; i < visitors.length; i++) {
318
321
  const visitor = explode$1(visitors[i]);
319
322
  const state = states[i];
@@ -332,12 +335,7 @@ function merge(visitors, states = [], wrapper) {
332
335
  mergePair(nodeVisitor, typeVisitor);
333
336
  }
334
337
  }
335
- {
336
- return Object.assign({}, mergedVisitor, {
337
- _exploded: true,
338
- _verified: true
339
- });
340
- }
338
+ return mergedVisitor;
341
339
  }
342
340
  function wrapWithStateOrWrapper(oldVisitor, state, wrapper) {
343
341
  const newVisitor = {};
@@ -408,13 +406,17 @@ const _environmentVisitor = {
408
406
  if (path.isArrowFunctionExpression()) return;
409
407
  path.skip();
410
408
  if (path.isMethod()) {
411
- path.requeueComputedKeyAndDecorators();
409
+ {
410
+ path.requeueComputedKeyAndDecorators();
411
+ }
412
412
  }
413
413
  },
414
414
  Property(path) {
415
415
  if (path.isObjectProperty()) return;
416
416
  path.skip();
417
- path.requeueComputedKeyAndDecorators();
417
+ {
418
+ path.requeueComputedKeyAndDecorators();
419
+ }
418
420
  }
419
421
  };
420
422
  function environmentVisitor(visitor) {
@@ -430,41 +432,9 @@ var visitors = /*#__PURE__*/Object.freeze({
430
432
  verify: verify$1
431
433
  });
432
434
 
433
- let pathsCache = new WeakMap();
434
- let scope = new WeakMap();
435
- function clear() {
436
- clearPath();
437
- clearScope();
438
- }
439
- function clearPath() {
440
- pathsCache = new WeakMap();
441
- }
442
- function clearScope() {
443
- scope = new WeakMap();
444
- }
445
- const nullHub = Object.freeze({});
446
- function getCachedPaths(hub, parent) {
447
- return pathsCache.get(hub ?? nullHub)?.get(parent);
448
- }
449
- function getOrCreateCachedPaths(hub, parent) {
450
- let parents = pathsCache.get(hub ?? nullHub);
451
- if (!parents) pathsCache.set(hub ?? nullHub, parents = new WeakMap());
452
- let paths = parents.get(parent);
453
- if (!paths) parents.set(parent, paths = new Map());
454
- return paths;
455
- }
456
-
457
- var cache = /*#__PURE__*/Object.freeze({
458
- __proto__: null,
459
- clear: clear,
460
- clearPath: clearPath,
461
- clearScope: clearScope,
462
- getCachedPaths: getCachedPaths,
463
- getOrCreateCachedPaths: getOrCreateCachedPaths,
464
- get path () { return pathsCache; },
465
- get scope () { return scope; }
466
- });
467
-
435
+ const {
436
+ getAssignmentIdentifiers: getAssignmentIdentifiers$1
437
+ } = _t;
468
438
  const renameVisitor = {
469
439
  ReferencedIdentifier({
470
440
  node
@@ -477,7 +447,9 @@ const renameVisitor = {
477
447
  if (!path.scope.bindingIdentifierEquals(state.oldName, state.binding.identifier)) {
478
448
  path.skip();
479
449
  if (path.isMethod()) {
480
- path.requeueComputedKeyAndDecorators();
450
+ {
451
+ path.requeueComputedKeyAndDecorators();
452
+ }
481
453
  }
482
454
  }
483
455
  },
@@ -494,7 +466,7 @@ const renameVisitor = {
494
466
  },
495
467
  "AssignmentExpression|Declaration|VariableDeclarator"(path, state) {
496
468
  if (path.isVariableDeclaration()) return;
497
- const ids = path.isAssignmentExpression() ? path.getAssignmentIdentifiers() : path.getOuterBindingIdentifiers();
469
+ const ids = path.isAssignmentExpression() ? getAssignmentIdentifiers$1(path.node) : path.getOuterBindingIdentifiers();
498
470
  for (const name in ids) {
499
471
  if (name === state.oldName) ids[name].name = state.newName;
500
472
  }
@@ -548,9 +520,18 @@ class Renamer {
548
520
  }
549
521
  }
550
522
  const blockToTraverse = scope.block;
551
- traverseNode(blockToTraverse, explode$1(renameVisitor), scope, this, scope.path, {
523
+ const skipKeys = {
552
524
  discriminant: true
553
- });
525
+ };
526
+ if (_t.isMethod(blockToTraverse)) {
527
+ if (blockToTraverse.computed) {
528
+ skipKeys.key = true;
529
+ }
530
+ if (!_t.isObjectMethod(blockToTraverse)) {
531
+ skipKeys.decorators = true;
532
+ }
533
+ }
534
+ traverseNode(blockToTraverse, explode$1(renameVisitor), scope, this, scope.path, skipKeys);
554
535
  {
555
536
  scope.removeOwnBinding(oldName);
556
537
  scope.bindings[newName] = binding;
@@ -638,11 +619,46 @@ function isDeclaredInLoop(path) {
638
619
  return false;
639
620
  }
640
621
 
622
+ let pathsCache = new WeakMap();
623
+ let scope = new WeakMap();
624
+ function clear() {
625
+ clearPath();
626
+ clearScope();
627
+ }
628
+ function clearPath() {
629
+ pathsCache = new WeakMap();
630
+ }
631
+ function clearScope() {
632
+ scope = new WeakMap();
633
+ }
634
+ const nullHub = Object.freeze({});
635
+ function getCachedPaths(hub, parent) {
636
+ return pathsCache.get(hub ?? nullHub)?.get(parent);
637
+ }
638
+ function getOrCreateCachedPaths(hub, parent) {
639
+ let parents = pathsCache.get(hub ?? nullHub);
640
+ if (!parents) pathsCache.set(hub ?? nullHub, parents = new WeakMap());
641
+ let paths = parents.get(parent);
642
+ if (!paths) parents.set(parent, paths = new Map());
643
+ return paths;
644
+ }
645
+
646
+ var cache = /*#__PURE__*/Object.freeze({
647
+ __proto__: null,
648
+ clear: clear,
649
+ clearPath: clearPath,
650
+ clearScope: clearScope,
651
+ getCachedPaths: getCachedPaths,
652
+ getOrCreateCachedPaths: getOrCreateCachedPaths,
653
+ get path () { return pathsCache; },
654
+ get scope () { return scope; }
655
+ });
656
+
641
657
  const {
642
658
  NOT_LOCAL_BINDING,
643
659
  assignmentExpression: assignmentExpression$3,
644
660
  callExpression: callExpression$3,
645
- cloneNode: cloneNode$4,
661
+ cloneNode: cloneNode$3,
646
662
  getBindingIdentifiers: getBindingIdentifiers$3,
647
663
  identifier: identifier$3,
648
664
  isArrayExpression,
@@ -677,8 +693,8 @@ const {
677
693
  memberExpression: memberExpression$1,
678
694
  numericLiteral: numericLiteral$2,
679
695
  toIdentifier,
680
- variableDeclaration: variableDeclaration$2,
681
- variableDeclarator: variableDeclarator$2,
696
+ variableDeclaration: variableDeclaration$1,
697
+ variableDeclarator: variableDeclarator$1,
682
698
  isRecordExpression,
683
699
  isTupleExpression,
684
700
  isObjectProperty,
@@ -896,12 +912,12 @@ const collectorVisitor = {
896
912
  for (const param of params) {
897
913
  path.scope.registerBinding("param", param);
898
914
  }
899
- if (path.isFunctionExpression() && path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) {
915
+ if (path.isFunctionExpression() && path.node.id && !path.node.id[NOT_LOCAL_BINDING]) {
900
916
  path.scope.registerBinding("local", path.get("id"), path);
901
917
  }
902
918
  },
903
919
  ClassExpression(path) {
904
- if (path.has("id") && !path.get("id").node[NOT_LOCAL_BINDING]) {
920
+ if (path.node.id && !path.node.id[NOT_LOCAL_BINDING]) {
905
921
  path.scope.registerBinding("local", path.get("id"), path);
906
922
  }
907
923
  },
@@ -914,8 +930,8 @@ class Scope {
914
930
  uid;
915
931
  path;
916
932
  block;
917
- labels;
918
933
  inited;
934
+ labels;
919
935
  bindings;
920
936
  references;
921
937
  globals;
@@ -950,31 +966,23 @@ class Scope {
950
966
  } while (path && !parent);
951
967
  return parent?.scope;
952
968
  }
953
- get parentBlock() {
954
- return this.path.parent;
955
- }
956
- get hub() {
957
- return this.path.hub;
958
- }
959
- traverse(node, opts, state) {
960
- traverse(node, opts, this, state, this.path);
961
- }
962
969
  generateDeclaredUidIdentifier(name) {
963
970
  const id = this.generateUidIdentifier(name);
964
971
  this.push({
965
972
  id
966
973
  });
967
- return cloneNode$4(id);
974
+ return cloneNode$3(id);
968
975
  }
969
976
  generateUidIdentifier(name) {
970
977
  return identifier$3(this.generateUid(name));
971
978
  }
972
979
  generateUid(name = "temp") {
973
- name = toIdentifier(name).replace(/^_+/, "").replace(/[0-9]+$/g, "");
980
+ name = toIdentifier(name).replace(/^_+/, "").replace(/\d+$/g, "");
974
981
  let uid;
975
982
  let i = 1;
976
983
  do {
977
- uid = this._generateUid(name, i);
984
+ uid = `_${name}`;
985
+ if (i > 1) uid += i;
978
986
  i++;
979
987
  } while (this.hasLabel(uid) || this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
980
988
  const program = this.getProgramParent();
@@ -982,11 +990,6 @@ class Scope {
982
990
  program.uids[uid] = true;
983
991
  return uid;
984
992
  }
985
- _generateUid(name, i) {
986
- let id = name;
987
- if (i > 1) id += i;
988
- return `_${id}`;
989
- }
990
993
  generateUidBasedOnNode(node, defaultName) {
991
994
  const parts = [];
992
995
  gatherNodeParts(node, parts);
@@ -1020,7 +1023,7 @@ class Scope {
1020
1023
  this.push({
1021
1024
  id
1022
1025
  });
1023
- return cloneNode$4(id);
1026
+ return cloneNode$3(id);
1024
1027
  }
1025
1028
  return id;
1026
1029
  }
@@ -1030,7 +1033,7 @@ class Scope {
1030
1033
  if (local.kind === "local") return;
1031
1034
  const duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && kind === "const";
1032
1035
  if (duplicate) {
1033
- throw this.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
1036
+ throw this.path.hub.buildError(id, `Duplicate declaration "${name}"`, TypeError);
1034
1037
  }
1035
1038
  }
1036
1039
  rename(oldName, newName) {
@@ -1043,12 +1046,6 @@ class Scope {
1043
1046
  }
1044
1047
  }
1045
1048
  }
1046
- _renameFromMap(map, oldName, newName, value) {
1047
- if (map[oldName]) {
1048
- map[newName] = value;
1049
- map[oldName] = null;
1050
- }
1051
- }
1052
1049
  dump() {
1053
1050
  const sep = "-".repeat(60);
1054
1051
  console.log(sep);
@@ -1067,37 +1064,6 @@ class Scope {
1067
1064
  } while (scope = scope.parent);
1068
1065
  console.log(sep);
1069
1066
  }
1070
- toArray(node, i, arrayLikeIsIterable) {
1071
- if (isIdentifier$5(node)) {
1072
- const binding = this.getBinding(node.name);
1073
- if (binding?.constant && binding.path.isGenericType("Array")) {
1074
- return node;
1075
- }
1076
- }
1077
- if (isArrayExpression(node)) {
1078
- return node;
1079
- }
1080
- if (isIdentifier$5(node, {
1081
- name: "arguments"
1082
- })) {
1083
- return callExpression$3(memberExpression$1(memberExpression$1(memberExpression$1(identifier$3("Array"), identifier$3("prototype")), identifier$3("slice")), identifier$3("call")), [node]);
1084
- }
1085
- let helperName;
1086
- const args = [node];
1087
- if (i === true) {
1088
- helperName = "toConsumableArray";
1089
- } else if (typeof i === "number") {
1090
- args.push(numericLiteral$2(i));
1091
- helperName = "slicedToArray";
1092
- } else {
1093
- helperName = "toArray";
1094
- }
1095
- if (arrayLikeIsIterable) {
1096
- args.unshift(this.hub.addHelper(helperName));
1097
- helperName = "maybeArrayLike";
1098
- }
1099
- return callExpression$3(this.hub.addHelper(helperName), args);
1100
- }
1101
1067
  hasLabel(name) {
1102
1068
  return !!this.getLabel(name);
1103
1069
  }
@@ -1375,12 +1341,12 @@ class Scope {
1375
1341
  const dataKey = `declaration:${kind}:${blockHoist}`;
1376
1342
  let declarPath = !unique && path.getData(dataKey);
1377
1343
  if (!declarPath) {
1378
- const declar = variableDeclaration$2(kind, []);
1344
+ const declar = variableDeclaration$1(kind, []);
1379
1345
  declar._blockHoist = blockHoist;
1380
1346
  [declarPath] = path.unshiftContainer("body", [declar]);
1381
1347
  if (!unique) path.setData(dataKey, declarPath);
1382
1348
  }
1383
- const declarator = variableDeclarator$2(id, init);
1349
+ const declarator = variableDeclarator$1(id, init);
1384
1350
  const len = declarPath.node.declarations.push(declarator);
1385
1351
  path.scope.registerBinding(kind, declarPath.get("declarations")[len - 1]);
1386
1352
  }
@@ -1433,20 +1399,6 @@ class Scope {
1433
1399
  } while (scope);
1434
1400
  return ids;
1435
1401
  }
1436
- getAllBindingsOfKind(...kinds) {
1437
- const ids = Object.create(null);
1438
- for (const kind of kinds) {
1439
- let scope = this;
1440
- do {
1441
- for (const name of Object.keys(scope.bindings)) {
1442
- const binding = scope.bindings[name];
1443
- if (binding.kind === kind) ids[name] = binding;
1444
- }
1445
- scope = scope.parent;
1446
- } while (scope);
1447
- }
1448
- return ids;
1449
- }
1450
1402
  bindingIdentifierEquals(name, node) {
1451
1403
  return this.getBindingIdentifier(name) === node;
1452
1404
  }
@@ -2191,167 +2143,6 @@ function isGenericType(genericName) {
2191
2143
  });
2192
2144
  }
2193
2145
 
2194
- const {
2195
- react
2196
- } = _t;
2197
- const {
2198
- cloneNode: cloneNode$3,
2199
- jsxExpressionContainer,
2200
- variableDeclaration: variableDeclaration$1,
2201
- variableDeclarator: variableDeclarator$1
2202
- } = _t;
2203
- const referenceVisitor = {
2204
- ReferencedIdentifier(path, state) {
2205
- if (path.isJSXIdentifier() && react.isCompatTag(path.node.name) && !path.parentPath.isJSXMemberExpression()) {
2206
- return;
2207
- }
2208
- if (path.node.name === "this") {
2209
- let scope = path.scope;
2210
- do {
2211
- if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) {
2212
- break;
2213
- }
2214
- } while (scope = scope.parent);
2215
- if (scope) state.breakOnScopePaths.push(scope.path);
2216
- }
2217
- const binding = path.scope.getBinding(path.node.name);
2218
- if (!binding) return;
2219
- for (const violation of binding.constantViolations) {
2220
- if (violation.scope !== binding.path.scope) {
2221
- state.mutableBinding = true;
2222
- path.stop();
2223
- return;
2224
- }
2225
- }
2226
- if (binding !== state.scope.getBinding(path.node.name)) return;
2227
- state.bindings[path.node.name] = binding;
2228
- }
2229
- };
2230
- class PathHoister {
2231
- breakOnScopePaths;
2232
- bindings;
2233
- mutableBinding;
2234
- scopes;
2235
- scope;
2236
- path;
2237
- attachAfter;
2238
- constructor(path, scope) {
2239
- this.breakOnScopePaths = [];
2240
- this.bindings = {};
2241
- this.mutableBinding = false;
2242
- this.scopes = [];
2243
- this.scope = scope;
2244
- this.path = path;
2245
- this.attachAfter = false;
2246
- }
2247
- isCompatibleScope(scope) {
2248
- for (const key of Object.keys(this.bindings)) {
2249
- const binding = this.bindings[key];
2250
- if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
2251
- return false;
2252
- }
2253
- }
2254
- return true;
2255
- }
2256
- getCompatibleScopes() {
2257
- let scope = this.path.scope;
2258
- do {
2259
- if (this.isCompatibleScope(scope)) {
2260
- this.scopes.push(scope);
2261
- } else {
2262
- break;
2263
- }
2264
- if (this.breakOnScopePaths.includes(scope.path)) {
2265
- break;
2266
- }
2267
- } while (scope = scope.parent);
2268
- }
2269
- getAttachmentPath() {
2270
- let path = this._getAttachmentPath();
2271
- if (!path) return;
2272
- let targetScope = path.scope;
2273
- if (targetScope.path === path) {
2274
- targetScope = path.scope.parent;
2275
- }
2276
- if (targetScope.path.isProgram() || targetScope.path.isFunction()) {
2277
- for (const name of Object.keys(this.bindings)) {
2278
- if (!targetScope.hasOwnBinding(name)) continue;
2279
- const binding = this.bindings[name];
2280
- if (binding.kind === "param" || binding.path.parentKey === "params") {
2281
- continue;
2282
- }
2283
- const bindingParentPath = this.getAttachmentParentForPath(binding.path);
2284
- if (bindingParentPath.key >= path.key) {
2285
- this.attachAfter = true;
2286
- path = binding.path;
2287
- for (const violationPath of binding.constantViolations) {
2288
- if (this.getAttachmentParentForPath(violationPath).key > path.key) {
2289
- path = violationPath;
2290
- }
2291
- }
2292
- }
2293
- }
2294
- }
2295
- return path;
2296
- }
2297
- _getAttachmentPath() {
2298
- const scopes = this.scopes;
2299
- const scope = scopes.pop();
2300
- if (!scope) return;
2301
- if (scope.path.isFunction()) {
2302
- if (this.hasOwnParamBindings(scope)) {
2303
- if (this.scope === scope) return;
2304
- const bodies = scope.path.get("body").get("body");
2305
- for (let i = 0; i < bodies.length; i++) {
2306
- if (bodies[i].node._blockHoist) continue;
2307
- return bodies[i];
2308
- }
2309
- } else {
2310
- return this.getNextScopeAttachmentParent();
2311
- }
2312
- } else if (scope.path.isProgram()) {
2313
- return this.getNextScopeAttachmentParent();
2314
- }
2315
- }
2316
- getNextScopeAttachmentParent() {
2317
- const scope = this.scopes.pop();
2318
- if (scope) return this.getAttachmentParentForPath(scope.path);
2319
- }
2320
- getAttachmentParentForPath(path) {
2321
- do {
2322
- if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
2323
- return path;
2324
- }
2325
- } while (path = path.parentPath);
2326
- }
2327
- hasOwnParamBindings(scope) {
2328
- for (const name of Object.keys(this.bindings)) {
2329
- if (!scope.hasOwnBinding(name)) continue;
2330
- const binding = this.bindings[name];
2331
- if (binding.kind === "param" && binding.constant) return true;
2332
- }
2333
- return false;
2334
- }
2335
- run() {
2336
- this.path.traverse(referenceVisitor, this);
2337
- if (this.mutableBinding) return;
2338
- this.getCompatibleScopes();
2339
- const attachTo = this.getAttachmentPath();
2340
- if (!attachTo) return;
2341
- if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
2342
- let uid = attachTo.scope.generateUidIdentifier("ref");
2343
- const declarator = variableDeclarator$1(uid, this.path.node);
2344
- const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
2345
- const [attached] = attachTo[insertFn]([attachTo.isVariableDeclarator() ? declarator : variableDeclaration$1("var", [declarator])]);
2346
- const parent = this.path.parentPath;
2347
- if (parent.isJSXElement() && this.path.container === parent.node.children) {
2348
- uid = jsxExpressionContainer(uid);
2349
- }
2350
- this.path.replaceWith(cloneNode$3(uid));
2351
- return attachTo.isVariableDeclarator() ? attached.get("init") : attached.get("declarations.0.init");
2352
- }
2353
- }
2354
-
2355
2146
  const hooks = [function (self, parent) {
2356
2147
  const removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
2357
2148
  if (removeParent) {
@@ -2387,247 +2178,48 @@ const {
2387
2178
  } = _t;
2388
2179
  function remove() {
2389
2180
  _assertUnremoved.call(this);
2390
- this.resync();
2391
- if (!this.opts?.noScope) {
2392
- _removeFromScope.call(this);
2393
- }
2181
+ resync.call(this);
2394
2182
  if (_callRemovalHooks.call(this)) {
2395
2183
  _markRemoved.call(this);
2396
2184
  return;
2397
2185
  }
2398
- this.shareCommentsWithSiblings();
2399
- _remove.call(this);
2400
- _markRemoved.call(this);
2401
- }
2402
- function _removeFromScope() {
2403
- const bindings = getBindingIdentifiers$2(this.node, false, false, true);
2404
- Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
2405
- }
2406
- function _callRemovalHooks() {
2407
- if (this.parentPath) {
2408
- for (const fn of hooks) {
2409
- if (fn(this, this.parentPath)) return true;
2410
- }
2411
- }
2412
- }
2413
- function _remove() {
2414
- if (Array.isArray(this.container)) {
2415
- this.container.splice(this.key, 1);
2416
- this.updateSiblingKeys(this.key, -1);
2417
- } else {
2418
- _replaceWith.call(this, null);
2419
- }
2420
- }
2421
- function _markRemoved() {
2422
- this._traverseFlags |= SHOULD_SKIP | REMOVED;
2423
- if (this.parent) {
2424
- getCachedPaths(this.hub, this.parent).delete(this.node);
2425
- }
2426
- this.node = null;
2427
- }
2428
- function _assertUnremoved() {
2429
- if (this.removed) {
2430
- throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
2431
- }
2432
- }
2433
-
2434
- function call(key) {
2435
- const opts = this.opts;
2436
- this.debug(key);
2437
- if (this.node) {
2438
- if (_call.call(this, opts[key])) return true;
2439
- }
2440
- if (this.node) {
2441
- return _call.call(this, opts[this.node.type]?.[key]);
2442
- }
2443
- return false;
2444
- }
2445
- function _call(fns) {
2446
- if (!fns) return false;
2447
- for (const fn of fns) {
2448
- if (!fn) continue;
2449
- const node = this.node;
2450
- if (!node) return true;
2451
- const ret = fn.call(this.state, this, this.state);
2452
- if (ret && typeof ret === "object" && typeof ret.then === "function") {
2453
- 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.`);
2454
- }
2455
- if (ret) {
2456
- throw new Error(`Unexpected return value from visitor method ${fn}`);
2457
- }
2458
- if (this.node !== node) return true;
2459
- if (this._traverseFlags > 0) return true;
2460
- }
2461
- return false;
2462
- }
2463
- function isDenylisted() {
2464
- const denylist = this.opts.denylist ?? this.opts.blacklist;
2465
- return denylist && denylist.indexOf(this.node.type) > -1;
2466
- }
2467
- function restoreContext(path, context) {
2468
- if (path.context !== context) {
2469
- path.context = context;
2470
- path.state = context.state;
2471
- path.opts = context.opts;
2472
- }
2473
- }
2474
- function visit() {
2475
- if (!this.node) {
2476
- return false;
2477
- }
2478
- if (this.isDenylisted()) {
2479
- return false;
2480
- }
2481
- if (this.opts.shouldSkip?.(this)) {
2482
- return false;
2483
- }
2484
- const currentContext = this.context;
2485
- if (this.shouldSkip || this.call("enter")) {
2486
- this.debug("Skip...");
2487
- return this.shouldStop;
2488
- }
2489
- restoreContext(this, currentContext);
2490
- this.debug("Recursing into...");
2491
- this.shouldStop = traverseNode(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
2492
- restoreContext(this, currentContext);
2493
- this.call("exit");
2494
- return this.shouldStop;
2495
- }
2496
- function skip() {
2497
- this.shouldSkip = true;
2498
- }
2499
- function skipKey(key) {
2500
- if (this.skipKeys == null) {
2501
- this.skipKeys = {};
2502
- }
2503
- this.skipKeys[key] = true;
2504
- }
2505
- function stop() {
2506
- this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;
2507
- }
2508
- function setScope() {
2509
- if (this.opts?.noScope) return;
2510
- let path = this.parentPath;
2511
- if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
2512
- path = path.parentPath;
2513
- }
2514
- let target;
2515
- while (path && !target) {
2516
- if (path.opts?.noScope) return;
2517
- target = path.scope;
2518
- path = path.parentPath;
2519
- }
2520
- this.scope = this.getScope(target);
2521
- this.scope?.init();
2522
- }
2523
- function setContext(context) {
2524
- if (this.skipKeys != null) {
2525
- this.skipKeys = {};
2526
- }
2527
- this._traverseFlags = 0;
2528
- if (context) {
2529
- this.context = context;
2530
- this.state = context.state;
2531
- this.opts = context.opts;
2532
- }
2533
- this.setScope();
2534
- return this;
2535
- }
2536
- function resync() {
2537
- if (this.removed) return;
2538
- _resyncParent.call(this);
2539
- _resyncList.call(this);
2540
- _resyncKey.call(this);
2541
- }
2542
- function _resyncParent() {
2543
- if (this.parentPath) {
2544
- this.parent = this.parentPath.node;
2545
- }
2546
- }
2547
- function _resyncKey() {
2548
- if (!this.container) return;
2549
- if (this.node === this.container[this.key]) {
2550
- return;
2551
- }
2552
- if (Array.isArray(this.container)) {
2553
- for (let i = 0; i < this.container.length; i++) {
2554
- if (this.container[i] === this.node) {
2555
- this.setKey(i);
2556
- return;
2557
- }
2558
- }
2559
- } else {
2560
- for (const key of Object.keys(this.container)) {
2561
- if (this.container[key] === this.node) {
2562
- this.setKey(key);
2563
- return;
2564
- }
2565
- }
2566
- }
2567
- this.key = null;
2568
- }
2569
- function _resyncList() {
2570
- if (!this.parent || !this.inList) return;
2571
- const newContainer = this.parent[this.listKey];
2572
- if (this.container === newContainer) return;
2573
- this.container = newContainer || null;
2574
- }
2575
- function popContext() {
2576
- this.contexts.pop();
2577
- if (this.contexts.length > 0) {
2578
- this.setContext(this.contexts[this.contexts.length - 1]);
2579
- } else {
2580
- this.setContext(undefined);
2581
- }
2582
- }
2583
- function pushContext(context) {
2584
- this.contexts.push(context);
2585
- this.setContext(context);
2586
- }
2587
- function setup(parentPath, container, listKey, key) {
2588
- this.listKey = listKey;
2589
- this.container = container;
2590
- this.parentPath = parentPath || this.parentPath;
2591
- this.setKey(key);
2186
+ if (!this.opts?.noScope) {
2187
+ _removeFromScope.call(this);
2188
+ }
2189
+ this.shareCommentsWithSiblings();
2190
+ _remove.call(this);
2191
+ _markRemoved.call(this);
2592
2192
  }
2593
- function setKey(key) {
2594
- this.key = key;
2595
- this.node = this.container[this.key];
2596
- this.type = this.node?.type;
2193
+ function _removeFromScope() {
2194
+ const bindings = getBindingIdentifiers$2(this.node, false, false, true);
2195
+ Object.keys(bindings).forEach(name => this.scope.removeBinding(name));
2597
2196
  }
2598
- function requeue(pathToQueue = this) {
2599
- if (pathToQueue.removed) return;
2600
- {
2601
- pathToQueue.shouldSkip = false;
2602
- }
2603
- const contexts = this.contexts;
2604
- for (const context of contexts) {
2605
- context.maybeQueue(pathToQueue);
2197
+ function _callRemovalHooks() {
2198
+ if (this.parentPath) {
2199
+ for (const fn of hooks) {
2200
+ if (fn(this, this.parentPath)) return true;
2201
+ }
2606
2202
  }
2607
2203
  }
2608
- function requeueComputedKeyAndDecorators() {
2609
- const {
2610
- context,
2611
- node
2612
- } = this;
2613
- if (!_t.isPrivate(node) && node.computed) {
2614
- context.maybeQueue(this.get("key"));
2204
+ function _remove() {
2205
+ if (Array.isArray(this.container)) {
2206
+ this.container.splice(this.key, 1);
2207
+ updateSiblingKeys.call(this, this.key, -1);
2208
+ } else {
2209
+ _replaceWith.call(this, null);
2615
2210
  }
2616
- if (node.decorators) {
2617
- for (const decorator of this.get("decorators")) {
2618
- context.maybeQueue(decorator);
2619
- }
2211
+ }
2212
+ function _markRemoved() {
2213
+ this._traverseFlags |= SHOULD_SKIP | REMOVED;
2214
+ if (this.parent) {
2215
+ getCachedPaths(this.hub, this.parent).delete(this.node);
2620
2216
  }
2217
+ this.node = null;
2621
2218
  }
2622
- function _getQueueContexts() {
2623
- let path = this;
2624
- let contexts = this.contexts;
2625
- while (!contexts.length) {
2626
- path = path.parentPath;
2627
- if (!path) break;
2628
- contexts = path.contexts;
2219
+ function _assertUnremoved() {
2220
+ if (this.removed) {
2221
+ throw this.buildCodeFrameError("NodePath has been removed so is read-only.");
2629
2222
  }
2630
- return contexts;
2631
2223
  }
2632
2224
 
2633
2225
  const {
@@ -2671,7 +2263,7 @@ function insertBefore(nodes_) {
2671
2263
  }
2672
2264
  }
2673
2265
  function _containerInsert(from, nodes) {
2674
- this.updateSiblingKeys(from, nodes.length);
2266
+ updateSiblingKeys.call(this, from, nodes.length);
2675
2267
  const paths = [];
2676
2268
  this.container.splice(from, 0, ...nodes);
2677
2269
  for (let i = 0; i < nodes.length; i++) {
@@ -2679,12 +2271,12 @@ function _containerInsert(from, nodes) {
2679
2271
  const path = this.getSibling(to);
2680
2272
  paths.push(path);
2681
2273
  if (this.context?.queue) {
2682
- path.pushContext(this.context);
2274
+ pushContext.call(path, this.context);
2683
2275
  }
2684
2276
  }
2685
2277
  const contexts = _getQueueContexts.call(this);
2686
2278
  for (const path of paths) {
2687
- path.setScope();
2279
+ setScope.call(path);
2688
2280
  path.debug("Inserted.");
2689
2281
  for (const context of contexts) {
2690
2282
  context.maybeQueue(path, true);
@@ -2774,7 +2366,7 @@ function updateSiblingKeys(fromIndex, incrementBy) {
2774
2366
  if (!this.parent) return;
2775
2367
  const paths = getCachedPaths(this.hub, this.parent) || [];
2776
2368
  for (const [, path] of paths) {
2777
- if (typeof path.key === "number" && path.key >= fromIndex) {
2369
+ if (typeof path.key === "number" && path.container === this.container && path.key >= fromIndex) {
2778
2370
  path.key += incrementBy;
2779
2371
  }
2780
2372
  }
@@ -2830,10 +2422,6 @@ function pushContainer(listKey, nodes) {
2830
2422
  }).setContext(this.context);
2831
2423
  return path.replaceWithMultiple(verifiedNodes);
2832
2424
  }
2833
- function hoist(scope = this.scope) {
2834
- const hoister = new PathHoister(this, scope);
2835
- return hoister.run();
2836
- }
2837
2425
 
2838
2426
  const {
2839
2427
  FUNCTION_TYPES,
@@ -2866,7 +2454,7 @@ const {
2866
2454
  yieldExpression
2867
2455
  } = _t;
2868
2456
  function replaceWithMultiple(nodes) {
2869
- this.resync();
2457
+ resync.call(this);
2870
2458
  nodes = _verifyNodeList.call(this, nodes);
2871
2459
  inheritLeadingComments(nodes[0], this.node);
2872
2460
  inheritTrailingComments(nodes[nodes.length - 1], this.node);
@@ -2881,7 +2469,7 @@ function replaceWithMultiple(nodes) {
2881
2469
  return paths;
2882
2470
  }
2883
2471
  function replaceWithSourceString(replacement) {
2884
- this.resync();
2472
+ resync.call(this);
2885
2473
  let ast;
2886
2474
  try {
2887
2475
  replacement = `(${replacement})`;
@@ -2904,7 +2492,7 @@ function replaceWithSourceString(replacement) {
2904
2492
  return this.replaceWith(expressionAST);
2905
2493
  }
2906
2494
  function replaceWith(replacementPath) {
2907
- this.resync();
2495
+ resync.call(this);
2908
2496
  if (this.removed) {
2909
2497
  throw new Error("You can't replace this node, we've already removed it");
2910
2498
  }
@@ -2943,7 +2531,7 @@ function replaceWith(replacementPath) {
2943
2531
  }
2944
2532
  _replaceWith.call(this, replacement);
2945
2533
  this.type = replacement.type;
2946
- this.setScope();
2534
+ setScope.call(this);
2947
2535
  this.requeue();
2948
2536
  return [nodePath ? this.get(nodePath) : this];
2949
2537
  }
@@ -2961,7 +2549,7 @@ function _replaceWith(node) {
2961
2549
  this.node = this.container[this.key] = node;
2962
2550
  }
2963
2551
  function replaceExpressionWithStatements(nodes) {
2964
- this.resync();
2552
+ resync.call(this);
2965
2553
  const declars = [];
2966
2554
  const nodesAsSingleExpression = gatherSequenceExpressions(nodes, declars);
2967
2555
  if (nodesAsSingleExpression) {
@@ -2971,8 +2559,8 @@ function replaceExpressionWithStatements(nodes) {
2971
2559
  return this.replaceWith(nodesAsSingleExpression)[0].get("expressions");
2972
2560
  }
2973
2561
  const functionParent = this.getFunctionParent();
2974
- const isParentAsync = functionParent?.is("async");
2975
- const isParentGenerator = functionParent?.is("generator");
2562
+ const isParentAsync = functionParent?.node.async;
2563
+ const isParentGenerator = functionParent?.node.generator;
2976
2564
  const container = arrowFunctionExpression$1([], blockStatement$1(nodes));
2977
2565
  this.replaceWith(callExpression$1(container, []));
2978
2566
  const callee = this.get("callee");
@@ -3061,7 +2649,7 @@ function gatherSequenceExpressions(nodes, declars) {
3061
2649
  }
3062
2650
  }
3063
2651
  function replaceInline(nodes) {
3064
- this.resync();
2652
+ resync.call(this);
3065
2653
  if (Array.isArray(nodes)) {
3066
2654
  if (Array.isArray(this.container)) {
3067
2655
  nodes = _verifyNodeList.call(this, nodes);
@@ -3499,7 +3087,7 @@ function ensureBlock() {
3499
3087
  }
3500
3088
  this.node.body = blockStatement(statements);
3501
3089
  const parentPath = this.get(stringPath);
3502
- body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
3090
+ setup.call(body, parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
3503
3091
  return this.node;
3504
3092
  }
3505
3093
  function unwrapFunctionEnvironment() {
@@ -4014,24 +3602,9 @@ const {
4014
3602
  function matchesPattern(pattern, allowPartial) {
4015
3603
  return _matchesPattern(this.node, pattern, allowPartial);
4016
3604
  }
4017
- function has(key) {
4018
- const val = this.node?.[key];
4019
- if (val && Array.isArray(val)) {
4020
- return !!val.length;
4021
- } else {
4022
- return !!val;
4023
- }
4024
- }
4025
3605
  function isStatic() {
4026
3606
  return this.scope.isStatic(this.node);
4027
3607
  }
4028
- const is = has;
4029
- function isnt(key) {
4030
- return !this.has(key);
4031
- }
4032
- function equals(key, value) {
4033
- return this.node[key] === value;
4034
- }
4035
3608
  function isNodeType(type) {
4036
3609
  return isType(this.type, type);
4037
3610
  }
@@ -4794,7 +4367,7 @@ const NodePath_Final = class NodePath {
4794
4367
  path = new NodePath(hub, parent);
4795
4368
  if (targetNode) paths.set(targetNode, path);
4796
4369
  }
4797
- path.setup(parentPath, container, listKey, key);
4370
+ setup.call(path, parentPath, container, listKey, key);
4798
4371
  return path;
4799
4372
  }
4800
4373
  getScope(scope) {
@@ -4886,11 +4459,7 @@ const methods = {
4886
4459
  splitExportDeclaration: splitExportDeclaration,
4887
4460
  ensureFunctionName: ensureFunctionName,
4888
4461
  matchesPattern: matchesPattern,
4889
- has: has,
4890
4462
  isStatic: isStatic,
4891
- is: is,
4892
- isnt: isnt,
4893
- equals: equals,
4894
4463
  isNodeType: isNodeType,
4895
4464
  canHaveVariableDeclarationOrExpression: canHaveVariableDeclarationOrExpression,
4896
4465
  canSwapBetweenExpressionAndStatement: canSwapBetweenExpressionAndStatement,
@@ -4903,29 +4472,19 @@ const methods = {
4903
4472
  resolve: resolve,
4904
4473
  isConstantExpression: isConstantExpression,
4905
4474
  isInStrictMode: isInStrictMode,
4906
- call: call,
4907
4475
  isDenylisted: isDenylisted,
4908
- isBlacklisted: isDenylisted,
4909
4476
  visit: visit,
4910
4477
  skip: skip,
4911
4478
  skipKey: skipKey,
4912
4479
  stop: stop,
4913
- setScope: setScope,
4914
4480
  setContext: setContext,
4915
- resync: resync,
4916
- popContext: popContext,
4917
- pushContext: pushContext,
4918
- setup: setup,
4919
- setKey: setKey,
4920
4481
  requeue: requeue,
4921
4482
  requeueComputedKeyAndDecorators: requeueComputedKeyAndDecorators,
4922
4483
  remove: remove,
4923
4484
  insertBefore: insertBefore,
4924
4485
  insertAfter: insertAfter,
4925
- updateSiblingKeys: updateSiblingKeys,
4926
4486
  unshiftContainer: unshiftContainer,
4927
4487
  pushContainer: pushContainer,
4928
- hoist: hoist,
4929
4488
  getOpposite: getOpposite,
4930
4489
  getCompletionRecords: getCompletionRecords,
4931
4490
  getSibling: getSibling,
@@ -5032,9 +4591,9 @@ class TraversalContext {
5032
4591
  for (; visitIndex < queue.length;) {
5033
4592
  const path = queue[visitIndex];
5034
4593
  visitIndex++;
5035
- path.resync();
4594
+ resync.call(path);
5036
4595
  if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
5037
- path.pushContext(this);
4596
+ pushContext.call(path, this);
5038
4597
  }
5039
4598
  if (path.key === null) continue;
5040
4599
  const {
@@ -5054,7 +4613,7 @@ class TraversalContext {
5054
4613
  }
5055
4614
  }
5056
4615
  for (let i = 0; i < visitIndex; i++) {
5057
- queue[i].popContext();
4616
+ popContext.call(queue[i]);
5058
4617
  }
5059
4618
  this.queue = null;
5060
4619
  return stop;
@@ -5090,6 +4649,205 @@ function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
5090
4649
  return false;
5091
4650
  }
5092
4651
 
4652
+ function call(key) {
4653
+ const opts = this.opts;
4654
+ this.debug(key);
4655
+ if (this.node) {
4656
+ if (_call.call(this, opts[key])) return true;
4657
+ }
4658
+ if (this.node) {
4659
+ return _call.call(this, opts[this.node.type]?.[key]);
4660
+ }
4661
+ return false;
4662
+ }
4663
+ function _call(fns) {
4664
+ if (!fns) return false;
4665
+ for (const fn of fns) {
4666
+ if (!fn) continue;
4667
+ const node = this.node;
4668
+ if (!node) return true;
4669
+ const ret = fn.call(this.state, this, this.state);
4670
+ if (ret && typeof ret === "object" && typeof ret.then === "function") {
4671
+ 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.`);
4672
+ }
4673
+ if (ret) {
4674
+ throw new Error(`Unexpected return value from visitor method ${fn}`);
4675
+ }
4676
+ if (this.node !== node) return true;
4677
+ if (this._traverseFlags > 0) return true;
4678
+ }
4679
+ return false;
4680
+ }
4681
+ function isDenylisted() {
4682
+ const denylist = this.opts.denylist ?? this.opts.blacklist;
4683
+ return denylist?.includes(this.node.type);
4684
+ }
4685
+ function restoreContext(path, context) {
4686
+ if (path.context !== context) {
4687
+ path.context = context;
4688
+ path.state = context.state;
4689
+ path.opts = context.opts;
4690
+ }
4691
+ }
4692
+ function visit() {
4693
+ if (!this.node) {
4694
+ return false;
4695
+ }
4696
+ if (this.isDenylisted()) {
4697
+ return false;
4698
+ }
4699
+ if (this.opts.shouldSkip?.(this)) {
4700
+ return false;
4701
+ }
4702
+ const currentContext = this.context;
4703
+ if (this.shouldSkip || call.call(this, "enter")) {
4704
+ this.debug("Skip...");
4705
+ return this.shouldStop;
4706
+ }
4707
+ restoreContext(this, currentContext);
4708
+ this.debug("Recursing into...");
4709
+ this.shouldStop = traverseNode(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
4710
+ restoreContext(this, currentContext);
4711
+ call.call(this, "exit");
4712
+ return this.shouldStop;
4713
+ }
4714
+ function skip() {
4715
+ this.shouldSkip = true;
4716
+ }
4717
+ function skipKey(key) {
4718
+ if (this.skipKeys == null) {
4719
+ this.skipKeys = {};
4720
+ }
4721
+ this.skipKeys[key] = true;
4722
+ }
4723
+ function stop() {
4724
+ this._traverseFlags |= SHOULD_SKIP | SHOULD_STOP;
4725
+ }
4726
+ function setScope() {
4727
+ if (this.opts?.noScope) return;
4728
+ let path = this.parentPath;
4729
+ if ((this.key === "key" || this.listKey === "decorators") && path.isMethod() || this.key === "discriminant" && path.isSwitchStatement()) {
4730
+ path = path.parentPath;
4731
+ }
4732
+ let target;
4733
+ while (path && !target) {
4734
+ if (path.opts?.noScope) return;
4735
+ target = path.scope;
4736
+ path = path.parentPath;
4737
+ }
4738
+ this.scope = this.getScope(target);
4739
+ this.scope?.init();
4740
+ }
4741
+ function setContext(context) {
4742
+ if (this.skipKeys != null) {
4743
+ this.skipKeys = {};
4744
+ }
4745
+ this._traverseFlags = 0;
4746
+ if (context) {
4747
+ this.context = context;
4748
+ this.state = context.state;
4749
+ this.opts = context.opts;
4750
+ }
4751
+ setScope.call(this);
4752
+ return this;
4753
+ }
4754
+ function resync() {
4755
+ if (this.removed) return;
4756
+ _resyncParent.call(this);
4757
+ _resyncList.call(this);
4758
+ _resyncKey.call(this);
4759
+ }
4760
+ function _resyncParent() {
4761
+ if (this.parentPath) {
4762
+ this.parent = this.parentPath.node;
4763
+ }
4764
+ }
4765
+ function _resyncKey() {
4766
+ if (!this.container) return;
4767
+ if (this.node === this.container[this.key]) {
4768
+ return;
4769
+ }
4770
+ if (Array.isArray(this.container)) {
4771
+ for (let i = 0; i < this.container.length; i++) {
4772
+ if (this.container[i] === this.node) {
4773
+ setKey.call(this, i);
4774
+ return;
4775
+ }
4776
+ }
4777
+ } else {
4778
+ for (const key of Object.keys(this.container)) {
4779
+ if (this.container[key] === this.node) {
4780
+ setKey.call(this, key);
4781
+ return;
4782
+ }
4783
+ }
4784
+ }
4785
+ this.key = null;
4786
+ }
4787
+ function _resyncList() {
4788
+ if (!this.parent || !this.inList) return;
4789
+ const newContainer = this.parent[this.listKey];
4790
+ if (this.container === newContainer) return;
4791
+ this.container = newContainer || null;
4792
+ }
4793
+ function popContext() {
4794
+ this.contexts.pop();
4795
+ if (this.contexts.length > 0) {
4796
+ this.setContext(this.contexts[this.contexts.length - 1]);
4797
+ } else {
4798
+ this.setContext(undefined);
4799
+ }
4800
+ }
4801
+ function pushContext(context) {
4802
+ this.contexts.push(context);
4803
+ this.setContext(context);
4804
+ }
4805
+ function setup(parentPath, container, listKey, key) {
4806
+ this.listKey = listKey;
4807
+ this.container = container;
4808
+ this.parentPath = parentPath || this.parentPath;
4809
+ setKey.call(this, key);
4810
+ }
4811
+ function setKey(key) {
4812
+ this.key = key;
4813
+ this.node = this.container[this.key];
4814
+ this.type = this.node?.type;
4815
+ }
4816
+ function requeue(pathToQueue = this) {
4817
+ if (pathToQueue.removed) return;
4818
+ {
4819
+ pathToQueue.shouldSkip = false;
4820
+ }
4821
+ const contexts = this.contexts;
4822
+ for (const context of contexts) {
4823
+ context.maybeQueue(pathToQueue);
4824
+ }
4825
+ }
4826
+ function requeueComputedKeyAndDecorators() {
4827
+ const {
4828
+ context,
4829
+ node
4830
+ } = this;
4831
+ if (!_t.isPrivate(node) && node.computed) {
4832
+ context.maybeQueue(this.get("key"));
4833
+ }
4834
+ if (node.decorators) {
4835
+ for (const decorator of this.get("decorators")) {
4836
+ context.maybeQueue(decorator);
4837
+ }
4838
+ }
4839
+ }
4840
+ function _getQueueContexts() {
4841
+ let path = this;
4842
+ let contexts = this.contexts;
4843
+ while (!contexts.length) {
4844
+ path = path.parentPath;
4845
+ if (!path) break;
4846
+ contexts = path.contexts;
4847
+ }
4848
+ return contexts;
4849
+ }
4850
+
5093
4851
  class Hub {
5094
4852
  getCode() {}
5095
4853
  getScope() {}