diff options
Diffstat (limited to 'node_modules/@babel/traverse/lib/path/replacement.js')
| -rw-r--r-- | node_modules/@babel/traverse/lib/path/replacement.js | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/node_modules/@babel/traverse/lib/path/replacement.js b/node_modules/@babel/traverse/lib/path/replacement.js index cca66d0f..4c052dfa 100644 --- a/node_modules/@babel/traverse/lib/path/replacement.js +++ b/node_modules/@babel/traverse/lib/path/replacement.js @@ -13,9 +13,10 @@ var _codeFrame = require("@babel/code-frame"); var _index = require("../index.js"); var _index2 = require("./index.js"); var _cache = require("../cache.js"); +var _modification = require("./modification.js"); var _parser = require("@babel/parser"); var _t = require("@babel/types"); -var _helperHoistVariables = require("@babel/helper-hoist-variables"); +var _context = require("./context.js"); const { FUNCTION_TYPES, arrowFunctionExpression, @@ -48,8 +49,8 @@ const { } = _t; function replaceWithMultiple(nodes) { var _getCachedPaths; - this.resync(); - nodes = this._verifyNodeList(nodes); + _context.resync.call(this); + nodes = _modification._verifyNodeList.call(this, nodes); inheritLeadingComments(nodes[0], this.node); inheritTrailingComments(nodes[nodes.length - 1], this.node); (_getCachedPaths = (0, _cache.getCachedPaths)(this.hub, this.parent)) == null || _getCachedPaths.delete(this.node); @@ -63,7 +64,7 @@ function replaceWithMultiple(nodes) { return paths; } function replaceWithSourceString(replacement) { - this.resync(); + _context.resync.call(this); let ast; try { replacement = `(${replacement})`; @@ -86,7 +87,7 @@ function replaceWithSourceString(replacement) { return this.replaceWith(expressionAST); } function replaceWith(replacementPath) { - this.resync(); + _context.resync.call(this); if (this.removed) { throw new Error("You can't replace this node, we've already removed it"); } @@ -123,9 +124,9 @@ function replaceWith(replacementPath) { inheritsComments(replacement, oldNode); removeComments(oldNode); } - this._replaceWith(replacement); + _replaceWith.call(this, replacement); this.type = replacement.type; - this.setScope(); + _context.setScope.call(this); this.requeue(); return [nodePath ? this.get(nodePath) : this]; } @@ -144,7 +145,7 @@ function _replaceWith(node) { this.node = this.container[this.key] = node; } function replaceExpressionWithStatements(nodes) { - this.resync(); + _context.resync.call(this); const declars = []; const nodesAsSingleExpression = gatherSequenceExpressions(nodes, declars); if (nodesAsSingleExpression) { @@ -154,17 +155,15 @@ function replaceExpressionWithStatements(nodes) { return this.replaceWith(nodesAsSingleExpression)[0].get("expressions"); } const functionParent = this.getFunctionParent(); - const isParentAsync = functionParent == null ? void 0 : functionParent.is("async"); - const isParentGenerator = functionParent == null ? void 0 : functionParent.is("generator"); + const isParentAsync = functionParent == null ? void 0 : functionParent.node.async; + const isParentGenerator = functionParent == null ? void 0 : functionParent.node.generator; const container = arrowFunctionExpression([], blockStatement(nodes)); this.replaceWith(callExpression(container, [])); const callee = this.get("callee"); - (0, _helperHoistVariables.default)(callee.get("body"), id => { - this.scope.push({ - id - }); - }, "var"); - const completionRecords = this.get("callee").getCompletionRecords(); + callee.get("body").scope.hoistVariables(id => this.scope.push({ + id + })); + const completionRecords = callee.getCompletionRecords(); for (const path of completionRecords) { if (!path.isExpressionStatement()) continue; const loop = path.findParent(path => path.isLoop()); @@ -246,11 +245,11 @@ function gatherSequenceExpressions(nodes, declars) { } } function replaceInline(nodes) { - this.resync(); + _context.resync.call(this); if (Array.isArray(nodes)) { if (Array.isArray(this.container)) { - nodes = this._verifyNodeList(nodes); - const paths = this._containerInsertAfter(nodes); + nodes = _modification._verifyNodeList.call(this, nodes); + const paths = _modification._containerInsertAfter.call(this, nodes); this.remove(); return paths; } else { |
