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

Function parseMappingPaths

src/resolution/frameworks/java.ts:542–559  ·  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

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