diff options
Diffstat (limited to 'node_modules/@babel/traverse/lib/path/modification.js')
| -rw-r--r-- | node_modules/@babel/traverse/lib/path/modification.js | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/node_modules/@babel/traverse/lib/path/modification.js b/node_modules/@babel/traverse/lib/path/modification.js index 3a55cc76..62d853f7 100644 --- a/node_modules/@babel/traverse/lib/path/modification.js +++ b/node_modules/@babel/traverse/lib/path/modification.js @@ -7,7 +7,6 @@ exports._containerInsert = _containerInsert; exports._containerInsertAfter = _containerInsertAfter; exports._containerInsertBefore = _containerInsertBefore; exports._verifyNodeList = _verifyNodeList; -exports.hoist = hoist; exports.insertAfter = insertAfter; exports.insertBefore = insertBefore; exports.pushContainer = pushContainer; @@ -16,6 +15,8 @@ exports.updateSiblingKeys = updateSiblingKeys; var _cache = require("../cache.js"); var _hoister = require("./lib/hoister.js"); var _index = require("./index.js"); +var _context = require("./context.js"); +var _removal = require("./removal.js"); var _t = require("@babel/types"); const { arrowFunctionExpression, @@ -35,8 +36,8 @@ const { thisExpression } = _t; function insertBefore(nodes_) { - this._assertUnremoved(); - const nodes = this._verifyNodeList(nodes_); + _removal._assertUnremoved.call(this); + const nodes = _verifyNodeList.call(this, nodes_); const { parentPath, parent @@ -47,7 +48,7 @@ function insertBefore(nodes_) { if (this.node) nodes.push(this.node); return this.replaceExpressionWithStatements(nodes); } else if (Array.isArray(this.container)) { - return this._containerInsertBefore(nodes); + return _containerInsertBefore.call(this, nodes); } else if (this.isStatementOrBlock()) { const node = this.node; const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null); @@ -58,7 +59,7 @@ function insertBefore(nodes_) { } } function _containerInsert(from, nodes) { - this.updateSiblingKeys(from, nodes.length); + updateSiblingKeys.call(this, from, nodes.length); const paths = []; this.container.splice(from, 0, ...nodes); for (let i = 0; i < nodes.length; i++) { @@ -67,12 +68,12 @@ function _containerInsert(from, nodes) { const path = this.getSibling(to); paths.push(path); if ((_this$context = this.context) != null && _this$context.queue) { - path.pushContext(this.context); + _context.pushContext.call(path, this.context); } } - const contexts = this._getQueueContexts(); + const contexts = _context._getQueueContexts.call(this); for (const path of paths) { - path.setScope(); + _context.setScope.call(path); path.debug("Inserted."); for (const context of contexts) { context.maybeQueue(path, true); @@ -81,10 +82,10 @@ function _containerInsert(from, nodes) { return paths; } function _containerInsertBefore(nodes) { - return this._containerInsert(this.key, nodes); + return _containerInsert.call(this, this.key, nodes); } function _containerInsertAfter(nodes) { - return this._containerInsert(this.key + 1, nodes); + return _containerInsert.call(this, this.key + 1, nodes); } const last = arr => arr[arr.length - 1]; function isHiddenInSequenceExpression(path) { @@ -98,11 +99,11 @@ function isAlmostConstantAssignment(node, scope) { return blockScope.hasOwnBinding(node.left.name) && blockScope.getOwnBinding(node.left.name).constantViolations.length <= 1; } function insertAfter(nodes_) { - this._assertUnremoved(); + _removal._assertUnremoved.call(this); if (this.isSequenceExpression()) { return last(this.get("expressions")).insertAfter(nodes_); } - const nodes = this._verifyNodeList(nodes_); + const nodes = _verifyNodeList.call(this, nodes_); const { parentPath, parent @@ -148,7 +149,7 @@ function insertAfter(nodes_) { } return this.replaceExpressionWithStatements(nodes); } else if (Array.isArray(this.container)) { - return this._containerInsertAfter(nodes); + return _containerInsertAfter.call(this, nodes); } else if (this.isStatementOrBlock()) { const node = this.node; const shouldInsertCurrentNode = node && (!this.isExpressionStatement() || node.expression != null); @@ -194,8 +195,8 @@ function _verifyNodeList(nodes) { return nodes; } function unshiftContainer(listKey, nodes) { - this._assertUnremoved(); - nodes = this._verifyNodeList(nodes); + _removal._assertUnremoved.call(this); + nodes = _verifyNodeList.call(this, nodes); const path = _index.default.get({ parentPath: this, parent: this.node, @@ -203,11 +204,11 @@ function unshiftContainer(listKey, nodes) { listKey, key: 0 }).setContext(this.context); - return path._containerInsertBefore(nodes); + return _containerInsertBefore.call(path, nodes); } function pushContainer(listKey, nodes) { - this._assertUnremoved(); - const verifiedNodes = this._verifyNodeList(nodes); + _removal._assertUnremoved.call(this); + const verifiedNodes = _verifyNodeList.call(this, nodes); const container = this.node[listKey]; const path = _index.default.get({ parentPath: this, @@ -218,9 +219,11 @@ function pushContainer(listKey, nodes) { }).setContext(this.context); return path.replaceWithMultiple(verifiedNodes); } -function hoist(scope = this.scope) { - const hoister = new _hoister.default(this, scope); - return hoister.run(); +{ + exports.hoist = function hoist(scope = this.scope) { + const hoister = new _hoister.default(this, scope); + return hoister.run(); + }; } //# sourceMappingURL=modification.js.map |
