@babel/traverse 8.0.0-beta.4 → 8.0.0-rc.1
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.d.ts +34 -93
- package/lib/index.js +136 -268
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -48,6 +48,134 @@ var virtualTypes = /*#__PURE__*/Object.freeze({
|
|
|
48
48
|
Var: Var
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
class TraversalContext {
|
|
52
|
+
constructor(opts, state) {
|
|
53
|
+
this.state = state;
|
|
54
|
+
this.opts = opts;
|
|
55
|
+
}
|
|
56
|
+
queue = null;
|
|
57
|
+
priorityQueue = null;
|
|
58
|
+
maybeQueue(path, notPriority) {
|
|
59
|
+
if (this.queue) {
|
|
60
|
+
if (notPriority) {
|
|
61
|
+
this.queue.push(path);
|
|
62
|
+
} else {
|
|
63
|
+
this.priorityQueue.push(path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
VISITOR_KEYS: VISITOR_KEYS$4
|
|
71
|
+
} = _t;
|
|
72
|
+
function _visitPaths(ctx, paths) {
|
|
73
|
+
ctx.queue = paths;
|
|
74
|
+
ctx.priorityQueue = [];
|
|
75
|
+
const visited = new Set();
|
|
76
|
+
let stop = false;
|
|
77
|
+
let visitIndex = 0;
|
|
78
|
+
for (; visitIndex < paths.length;) {
|
|
79
|
+
const path = paths[visitIndex];
|
|
80
|
+
visitIndex++;
|
|
81
|
+
resync.call(path);
|
|
82
|
+
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== ctx) {
|
|
83
|
+
pushContext.call(path, ctx);
|
|
84
|
+
}
|
|
85
|
+
if (path.key === null) continue;
|
|
86
|
+
const {
|
|
87
|
+
node
|
|
88
|
+
} = path;
|
|
89
|
+
if (visited.has(node)) continue;
|
|
90
|
+
if (node) visited.add(node);
|
|
91
|
+
if (_visit(ctx, path)) {
|
|
92
|
+
stop = true;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
if (ctx.priorityQueue.length) {
|
|
96
|
+
stop = _visitPaths(ctx, ctx.priorityQueue);
|
|
97
|
+
ctx.priorityQueue = [];
|
|
98
|
+
ctx.queue = paths;
|
|
99
|
+
if (stop) break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (let i = 0; i < visitIndex; i++) {
|
|
103
|
+
popContext.call(paths[i]);
|
|
104
|
+
}
|
|
105
|
+
ctx.queue = null;
|
|
106
|
+
return stop;
|
|
107
|
+
}
|
|
108
|
+
function _visit(ctx, path) {
|
|
109
|
+
const node = path.node;
|
|
110
|
+
if (!node) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const opts = ctx.opts;
|
|
114
|
+
const denylist = opts.denylist;
|
|
115
|
+
if (denylist?.includes(node.type)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (opts.shouldSkip?.(path)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (path.shouldSkip) return path.shouldStop;
|
|
122
|
+
if (_call.call(path, opts.enter)) return path.shouldStop;
|
|
123
|
+
if (path.node) {
|
|
124
|
+
if (_call.call(path, opts[node.type]?.enter)) return path.shouldStop;
|
|
125
|
+
}
|
|
126
|
+
path.shouldStop = traverseNode(path.node, opts, path.scope, ctx.state, path, path.skipKeys);
|
|
127
|
+
if (path.node) {
|
|
128
|
+
if (_call.call(path, opts.exit)) return true;
|
|
129
|
+
}
|
|
130
|
+
if (path.node) {
|
|
131
|
+
_call.call(path, opts[node.type]?.exit);
|
|
132
|
+
}
|
|
133
|
+
return path.shouldStop;
|
|
134
|
+
}
|
|
135
|
+
function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
|
|
136
|
+
const keys = VISITOR_KEYS$4[node.type];
|
|
137
|
+
if (!keys?.length) return false;
|
|
138
|
+
const ctx = new TraversalContext(opts, state);
|
|
139
|
+
if (visitSelf) {
|
|
140
|
+
if (skipKeys?.[path.parentKey]) return false;
|
|
141
|
+
return _visitPaths(ctx, [path]);
|
|
142
|
+
}
|
|
143
|
+
const hub = path == null ? node.type === "Program" || node.type === "File" ? new Hub() : undefined : path.hub;
|
|
144
|
+
for (const key of keys) {
|
|
145
|
+
if (skipKeys?.[key]) continue;
|
|
146
|
+
const prop = node[key];
|
|
147
|
+
if (!prop) continue;
|
|
148
|
+
if (Array.isArray(prop)) {
|
|
149
|
+
if (!prop.length) continue;
|
|
150
|
+
const paths = [];
|
|
151
|
+
for (let i = 0; i < prop.length; i++) {
|
|
152
|
+
const childPath = NodePath_Final.get({
|
|
153
|
+
parentPath: path,
|
|
154
|
+
parent: node,
|
|
155
|
+
container: prop,
|
|
156
|
+
key: i,
|
|
157
|
+
listKey: key,
|
|
158
|
+
hub
|
|
159
|
+
});
|
|
160
|
+
paths.push(childPath);
|
|
161
|
+
}
|
|
162
|
+
if (_visitPaths(ctx, paths)) return true;
|
|
163
|
+
} else {
|
|
164
|
+
if (_visitPaths(ctx, [NodePath_Final.get({
|
|
165
|
+
parentPath: path,
|
|
166
|
+
parent: node,
|
|
167
|
+
container: node,
|
|
168
|
+
key,
|
|
169
|
+
listKey: null,
|
|
170
|
+
hub
|
|
171
|
+
})])) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
51
179
|
const {
|
|
52
180
|
isBinding,
|
|
53
181
|
isBlockScoped: nodeIsBlockScoped,
|
|
@@ -289,7 +417,7 @@ function verify$1(visitor) {
|
|
|
289
417
|
}
|
|
290
418
|
if (shouldIgnoreKey(nodeType)) continue;
|
|
291
419
|
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 in @babel/traverse ${"8.0.0-
|
|
420
|
+
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-rc.1"}`);
|
|
293
421
|
}
|
|
294
422
|
const visitors = visitor[nodeType];
|
|
295
423
|
if (typeof visitors === "object") {
|
|
@@ -540,7 +668,7 @@ class Renamer {
|
|
|
540
668
|
}
|
|
541
669
|
|
|
542
670
|
const {
|
|
543
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
671
|
+
VISITOR_KEYS: VISITOR_KEYS$3
|
|
544
672
|
} = _t;
|
|
545
673
|
function traverseForScope(path, visitors, state) {
|
|
546
674
|
const exploded = explode$1(visitors);
|
|
@@ -570,7 +698,7 @@ function traverseForScope(path, visitors, state) {
|
|
|
570
698
|
if (path.shouldSkip) {
|
|
571
699
|
return;
|
|
572
700
|
}
|
|
573
|
-
const keys = VISITOR_KEYS$
|
|
701
|
+
const keys = VISITOR_KEYS$3[node.type];
|
|
574
702
|
if (!keys?.length) {
|
|
575
703
|
return;
|
|
576
704
|
}
|
|
@@ -1600,7 +1728,7 @@ class Scope {
|
|
|
1600
1728
|
}
|
|
1601
1729
|
|
|
1602
1730
|
const {
|
|
1603
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
1731
|
+
VISITOR_KEYS: VISITOR_KEYS$2
|
|
1604
1732
|
} = _t;
|
|
1605
1733
|
function findParent(callback) {
|
|
1606
1734
|
let path = this;
|
|
@@ -1636,7 +1764,7 @@ function getStatementParent() {
|
|
|
1636
1764
|
function getEarliestCommonAncestorFrom(paths) {
|
|
1637
1765
|
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
|
|
1638
1766
|
let earliest;
|
|
1639
|
-
const keys = VISITOR_KEYS$
|
|
1767
|
+
const keys = VISITOR_KEYS$2[deepest.type];
|
|
1640
1768
|
for (const ancestry of ancestries) {
|
|
1641
1769
|
const path = ancestry[i + 1];
|
|
1642
1770
|
if (!earliest) {
|
|
@@ -3048,7 +3176,7 @@ function _evaluate(path, state) {
|
|
|
3048
3176
|
if (callee.isMemberExpression()) {
|
|
3049
3177
|
const object = callee.get("object");
|
|
3050
3178
|
const property = callee.get("property");
|
|
3051
|
-
if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name)) {
|
|
3179
|
+
if (object.isIdentifier() && property.isIdentifier() && isValidObjectCallee(object.node.name) && !isInvalidMethod(property.node.name) && !path.scope.getBinding(object.node.name)) {
|
|
3052
3180
|
context = global[object.node.name];
|
|
3053
3181
|
const key = property.node.name;
|
|
3054
3182
|
if (Object.hasOwn(context, key)) {
|
|
@@ -3685,7 +3813,7 @@ function getFunctionArity(node) {
|
|
|
3685
3813
|
|
|
3686
3814
|
const {
|
|
3687
3815
|
STATEMENT_OR_BLOCK_KEYS,
|
|
3688
|
-
VISITOR_KEYS: VISITOR_KEYS$
|
|
3816
|
+
VISITOR_KEYS: VISITOR_KEYS$1,
|
|
3689
3817
|
isBlockStatement,
|
|
3690
3818
|
isExpression,
|
|
3691
3819
|
isIdentifier,
|
|
@@ -3871,7 +3999,7 @@ function _guessExecutionStatusRelativeToCached(base, target, cache) {
|
|
|
3871
3999
|
if (divergence.target.listKey && divergence.this.listKey && divergence.target.container === divergence.this.container) {
|
|
3872
4000
|
return divergence.target.key > divergence.this.key ? "before" : "after";
|
|
3873
4001
|
}
|
|
3874
|
-
const keys = VISITOR_KEYS$
|
|
4002
|
+
const keys = VISITOR_KEYS$1[commonPath.type];
|
|
3875
4003
|
const keyPosition = {
|
|
3876
4004
|
this: keys.indexOf(divergence.this.parentKey),
|
|
3877
4005
|
target: keys.indexOf(divergence.target.parentKey)
|
|
@@ -4576,7 +4704,6 @@ const methods = {
|
|
|
4576
4704
|
isConstantExpression: isConstantExpression,
|
|
4577
4705
|
isInStrictMode: isInStrictMode,
|
|
4578
4706
|
isDenylisted: isDenylisted,
|
|
4579
|
-
visit: visit,
|
|
4580
4707
|
skip: skip,
|
|
4581
4708
|
skipKey: skipKey,
|
|
4582
4709
|
stop: stop,
|
|
@@ -4624,236 +4751,6 @@ for (const type of Object.keys(virtualTypes)) {
|
|
|
4624
4751
|
if (!_t.TYPES.includes(type)) _t.TYPES.push(type);
|
|
4625
4752
|
}
|
|
4626
4753
|
|
|
4627
|
-
const {
|
|
4628
|
-
VISITOR_KEYS: VISITOR_KEYS$2
|
|
4629
|
-
} = _t;
|
|
4630
|
-
class TraversalContext {
|
|
4631
|
-
constructor(scope, opts, state, parentPath) {
|
|
4632
|
-
this.parentPath = parentPath;
|
|
4633
|
-
this.scope = scope;
|
|
4634
|
-
this.state = state;
|
|
4635
|
-
this.opts = opts;
|
|
4636
|
-
}
|
|
4637
|
-
queue = null;
|
|
4638
|
-
priorityQueue = null;
|
|
4639
|
-
shouldVisit(node) {
|
|
4640
|
-
const opts = this.opts;
|
|
4641
|
-
if (opts.enter || opts.exit) return true;
|
|
4642
|
-
if (opts[node.type]) return true;
|
|
4643
|
-
const keys = VISITOR_KEYS$2[node.type];
|
|
4644
|
-
if (!keys?.length) return false;
|
|
4645
|
-
for (const key of keys) {
|
|
4646
|
-
if (node[key]) {
|
|
4647
|
-
return true;
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
return false;
|
|
4651
|
-
}
|
|
4652
|
-
create(node, container, key, listKey) {
|
|
4653
|
-
return NodePath_Final.get({
|
|
4654
|
-
parentPath: this.parentPath,
|
|
4655
|
-
parent: node,
|
|
4656
|
-
container,
|
|
4657
|
-
key: key,
|
|
4658
|
-
listKey
|
|
4659
|
-
});
|
|
4660
|
-
}
|
|
4661
|
-
maybeQueue(path, notPriority) {
|
|
4662
|
-
if (this.queue) {
|
|
4663
|
-
if (notPriority) {
|
|
4664
|
-
this.queue.push(path);
|
|
4665
|
-
} else {
|
|
4666
|
-
this.priorityQueue.push(path);
|
|
4667
|
-
}
|
|
4668
|
-
}
|
|
4669
|
-
}
|
|
4670
|
-
visitMultiple(container, parent, listKey) {
|
|
4671
|
-
if (container.length === 0) return false;
|
|
4672
|
-
const queue = [];
|
|
4673
|
-
for (let key = 0; key < container.length; key++) {
|
|
4674
|
-
const node = container[key];
|
|
4675
|
-
if (node && this.shouldVisit(node)) {
|
|
4676
|
-
queue.push(this.create(parent, container, key, listKey));
|
|
4677
|
-
}
|
|
4678
|
-
}
|
|
4679
|
-
return this.visitQueue(queue);
|
|
4680
|
-
}
|
|
4681
|
-
visitSingle(node, key) {
|
|
4682
|
-
if (this.shouldVisit(node[key])) {
|
|
4683
|
-
return this.visitQueue([this.create(node, node, key)]);
|
|
4684
|
-
} else {
|
|
4685
|
-
return false;
|
|
4686
|
-
}
|
|
4687
|
-
}
|
|
4688
|
-
visitQueue(queue) {
|
|
4689
|
-
this.queue = queue;
|
|
4690
|
-
this.priorityQueue = [];
|
|
4691
|
-
const visited = new WeakSet();
|
|
4692
|
-
let stop = false;
|
|
4693
|
-
let visitIndex = 0;
|
|
4694
|
-
for (; visitIndex < queue.length;) {
|
|
4695
|
-
const path = queue[visitIndex];
|
|
4696
|
-
visitIndex++;
|
|
4697
|
-
resync.call(path);
|
|
4698
|
-
if (path.key === null) continue;
|
|
4699
|
-
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
|
4700
|
-
pushContext.call(path, this);
|
|
4701
|
-
}
|
|
4702
|
-
const {
|
|
4703
|
-
node
|
|
4704
|
-
} = path;
|
|
4705
|
-
if (visited.has(node)) continue;
|
|
4706
|
-
if (node) visited.add(node);
|
|
4707
|
-
if (path.visit()) {
|
|
4708
|
-
stop = true;
|
|
4709
|
-
break;
|
|
4710
|
-
}
|
|
4711
|
-
if (this.priorityQueue.length) {
|
|
4712
|
-
stop = this.visitQueue(this.priorityQueue);
|
|
4713
|
-
this.priorityQueue = [];
|
|
4714
|
-
this.queue = queue;
|
|
4715
|
-
if (stop) break;
|
|
4716
|
-
}
|
|
4717
|
-
}
|
|
4718
|
-
for (let i = 0; i < visitIndex; i++) {
|
|
4719
|
-
if (queue[i].key === null) continue;
|
|
4720
|
-
popContext.call(queue[i]);
|
|
4721
|
-
}
|
|
4722
|
-
this.queue = null;
|
|
4723
|
-
return stop;
|
|
4724
|
-
}
|
|
4725
|
-
visit(node, key) {
|
|
4726
|
-
const nodes = node[key];
|
|
4727
|
-
if (!nodes) return false;
|
|
4728
|
-
if (Array.isArray(nodes)) {
|
|
4729
|
-
return this.visitMultiple(nodes, node, key);
|
|
4730
|
-
} else {
|
|
4731
|
-
return this.visitSingle(node, key);
|
|
4732
|
-
}
|
|
4733
|
-
}
|
|
4734
|
-
}
|
|
4735
|
-
|
|
4736
|
-
const {
|
|
4737
|
-
VISITOR_KEYS: VISITOR_KEYS$1
|
|
4738
|
-
} = _t;
|
|
4739
|
-
function _visitPaths(ctx, paths) {
|
|
4740
|
-
ctx.queue = paths;
|
|
4741
|
-
ctx.priorityQueue = [];
|
|
4742
|
-
const visited = new Set();
|
|
4743
|
-
let stop = false;
|
|
4744
|
-
let visitIndex = 0;
|
|
4745
|
-
for (; visitIndex < paths.length;) {
|
|
4746
|
-
const path = paths[visitIndex];
|
|
4747
|
-
visitIndex++;
|
|
4748
|
-
resync.call(path);
|
|
4749
|
-
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== ctx) {
|
|
4750
|
-
pushContext.call(path, ctx);
|
|
4751
|
-
}
|
|
4752
|
-
if (path.key === null) continue;
|
|
4753
|
-
const {
|
|
4754
|
-
node
|
|
4755
|
-
} = path;
|
|
4756
|
-
if (visited.has(node)) continue;
|
|
4757
|
-
if (node) visited.add(node);
|
|
4758
|
-
if (_visit(ctx, path)) {
|
|
4759
|
-
stop = true;
|
|
4760
|
-
break;
|
|
4761
|
-
}
|
|
4762
|
-
if (ctx.priorityQueue.length) {
|
|
4763
|
-
stop = _visitPaths(ctx, ctx.priorityQueue);
|
|
4764
|
-
ctx.priorityQueue = [];
|
|
4765
|
-
ctx.queue = paths;
|
|
4766
|
-
if (stop) break;
|
|
4767
|
-
}
|
|
4768
|
-
}
|
|
4769
|
-
for (let i = 0; i < visitIndex; i++) {
|
|
4770
|
-
popContext.call(paths[i]);
|
|
4771
|
-
}
|
|
4772
|
-
ctx.queue = null;
|
|
4773
|
-
return stop;
|
|
4774
|
-
}
|
|
4775
|
-
function _visit(ctx, path) {
|
|
4776
|
-
const node = path.node;
|
|
4777
|
-
if (!node) {
|
|
4778
|
-
return false;
|
|
4779
|
-
}
|
|
4780
|
-
const opts = ctx.opts;
|
|
4781
|
-
const denylist = opts.denylist;
|
|
4782
|
-
if (denylist?.includes(node.type)) {
|
|
4783
|
-
return false;
|
|
4784
|
-
}
|
|
4785
|
-
if (opts.shouldSkip?.(path)) {
|
|
4786
|
-
return false;
|
|
4787
|
-
}
|
|
4788
|
-
if (path.shouldSkip) return path.shouldStop;
|
|
4789
|
-
if (_call.call(path, opts.enter)) return path.shouldStop;
|
|
4790
|
-
if (path.node) {
|
|
4791
|
-
if (_call.call(path, opts[node.type]?.enter)) return path.shouldStop;
|
|
4792
|
-
}
|
|
4793
|
-
path.shouldStop = traverseNode(path.node, opts, path.scope, ctx.state, path, path.skipKeys);
|
|
4794
|
-
if (path.node) {
|
|
4795
|
-
if (_call.call(path, opts.exit)) return true;
|
|
4796
|
-
}
|
|
4797
|
-
if (path.node) {
|
|
4798
|
-
_call.call(path, opts[node.type]?.exit);
|
|
4799
|
-
}
|
|
4800
|
-
return path.shouldStop;
|
|
4801
|
-
}
|
|
4802
|
-
function traverseNode(node, opts, scope, state, path, skipKeys, visitSelf) {
|
|
4803
|
-
const keys = VISITOR_KEYS$1[node.type];
|
|
4804
|
-
if (!keys?.length) return false;
|
|
4805
|
-
const ctx = new TraversalContext(scope, opts, state, path);
|
|
4806
|
-
if (visitSelf) {
|
|
4807
|
-
if (skipKeys?.[path.parentKey]) return false;
|
|
4808
|
-
return _visitPaths(ctx, [path]);
|
|
4809
|
-
}
|
|
4810
|
-
const hub = path == null ? node.type === "Program" || node.type === "File" ? new Hub() : undefined : path.hub;
|
|
4811
|
-
for (const key of keys) {
|
|
4812
|
-
if (skipKeys?.[key]) continue;
|
|
4813
|
-
const prop = node[key];
|
|
4814
|
-
if (!prop) continue;
|
|
4815
|
-
if (Array.isArray(prop)) {
|
|
4816
|
-
if (!prop.length) continue;
|
|
4817
|
-
const paths = [];
|
|
4818
|
-
for (let i = 0; i < prop.length; i++) {
|
|
4819
|
-
const childPath = NodePath_Final.get({
|
|
4820
|
-
parentPath: path,
|
|
4821
|
-
parent: node,
|
|
4822
|
-
container: prop,
|
|
4823
|
-
key: i,
|
|
4824
|
-
listKey: key,
|
|
4825
|
-
hub
|
|
4826
|
-
});
|
|
4827
|
-
paths.push(childPath);
|
|
4828
|
-
}
|
|
4829
|
-
if (_visitPaths(ctx, paths)) return true;
|
|
4830
|
-
} else {
|
|
4831
|
-
if (_visitPaths(ctx, [NodePath_Final.get({
|
|
4832
|
-
parentPath: path,
|
|
4833
|
-
parent: node,
|
|
4834
|
-
container: node,
|
|
4835
|
-
key,
|
|
4836
|
-
listKey: null,
|
|
4837
|
-
hub
|
|
4838
|
-
})])) {
|
|
4839
|
-
return true;
|
|
4840
|
-
}
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4843
|
-
return false;
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
function call(key) {
|
|
4847
|
-
const opts = this.opts;
|
|
4848
|
-
this.debug(key);
|
|
4849
|
-
if (this.node) {
|
|
4850
|
-
if (_call.call(this, opts[key])) return true;
|
|
4851
|
-
}
|
|
4852
|
-
if (this.node) {
|
|
4853
|
-
return _call.call(this, opts[this.node.type]?.[key]);
|
|
4854
|
-
}
|
|
4855
|
-
return false;
|
|
4856
|
-
}
|
|
4857
4754
|
function _call(fns) {
|
|
4858
4755
|
if (!fns) return false;
|
|
4859
4756
|
for (const fn of fns) {
|
|
@@ -4875,35 +4772,6 @@ function _call(fns) {
|
|
|
4875
4772
|
function isDenylisted() {
|
|
4876
4773
|
return !!this.opts.denylist?.includes(this.node.type);
|
|
4877
4774
|
}
|
|
4878
|
-
function restoreContext(path, context) {
|
|
4879
|
-
if (path.context !== context) {
|
|
4880
|
-
path.context = context;
|
|
4881
|
-
path.state = context.state;
|
|
4882
|
-
path.opts = context.opts;
|
|
4883
|
-
}
|
|
4884
|
-
}
|
|
4885
|
-
function visit() {
|
|
4886
|
-
if (!this.node) {
|
|
4887
|
-
return false;
|
|
4888
|
-
}
|
|
4889
|
-
if (this.isDenylisted()) {
|
|
4890
|
-
return false;
|
|
4891
|
-
}
|
|
4892
|
-
if (this.opts.shouldSkip?.(this)) {
|
|
4893
|
-
return false;
|
|
4894
|
-
}
|
|
4895
|
-
const currentContext = this.context;
|
|
4896
|
-
if (this.shouldSkip || call.call(this, "enter")) {
|
|
4897
|
-
this.debug("Skip...");
|
|
4898
|
-
return this.shouldStop;
|
|
4899
|
-
}
|
|
4900
|
-
restoreContext(this, currentContext);
|
|
4901
|
-
this.debug("Recursing into...");
|
|
4902
|
-
this.shouldStop = traverseNode(this.node, this.opts, this.scope, this.state, this, this.skipKeys);
|
|
4903
|
-
restoreContext(this, currentContext);
|
|
4904
|
-
call.call(this, "exit");
|
|
4905
|
-
return this.shouldStop;
|
|
4906
|
-
}
|
|
4907
4775
|
function skip() {
|
|
4908
4776
|
this.shouldSkip = true;
|
|
4909
4777
|
}
|