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

Function parseMappingPaths

src/resolution/frameworks/java.ts:544–561  ·  view source on GitHub ↗

All declared paths; [''] for an omitted path, [] for an unresolved one.

(args: string, consts: Map<string, string>)

Source from the content-addressed store, hash-verified

542
543/** All declared paths; [''] for an omitted path, [] for an unresolved one. */
544function parseMappingPaths(args: string, consts: Map<string, string>): string[] {
545 const paths: string[] = [];
546 let hasPaths = false;
547 // Keep Java/Kotlin arrays and quoted URI variables together when separating
548 // attributes. Strings in produces/consumes/etc. are never mapping paths.
549 const argRe = /(?:^|,)\s*(?:(\w+)\s*=\s*)?(\{(?:[^"'}]|"[^"]*"|'[^']*')*\}|\[(?:[^"'\]]|"[^"]*"|'[^']*')*\]|"[^"]*"|'[^']*'|[^,]+)/g;
550 for (const arg of args.matchAll(argRe)) {
551 if (arg[1] && arg[1] !== 'value' && arg[1] !== 'path') continue;
552 hasPaths = true;
553 const scope = arg[2]!.trim().replace(/^[{\[]|[}\]]$/g, '').trim();
554 if (!scope) paths.push(''); // An explicitly empty path array also inherits the prefix.
555 for (const value of scope.matchAll(/(?:^|,)\s*(?:"([^"]*)"|'([^']*)'|([\w.]+))\s*(?=,|$)/g)) {
556 const path = value[1] ?? value[2] ?? consts.get(value[3]!.split('.').pop()!);
557 if (path !== undefined) paths.push(path);
558 }
559 }
560 return hasPaths ? [...new Set(paths)] : [''];
561}
562
563/** Join a class-level prefix and a method sub-path into one normalized `/path`. */
564function joinPath(prefix: string, sub: string): string {

Callers 1

extractFunction · 0.85

Calls 2

pushMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected