(binding: Binding, module: SourceModule)
| 5224 | // e.g. `o.a = 1`, `list.push(x)` or `Object.assign(o, x)`, changing what a |
| 5225 | // binding holds without assigning it |
| 5226 | writesThrough(binding: Binding, module: SourceModule): Node[] { |
| 5227 | let result = this.writesByBinding.get(binding) |
| 5228 | if (!result) { |
| 5229 | result = [] |
| 5230 | this.writesByBinding.set(binding, result) |
| 5231 | for (const reference of binding.references) { |
| 5232 | if (reference.isWrite) continue |
| 5233 | const write = this.writeFrom(reference.id, module) |
| 5234 | if (write) result.push(write) |
| 5235 | } |
| 5236 | // e.g. `static { this.T = User }`, writing its class |
| 5237 | if (binding.kind === "class") { |
| 5238 | walk(binding.declaration, node => { |
| 5239 | if ( |
| 5240 | node.type === "MemberExpression" && |
| 5241 | unwrapChain(node.object).type === "ThisExpression" && |
| 5242 | staticOwnerOf(node) === binding.declaration && |
| 5243 | isWriteTarget(node) |
| 5244 | ) |
| 5245 | result!.push(writeOf(node)) |
| 5246 | return true |
| 5247 | }) |
| 5248 | } |
| 5249 | } |
| 5250 | return result |
| 5251 | } |
| 5252 | |
| 5253 | private writeFrom(node: Node, module: SourceModule): Node | undefined { |
| 5254 | for (;;) { |
no test coverage detected