All declared paths; [''] for an omitted path, [] for an unresolved one.
(args: string, consts: Map<string, string>)
| 540 | |
| 541 | /** All declared paths; [''] for an omitted path, [] for an unresolved one. */ |
| 542 | function 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`. */ |
| 562 | function joinPath(prefix: string, sub: string): string { |