replacement.js.map
17.9 KB
{"version":3,"names":["FUNCTION_TYPES","arrowFunctionExpression","assignmentExpression","awaitExpression","blockStatement","callExpression","cloneNode","expressionStatement","identifier","inheritLeadingComments","inheritTrailingComments","inheritsComments","isExpression","isProgram","isStatement","removeComments","returnStatement","toSequenceExpression","validate","yieldExpression","replaceWithMultiple","nodes","resync","_verifyNodeList","node","length","pathCache","get","parent","delete","container","key","paths","insertAfter","requeue","remove","replaceWithSourceString","replacement","ast","parse","err","loc","message","codeFrameColumns","start","line","column","code","expressionAST","program","body","expression","traverse","removeProperties","replaceWith","replacementPath","removed","Error","NodePath","Array","isArray","nodePath","isNodeType","canHaveVariableDeclarationOrExpression","canSwapBetweenExpressionAndStatement","parentPath","isExportDefaultDeclaration","replaceExpressionWithStatements","oldNode","_replaceWith","type","setScope","ReferenceError","inList","debug","set","nodesAsSequenceExpression","scope","functionParent","getFunctionParent","isParentAsync","is","isParentGenerator","callee","hoistVariables","id","push","completionRecords","getCompletionRecords","path","isExpressionStatement","loop","findParent","isLoop","uid","getData","generateDeclaredUidIdentifier","pushContainer","setData","name","arrowFunctionToExpression","newCallee","needToAwaitFunction","hasType","needToYieldFunction","replaceInline","_containerInsertAfter"],"sources":["../../src/path/replacement.ts"],"sourcesContent":["// This file contains methods responsible for replacing a node with another.\n\nimport { codeFrameColumns } from \"@babel/code-frame\";\nimport traverse from \"../index\";\nimport NodePath from \"./index\";\nimport { path as pathCache } from \"../cache\";\nimport { parse } from \"@babel/parser\";\nimport {\n FUNCTION_TYPES,\n arrowFunctionExpression,\n assignmentExpression,\n awaitExpression,\n blockStatement,\n callExpression,\n cloneNode,\n expressionStatement,\n identifier,\n inheritLeadingComments,\n inheritTrailingComments,\n inheritsComments,\n isExpression,\n isProgram,\n isStatement,\n removeComments,\n returnStatement,\n toSequenceExpression,\n validate,\n yieldExpression,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport hoistVariables from \"@babel/helper-hoist-variables\";\n\n/**\n * Replace a node with an array of multiple. This method performs the following steps:\n *\n * - Inherit the comments of first provided node with that of the current node.\n * - Insert the provided nodes after the current node.\n * - Remove the current node.\n */\n\nexport function replaceWithMultiple(\n this: NodePath,\n nodes: t.Node | t.Node[],\n): NodePath[] {\n this.resync();\n\n nodes = this._verifyNodeList(nodes);\n inheritLeadingComments(nodes[0], this.node);\n inheritTrailingComments(nodes[nodes.length - 1], this.node);\n pathCache.get(this.parent)?.delete(this.node);\n this.node =\n // @ts-expect-error this.key must present in this.container\n this.container[this.key] = null;\n const paths = this.insertAfter(nodes);\n\n if (this.node) {\n this.requeue();\n } else {\n this.remove();\n }\n return paths;\n}\n\n/**\n * Parse a string as an expression and replace the current node with the result.\n *\n * NOTE: This is typically not a good idea to use. Building source strings when\n * transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's\n * easier to use, your transforms will be extremely brittle.\n */\n\nexport function replaceWithSourceString(this: NodePath, replacement: string) {\n this.resync();\n let ast: t.File;\n\n try {\n replacement = `(${replacement})`;\n // @ts-expect-error todo: use babel-types ast typings in Babel parser\n ast = parse(replacement);\n } catch (err) {\n const loc = err.loc;\n if (loc) {\n err.message +=\n \" - make sure this is an expression.\\n\" +\n codeFrameColumns(replacement, {\n start: {\n line: loc.line,\n column: loc.column + 1,\n },\n });\n err.code = \"BABEL_REPLACE_SOURCE_ERROR\";\n }\n throw err;\n }\n\n const expressionAST = (ast.program.body[0] as t.ExpressionStatement)\n .expression;\n traverse.removeProperties(expressionAST);\n return this.replaceWith(expressionAST);\n}\n\n/**\n * Replace the current node with another.\n */\n\nexport function replaceWith<R extends t.Node>(\n this: NodePath,\n replacementPath: R | NodePath<R>,\n): [NodePath<R>] {\n this.resync();\n\n if (this.removed) {\n throw new Error(\"You can't replace this node, we've already removed it\");\n }\n\n let replacement: t.Node =\n replacementPath instanceof NodePath\n ? replacementPath.node\n : replacementPath;\n\n if (!replacement) {\n throw new Error(\n \"You passed `path.replaceWith()` a falsy node, use `path.remove()` instead\",\n );\n }\n\n if (this.node === replacement) {\n return [this as NodePath<R>];\n }\n\n if (this.isProgram() && !isProgram(replacement)) {\n throw new Error(\n \"You can only replace a Program root node with another Program node\",\n );\n }\n\n if (Array.isArray(replacement)) {\n throw new Error(\n \"Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`\",\n );\n }\n\n if (typeof replacement === \"string\") {\n throw new Error(\n \"Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`\",\n );\n }\n\n let nodePath = \"\";\n\n if (this.isNodeType(\"Statement\") && isExpression(replacement)) {\n if (\n !this.canHaveVariableDeclarationOrExpression() &&\n !this.canSwapBetweenExpressionAndStatement(replacement) &&\n !this.parentPath.isExportDefaultDeclaration()\n ) {\n // replacing a statement with an expression so wrap it in an expression statement\n replacement = expressionStatement(replacement);\n nodePath = \"expression\";\n }\n }\n\n if (this.isNodeType(\"Expression\") && isStatement(replacement)) {\n if (\n !this.canHaveVariableDeclarationOrExpression() &&\n !this.canSwapBetweenExpressionAndStatement(replacement)\n ) {\n // replacing an expression with a statement so let's explode it\n return this.replaceExpressionWithStatements([replacement]) as [\n NodePath<R>,\n ];\n }\n }\n\n const oldNode = this.node;\n if (oldNode) {\n inheritsComments(replacement, oldNode);\n removeComments(oldNode);\n }\n\n // replace the node\n this._replaceWith(replacement);\n this.type = replacement.type;\n\n // potentially create new scope\n this.setScope();\n\n // requeue for visiting\n this.requeue();\n\n return [\n nodePath ? (this.get(nodePath) as NodePath<R>) : (this as NodePath<R>),\n ];\n}\n\n/**\n * Description\n */\n\nexport function _replaceWith(this: NodePath, node: t.Node) {\n if (!this.container) {\n throw new ReferenceError(\"Container is falsy\");\n }\n\n if (this.inList) {\n // @ts-expect-error todo(flow->ts): check if validate accepts a numeric key\n validate(this.parent, this.key, [node]);\n } else {\n validate(this.parent, this.key as string, node);\n }\n\n this.debug(`Replace with ${node?.type}`);\n pathCache.get(this.parent)?.set(node, this).delete(this.node);\n\n this.node =\n // @ts-expect-error this.key must present in this.container\n this.container[this.key] = node;\n}\n\n/**\n * This method takes an array of statements nodes and then explodes it\n * into expressions. This method retains completion records which is\n * extremely important to retain original semantics.\n */\n\nexport function replaceExpressionWithStatements(\n this: NodePath,\n nodes: Array<t.Statement>,\n) {\n this.resync();\n\n const nodesAsSequenceExpression = toSequenceExpression(nodes, this.scope);\n\n if (nodesAsSequenceExpression) {\n return this.replaceWith(nodesAsSequenceExpression)[0].get(\"expressions\");\n }\n\n const functionParent = this.getFunctionParent();\n const isParentAsync = functionParent?.is(\"async\");\n const isParentGenerator = functionParent?.is(\"generator\");\n\n const container = arrowFunctionExpression([], blockStatement(nodes));\n\n this.replaceWith(callExpression(container, []));\n // replaceWith changes the type of \"this\", but it isn't trackable by TS\n type ThisType = NodePath<\n t.CallExpression & {\n callee: t.ArrowFunctionExpression & { body: t.BlockStatement };\n }\n >;\n\n // hoist variable declaration in do block\n // `(do { var x = 1; x;})` -> `var x; (() => { x = 1; return x; })()`\n const callee = (this as ThisType).get(\"callee\");\n hoistVariables(\n callee.get(\"body\"),\n (id: t.Identifier) => {\n this.scope.push({ id });\n },\n \"var\",\n );\n\n // add implicit returns to all ending expression statements\n const completionRecords: Array<NodePath> = (this as ThisType)\n .get(\"callee\")\n .getCompletionRecords();\n for (const path of completionRecords) {\n if (!path.isExpressionStatement()) continue;\n\n const loop = path.findParent(path => path.isLoop());\n if (loop) {\n let uid = loop.getData(\"expressionReplacementReturnUid\");\n\n if (!uid) {\n uid = callee.scope.generateDeclaredUidIdentifier(\"ret\");\n callee\n .get(\"body\")\n .pushContainer(\"body\", returnStatement(cloneNode(uid)));\n loop.setData(\"expressionReplacementReturnUid\", uid);\n } else {\n uid = identifier(uid.name);\n }\n\n path\n .get(\"expression\")\n .replaceWith(\n assignmentExpression(\"=\", cloneNode(uid), path.node.expression),\n );\n } else {\n path.replaceWith(returnStatement(path.node.expression));\n }\n }\n\n // This is an IIFE, so we don't need to worry about the noNewArrows assumption\n callee.arrowFunctionToExpression();\n // Fixme: we can not `assert this is NodePath<t.FunctionExpression>` in `arrowFunctionToExpression`\n // because it is not a class method known at compile time.\n const newCallee = callee as unknown as NodePath<t.FunctionExpression>;\n\n // (() => await xxx)() -> await (async () => await xxx)();\n const needToAwaitFunction =\n isParentAsync &&\n traverse.hasType(\n (this.get(\"callee.body\") as NodePath<t.BlockStatement>).node,\n \"AwaitExpression\",\n FUNCTION_TYPES,\n );\n const needToYieldFunction =\n isParentGenerator &&\n traverse.hasType(\n (this.get(\"callee.body\") as NodePath<t.BlockStatement>).node,\n \"YieldExpression\",\n FUNCTION_TYPES,\n );\n if (needToAwaitFunction) {\n newCallee.set(\"async\", true);\n // yield* will await the generator return result\n if (!needToYieldFunction) {\n this.replaceWith(awaitExpression((this as ThisType).node));\n }\n }\n if (needToYieldFunction) {\n newCallee.set(\"generator\", true);\n this.replaceWith(yieldExpression((this as ThisType).node, true));\n }\n\n return newCallee.get(\"body.body\");\n}\n\nexport function replaceInline(this: NodePath, nodes: t.Node | Array<t.Node>) {\n this.resync();\n\n if (Array.isArray(nodes)) {\n if (Array.isArray(this.container)) {\n nodes = this._verifyNodeList(nodes);\n const paths = this._containerInsertAfter(nodes);\n this.remove();\n return paths;\n } else {\n return this.replaceWithMultiple(nodes);\n }\n } else {\n return this.replaceWith(nodes);\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AAuBA;AAA2D;EAtBzDA,cAAc;EACdC,uBAAuB;EACvBC,oBAAoB;EACpBC,eAAe;EACfC,cAAc;EACdC,cAAc;EACdC,SAAS;EACTC,mBAAmB;EACnBC,UAAU;EACVC,sBAAsB;EACtBC,uBAAuB;EACvBC,gBAAgB;EAChBC,YAAY;EACZC,SAAS;EACTC,WAAW;EACXC,cAAc;EACdC,eAAe;EACfC,oBAAoB;EACpBC,QAAQ;EACRC;AAAe;;AAaV,SAASC,mBAAmB,CAEjCC,KAAwB,EACZ;EAAA;EACZ,IAAI,CAACC,MAAM,EAAE;EAEbD,KAAK,GAAG,I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