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

Function parseTargetPaths

src/resolution/frameworks/cargo-workspace.ts:167–183  ·  view source on GitHub ↗
(cargoToml: string)

Source from the content-addressed store, hash-verified

165 * manifest's directory.
166 */
167export function parseTargetPaths(cargoToml: string): { lib?: string; bins: string[]; others: string[] } {
168 const out: { lib?: string; bins: string[]; others: string[] } = { bins: [], others: [] };
169 let table: 'lib' | 'bin' | 'other' | null = null;
170 for (const raw of cargoToml.split(/\r?\n/)) {
171 const line = raw.replace(/#.*$/, '').trim();
172 if (line.startsWith('[')) {
173 table = line === '[lib]' ? 'lib' : line === '[[bin]]' ? 'bin' : /^\[\[(?:example|test|bench)\]\]$/.test(line) ? 'other' : null;
174 continue;
175 }
176 const at = table && /^path\s*=\s*["']([^"'\n]+)["']/.exec(line)?.[1]?.replace(/\\/g, '/');
177 if (!at) continue;
178 if (table === 'lib') out.lib = at;
179 else if (table === 'bin') out.bins.push(at);
180 else out.others.push(at);
181 }
182 return out;
183}
184
185function addCrateAlias(map: Map<string, string>, crateName: string, memberPath: string): void {
186 const normalized = crateName.replace(/-/g, '_');

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected