trySuffixMatch finds files where the path ends with the normalized import
(normalized string, idx *fileIndex)
| 270 | |
| 271 | // trySuffixMatch finds files where the path ends with the normalized import |
| 272 | func trySuffixMatch(normalized string, idx *fileIndex) []string { |
| 273 | // Extension list derived from the canonical scanner registry. |
| 274 | extensions := ResolverExtensions() |
| 275 | |
| 276 | for _, ext := range extensions { |
| 277 | candidate := normalized + ext |
| 278 | if files, ok := idx.bySuffix[candidate]; ok { |
| 279 | // Return the shortest match (most specific) |
| 280 | if len(files) == 1 { |
| 281 | return files |
| 282 | } |
| 283 | // Multiple matches - return all, let caller dedupe |
| 284 | return files |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | // Also try __init__.py for Python packages |
| 289 | initCandidate := filepath.Join(normalized, "__init__.py") |
| 290 | if files, ok := idx.bySuffix[initCandidate]; ok { |
| 291 | return files |
| 292 | } |
| 293 | |
| 294 | return nil |
| 295 | } |
| 296 | |
| 297 | // tryDirMatch returns all files whose parent directory matches the given path. |
| 298 | // This resolves namespace-level imports (e.g. C# "using Foo.Bar;" -> "Foo/Bar/") |