(parser, parserOptions)
| 75 | * @returns {void} |
| 76 | */ |
| 77 | const handler = (parser, parserOptions) => { |
| 78 | /** |
| 79 | * Processes the provided sup. |
| 80 | * @param {Expression} sup sup |
| 81 | */ |
| 82 | const onUsageSuper = (sup) => { |
| 83 | innerGraph.onUsage(parser.state, (usedByExports, module) => { |
| 84 | switch (usedByExports) { |
| 85 | case undefined: |
| 86 | case true: |
| 87 | return; |
| 88 | default: { |
| 89 | const dep = new PureExpressionDependency( |
| 90 | /** @type {Range} */ |
| 91 | (sup.range) |
| 92 | ); |
| 93 | dep.loc = /** @type {DependencyLocation} */ (sup.loc); |
| 94 | dep.usedByExports = usedByExports; |
| 95 | addPureDependency(module, dep); |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | }); |
| 100 | }; |
| 101 | |
| 102 | parser.hooks.program.tap(PLUGIN_NAME, () => { |
| 103 | innerGraph.enable(parser.state); |
| 104 | |
| 105 | statementWithTopLevelSymbol = new WeakMap(); |
| 106 | statementPurePart = new WeakMap(); |
| 107 | classWithTopLevelSymbol = new WeakMap(); |
| 108 | declWithTopLevelSymbol = new WeakMap(); |
| 109 | pureDeclarators = new WeakSet(); |
| 110 | pureConditionByCallExpr = new WeakMap(); |
| 111 | }); |
| 112 | |
| 113 | class="cm">// During prewalking the following datastructures are filled with |
| 114 | class="cm">// nodes that have a TopLevelSymbol assigned and |
| 115 | class="cm">// variables are tagged with the assigned TopLevelSymbol |
| 116 | |
| 117 | class="cm">// We differ 3 types of nodes: |
| 118 | class="cm">// 1. full statements (export default, function declaration) |
| 119 | class="cm">// 2. classes (class declaration, class expression) |
| 120 | class="cm">// 3. variable declarators (const x = ...) |
| 121 | |
| 122 | /** @type {WeakMap<Node | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration, TopLevelSymbol>} */ |
| 123 | let statementWithTopLevelSymbol = new WeakMap(); |
| 124 | /** @type {WeakMap<Node | MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration, Node>} */ |
| 125 | let statementPurePart = new WeakMap(); |
| 126 | |
| 127 | /** @type {WeakMap<ClassExpression | ClassDeclaration | MaybeNamedClassDeclaration, TopLevelSymbol>} */ |
| 128 | let classWithTopLevelSymbol = new WeakMap(); |
| 129 | |
| 130 | /** @type {WeakMap<VariableDeclarator, TopLevelSymbol>} */ |
| 131 | let declWithTopLevelSymbol = new WeakMap(); |
| 132 | /** @type {WeakSet<VariableDeclarator>} */ |
| 133 | let pureDeclarators = new WeakSet(); |
| 134 |
nothing calls this directly
no test coverage detected