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

Function extractSpringValueBindings

src/resolution/frameworks/java.ts:452–524  ·  view source on GitHub ↗

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[],
)

Source from the content-addressed store, hash-verified

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

Callers 1

extractFunction · 0.85

Calls 3

lineAtFunction · 0.90
pushMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected