* 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 )
| 4181 | * `resolveViaImport` can still try the file-based path. |
| 4182 | */ |
| 4183 | function resolveGoCrossPackageReference( |
| 4184 | ref: UnresolvedRef, |
| 4185 | imports: ImportMapping[], |
| 4186 | context: ResolutionContext |
| 4187 | ): ResolvedRef | null { |
| 4188 | // Qualified call: receiver before `.`, member after. A bare reference |
| 4189 | // (no dot) is a same-package name — unless the source spells a package in |
| 4190 | // front of it: `store.Manager` in a field or a signature, which the index |
| 4191 | // keeps as `Manager` (#2322). |
| 4192 | const dotIdx = ref.referenceName.indexOf('.'); |
| 4193 | if (dotIdx <= 0) { |
| 4194 | const imp = goRefQualifier(ref, context); |
| 4195 | return imp ? findGoPackageMember(ref.referenceName, imp, ref, context) : null; |
| 4196 | } |
| 4197 | const receiver = ref.referenceName.substring(0, dotIdx); |
| 4198 | const memberName = ref.referenceName.substring(dotIdx + 1); |
| 4199 | if (!memberName) return null; |
| 4200 | // A parameter or local named like the import holds the call there: |
| 4201 | // `store := newStore()`, then `store.Get(k)` is no call into package store. |
| 4202 | if (!goRefQualifier(ref, context)) return null; |
| 4203 | |
| 4204 | for (const imp of imports) { |
| 4205 | if (imp.localName !== receiver) continue; |
| 4206 | const found = findGoPackageMember(memberName, imp, ref, context); |
| 4207 | if (found) return found; |
| 4208 | } |
| 4209 | return null; |
| 4210 | } |
| 4211 | |
| 4212 | /** |
| 4213 | * The exported `memberName` of the project package `imp` names, looked up in |
no test coverage detected