MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / buildBasenameStems

Function buildBasenameStems

src/search/query-paths.ts:161–173  ·  view source on GitHub ↗

* Lowercased basename stems of the hyphen-named indexed files, stem → paths. * A stem drops only the LAST extension (`a-b.module.scss` → `a-b.module`), so * a bare kebab token can't accidentally pin a same-named stylesheet or * `.d.ts` sibling of the source file it names; an extension-less basena

(indexedPaths: readonly string[])

Source from the content-addressed store, hash-verified

159 * near-empty in repos that don't name files this way.
160 */
161function buildBasenameStems(indexedPaths: readonly string[]): Map<string, string[]> {
162 const stems = new Map<string, string[]>();
163 for (const p of indexedPaths) {
164 const basename = p.slice(Math.max(p.lastIndexOf('/'), p.lastIndexOf('\\')) + 1);
165 if (!basename.includes('-')) continue;
166 const stem = basename.replace(LAST_EXTENSION, '').toLowerCase();
167 if (!stem) continue;
168 const existing = stems.get(stem);
169 if (existing) existing.push(p);
170 else stems.set(stem, [p]);
171 }
172 return stems;
173}
174
175/**
176 * Line references that ride along in agent-written paths: `foo.ts:123`,

Callers 1

extractQueryPathsFunction · 0.85

Calls 3

pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected