@babel/traverse 7.17.9 → 7.23.2

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.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/lib/cache.js +27 -7
  3. package/lib/cache.js.map +1 -0
  4. package/lib/context.js +9 -31
  5. package/lib/context.js.map +1 -0
  6. package/lib/hub.js +2 -6
  7. package/lib/hub.js.map +1 -0
  8. package/lib/index.js +17 -33
  9. package/lib/index.js.map +1 -0
  10. package/lib/path/ancestry.js +3 -42
  11. package/lib/path/ancestry.js.map +1 -0
  12. package/lib/path/comments.js +23 -11
  13. package/lib/path/comments.js.map +1 -0
  14. package/lib/path/context.js +24 -65
  15. package/lib/path/context.js.map +1 -0
  16. package/lib/path/conversion.js +37 -100
  17. package/lib/path/conversion.js.map +1 -0
  18. package/lib/path/evaluation.js +69 -123
  19. package/lib/path/evaluation.js.map +1 -0
  20. package/lib/path/family.js +5 -76
  21. package/lib/path/family.js.map +1 -0
  22. package/lib/path/index.js +26 -90
  23. package/lib/path/index.js.map +1 -0
  24. package/lib/path/inference/index.js +26 -33
  25. package/lib/path/inference/index.js.map +1 -0
  26. package/lib/path/inference/inferer-reference.js +6 -61
  27. package/lib/path/inference/inferer-reference.js.map +1 -0
  28. package/lib/path/inference/inferers.js +32 -86
  29. package/lib/path/inference/inferers.js.map +1 -0
  30. package/lib/path/inference/util.js +30 -0
  31. package/lib/path/inference/util.js.map +1 -0
  32. package/lib/path/introspection.js +54 -105
  33. package/lib/path/introspection.js.map +1 -0
  34. package/lib/path/lib/hoister.js +2 -37
  35. package/lib/path/lib/hoister.js.map +1 -0
  36. package/lib/path/lib/removal-hooks.js +4 -4
  37. package/lib/path/lib/removal-hooks.js.map +1 -0
  38. package/lib/path/lib/virtual-types-validator.js +161 -0
  39. package/lib/path/lib/virtual-types-validator.js.map +1 -0
  40. package/lib/path/lib/virtual-types.js +20 -206
  41. package/lib/path/lib/virtual-types.js.map +1 -0
  42. package/lib/path/modification.js +17 -61
  43. package/lib/path/modification.js.map +1 -0
  44. package/lib/path/removal.js +9 -22
  45. package/lib/path/removal.js.map +1 -0
  46. package/lib/path/replacement.js +17 -72
  47. package/lib/path/replacement.js.map +1 -0
  48. package/lib/scope/binding.js +20 -12
  49. package/lib/scope/binding.js.map +1 -0
  50. package/lib/scope/index.js +115 -245
  51. package/lib/scope/index.js.map +1 -0
  52. package/lib/scope/lib/renamer.js +41 -74
  53. package/lib/scope/lib/renamer.js.map +1 -0
  54. package/lib/traverse-node.js +10 -11
  55. package/lib/traverse-node.js.map +1 -0
  56. package/lib/types.js +1 -3
  57. package/lib/types.js.map +1 -0
  58. package/lib/visitors.js +59 -83
  59. package/lib/visitors.js.map +1 -0
  60. package/package.json +13 -11
  61. package/lib/path/generated/asserts.js +0 -5
  62. package/lib/path/generated/validators.js +0 -5
  63. package/lib/path/generated/virtual-types.js +0 -3
  64. package/scripts/generators/asserts.js +0 -25
  65. package/scripts/generators/validators.js +0 -42
  66. package/scripts/generators/virtual-types.js +0 -24
  67. package/scripts/package.json +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
4
4
 
5
- See our website [@babel/traverse](https://babeljs.io/docs/en/babel-traverse) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen) associated with this package.
5
+ See our website [@babel/traverse](https://babeljs.io/docs/babel-traverse) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20traverse%22+is%3Aopen) associated with this package.
6
6
 
7
7
  ## Install
8
8
 
package/lib/cache.js CHANGED
@@ -6,21 +6,41 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.clear = clear;
7
7
  exports.clearPath = clearPath;
8
8
  exports.clearScope = clearScope;
9
+ exports.getCachedPaths = getCachedPaths;
10
+ exports.getOrCreateCachedPaths = getOrCreateCachedPaths;
9
11
  exports.scope = exports.path = void 0;
10
- let path = new WeakMap();
11
- exports.path = path;
12
+ let pathsCache = new WeakMap();
13
+ exports.path = pathsCache;
12
14
  let scope = new WeakMap();
13
15
  exports.scope = scope;
14
-
15
16
  function clear() {
16
17
  clearPath();
17
18
  clearScope();
18
19
  }
19
-
20
20
  function clearPath() {
21
- exports.path = path = new WeakMap();
21
+ exports.path = pathsCache = new WeakMap();
22
22
  }
23
-
24
23
  function clearScope() {
25
24
  exports.scope = scope = new WeakMap();
26
- }
25
+ }
26
+ const nullHub = Object.freeze({});
27
+ function getCachedPaths(hub, parent) {
28
+ var _pathsCache$get, _hub;
29
+ {
30
+ hub = null;
31
+ }
32
+ return (_pathsCache$get = pathsCache.get((_hub = hub) != null ? _hub : nullHub)) == null ? void 0 : _pathsCache$get.get(parent);
33
+ }
34
+ function getOrCreateCachedPaths(hub, parent) {
35
+ var _hub2, _hub3;
36
+ {
37
+ hub = null;
38
+ }
39
+ let parents = pathsCache.get((_hub2 = hub) != null ? _hub2 : nullHub);
40
+ if (!parents) pathsCache.set((_hub3 = hub) != null ? _hub3 : nullHub, parents = new WeakMap());
41
+ let paths = parents.get(parent);
42
+ if (!paths) parents.set(parent, paths = new Map());
43
+ return paths;
44
+ }
45
+
46
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pathsCache","WeakMap","exports","path","scope","clear","clearPath","clearScope","nullHub","Object","freeze","getCachedPaths","hub","parent","_pathsCache$get","_hub","get","getOrCreateCachedPaths","_hub2","_hub3","parents","set","paths","Map"],"sources":["../src/cache.ts"],"sourcesContent":["import type { Node } from \"@babel/types\";\nimport type NodePath from \"./path/index.ts\";\nimport type Scope from \"./scope/index.ts\";\nimport type { HubInterface } from \"./hub.ts\";\n\nlet pathsCache: WeakMap<\n HubInterface | typeof nullHub,\n WeakMap<Node, Map<Node, NodePath>>\n> = new WeakMap();\nexport { pathsCache as path };\nexport let scope: WeakMap<Node, Scope> = new WeakMap();\n\nexport function clear() {\n clearPath();\n clearScope();\n}\n\nexport function clearPath() {\n pathsCache = new WeakMap();\n}\n\nexport function clearScope() {\n scope = new WeakMap();\n}\n\n// NodePath#hub can be null, but it's not a valid weakmap key because it\n// cannot be collected by GC. Use an object, knowing tht it will not be\n// collected anyway. It's not a memory leak because pathsCache.get(nullHub)\n// is itself a weakmap, so its entries can still be collected.\nconst nullHub = Object.freeze({} as const);\n\nexport function getCachedPaths(hub: HubInterface | null, parent: Node) {\n if (!process.env.BABEL_8_BREAKING) {\n // Only use Hub as part of the cache key in Babel 8, because it is a\n // breaking change (it causes incompatibilities with older `@babel/core`\n // versions: see https://github.com/babel/babel/pull/15759)\n hub = null;\n }\n return pathsCache.get(hub ?? nullHub)?.get(parent);\n}\n\nexport function getOrCreateCachedPaths(hub: HubInterface | null, parent: Node) {\n if (!process.env.BABEL_8_BREAKING) {\n hub = null;\n }\n\n let parents = pathsCache.get(hub ?? nullHub);\n if (!parents) pathsCache.set(hub ?? nullHub, (parents = new WeakMap()));\n\n let paths = parents.get(parent);\n if (!paths) parents.set(parent, (paths = new Map()));\n\n return paths;\n}\n"],"mappings":";;;;;;;;;;;AAKA,IAAIA,UAGH,GAAG,IAAIC,OAAO,CAAC,CAAC;AAACC,OAAA,CAAAC,IAAA,GAAAH,UAAA;AAEX,IAAII,KAA2B,GAAG,IAAIH,OAAO,CAAC,CAAC;AAACC,OAAA,CAAAE,KAAA,GAAAA,KAAA;AAEhD,SAASC,KAAKA,CAAA,EAAG;EACtBC,SAAS,CAAC,CAAC;EACXC,UAAU,CAAC,CAAC;AACd;AAEO,SAASD,SAASA,CAAA,EAAG;EAC1BJ,OAAA,CAAAC,IAAA,GAAAH,UAAU,GAAG,IAAIC,OAAO,CAAC,CAAC;AAC5B;AAEO,SAASM,UAAUA,CAAA,EAAG;EAC3BL,OAAA,CAAAE,KAAA,GAAAA,KAAK,GAAG,IAAIH,OAAO,CAAC,CAAC;AACvB;AAMA,MAAMO,OAAO,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAU,CAAC;AAEnC,SAASC,cAAcA,CAACC,GAAwB,EAAEC,MAAY,EAAE;EAAA,IAAAC,eAAA,EAAAC,IAAA;EAClC;IAIjCH,GAAG,GAAG,IAAI;EACZ;EACA,QAAAE,eAAA,GAAOd,UAAU,CAACgB,GAAG,EAAAD,IAAA,GAACH,GAAG,YAAAG,IAAA,GAAIP,OAAO,CAAC,qBAA9BM,eAAA,CAAgCE,GAAG,CAACH,MAAM,CAAC;AACpD;AAEO,SAASI,sBAAsBA,CAACL,GAAwB,EAAEC,MAAY,EAAE;EAAA,IAAAK,KAAA,EAAAC,KAAA;EAC1C;IACjCP,GAAG,GAAG,IAAI;EACZ;EAEA,IAAIQ,OAAO,GAAGpB,UAAU,CAACgB,GAAG,EAAAE,KAAA,GAACN,GAAG,YAAAM,KAAA,GAAIV,OAAO,CAAC;EAC5C,IAAI,CAACY,OAAO,EAAEpB,UAAU,CAACqB,GAAG,EAAAF,KAAA,GAACP,GAAG,YAAAO,KAAA,GAAIX,OAAO,EAAGY,OAAO,GAAG,IAAInB,OAAO,CAAC,CAAE,CAAC;EAEvE,IAAIqB,KAAK,GAAGF,OAAO,CAACJ,GAAG,CAACH,MAAM,CAAC;EAC/B,IAAI,CAACS,KAAK,EAAEF,OAAO,CAACC,GAAG,CAACR,MAAM,EAAGS,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAE,CAAC;EAEpD,OAAOD,KAAK;AACd"}
package/lib/context.js CHANGED
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
- var _path = require("./path");
9
-
7
+ var _index = require("./path/index.js");
10
8
  var _t = require("@babel/types");
11
-
12
9
  const {
13
10
  VISITOR_KEYS
14
11
  } = _t;
15
-
16
12
  class TraversalContext {
17
13
  constructor(scope, opts, state, parentPath) {
18
14
  this.queue = null;
@@ -22,31 +18,28 @@ class TraversalContext {
22
18
  this.state = state;
23
19
  this.opts = opts;
24
20
  }
25
-
26
21
  shouldVisit(node) {
27
22
  const opts = this.opts;
28
23
  if (opts.enter || opts.exit) return true;
29
24
  if (opts[node.type]) return true;
30
25
  const keys = VISITOR_KEYS[node.type];
31
26
  if (!(keys != null && keys.length)) return false;
32
-
33
27
  for (const key of keys) {
34
- if (node[key]) return true;
28
+ if (node[key]) {
29
+ return true;
30
+ }
35
31
  }
36
-
37
32
  return false;
38
33
  }
39
-
40
- create(node, obj, key, listKey) {
41
- return _path.default.get({
34
+ create(node, container, key, listKey) {
35
+ return _index.default.get({
42
36
  parentPath: this.parentPath,
43
37
  parent: node,
44
- container: obj,
38
+ container,
45
39
  key: key,
46
40
  listKey
47
41
  });
48
42
  }
49
-
50
43
  maybeQueue(path, notPriority) {
51
44
  if (this.queue) {
52
45
  if (notPriority) {
@@ -56,22 +49,17 @@ class TraversalContext {
56
49
  }
57
50
  }
58
51
  }
59
-
60
52
  visitMultiple(container, parent, listKey) {
61
53
  if (container.length === 0) return false;
62
54
  const queue = [];
63
-
64
55
  for (let key = 0; key < container.length; key++) {
65
56
  const node = container[key];
66
-
67
57
  if (node && this.shouldVisit(node)) {
68
58
  queue.push(this.create(parent, container, key, listKey));
69
59
  }
70
60
  }
71
-
72
61
  return this.visitQueue(queue);
73
62
  }
74
-
75
63
  visitSingle(node, key) {
76
64
  if (this.shouldVisit(node[key])) {
77
65
  return this.visitQueue([this.create(node, node, key)]);
@@ -79,32 +67,26 @@ class TraversalContext {
79
67
  return false;
80
68
  }
81
69
  }
82
-
83
70
  visitQueue(queue) {
84
71
  this.queue = queue;
85
72
  this.priorityQueue = [];
86
73
  const visited = new WeakSet();
87
74
  let stop = false;
88
-
89
75
  for (const path of queue) {
90
76
  path.resync();
91
-
92
77
  if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
93
78
  path.pushContext(this);
94
79
  }
95
-
96
80
  if (path.key === null) continue;
97
81
  const {
98
82
  node
99
83
  } = path;
100
84
  if (visited.has(node)) continue;
101
85
  if (node) visited.add(node);
102
-
103
86
  if (path.visit()) {
104
87
  stop = true;
105
88
  break;
106
89
  }
107
-
108
90
  if (this.priorityQueue.length) {
109
91
  stop = this.visitQueue(this.priorityQueue);
110
92
  this.priorityQueue = [];
@@ -112,26 +94,22 @@ class TraversalContext {
112
94
  if (stop) break;
113
95
  }
114
96
  }
115
-
116
97
  for (const path of queue) {
117
98
  path.popContext();
118
99
  }
119
-
120
100
  this.queue = null;
121
101
  return stop;
122
102
  }
123
-
124
103
  visit(node, key) {
125
104
  const nodes = node[key];
126
105
  if (!nodes) return false;
127
-
128
106
  if (Array.isArray(nodes)) {
129
107
  return this.visitMultiple(nodes, node, key);
130
108
  } else {
131
109
  return this.visitSingle(node, key);
132
110
  }
133
111
  }
134
-
135
112
  }
113
+ exports.default = TraversalContext;
136
114
 
137
- exports.default = TraversalContext;
115
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_index","require","_t","VISITOR_KEYS","TraversalContext","constructor","scope","opts","state","parentPath","queue","priorityQueue","shouldVisit","node","enter","exit","type","keys","length","key","create","container","listKey","NodePath","get","parent","maybeQueue","path","notPriority","push","visitMultiple","visitQueue","visitSingle","visited","WeakSet","stop","resync","contexts","pushContext","has","add","visit","popContext","nodes","Array","isArray","exports","default"],"sources":["../src/context.ts"],"sourcesContent":["import NodePath from \"./path/index.ts\";\nimport { VISITOR_KEYS } from \"@babel/types\";\nimport type Scope from \"./scope/index.ts\";\nimport type { ExplodedTraverseOptions } from \"./index.ts\";\nimport type * as t from \"@babel/types\";\nimport type { Visitor } from \"./types.ts\";\n\nexport default class TraversalContext<S = unknown> {\n constructor(\n scope: Scope,\n opts: ExplodedTraverseOptions<S>,\n state: S,\n parentPath: NodePath,\n ) {\n this.parentPath = parentPath;\n this.scope = scope;\n this.state = state;\n this.opts = opts;\n }\n\n declare parentPath: NodePath;\n declare scope: Scope;\n declare state: S;\n declare opts: ExplodedTraverseOptions<S>;\n queue: Array<NodePath> | null = null;\n priorityQueue: Array<NodePath> | null = null;\n\n /**\n * This method does a simple check to determine whether or not we really need to attempt\n * visit a node. This will prevent us from constructing a NodePath.\n */\n\n shouldVisit(node: t.Node): boolean {\n const opts = this.opts as Visitor;\n if (opts.enter || opts.exit) return true;\n\n // check if we have a visitor for this node\n if (opts[node.type]) return true;\n\n // check if we're going to traverse into this node\n const keys: Array<string> | undefined = VISITOR_KEYS[node.type];\n if (!keys?.length) return false;\n\n // we need to traverse into this node so ensure that it has children to traverse into!\n for (const key of keys) {\n if (\n // @ts-expect-error key is from visitor keys\n node[key]\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n create(\n node: t.Node,\n container: t.Node | t.Node[],\n key: string | number,\n listKey?: string,\n ): NodePath {\n // We don't need to `.setContext()` here, since `.visitQueue()` already\n // calls `.pushContext`.\n return NodePath.get({\n parentPath: this.parentPath,\n parent: node,\n container,\n key: key,\n listKey,\n });\n }\n\n maybeQueue(path: NodePath, notPriority?: boolean) {\n if (this.queue) {\n if (notPriority) {\n this.queue.push(path);\n } else {\n this.priorityQueue.push(path);\n }\n }\n }\n\n visitMultiple(container: t.Node[], parent: t.Node, listKey: string) {\n // nothing to traverse!\n if (container.length === 0) return false;\n\n const queue = [];\n\n // build up initial queue\n for (let key = 0; key < container.length; key++) {\n const node = container[key];\n if (node && this.shouldVisit(node)) {\n queue.push(this.create(parent, container, key, listKey));\n }\n }\n\n return this.visitQueue(queue);\n }\n\n visitSingle(node: t.Node, key: string): boolean {\n if (\n this.shouldVisit(\n // @ts-expect-error key may not index node\n node[key],\n )\n ) {\n return this.visitQueue([this.create(node, node, key)]);\n } else {\n return false;\n }\n }\n\n visitQueue(queue: Array<NodePath>): boolean {\n // set queue\n this.queue = queue;\n this.priorityQueue = [];\n\n const visited = new WeakSet();\n let stop = false;\n\n // visit the queue\n for (const path of queue) {\n path.resync();\n\n if (\n path.contexts.length === 0 ||\n path.contexts[path.contexts.length - 1] !== this\n ) {\n // The context might already have been pushed when this path was inserted and queued.\n // If we always re-pushed here, we could get duplicates and risk leaving contexts\n // on the stack after the traversal has completed, which could break things.\n path.pushContext(this);\n }\n\n // this path no longer belongs to the tree\n if (path.key === null) continue;\n\n // ensure we don't visit the same node twice\n const { node } = path;\n if (visited.has(node)) continue;\n if (node) visited.add(node);\n\n if (path.visit()) {\n stop = true;\n break;\n }\n\n if (this.priorityQueue.length) {\n stop = this.visitQueue(this.priorityQueue);\n this.priorityQueue = [];\n this.queue = queue;\n if (stop) break;\n }\n }\n\n // clear queue\n for (const path of queue) {\n path.popContext();\n }\n\n // clear queue\n this.queue = null;\n\n return stop;\n }\n\n visit(node: t.Node, key: string) {\n // @ts-expect-error key may not index node\n const nodes = node[key] as t.Node | t.Node[] | null;\n if (!nodes) return false;\n\n if (Array.isArray(nodes)) {\n return this.visitMultiple(nodes, node, key);\n } else {\n return this.visitSingle(node, key);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,EAAA,GAAAD,OAAA;AAA4C;EAAnCE;AAAY,IAAAD,EAAA;AAMN,MAAME,gBAAgB,CAAc;EACjDC,WAAWA,CACTC,KAAY,EACZC,IAAgC,EAChCC,KAAQ,EACRC,UAAoB,EACpB;IAAA,KAWFC,KAAK,GAA2B,IAAI;IAAA,KACpCC,aAAa,GAA2B,IAAI;IAX1C,IAAI,CAACF,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACH,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACE,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACD,IAAI,GAAGA,IAAI;EAClB;EAcAK,WAAWA,CAACC,IAAY,EAAW;IACjC,MAAMN,IAAI,GAAG,IAAI,CAACA,IAAe;IACjC,IAAIA,IAAI,CAACO,KAAK,IAAIP,IAAI,CAACQ,IAAI,EAAE,OAAO,IAAI;IAGxC,IAAIR,IAAI,CAACM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AAI,CAACxB,aAAa,CAACO,MAAM,EAAE;QAC7BiB,IAAI,GAAG,IAAI,CAACJ,UAAU,CAAC,IAAI,CAACpB,aAAa,CAAC;QAC1C,IAAI,CAACA,aAAa,GAAG,EAAE;QACvB,IAAI,CAACD,KAAK,GAAGA,KAAK;QAClB,IAAIyB,IAAI,EAAE;MACZ;IACF;IAGA,KAAK,MAAMR,IAAI,IAAIjB,KAAK,EAAE;MACxBiB,IAAI,CAACe,UAAU,CAAC,CAAC;IACnB;IAGA,IAAI,CAAChC,KAAK,GAAG,IAAI;IAEjB,OAAOyB,IAAI;EACb;EAEAM,KAAKA,CAAC5B,IAAY,EAAEM,GAAW,EAAE;IAE/B,MAAMwB,KAAK,GAAG9B,IAAI,CAACM,GAAG,CAA6B;IACnD,IAAI,CAACwB,KAAK,EAAE,OAAO,KAAK;IAExB,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACxB,OAAO,IAAI,CAACb,aAAa,CAACa,KAAK,EAAE9B,IAAI,EAAEM,GAAG,CAAC;IAC7C,CAAC,MAAM;MACL,OAAO,IAAI,CAACa,WAAW,CAACnB,IAAI,EAAEM,GAAG,CAAC;IACpC;EACF;AACF;AAAC2B,OAAA,CAAAC,OAAA,GAAA3C,gBAAA"}
package/lib/hub.js CHANGED
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  class Hub {
9
8
  getCode() {}
10
-
11
9
  getScope() {}
12
-
13
10
  addHelper() {
14
11
  throw new Error("Helpers are not supported by the default hub.");
15
12
  }
16
-
17
13
  buildError(node, msg, Error = TypeError) {
18
14
  return new Error(msg);
19
15
  }
20
-
21
16
  }
17
+ exports.default = Hub;
22
18
 
23
- exports.default = Hub;
19
+ //# sourceMappingURL=hub.js.map
package/lib/hub.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Hub","getCode","getScope","addHelper","Error","buildError","node","msg","TypeError","exports","default"],"sources":["../src/hub.ts"],"sourcesContent":["import type Scope from \"./scope/index.ts\";\nimport type { Node } from \"@babel/types\";\n\nexport interface HubInterface {\n getCode(): string | void;\n getScope(): Scope | void;\n addHelper(name: string): any;\n buildError(node: Node, msg: string, Error: new () => Error): Error;\n}\n\nexport default class Hub implements HubInterface {\n getCode() {}\n\n getScope() {}\n\n addHelper() {\n throw new Error(\"Helpers are not supported by the default hub.\");\n }\n\n buildError(node: Node, msg: string, Error = TypeError): Error {\n return new Error(msg);\n }\n}\n"],"mappings":";;;;;;AAUe,MAAMA,GAAG,CAAyB;EAC/CC,OAAOA,CAAA,EAAG,CAAC;EAEXC,QAAQA,CAAA,EAAG,CAAC;EAEZC,SAASA,CAAA,EAAG;IACV,MAAM,IAAIC,KAAK,CAAC,+CAA+C,CAAC;EAClE;EAEAC,UAAUA,CAACC,IAAU,EAAEC,GAAW,EAAEH,KAAK,GAAGI,SAAS,EAAS;IAC5D,OAAO,IAAIJ,KAAK,CAACG,GAAG,CAAC;EACvB;AACF;AAACE,OAAA,CAAAC,OAAA,GAAAV,GAAA"}
package/lib/index.js CHANGED
@@ -12,87 +12,70 @@ Object.defineProperty(exports, "Hub", {
12
12
  Object.defineProperty(exports, "NodePath", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _path.default;
15
+ return _index.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "Scope", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _scope.default;
21
+ return _index2.default;
22
22
  }
23
23
  });
24
24
  exports.visitors = exports.default = void 0;
25
-
26
- var visitors = require("./visitors");
27
-
25
+ var visitors = require("./visitors.js");
28
26
  exports.visitors = visitors;
29
-
30
27
  var _t = require("@babel/types");
31
-
32
- var cache = require("./cache");
33
-
34
- var _traverseNode = require("./traverse-node");
35
-
36
- var _path = require("./path");
37
-
38
- var _scope = require("./scope");
39
-
40
- var _hub = require("./hub");
41
-
28
+ var cache = require("./cache.js");
29
+ var _traverseNode = require("./traverse-node.js");
30
+ var _index = require("./path/index.js");
31
+ var _index2 = require("./scope/index.js");
32
+ var _hub = require("./hub.js");
42
33
  const {
43
34
  VISITOR_KEYS,
44
35
  removeProperties,
45
36
  traverseFast
46
37
  } = _t;
47
-
48
- function traverse(parent, opts = {}, scope, state, parentPath) {
38
+ function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) {
49
39
  if (!parent) return;
50
-
51
40
  if (!opts.noScope && !scope) {
52
41
  if (parent.type !== "Program" && parent.type !== "File") {
53
42
  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.");
54
43
  }
55
44
  }
56
-
45
+ if (!parentPath && visitSelf) {
46
+ throw new Error("visitSelf can only be used when providing a NodePath.");
47
+ }
57
48
  if (!VISITOR_KEYS[parent.type]) {
58
49
  return;
59
50
  }
60
-
61
51
  visitors.explode(opts);
62
- (0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath);
52
+ (0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath, null, visitSelf);
63
53
  }
64
-
65
54
  var _default = traverse;
66
55
  exports.default = _default;
67
56
  traverse.visitors = visitors;
68
57
  traverse.verify = visitors.verify;
69
58
  traverse.explode = visitors.explode;
70
-
71
59
  traverse.cheap = function (node, enter) {
72
- return traverseFast(node, enter);
60
+ traverseFast(node, enter);
61
+ return;
73
62
  };
74
-
75
63
  traverse.node = function (node, opts, scope, state, path, skipKeys) {
76
64
  (0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys);
77
65
  };
78
-
79
66
  traverse.clearNode = function (node, opts) {
80
67
  removeProperties(node, opts);
81
- cache.path.delete(node);
82
68
  };
83
-
84
69
  traverse.removeProperties = function (tree, opts) {
85
70
  traverseFast(tree, traverse.clearNode, opts);
86
71
  return tree;
87
72
  };
88
-
89
73
  function hasDenylistedType(path, state) {
90
74
  if (path.node.type === state.type) {
91
75
  state.has = true;
92
76
  path.stop();
93
77
  }
94
78
  }
95
-
96
79
  traverse.hasType = function (tree, type, denylistTypes) {
97
80
  if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
98
81
  if (tree.type === type) return true;
@@ -107,5 +90,6 @@ traverse.hasType = function (tree, type, denylistTypes) {
107
90
  }, null, state);
108
91
  return state.has;
109
92
  };
93
+ traverse.cache = cache;
110
94
 
111
- traverse.cache = cache;
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["visitors","require","exports","_t","cache","_traverseNode","_index","_index2","_hub","VISITOR_KEYS","removeProperties","traverseFast","traverse","parent","opts","scope","state","parentPath","visitSelf","noScope","type","Error","explode","traverseNode","_default","default","verify","cheap","node","enter","path","skipKeys","clearNode","tree","hasDenylistedType","has","stop","hasType","denylistTypes","includes","denylist"],"sources":["../src/index.ts"],"sourcesContent":["import * as visitors from \"./visitors.ts\";\nimport {\n VISITOR_KEYS,\n removeProperties,\n type RemovePropertiesOptions,\n traverseFast,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport * as cache from \"./cache.ts\";\nimport type NodePath from \"./path/index.ts\";\nimport type { default as Scope, Binding } from \"./scope/index.ts\";\nimport type { ExplodedVisitor, Visitor } from \"./types.ts\";\nimport { traverseNode } from \"./traverse-node.ts\";\n\nexport type { ExplodedVisitor, Visitor, Binding };\nexport { default as NodePath } from \"./path/index.ts\";\nexport { default as Scope } from \"./scope/index.ts\";\nexport { default as Hub } from \"./hub.ts\";\nexport type { HubInterface } from \"./hub.ts\";\n\nexport { visitors };\n\nexport type TraverseOptions<S = t.Node> = {\n scope?: Scope;\n noScope?: boolean;\n denylist?: string[];\n shouldSkip?: (node: NodePath) => boolean;\n} & Visitor<S>;\n\nexport type ExplodedTraverseOptions<S = t.Node> = TraverseOptions<S> &\n ExplodedVisitor<S>;\n\nfunction traverse<S>(\n parent: t.Node,\n opts: TraverseOptions<S>,\n scope: Scope | undefined,\n state: S,\n parentPath?: NodePath,\n visitSelf?: boolean,\n): void;\n\nfunction traverse(\n parent: t.Node,\n opts: TraverseOptions,\n scope?: Scope,\n state?: any,\n parentPath?: NodePath,\n visitSelf?: boolean,\n): void;\n\nfunction traverse<Options extends TraverseOptions>(\n parent: t.Node,\n // @ts-expect-error provide {} as default value for Options\n opts: Options = {},\n scope?: Scope,\n state?: any,\n parentPath?: NodePath,\n visitSelf?: boolean,\n) {\n if (!parent) return;\n\n if (!opts.noScope && !scope) {\n if (parent.type !== \"Program\" && parent.type !== \"File\") {\n throw new Error(\n \"You must pass a scope and parentPath unless traversing a Program/File. \" +\n `Instead of that you tried to traverse a ${parent.type} node without ` +\n \"passing scope and parentPath.\",\n );\n }\n }\n\n if (!parentPath && visitSelf) {\n throw new Error(\"visitSelf can only be used when providing a NodePath.\");\n }\n\n if (!VISITOR_KEYS[parent.type]) {\n return;\n }\n\n visitors.explode(opts as Visitor);\n\n traverseNode(\n parent,\n opts as ExplodedVisitor,\n scope,\n state,\n parentPath,\n /* skipKeys */ null,\n visitSelf,\n );\n}\n\nexport default traverse;\n\ntraverse.visitors = visitors;\ntraverse.verify = visitors.verify;\ntraverse.explode = visitors.explode;\n\ntraverse.cheap = function (node: t.Node, enter: (node: t.Node) => void) {\n traverseFast(node, enter);\n return;\n};\n\ntraverse.node = function (\n node: t.Node,\n opts: ExplodedTraverseOptions,\n scope?: Scope,\n state?: any,\n path?: NodePath,\n skipKeys?: Record<string, boolean>,\n) {\n traverseNode(node, opts, scope, state, path, skipKeys);\n // traverse.node always returns undefined\n};\n\ntraverse.clearNode = function (node: t.Node, opts?: RemovePropertiesOptions) {\n removeProperties(node, opts);\n};\n\ntraverse.removeProperties = function (\n tree: t.Node,\n opts?: RemovePropertiesOptions,\n) {\n traverseFast(tree, traverse.clearNode, opts);\n return tree;\n};\n\ntype HasDenylistedTypeState = {\n has: boolean;\n type: t.Node[\"type\"];\n};\nfunction hasDenylistedType(path: NodePath, state: HasDenylistedTypeState) {\n if (path.node.type === state.type) {\n state.has = true;\n path.stop();\n }\n}\n\ntraverse.hasType = function (\n tree: t.Node,\n type: t.Node[\"type\"],\n denylistTypes?: Array<string>,\n): boolean {\n // the node we're searching in is denylisted\n if (denylistTypes?.includes(tree.type)) return false;\n\n // the type we're looking for is the same as the passed node\n if (tree.type === type) return true;\n\n const state: HasDenylistedTypeState = {\n has: false,\n type: type,\n };\n\n traverse(\n tree,\n {\n noScope: true,\n denylist: denylistTypes,\n enter: hasDenylistedType,\n },\n null,\n state,\n );\n\n return state.has;\n};\n\ntraverse.cache = cache;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAA0CC,OAAA,CAAAF,QAAA,GAAAA,QAAA;AAC1C,IAAAG,EAAA,GAAAF,OAAA;AAOA,IAAAG,KAAA,GAAAH,OAAA;AAIA,IAAAI,aAAA,GAAAJ,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,IAAA,GAAAP,OAAA;AAA0C;EAfxCQ,YAAY;EACZC,gBAAgB;EAEhBC;AAAY,IAAAR,EAAA;AA6Cd,SAASS,QAAQA,CACfC,MAAc,EAEdC,IAAa,GAAG,CAAC,CAAC,EAClBC,KAAa,EACbC,KAAW,EACXC,UAAqB,EACrBC,SAAmB,EACnB;EACA,IAAI,CAACL,MAAM,EAAE;EAEb,IAAI,CAACC,IAAI,CAACK,OAAO,IAAI,CAACJ,KAAK,EAAE;IAC3B,IAAIF,MAAM,CAACO,IAAI,KAAK,SAAS,IAAIP,MAAM,CAACO,IAAI,KAAK,MAAM,EAAE;MACvD,MAAM,IAAIC,KAAK,CACb,yEAAyE,GACtE,2CAA0CR,MAAM,CAACO,IAAK,gBAAe,GACtE,+BACJ,CAAC;IACH;EACF;EAEA,IAAI,CAACH,UAAU,IAAIC,SAAS,EAAE;IAC5B,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC;EAC1E;EAEA,IAAI,CAACZ,YAAY,CAACI,M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AAI,EAAE;IACjCJ,KAAK,CAACmB,GAAG,GAAG,IAAI;IAChBL,IAAI,CAACM,IAAI,CAAC,CAAC;EACb;AACF;AAEAxB,QAAQ,CAACyB,OAAO,GAAG,UACjBJ,IAAY,EACZb,IAAoB,EACpBkB,aAA6B,EACpB;EAET,IAAIA,aAAa,YAAbA,aAAa,CAAEC,QAAQ,CAACN,IAAI,CAACb,IAAI,CAAC,EAAE,OAAO,KAAK;EAGpD,IAAIa,IAAI,CAACb,IAAI,KAAKA,IAAI,EAAE,OAAO,IAAI;EAEnC,MAAMJ,KAA6B,GAAG;IACpCmB,GAAG,EAAE,KAAK;IACVf,IAAI,EAAEA;EACR,CAAC;EAEDR,QAAQ,CACNqB,IAAI,EACJ;IACEd,OAAO,EAAE,IAAI;IACbqB,QAAQ,EAAEF,aAAa;IACvBT,KAAK,EAAEK;EACT,CAAC,EACD,IAAI,EACJlB,KACF,CAAC;EAED,OAAOA,KAAK,CAACmB,GAAG;AAClB,CAAC;AAEDvB,QAAQ,CAACR,KAAK,GAAGA,KAAK"}
@@ -13,42 +13,29 @@ exports.getStatementParent = getStatementParent;
13
13
  exports.inType = inType;
14
14
  exports.isAncestor = isAncestor;
15
15
  exports.isDescendant = isDescendant;
16
-
17
16
  var _t = require("@babel/types");
18
-
19
- var _index = require("./index");
20
-
21
17
  const {
22
18
  VISITOR_KEYS
23
19
  } = _t;
24
-
25
20
  function findParent(callback) {
26
21
  let path = this;
27
-
28
22
  while (path = path.parentPath) {
29
23
  if (callback(path)) return path;
30
24
  }
31
-
32
25
  return null;
33
26
  }
34
-
35
27
  function find(callback) {
36
28
  let path = this;
37
-
38
29
  do {
39
30
  if (callback(path)) return path;
40
31
  } while (path = path.parentPath);
41
-
42
32
  return null;
43
33
  }
44
-
45
34
  function getFunctionParent() {
46
35
  return this.findParent(p => p.isFunction());
47
36
  }
48
-
49
37
  function getStatementParent() {
50
38
  let path = this;
51
-
52
39
  do {
53
40
  if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
54
41
  break;
@@ -56,85 +43,66 @@ function getStatementParent() {
56
43
  path = path.parentPath;
57
44
  }
58
45
  } while (path);
59
-
60
46
  if (path && (path.isProgram() || path.isFile())) {
61
47
  throw new Error("File/Program node, we can't possibly find a statement parent to this");
62
48
  }
63
-
64
49
  return path;
65
50
  }
66
-
67
51
  function getEarliestCommonAncestorFrom(paths) {
68
52
  return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
69
53
  let earliest;
70
54
  const keys = VISITOR_KEYS[deepest.type];
71
-
72
55
  for (const ancestry of ancestries) {
73
56
  const path = ancestry[i + 1];
74
-
75
57
  if (!earliest) {
76
58
  earliest = path;
77
59
  continue;
78
60
  }
79
-
80
61
  if (path.listKey && earliest.listKey === path.listKey) {
81
62
  if (path.key < earliest.key) {
82
63
  earliest = path;
83
64
  continue;
84
65
  }
85
66
  }
86
-
87
67
  const earliestKeyIndex = keys.indexOf(earliest.parentKey);
88
68
  const currentKeyIndex = keys.indexOf(path.parentKey);
89
-
90
69
  if (earliestKeyIndex > currentKeyIndex) {
91
70
  earliest = path;
92
71
  }
93
72
  }
94
-
95
73
  return earliest;
96
74
  });
97
75
  }
98
-
99
76
  function getDeepestCommonAncestorFrom(paths, filter) {
100
77
  if (!paths.length) {
101
78
  return this;
102
79
  }
103
-
104
80
  if (paths.length === 1) {
105
81
  return paths[0];
106
82
  }
107
-
108
83
  let minDepth = Infinity;
109
84
  let lastCommonIndex, lastCommon;
110
85
  const ancestries = paths.map(path => {
111
86
  const ancestry = [];
112
-
113
87
  do {
114
88
  ancestry.unshift(path);
115
89
  } while ((path = path.parentPath) && path !== this);
116
-
117
90
  if (ancestry.length < minDepth) {
118
91
  minDepth = ancestry.length;
119
92
  }
120
-
121
93
  return ancestry;
122
94
  });
123
95
  const first = ancestries[0];
124
-
125
96
  depthLoop: for (let i = 0; i < minDepth; i++) {
126
97
  const shouldMatch = first[i];
127
-
128
98
  for (const ancestry of ancestries) {
129
99
  if (ancestry[i] !== shouldMatch) {
130
100
  break depthLoop;
131
101
  }
132
102
  }
133
-
134
103
  lastCommonIndex = i;
135
104
  lastCommon = shouldMatch;
136
105
  }
137
-
138
106
  if (lastCommon) {
139
107
  if (filter) {
140
108
  return filter(lastCommon, lastCommonIndex, ancestries);
@@ -145,36 +113,29 @@ function getDeepestCommonAncestorFrom(paths, filter) {
145
113
  throw new Error("Couldn't find intersection");
146
114
  }
147
115
  }
148
-
149
116
  function getAncestry() {
150
117
  let path = this;
151
118
  const paths = [];
152
-
153
119
  do {
154
120
  paths.push(path);
155
121
  } while (path = path.parentPath);
156
-
157
122
  return paths;
158
123
  }
159
-
160
124
  function isAncestor(maybeDescendant) {
161
125
  return maybeDescendant.isDescendant(this);
162
126
  }
163
-
164
127
  function isDescendant(maybeAncestor) {
165
128
  return !!this.findParent(parent => parent === maybeAncestor);
166
129
  }
167
-
168
130
  function inType(...candidateTypes) {
169
131
  let path = this;
170
-
171
132
  while (path) {
172
133
  for (const type of candidateTypes) {
173
134
  if (path.node.type === type) return true;
174
135
  }
175
-
176
136
  path = path.parentPath;
177
137
  }
178
-
179
138
  return false;
180
- }
139
+ }
140
+
141
+ //# sourceMappingURL=ancestry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_t","require","VISITOR_KEYS","findParent","callback","path","parentPath","find","getFunctionParent","p","isFunction","getStatementParent","Array","isArray","container","isStatement","isProgram","isFile","Error","getEarliestCommonAncestorFrom","paths","getDeepestCommonAncestorFrom","deepest","i","ancestries","earliest","keys","type","ancestry","listKey","key","earliestKeyIndex","indexOf","parentKey","currentKeyIndex","filter","length","minDepth","Infinity","lastCommonIndex","lastCommon","map","unshift","first","depthLoop","shouldMatch","getAncestry","push","isAncestor","maybeDescendant","isDescendant","maybeAncestor","parent","inType","candidateTypes","node"],"sources":["../../src/path/ancestry.ts"],"sourcesContent":["// This file contains that retrieve or validate anything related to the current paths ancestry.\n\nimport { VISITOR_KEYS } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type NodePath from \"./index.ts\";\n\n/**\n * Starting at the parent path of the current `NodePath` and going up the\n * tree, return the first `NodePath` that causes the provided `callback`\n * to return a truthy value, or `null` if the `callback` never returns a\n * truthy value.\n */\n\nexport function findParent(\n this: NodePath,\n callback: (path: NodePath) => boolean,\n): NodePath | null {\n let path = this;\n while ((path = path.parentPath)) {\n if (callback(path)) return path;\n }\n return null;\n}\n\n/**\n * Starting at current `NodePath` and going up the tree, return the first\n * `NodePath` that causes the provided `callback` to return a truthy value,\n * or `null` if the `callback` never returns a truthy value.\n */\n\nexport function find(\n this: NodePath,\n callback: (path: NodePath) => boolean,\n): NodePath | null {\n let path = this;\n do {\n if (callback(path)) return path;\n } while ((path = path.parentPath));\n return null;\n}\n\n/**\n * Get the parent function of the current path.\n */\n\nexport function getFunctionParent(this: NodePath): NodePath<t.Function> | null {\n return this.findParent(p => p.isFunction()) as NodePath<t.Function> | null;\n}\n\n/**\n * Walk up the tree until we hit a parent node path in a list.\n */\n\nexport function getStatementParent(this: NodePath): NodePath<t.Statement> {\n let path = this;\n\n do {\n if (\n !path.parentPath ||\n (Array.isArray(path.container) && path.isStatement())\n ) {\n break;\n } else {\n path = path.parentPath;\n }\n } while (path);\n\n if (path && (path.isProgram() || path.isFile())) {\n throw new Error(\n \"File/Program node, we can't possibly find a statement parent to this\",\n );\n }\n\n return path as NodePath<t.Statement>;\n}\n\n/**\n * Get the deepest common ancestor and then from it, get the earliest relationship path\n * to that ancestor.\n *\n * Earliest is defined as being \"before\" all the other nodes in terms of list container\n * position and visiting key.\n */\n\nexport function getEarliestCommonAncestorFrom(\n this: NodePath,\n paths: Array<NodePath>,\n): NodePath {\n return this.getDeepestCommonAncestorFrom(\n paths,\n function (deepest, i, ancestries) {\n let earliest;\n const keys = VISITOR_KEYS[deepest.type];\n\n for (const ancestry of ancestries) {\n const path = ancestry[i + 1];\n\n // first path\n if (!earliest) {\n earliest = path;\n continue;\n }\n\n // handle containers\n if (path.listKey && earliest.listKey === path.listKey) {\n // we're in the same container so check if we're earlier\n if (path.key < earliest.key) {\n earliest = path;\n continue;\n }\n }\n\n // handle keys\n const earliestKeyIndex = keys.indexOf(earliest.parentKey);\n const currentKeyIndex = keys.indexOf(path.parentKey);\n if (earliestKeyIndex > currentKeyIndex) {\n // key appears before so it's earlier\n earliest = path;\n }\n }\n\n return earliest;\n },\n );\n}\n\n/**\n * Get the earliest path in the tree where the provided `paths` intersect.\n *\n * TODO: Possible optimisation target.\n */\n\nexport function getDeepestCommonAncestorFrom(\n this: NodePath,\n paths: Array<NodePath>,\n filter?: (deepest: NodePath, i: number, ancestries: NodePath[][]) => NodePath,\n): NodePath {\n if (!paths.length) {\n return this;\n }\n\n if (paths.length === 1) {\n return paths[0];\n }\n\n // minimum depth of the tree so we know the highest node\n let minDepth = Infinity;\n\n // last common ancestor\n let lastCommonIndex, lastCommon;\n\n // get the ancestors of the path, breaking when the parent exceeds ourselves\n const ancestries = paths.map(path => {\n const ancestry: NodePath[] = [];\n\n do {\n ancestry.unshift(path);\n } while ((path = path.parentPath) && path !== this);\n\n // save min depth to avoid going too far in\n if (ancestry.length < minDepth) {\n minDepth = ancestry.length;\n }\n\n return ancestry;\n });\n\n // get the first ancestry so we have a seed to assess all other ancestries with\n const first = ancestries[0];\n\n // check ancestor equality\n depthLoop: for (let i = 0; i < minDepth; i++) {\n const shouldMatch = first[i];\n\n for (const ancestry of ancestries) {\n if (ancestry[i] !== shouldMatch) {\n // we've hit a snag\n break depthLoop;\n }\n }\n\n // next iteration may break so store these so they can be returned\n lastCommonIndex = i;\n lastCommon = shouldMatch;\n }\n\n if (lastCommon) {\n if (filter) {\n return filter(lastCommon, lastCommonIndex, ancestries);\n } else {\n return lastCommon;\n }\n } else {\n throw new Error(\"Couldn't find intersection\");\n }\n}\n\n/**\n * Build an array of node paths containing the entire ancestry of the current node path.\n *\n * NOTE: The current node path is included in this.\n */\n\nexport function getAncestry(this: NodePath): Array<NodePath> {\n let path = this;\n const paths = [];\n do {\n paths.push(path);\n } while ((path = path.parentPath));\n return paths;\n}\n\n/**\n * A helper to find if `this` path is an ancestor of @param maybeDescendant\n */\nexport function isAncestor(this: NodePath, maybeDescendant: NodePath): boolean {\n return maybeDescendant.isDescendant(this);\n}\n\n/**\n * A helper to find if `this` path is a descendant of @param maybeAncestor\n */\nexport function isDescendant(this: NodePath, maybeAncestor: NodePath): boolean {\n return !!this.findParent(parent => parent === maybeAncestor);\n}\n\nexport function inType(this: NodePath, ...candidateTypes: string[]): boolean {\n let path = this;\n while (path) {\n for (const type of candidateTypes) {\n if (path.node.type === type) return true;\n }\n path = path.parentPath;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAAA,EAAA,GAAAC,OAAA;AAA4C;EAAnCC;AAAY,IAAAF,EAAA;AAWd,SAASG,UAAUA,CAExBC,QAAqC,EACpB;EACjB,IAAIC,IAAI,GAAG,IAAI;EACf,OAAQA,IAAI,GAAGA,IAAI,CAACC,UAAU,EAAG;IAC/B,IAAIF,QAAQ,CAACC,IAAI,CAAC,EAAE,OAAOA,IAAI;EACjC;EACA,OAAO,IAAI;AACb;AAQO,SAASE,IAAIA,CAElBH,QAAqC,EACpB;EACjB,IAAIC,IAAI,GAAG,IAAI;EACf,GAAG;IACD,IAAID,QAAQ,CAACC,IAAI,CAAC,EAAE,OAAOA,IAAI;EACjC,CAAC,QAASA,IAAI,GAAGA,IAAI,CAACC,UAAU;EAChC,OAAO,IAAI;AACb;AAMO,SAASE,iBAAiBA,CAAA,EAA8C;EAC7E,OAAO,IAAI,CAACL,UAAU,CAACM,CAAC,IAAIA,CAAC,CAACC,UAAU,CAAC,CAAC,CAAC;AAC7C;AAMO,SAASC,kBAAkBA,CAAA,EAAwC;EACxE,IAAIN,IAAI,GAAG,IAAI;EAEf,GAAG;IACD,IACE,CAACA,IAAI,CAACC,UAAU,IACfM,KAAK,CAACC,OAAO,CAACR,IAAI,CAACS,SAAS,CAAC,IAAIT,IAAI,CAACU,WAAW,CA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,CAAC,4BAA4B,CAAC;EAC/C;AACF;AAQO,SAAS4B,WAAWA,CAAA,EAAkC;EAC3D,IAAIzC,IAAI,GAAG,IAAI;EACf,MAAMe,KAAK,GAAG,EAAE;EAChB,GAAG;IACDA,KAAK,CAAC2B,IAAI,CAAC1C,IAAI,CAAC;EAClB,CAAC,QAASA,IAAI,GAAGA,IAAI,CAACC,UAAU;EAChC,OAAOc,KAAK;AACd;AAKO,SAAS4B,UAAUA,CAAiBC,eAAyB,EAAW;EAC7E,OAAOA,eAAe,CAACC,YAAY,CAAC,IAAI,CAAC;AAC3C;AAKO,SAASA,YAAYA,CAAiBC,aAAuB,EAAW;EAC7E,OAAO,CAAC,CAAC,IAAI,CAAChD,UAAU,CAACiD,MAAM,IAAIA,MAAM,KAAKD,aAAa,CAAC;AAC9D;AAEO,SAASE,MAAMA,CAAiB,GAAGC,cAAwB,EAAW;EAC3E,IAAIjD,IAAI,GAAG,IAAI;EACf,OAAOA,IAAI,EAAE;IACX,KAAK,MAAMsB,IAAI,IAAI2B,cAAc,EAAE;MACjC,IAAIjD,IAAI,CAACkD,IAAI,CAAC5B,IAAI,KAAKA,IAAI,EAAE,OAAO,IAAI;IAC1C;IACAtB,IAAI,GAAGA,IAAI,CAACC,UAAU;EACxB;EAEA,OAAO,KAAK;AACd"}
@@ -6,14 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addComment = addComment;
7
7
  exports.addComments = addComments;
8
8
  exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
9
-
10
9
  var _t = require("@babel/types");
11
-
12
10
  const {
13
11
  addComment: _addComment,
14
12
  addComments: _addComments
15
13
  } = _t;
16
-
17
14
  function shareCommentsWithSiblings() {
18
15
  if (typeof this.key === "string") return;
19
16
  const node = this.node;
@@ -25,18 +22,33 @@ function shareCommentsWithSiblings() {
25
22
  const next = this.getSibling(this.key + 1);
26
23
  const hasPrev = Boolean(prev.node);
27
24
  const hasNext = Boolean(next.node);
28
-
29
- if (hasPrev && !hasNext) {
30
- prev.addComments("trailing", trailing);
31
- } else if (hasNext && !hasPrev) {
32
- next.addComments("leading", leading);
25
+ if (hasPrev) {
26
+ if (leading) {
27
+ prev.addComments("trailing", removeIfExisting(leading, prev.node.trailingComments));
28
+ }
29
+ if (trailing && !hasNext) prev.addComments("trailing", trailing);
30
+ }
31
+ if (hasNext) {
32
+ if (trailing) {
33
+ next.addComments("leading", removeIfExisting(trailing, next.node.leadingComments));
34
+ }
35
+ if (leading && !hasPrev) next.addComments("leading", leading);
33
36
  }
34
37
  }
35
-
38
+ function removeIfExisting(list, toRemove) {
39
+ if (!toRemove) return list;
40
+ let lastFoundIndex = -1;
41
+ return list.filter(el => {
42
+ const i = toRemove.indexOf(el, lastFoundIndex);
43
+ if (i === -1) return true;
44
+ lastFoundIndex = i;
45
+ });
46
+ }
36
47
  function addComment(type, content, line) {
37
48
  _addComment(this.node, type, content, line);
38
49
  }
39
-
40
50
  function addComments(type, comments) {
41
51
  _addComments(this.node, type, comments);
42
- }
52
+ }
53
+
54
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_t","require","addComment","_addComment","addComments","_addComments","shareCommentsWithSiblings","key","node","trailing","trailingComments","leading","leadingComments","prev","getSibling","next","hasPrev","Boolean","hasNext","removeIfExisting","list","toRemove","lastFoundIndex","filter","el","i","indexOf","type","content","line","comments"],"sources":["../../src/path/comments.ts"],"sourcesContent":["// This file contains methods responsible for dealing with comments.\nimport type * as t from \"@babel/types\";\nimport type NodePath from \"./index.ts\";\nimport {\n addComment as _addComment,\n addComments as _addComments,\n} from \"@babel/types\";\n\n/**\n * Share comments amongst siblings.\n */\n\nexport function shareCommentsWithSiblings(this: NodePath) {\n // NOTE: this assumes numbered keys\n if (typeof this.key === \"string\") return;\n\n const node = this.node;\n if (!node) return;\n\n const trailing = node.trailingComments;\n const leading = node.leadingComments;\n if (!trailing && !leading) return;\n\n const prev = this.getSibling(this.key - 1);\n const next = this.getSibling(this.key + 1);\n const hasPrev = Boolean(prev.node);\n const hasNext = Boolean(next.node);\n\n if (hasPrev) {\n if (leading) {\n prev.addComments(\n \"trailing\",\n removeIfExisting(leading, prev.node.trailingComments),\n );\n }\n if (trailing && !hasNext) prev.addComments(\"trailing\", trailing);\n }\n if (hasNext) {\n if (trailing) {\n next.addComments(\n \"leading\",\n removeIfExisting(trailing, next.node.leadingComments),\n );\n }\n if (leading && !hasPrev) next.addComments(\"leading\", leading);\n }\n}\n\nfunction removeIfExisting<T>(list: T[], toRemove?: T[]): T[] {\n if (!toRemove) return list;\n let lastFoundIndex = -1;\n return list.filter(el => {\n const i = toRemove.indexOf(el, lastFoundIndex);\n if (i === -1) return true;\n lastFoundIndex = i;\n });\n}\n\nexport function addComment(\n this: NodePath,\n type: t.CommentTypeShorthand,\n content: string,\n line?: boolean,\n) {\n _addComment(this.node, type, content, line);\n}\n\n/**\n * Give node `comments` of the specified `type`.\n */\n\nexport function addComments(\n this: NodePath,\n type: t.CommentTypeShorthand,\n comments: t.Comment[],\n) {\n _addComments(this.node, type, comments);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,EAAA,GAAAC,OAAA;AAGsB;EAFpBC,UAAU,EAAIC,WAAW;EACzBC,WAAW,EAAIC;AAAY,IAAAL,EAAA;AAOtB,SAASM,yBAAyBA,CAAA,EAAiB;EAExD,IAAI,OAAO,IAAI,CAACC,GAAG,KAAK,QAAQ,EAAE;EAElC,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EACtB,IAAI,CAACA,IAAI,EAAE;EAEX,MAAMC,QAAQ,GAAGD,IAAI,CAACE,gBAAgB;EACtC,MAAMC,OAAO,GAAGH,IAAI,CAACI,eAAe;EACpC,IAAI,CAACH,QAAQ,IAAI,CAACE,OAAO,EAAE;EAE3B,MAAME,IAAI,GAAG,IAAI,CAACC,UAAU,CAAC,IAAI,CAACP,GAAG,GAAG,CAAC,CAAC;EAC1C,MAAMQ,IAAI,GAAG,IAAI,CAACD,UAAU,CAAC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