Append `@Value("${k}")` and `@ConfigurationProperties(prefix=...)` * references discovered in `safe` (comments stripped) into the caller's * `nodes`/`references` arrays.
( filePath: string, safe: string, lang: 'java' | 'kotlin', now: number, nodes: Node[], references: UnresolvedRef[], )
| 448 | * references discovered in `safe` (comments stripped) into the caller's |
| 449 | * `nodes`/`references` arrays. */ |
| 450 | function extractSpringValueBindings( |
| 451 | filePath: string, |
| 452 | safe: string, |
| 453 | lang: 'java' | 'kotlin', |
| 454 | now: number, |
| 455 | nodes: Node[], |
| 456 | references: UnresolvedRef[], |
| 457 | ): void { |
| 458 | const valueRe = /@Value\s*\(\s*["']\$\{([^}:]+)(?::[^}]*)?\}["']\s*\)/g; |
| 459 | let m: RegExpExecArray | null; |
| 460 | while ((m = valueRe.exec(safe)) !== null) { |
| 461 | const key = m[1]!.trim(); |
| 462 | if (!key) continue; |
| 463 | const line = safe.slice(0, m.index).split('\n').length; |
| 464 | const bindNode: Node = { |
| 465 | id: `spring-value:${filePath}:${line}:${key}`, |
| 466 | kind: 'constant', |
| 467 | name: key, |
| 468 | qualifiedName: `${filePath}::@Value:${key}`, |
| 469 | filePath, |
| 470 | startLine: line, |
| 471 | endLine: line, |
| 472 | startColumn: 0, |
| 473 | endColumn: m[0].length, |
| 474 | language: lang, |
| 475 | signature: `@Value("${key}")`, |
| 476 | updatedAt: now, |
| 477 | }; |
| 478 | nodes.push(bindNode); |
| 479 | references.push({ |
| 480 | fromNodeId: bindNode.id, |
| 481 | referenceName: key, |
| 482 | referenceKind: 'references', |
| 483 | line, |
| 484 | column: 0, |
| 485 | filePath, |
| 486 | language: lang, |
| 487 | }); |
| 488 | } |
| 489 | |
| 490 | const cpRe = /@ConfigurationProperties\s*\(\s*(?:prefix\s*=\s*)?["']([^"']+)["']/g; |
| 491 | while ((m = cpRe.exec(safe)) !== null) { |
| 492 | const prefix = m[1]!.trim(); |
| 493 | if (!prefix) continue; |
| 494 | const line = safe.slice(0, m.index).split('\n').length; |
| 495 | const bindNode: Node = { |
| 496 | id: `spring-cp:${filePath}:${line}:${prefix}`, |
| 497 | kind: 'constant', |
| 498 | name: prefix, |
| 499 | qualifiedName: `${filePath}::@ConfigurationProperties:${prefix}`, |
| 500 | filePath, |
| 501 | startLine: line, |
| 502 | endLine: line, |
| 503 | startColumn: 0, |
| 504 | endColumn: m[0].length, |
| 505 | language: lang, |
| 506 | signature: `@ConfigurationProperties("${prefix}")`, |
| 507 | updatedAt: now, |