* Resolve a CALL through an imported value to the method on the value's own * type: `reproStore.notifyJoinGuildStatus()` where `reproStore` is * `export const reproStore = new ReproStore()` in the imported file (#1292). * The same-file form of this call already resolves via local-variable * rece
( value: Node, ref: UnresolvedRef, localName: string, context: ResolutionContext )
| 2220 | * caller keeps its existing constant-edge behavior. |
| 2221 | */ |
| 2222 | function resolveImportedInstanceMember( |
| 2223 | value: Node, |
| 2224 | ref: UnresolvedRef, |
| 2225 | localName: string, |
| 2226 | context: ResolutionContext |
| 2227 | ): ResolvedRef | null { |
| 2228 | if (ref.referenceKind !== 'calls') return null; |
| 2229 | if (value.kind !== 'constant' && value.kind !== 'variable') return null; |
| 2230 | const member = ref.referenceName.slice(localName.length + 1).split('.')[0]; |
| 2231 | if (!member) return null; |
| 2232 | |
| 2233 | const source = context.readFile(value.filePath); |
| 2234 | if (!source) return null; |
| 2235 | // Only the value's own declaration lines — never the whole file, so a |
| 2236 | // same-named identifier elsewhere can't donate a type. |
| 2237 | const lines = source.split('\n'); |
| 2238 | const declSlice = lines.slice(Math.max(0, value.startLine - 1), value.endLine).join('\n'); |
| 2239 | |
| 2240 | const receiver = value.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
| 2241 | for (const pattern of localReceiverTypePatterns(value.language as Language, receiver)) { |
| 2242 | const m = declSlice.match(pattern); |
| 2243 | if (!m || !m[1]) continue; |
| 2244 | const typeName = normalizeInferredTypeName(m[1]); |
| 2245 | if (!typeName) continue; |
| 2246 | const resolved = resolveMethodOnType(typeName, member, ref, context, 0.85, 'instance-method'); |
| 2247 | if (resolved) return resolved; |
| 2248 | } |
| 2249 | return null; |
| 2250 | } |
| 2251 | |
| 2252 | function resolveStaticMember( |
| 2253 | container: Node, |
no test coverage detected