( callee: Node, module: SourceModule )
| 6023 | |
| 6024 | // e.g. `store.add` given `const store = new Store()` |
| 6025 | private instanceMethodOf( |
| 6026 | callee: Node, |
| 6027 | module: SourceModule |
| 6028 | ): [FunctionNode, SourceModule] | undefined { |
| 6029 | callee = unwrapChain(callee) |
| 6030 | if (callee.type !== "MemberExpression") return |
| 6031 | const name = memberNameOf(callee) |
| 6032 | const object = unwrapChain(callee.object) |
| 6033 | const binding = module.scopes.byId.get(object)?.binding |
| 6034 | const init = |
| 6035 | ( |
| 6036 | binding?.kind === "const" && |
| 6037 | binding.declaration.type === "VariableDeclarator" && |
| 6038 | binding.declaration.init |
| 6039 | ) ? |
| 6040 | unwrapExpression(binding.declaration.init) |
| 6041 | : undefined |
| 6042 | if ( |
| 6043 | typeof name !== "string" || |
| 6044 | init?.type !== "NewExpression" || |
| 6045 | !readsOnlyMembers(binding!) |
| 6046 | ) |
| 6047 | return |
| 6048 | const cls = this.instanceClassOf(init.callee, module) |
| 6049 | return cls && methodIn(cls[0], name, cls[1]) |
| 6050 | } |
| 6051 | |
| 6052 | // e.g. `Store` of `class Store {}`, unless the program may change it, or |
| 6053 | // one a package exports where the build reads the whole program |
no test coverage detected