| 1 | import type NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# from "../path"scip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/; |
| 2 | 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`/; |
| 3 | import type Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope# from "./index"scip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/; |
| 4 | |
| 5 | export type BindingKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/BindingKind# = |
| 6 | | "var" /* var declarator */ |
| 7 | | "let" /* let declarator, class declaration id, catch clause parameters */ |
| 8 | | "const" /* const/using declarator */ |
| 9 | | "module" /* import specifiers */ |
| 10 | | "hoisted" /* function declaration id */ |
| 11 | | "param" /* function declaration parameters */ |
| 12 | | "local" /* function expression id, class expression id */ |
| 13 | | "unknown"; /* export specifiers */ |
| 14 | /** |
| 15 | * This class is responsible for a binding inside of a scope. |
| 16 | * |
| 17 | * It tracks the following: |
| 18 | * |
| 19 | * * Node path. |
| 20 | * * Amount of times referenced by other nodes. |
| 21 | * * Paths to nodes that reassign or modify this binding. |
| 22 | * * The kind of binding. (Is it a parameter, declaration etc) |
| 23 | */ |
| 24 | |
| 25 | export default class Bindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding# { |
| 26 | identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#identifier.: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#; |
| 27 | scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#scope.: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#; |
| 28 | pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#path.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#; |
| 29 | kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind.: BindingKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/BindingKind#; |
| 30 | |
| 31 | constructorscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().({ |
| 32 | identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:identifier., |
| 33 | scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:scope., |
| 34 | pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:path., |
| 35 | kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:kind., |
| 36 | }: { |
| 37 | identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:identifier.: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier#; |
| 38 | scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:scope.: Scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#; |
| 39 | pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:path.: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#; |
| 40 | kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#`<constructor>`().(`{ identifier, scope, path, kind, }`)typeLiteral2:kind.: BindingKindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/BindingKind#; |
| 41 | }) { |
| 42 | this.identifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#identifier. = identifier; |
| 43 | this.scopescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#scope. = scope; |
| 44 | this.pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#path. = path; |
| 45 | this.kindscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#kind. = kind; |
| 46 | |
| 47 | if ( |
| 48 | (kind === "var" || kind === "hoisted") && |
| 49 | // https://github.com/rollup/rollup/issues/4654 |
| 50 | // Rollup removes the path argument from this call. Add an |
| 51 | // unreachable IIFE (that rollup doesn't know is unreachable) |
| 52 | // with side effects, to prevent it from messing up with arguments. |
| 53 | // You can reproduce this with |
| 54 | // BABEL_8_BREAKING=true make prepublish-build |
| 55 | isDeclaredInLoopscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/isDeclaredInLoop().( |
| 56 | path || |
| 57 | (() => { |
| 58 | throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Internal Babel error: unreachable "); |
| 59 | })(), |
| 60 | ) |
| 61 | ) { |
| 62 | this.reassignscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(path); |
| 63 | } |
| 64 | |
| 65 | this.clearValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#clearValue().(); |
| 66 | } |
| 67 | |
| 68 | constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constantViolations.: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#> = []; |
| 69 | constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant.: boolean = true; |
| 70 | |
| 71 | referencePathsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referencePaths.: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#> = []; |
| 72 | referencedscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referenced.: boolean = false; |
| 73 | referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#references.: number = 0; |
| 74 | |
| 75 | declare hasDeoptedValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasDeoptedValue.: boolean; |
| 76 | declare hasValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasValue.: boolean; |
| 77 | declare valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#value.: any; |
| 78 | |
| 79 | deoptValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#deoptValue().() { |
| 80 | this.clearValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#clearValue().(); |
| 81 | this.hasDeoptedValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasDeoptedValue. = true; |
| 82 | } |
| 83 | |
| 84 | setValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#setValue().(valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#setValue().(value): any) { |
| 85 | if (this.hasDeoptedValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasDeoptedValue.) return; |
| 86 | this.hasValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasValue. = true; |
| 87 | this.valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#value. = valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#setValue().(value); |
| 88 | } |
| 89 | |
| 90 | clearValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#clearValue().() { |
| 91 | this.hasDeoptedValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasDeoptedValue. = false; |
| 92 | this.hasValuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#hasValue. = false; |
| 93 | this.valuescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#value. = null; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Register a constant violation with the provided `path`. |
| 98 | */ |
| 99 | |
| 100 | reassignscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 101 | this.constantscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constant. = false; |
| 102 | if (this.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constantViolations..indexOfscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#indexOf().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(path)) !== -1) { |
| 103 | return; |
| 104 | } |
| 105 | this.constantViolationsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#constantViolations..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reassign().(path)); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Increment the amount of references to this binding. |
| 110 | */ |
| 111 | |
| 112 | referencescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 113 | if (this.referencePathsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referencePaths..indexOfscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#indexOf().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(path)) !== -1) { |
| 114 | return; |
| 115 | } |
| 116 | this.referencedscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referenced. = true; |
| 117 | this.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#references.++; |
| 118 | this.referencePathsscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referencePaths..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#reference().(path)); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Decrement the amount of references to this binding. |
| 123 | */ |
| 124 | |
| 125 | dereferencescip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#dereference().() { |
| 126 | this.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#references.--; |
| 127 | this.referencedscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#referenced. = !!this.referencesscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/Binding#references.; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | function isDeclaredInLoopscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/isDeclaredInLoop().(pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/isDeclaredInLoop().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#) { |
| 132 | for ( |
| 133 | let { parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath., keyscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#key. } = pathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/isDeclaredInLoop().(path); |
| 134 | parentPath; |
| 135 | { parentPathscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/parentPath0:, keyscip-typescript npm @babel/traverse 7.20.13 src/scope/`binding.ts`/key0: } = parentPath |
| 136 | ) { |
| 137 | if (parentPath.isFunctionParentscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isFunctionParent().()) return false; |
| 138 | if ( |
| 139 | parentPath.isWhilescip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isWhile().() || |
| 140 | parentPath.isForXStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isForXStatement().() || |
| 141 | (parentPath.isForStatementscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isForStatement().() && key === "body") |
| 142 | ) { |
| 143 | return true; |
| 144 | } |
| 145 | } |
| 146 | return false; |
| 147 | } |