* Resolve a Go cross-package qualified reference (`pkga.FuncX`) by matching * the package alias against an in-project import, mapping the import to the * package's project directory, and locating the exported symbol in a `.go` * file directly in that directory. Returns `null` for stdlib / third-p
( ref: UnresolvedRef, imports: ImportMapping[], context: ResolutionContext )
| 4382 | * `resolveViaImport` can still try the file-based path. |
| 4383 | */ |
| 4384 | function resolveGoCrossPackageReference( |
| 4385 | ref: UnresolvedRef, |
| 4386 | imports: ImportMapping[], |
| 4387 | context: ResolutionContext |
| 4388 | ): ResolvedRef | null { |
| 4389 | // Qualified call: receiver before `.`, member after. A bare reference |
| 4390 | // (no dot) is a same-package name — unless the source spells a package in |
| 4391 | // front of it: `store.Manager` in a field or a signature, which the index |
| 4392 | // keeps as `Manager` (#2322). |
| 4393 | const dotIdx = ref.referenceName.indexOf('.'); |
| 4394 | if (dotIdx <= 0) { |
| 4395 | const imp = goRefQualifier(ref, context); |
| 4396 | return imp ? findGoPackageMember(ref.referenceName, imp, ref, context) : null; |
| 4397 | } |
| 4398 | const receiver = ref.referenceName.substring(0, dotIdx); |
| 4399 | const memberName = ref.referenceName.substring(dotIdx + 1); |
| 4400 | if (!memberName) return null; |
| 4401 | // A parameter or local named like the import holds the call there: |
| 4402 | // `store := newStore()`, then `store.Get(k)` is no call into package store. |
| 4403 | if (!goRefQualifier(ref, context)) return null; |
| 4404 | |
| 4405 | for (const imp of imports) { |
| 4406 | if (imp.localName !== receiver) continue; |
| 4407 | const found = findGoPackageMember(memberName, imp, ref, context); |
| 4408 | if (found) return found; |
| 4409 | } |
| 4410 | return null; |
| 4411 | } |
| 4412 | |
| 4413 | /** |
| 4414 | * The exported `memberName` of the project package `imp` names, looked up in |
no test coverage detected