File: /var/www/linde-ai/html/node_modules/@babel/traverse/lib/path/lib/removal-hooks.js.map
{"version":3,"names":["hooks","self","parent","removeParent","key","isWhile","isSwitchCase","isExportDeclaration","isLabeledStatement","listKey","isVariableDeclaration","node","declarations","length","isExpressionStatement","remove","isSequenceExpression","expressions","replaceWith","isBinary","right","left","isIfStatement","isLoop","isArrowFunctionExpression","type","body"],"sources":["../../../src/path/lib/removal-hooks.ts"],"sourcesContent":["// this file contains hooks that handle ancestry cleanup of parent nodes when removing children\n\nimport type NodePath from \"..\";\nimport type * as t from \"@babel/types\";\n/**\n * Pre hooks should be used for either rejecting removal or delegating removal\n */\n\nexport const hooks = [\n function (self: NodePath, parent: NodePath) {\n const removeParent =\n // while (NODE);\n // removing the test of a while/switch, we can either just remove it entirely *or* turn the\n // `test` into `true` unlikely that the latter will ever be what's wanted so we just remove\n // the loop to avoid infinite recursion\n (self.key === \"test\" && (parent.isWhile() || parent.isSwitchCase())) ||\n // export NODE;\n // just remove a declaration for an export as this is no longer valid\n (self.key === \"declaration\" && parent.isExportDeclaration()) ||\n // label: NODE\n // stray labeled statement with no body\n (self.key === \"body\" && parent.isLabeledStatement()) ||\n // let NODE;\n // remove an entire declaration if there are no declarators left\n (self.listKey === \"declarations\" &&\n parent.isVariableDeclaration() &&\n parent.node.declarations.length === 1) ||\n // NODE;\n // remove the entire expression statement if there's no expression\n (self.key === \"expression\" && parent.isExpressionStatement());\n\n if (removeParent) {\n parent.remove();\n return true;\n }\n },\n\n function (self: NodePath, parent: NodePath) {\n if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {\n // (node, NODE);\n // we've just removed the second element of a sequence expression so let's turn that sequence\n // expression into a regular expression\n parent.replaceWith(parent.node.expressions[0]);\n return true;\n }\n },\n\n function (self: NodePath, parent: NodePath) {\n if (parent.isBinary()) {\n // left + NODE;\n // NODE + right;\n // we're in a binary expression, better remove it and replace it with the last expression\n if (self.key === \"left\") {\n parent.replaceWith(parent.node.right);\n } else {\n // key === \"right\"\n parent.replaceWith(parent.node.left);\n }\n return true;\n }\n },\n\n function (self: NodePath, parent: NodePath) {\n if (\n (parent.isIfStatement() && self.key === \"consequent\") ||\n (self.key === \"body\" &&\n (parent.isLoop() || parent.isArrowFunctionExpression()))\n ) {\n self.replaceWith({\n type: \"BlockStatement\",\n body: [],\n } as t.BlockStatement);\n return true;\n }\n },\n];\n"],"mappings":";;;;;;AAQO,MAAMA,KAAK,GAAG,CACnB,UAAUC,IAAV,EAA0BC,MAA1B,EAA4C;EAC1C,MAAMC,YAAY,GAKfF,IAAI,CAACG,GAAL,KAAa,MAAb,KAAwBF,MAAM,CAACG,OAAP,MAAoBH,MAAM,CAACI,YAAP,EAA5C,CAAD,IAGCL,IAAI,CAACG,GAAL,KAAa,aAAb,IAA8BF,MAAM,CAACK,mBAAP,EAH/B,IAMCN,IAAI,CAACG,GAAL,KAAa,MAAb,IAAuBF,MAAM,CAACM,kBAAP,EANxB,IASCP,IAAI,CAACQ,OAAL,KAAiB,cAAjB,IACCP,MAAM,CAACQ,qBAAP,EADD,IAECR,MAAM,CAACS,IAAP,CAAYC,YAAZ,CAAyBC,MAAzB,KAAoC,CAXtC,IAcCZ,IAAI,CAACG,GAAL,KAAa,YAAb,IAA6BF,MAAM,CAACY,qBAAP,EAnBhC;;EAqBA,IAAIX,YAAJ,EAAkB;IAChBD,MAAM,CAACa,MAAP;IACA,OAAO,IAAP;EACD;AACF,CA3BkB,EA6BnB,UAAUd,IAAV,EAA0BC,MAA1B,EAA4C;EAC1C,IAAIA,MAAM,CAACc,oBAAP,MAAiCd,MAAM,CAACS,IAAP,CAAYM,WAAZ,CAAwBJ,MAAxB,KAAmC,CAAxE,EAA2E;IAIzEX,MAAM,CAACgB,WAAP,CAAmBhB,MAAM,CAACS,IAAP,CAAYM,WAAZ,CAAwB,CAAxB,CAAnB;IACA,OAAO,IAAP;EACD;AACF,CArCkB,EAuCnB,UAAUhB,IAAV,EAA0BC,MAA1B,EAA4C;EAC1C,IAAIA,MAAM,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