| 1 | // This file contains methods responsible for maintaining a TraversalContext. |
| 2 | |
| 3 | import { traverseNodescip-typescript npm @babel/traverse 7.20.13 src/`traverse-node.ts`/traverseNode(). } from "../traverse-node"scip-typescript npm @babel/traverse 7.20.13 src/`traverse-node.ts`/; |
| 4 | import { SHOULD_SKIPscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/SHOULD_SKIP., SHOULD_STOPscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/SHOULD_STOP. } from "./index"scip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/; |
| 5 | import type TraversalContextscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext# from "../context"scip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/; |
| 6 | import type NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# from "./index"scip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/; |
| 7 | import type * as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/ from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/; |
| 8 | |
| 9 | export function callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(key): string): boolean { |
| 10 | const opts = this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts.; |
| 11 | |
| 12 | this.debugscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#debug().(keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(key)); |
| 13 | |
| 14 | if (this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.) { |
| 15 | if (this._callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(opts[keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(key)])) return true; |
| 16 | } |
| 17 | |
| 18 | if (this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.) { |
| 19 | return this._callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(opts[this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.] && opts[this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.][keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().(key)]); |
| 20 | } |
| 21 | |
| 22 | return false; |
| 23 | } |
| 24 | |
| 25 | export function _callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, fnsscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(fns)?: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<Functionscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Function#>): boolean { |
| 26 | if (!fnsscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(fns)) return false; |
| 27 | |
| 28 | for (const fn of fnsscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_call().(fns)) { |
| 29 | if (!fn) continue; |
| 30 | |
| 31 | const node = this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.; |
| 32 | if (!node) return true; |
| 33 | |
| 34 | const ret = fn.callscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Function#call().(this.statescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#state., this, this.statescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#state.); |
| 35 | if (ret && typeof ret === "object" && typeof ret.then === "function") { |
| 36 | throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#( |
| 37 | `You appear to be using a plugin with an async traversal visitor, ` + |
| 38 | `which your current version of Babel does not support. ` + |
| 39 | `If you're using a published plugin, you may need to upgrade ` + |
| 40 | `your @babel/core version.`, |
| 41 | ); |
| 42 | } |
| 43 | if (ret) { |
| 44 | throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(`Unexpected return value from visitor method ${fn}`); |
| 45 | } |
| 46 | |
| 47 | // node has been replaced, it will have been requeued |
| 48 | if (this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. !== node) return true; |
| 49 | |
| 50 | // this.shouldSkip || this.shouldStop || this.removed |
| 51 | if (this._traverseFlagsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#_traverseFlags. > 0) return true; |
| 52 | } |
| 53 | |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | export function isDenylistedscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/isDenylisted().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/isDenylisted().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#): boolean { |
| 58 | const denylist = this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..denylist ?? this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..blacklist; |
| 59 | return denylist && denylist.indexOf(this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node..typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.) > -1; |
| 60 | } |
| 61 | |
| 62 | // TODO: Remove in Babel 8 |
| 63 | export { isDenylistedscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/isDenylisted(). as isBlacklistedscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/isDenylisted(). }; |
| 64 | |
| 65 | function restoreContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(pathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(context): TraversalContextscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#) { |
| 66 | if (pathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(path).contextscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#context. !== contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(context)) { |
| 67 | pathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(path).contextscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#context. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(context); |
| 68 | pathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(path).statescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#state. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(context).statescip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#state.; |
| 69 | pathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(path).optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(context).optsscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#opts.; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | export function visitscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/visit().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/visit().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#): boolean { |
| 74 | if (!this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.) { |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | if (this.isDenylistedscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/isDenylisted().()) { |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | if (this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..shouldSkip && this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..shouldSkip(this)) { |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | const currentContext = this.contextscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#context.; |
| 87 | // Note: We need to check "this.shouldSkip" first because |
| 88 | // another visitor can set it to true. Usually .shouldSkip is false |
| 89 | // before calling the enter visitor, but it can be true in case of |
| 90 | // a requeued node (e.g. by .replaceWith()) that is then marked |
| 91 | // with .skip(). |
| 92 | if (this.shouldSkipscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldSkip`(). || this.callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().("enter")) { |
| 93 | this.debugscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#debug().("Skip..."); |
| 94 | return this.shouldStopscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldStop`().; |
| 95 | } |
| 96 | restoreContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(this, currentContext); |
| 97 | |
| 98 | this.debugscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#debug().("Recursing into..."); |
| 99 | this.shouldStopscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldStop`(). = traverseNodescip-typescript npm @babel/traverse 7.20.13 src/`traverse-node.ts`/traverseNode().( |
| 100 | this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., |
| 101 | this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts., |
| 102 | this.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope., |
| 103 | this.statescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#state., |
| 104 | this, |
| 105 | this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys., |
| 106 | ); |
| 107 | |
| 108 | restoreContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/restoreContext().(this, currentContext); |
| 109 | |
| 110 | this.callscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/call().("exit"); |
| 111 | |
| 112 | return this.shouldStopscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldStop`().; |
| 113 | } |
| 114 | |
| 115 | export function skipscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skip().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skip().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 116 | this.shouldSkipscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldSkip`(). = true; |
| 117 | } |
| 118 | |
| 119 | export function skipKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skipKey().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skipKey().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skipKey().(key): string) { |
| 120 | if (this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys. == null) { |
| 121 | this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys. = {}; |
| 122 | } |
| 123 | this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys.[keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skipKey().(key)] = true; |
| 124 | } |
| 125 | |
| 126 | export function stopscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/stop().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/stop().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 127 | // this.shouldSkip = true; this.shouldStop = true; |
| 128 | this._traverseFlagsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#_traverseFlags. |= SHOULD_SKIPscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/SHOULD_SKIP. | SHOULD_STOPscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/SHOULD_STOP.; |
| 129 | } |
| 130 | |
| 131 | export function setScopescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setScope().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setScope().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 132 | if (this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts. && this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..noScope) return; |
| 133 | |
| 134 | let path = this.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.; |
| 135 | |
| 136 | if ( |
| 137 | // Skip method scope if is computed method key or decorator expression |
| 138 | ((this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. === "key" || this.listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#listKey. === "decorators") && |
| 139 | path.isMethodscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isMethod().()) || |
| 140 | // Skip switch scope if for discriminant (`x` in `switch (x) {}`). |
| 141 | (this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. === "discriminant" && path.isSwitchStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isSwitchStatement().()) |
| 142 | ) { |
| 143 | path = path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.; |
| 144 | } |
| 145 | |
| 146 | let target; |
| 147 | while (path && !target) { |
| 148 | if (path.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts. && path.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts..noScope) return; |
| 149 | |
| 150 | target = path.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope.; |
| 151 | path = path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.; |
| 152 | } |
| 153 | |
| 154 | this.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. = this.getScopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#getScope().(target); |
| 155 | if (this.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope.) this.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..initscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#init().(); |
| 156 | } |
| 157 | |
| 158 | export function setContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().<Sscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().[S] = unknown>( |
| 159 | thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, |
| 160 | contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(context)?: TraversalContextscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#<Sscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().[S]>, |
| 161 | ) { |
| 162 | if (this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys. != null) { |
| 163 | this.skipKeysscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#skipKeys. = {}; |
| 164 | } |
| 165 | // this.shouldSkip = false; this.shouldStop = false; this.removed = false; |
| 166 | this._traverseFlagsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#_traverseFlags. = 0; |
| 167 | |
| 168 | if (contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(context)) { |
| 169 | this.contextscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#context. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(context); |
| 170 | this.statescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#state. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(context).statescip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#state.; |
| 171 | this.optsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#opts. = contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(context).optsscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#opts.; |
| 172 | } |
| 173 | |
| 174 | this.setScopescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setScope().(); |
| 175 | |
| 176 | return this; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Here we resync the node paths `key` and `container`. If they've changed according |
| 181 | * to what we have stored internally then we attempt to resync by crawling and looking |
| 182 | * for the new values. |
| 183 | */ |
| 184 | |
| 185 | export function resyncscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/resync().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/resync().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 186 | if (this.removedscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>removed`().) return; |
| 187 | |
| 188 | this._resyncParentscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncParent().(); |
| 189 | this._resyncListscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncList().(); |
| 190 | this._resyncKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncKey().(); |
| 191 | //this._resyncRemoved(); |
| 192 | } |
| 193 | |
| 194 | export function _resyncParentscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncParent().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncParent().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 195 | if (this.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.) { |
| 196 | this.parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent. = this.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | export function _resyncKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncKey().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncKey().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 201 | if (!this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.) return; |
| 202 | |
| 203 | if ( |
| 204 | this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. === |
| 205 | // @ts-expect-error this.key should present in this.container |
| 206 | this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.[this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key.] |
| 207 | ) { |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | // grrr, path key is out of sync. this is likely due to a modification to the AST |
| 212 | // not done through our path APIs |
| 213 | |
| 214 | if (Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#.isArrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ArrayConstructor#isArray().(this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.)) { |
| 215 | for (let i = 0; i < this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container..lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length.; i++) { |
| 216 | if (this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.[i] === this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.) { |
| 217 | return this.setKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(i); |
| 218 | } |
| 219 | } |
| 220 | } else { |
| 221 | for (const key of Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.)) { |
| 222 | // @ts-expect-error this.key should present in this.container |
| 223 | if (this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.[key] === this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.) { |
| 224 | return this.setKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(key); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // ¯\_(ツ)_/¯ who knows where it's gone lol |
| 230 | this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. = null; |
| 231 | } |
| 232 | |
| 233 | export function _resyncListscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncList().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncList().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 234 | if (!this.parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent. || !this.inListscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>inList`().) return; |
| 235 | |
| 236 | const newContainer = |
| 237 | // @ts-expect-error this.listKey should present in this.parent |
| 238 | this.parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent.[this.listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#listKey.]; |
| 239 | if (this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container. === newContainer) return; |
| 240 | |
| 241 | // container is out of sync. this is likely the result of it being reassigned |
| 242 | this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container. = newContainer || null; |
| 243 | } |
| 244 | |
| 245 | export function _resyncRemovedscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncRemoved().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_resyncRemoved().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 246 | if ( |
| 247 | this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. == null || |
| 248 | !this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container. || |
| 249 | // @ts-expect-error this.key should present in this.container |
| 250 | this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.[this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key.] !== this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. |
| 251 | ) { |
| 252 | this._markRemovedscip-typescript npm @babel/traverse 7.20.13 src/path/`removal.ts`/_markRemoved().(); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | export function popContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/popContext().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/popContext().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 257 | this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts..popscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#pop().(); |
| 258 | if (this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts..lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. > 0) { |
| 259 | this.setContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts.[this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts..lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length. - 1]); |
| 260 | } else { |
| 261 | this.setContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(undefined); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | export function pushContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/pushContext().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/pushContext().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/pushContext().(context): TraversalContextscip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#) { |
| 266 | this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/pushContext().(context)); |
| 267 | this.setContextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setContext().(contextscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/pushContext().(context)); |
| 268 | } |
| 269 | |
| 270 | export function setupscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().( |
| 271 | thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, |
| 272 | parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(parentPath): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# | undefined, |
| 273 | containerscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(container): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Nodescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Node#, |
| 274 | listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(listKey): string, |
| 275 | keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(key): string | number, |
| 276 | ) { |
| 277 | this.listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#listKey. = listKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(listKey); |
| 278 | this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container. = containerscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(container); |
| 279 | |
| 280 | this.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath. = parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(parentPath) || this.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.; |
| 281 | this.setKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setup().(key)); |
| 282 | } |
| 283 | |
| 284 | export function setKeyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(key): string | number) { |
| 285 | this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. = keyscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/setKey().(key); |
| 286 | this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node. = |
| 287 | // @ts-expect-error this.key must present in this.container |
| 288 | this.containerscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#container.[this.keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key.]; |
| 289 | this.typescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#type. = this.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.?.typescip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ArrayExpression#type.; |
| 290 | } |
| 291 | |
| 292 | export function requeuescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#, pathToQueuescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(pathToQueue) = this) { |
| 293 | if (pathToQueuescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(pathToQueue).removedscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>removed`().) return; |
| 294 | |
| 295 | // If a path is skipped, and then replaced with a |
| 296 | // new one, the new one shouldn't probably be skipped. |
| 297 | if (process.env.BABEL_8_BREAKING) { |
| 298 | pathToQueuescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(pathToQueue).shouldSkipscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#`<get>shouldSkip`(). = false; |
| 299 | } |
| 300 | |
| 301 | // TODO(loganfsmyth): This should be switched back to queue in parent contexts |
| 302 | // automatically once #2892 and #4135 have been resolved. See #4140. |
| 303 | // let contexts = this._getQueueContexts(); |
| 304 | const contexts = this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts.; |
| 305 | |
| 306 | for (const context of contexts) { |
| 307 | context.maybeQueuescip-typescript npm @babel/traverse 7.20.13 src/`context.ts`/TraversalContext#maybeQueue().(pathToQueuescip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/requeue().(pathToQueue)); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | export function _getQueueContextsscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_getQueueContexts().(thisscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/_getQueueContexts().(this): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 312 | let path = this; |
| 313 | let contexts = this.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts.; |
| 314 | while (!contexts.lengthscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#length.) { |
| 315 | path = path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath.; |
| 316 | if (!path) break; |
| 317 | contexts = path.contextsscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#contexts.; |
| 318 | } |
| 319 | return contexts; |
| 320 | } |