MCPcopy Create free account
hub / github.com/JordanCoin/codemap / trySuffixMatch

Function trySuffixMatch

scanner/filegraph.go:272–295  ·  view source on GitHub ↗

trySuffixMatch finds files where the path ends with the normalized import

(normalized string, idx *fileIndex)

Source from the content-addressed store, hash-verified

270
271// trySuffixMatch finds files where the path ends with the normalized import
272func 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/")

Callers 3

fuzzyResolveFunction · 0.85
resolvePathAliasFunction · 0.85
TestTrySuffixMatchFunction · 0.85

Calls 1

ResolverExtensionsFunction · 0.85

Tested by 1

TestTrySuffixMatchFunction · 0.68