MCPcopy Create free account
hub / github.com/angular/angular / resolveLocal

Method resolveLocal

packages/compiler/src/typecheck/ops/scope.ts:398–434  ·  view source on GitHub ↗
(ref: LocalSymbol, directive?: TcbDirectiveMetadata)

Source from the content-addressed store, hash-verified

396 }
397
398 private resolveLocal(ref: LocalSymbol, directive?: TcbDirectiveMetadata): TcbExpr | null {
399 if (ref instanceof Reference && this.referenceOpMap.has(ref)) {
400 return this.resolveOp(this.referenceOpMap.get(ref)!);
401 } else if (ref instanceof LetDeclaration && this.letDeclOpMap.has(ref.name)) {
402 return this.resolveOp(this.letDeclOpMap.get(ref.name)!.opIndex);
403 } else if (ref instanceof Variable && this.varMap.has(ref)) {
404 // Resolving a context variable for this template.
405 // Execute the `TcbVariableOp` associated with the `Variable`.
406 const opIndexOrNode = this.varMap.get(ref)!;
407 return typeof opIndexOrNode === 'number'
408 ? this.resolveOp(opIndexOrNode)
409 : new TcbExpr(opIndexOrNode.print(true /* ignoreComments */));
410 } else if (
411 ref instanceof Template &&
412 directive === undefined &&
413 this.templateCtxOpMap.has(ref)
414 ) {
415 // Resolving the context of the given sub-template.
416 // Execute the `TcbTemplateContextOp` for the template.
417 return this.resolveOp(this.templateCtxOpMap.get(ref)!);
418 } else if (
419 (ref instanceof Element || ref instanceof Template || ref instanceof HostElement) &&
420 directive !== undefined &&
421 this.directiveOpMap.has(ref)
422 ) {
423 // Resolving a directive on an element or sub-template.
424 const dirMap = this.directiveOpMap.get(ref)!;
425 return dirMap.has(directive) ? this.resolveOp(dirMap.get(directive)!) : null;
426 } else if (ref instanceof Element && this.elementOpMap.has(ref)) {
427 // Resolving the DOM node of an element in this template.
428 return this.resolveOp(this.elementOpMap.get(ref)!);
429 } else if (ref instanceof HostElement && this.hostElementOpMap.has(ref)) {
430 return this.resolveOp(this.hostElementOpMap.get(ref)!);
431 } else {
432 return null;
433 }
434 }
435
436 /**
437 * Like `executeOp`, but assert that the operation actually returned `TcbExpr`.

Callers 1

resolveMethod · 0.95

Calls 4

resolveOpMethod · 0.95
hasMethod · 0.65
getMethod · 0.65
printMethod · 0.45

Tested by

no test coverage detected