MCPcopy
hub / github.com/google-labs-code/design.md / resolveReference

Function resolveReference

packages/cli/src/linter/model/handler.ts:377–397  ·  view source on GitHub ↗

* Resolve a token reference with chained resolution and cycle detection. * Returns null if the reference cannot be resolved (not found or circular).

(
  symbolTable: Map<string, ResolvedValue>,
  path: string,
  visited: Set<string>,
  depth: number = 0,
)

Source from the content-addressed store, hash-verified

375 * Returns null if the reference cannot be resolved (not found or circular).
376 */
377function resolveReference(
378 symbolTable: Map<string, ResolvedValue>,
379 path: string,
380 visited: Set<string>,
381 depth: number = 0,
382): ResolvedValue | null {
383 if (depth > MAX_REFERENCE_DEPTH) return null;
384 if (visited.has(path)) return null; // Circular reference
385 visited.add(path);
386
387 const value = symbolTable.get(path);
388 if (value === undefined) return null;
389
390 // If the value is itself a reference string, follow the chain
391 if (typeof value === 'string' && isTokenReference(value)) {
392 const innerPath = value.slice(1, -1);
393 return resolveReference(symbolTable, innerPath, visited, depth + 1);
394 }
395
396 return value;
397}
398
399/**
400 * WCAG 2.1 contrast ratio between two resolved colors.

Callers 1

executeMethod · 0.85

Calls 1

isTokenReferenceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…