Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 204x 204x 19x 185x 185x 185x 20x 165x | /**
* Simple Identifier Resolver
*
* Resolves simple identifiers (no prefix, no postfix operations)
* in assignment targets. Handles parameter lookup, local variable
* detection, and bare identifier resolution.
*
* Extracted from CodeGenerator.doGenerateAssignmentTarget to reduce
* cognitive complexity.
*
* ADR-006, ADR-016
*/
import ISimpleIdentifierDeps from "../types/ISimpleIdentifierDeps";
/**
* Static utility for resolving simple identifiers
*/
class SimpleIdentifierResolver {
/**
* Resolve a simple identifier (no prefix, no postfix operations)
*
* Resolution priority:
* 1. Function parameters (with dereference if needed)
* 2. Bare identifier resolution (local -> scope -> global)
* 3. Original identifier as fallback
*
* @param id The identifier to resolve
* @param deps Dependencies for resolution
* @returns The resolved identifier string
*/
static resolve(id: string, deps: ISimpleIdentifierDeps): string {
// ADR-006: Check if it's a function parameter
const paramInfo = deps.getParameterInfo(id);
if (paramInfo) {
return deps.resolveParameter(id, paramInfo);
}
// Check if it's a local variable
const isLocalVariable = deps.isLocalVariable(id);
// ADR-016: Resolve bare identifier using local -> scope -> global priority
const resolved = deps.resolveBareIdentifier(id, isLocalVariable);
// If resolved to a different name, use it
if (resolved !== null) {
return resolved;
}
return id;
}
}
export default SimpleIdentifierResolver;
|