MCPcopy
hub / github.com/babel/babel / _forceSetScope

Function _forceSetScope

packages/babel-traverse/src/path/context.ts:62–84  ·  view source on GitHub ↗
(this: NodePath)

Source from the content-addressed store, hash-verified

60}
61
62export function _forceSetScope(this: NodePath) {
63 let path = this.parentPath;
64
65 if (
66 // Skip method scope if is computed method key or decorator expression
67 ((this.key === "key" || this.listKey === "decorators") &&
68 path.isMethod()) ||
69 // Skip switch scope if for discriminant (`x` in `switch (x) {}`).
70 (this.key === "discriminant" && path.isSwitchStatement())
71 ) {
72 path = path.parentPath;
73 }
74
75 let target;
76 while (path && !target) {
77 target = path.scope;
78 path = path.parentPath;
79 }
80
81 // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
82 this.scope = this.getScope(target!);
83 this.scope?.init();
84}
85
86export function setScope(this: NodePath<t.Node | null>) {
87 if (this.opts?.noScope) return;

Callers

nothing calls this directly

Calls 4

isMethodMethod · 0.80
isSwitchStatementMethod · 0.80
getScopeMethod · 0.65
initMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…