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

Method resolveLocal

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

Source from the content-addressed store, hash-verified

382 }
383
384 private resolveLocal(ref: LocalSymbol, directive?: TcbDirectiveMetadata): TcbExpr | null {
385 if (ref instanceof Reference && this.referenceOpMap.has(ref)) {
386 return this.resolveOp(this.referenceOpMap.get(ref)!);
387 } else if (ref instanceof LetDeclaration && this.letDeclOpMap.has(ref.name)) {
388 return this.resolveOp(this.letDeclOpMap.get(ref.name)!.opIndex);
389 } else if (ref instanceof Variable && this.varMap.has(ref)) {
390 // Resolving a context variable for this template.
391 // Execute the `TcbVariableOp` associated with the `Variable`.
392 const opIndexOrNode = this.varMap.get(ref)!;
393 return typeof opIndexOrNode === 'number'
394 ? this.resolveOp(opIndexOrNode)
395 : new TcbExpr(opIndexOrNode.print(true /* ignoreComments */));
396 } else if (
397 ref instanceof Template &&
398 directive === undefined &&
399 this.templateCtxOpMap.has(ref)
400 ) {
401 // Resolving the context of the given sub-template.
402 // Execute the `TcbTemplateContextOp` for the template.
403 return this.resolveOp(this.templateCtxOpMap.get(ref)!);
404 } else if (
405 (ref instanceof Element ||
406 ref instanceof Template ||
407 ref instanceof Component ||
408 ref instanceof Directive ||
409 ref instanceof HostElement) &&
410 directive !== undefined &&
411 this.directiveOpMap.has(ref)
412 ) {
413 // Resolving a directive on an element or sub-template.
414 const dirMap = this.directiveOpMap.get(ref)!;
415 return dirMap.has(directive) ? this.resolveOp(dirMap.get(directive)!) : null;
416 } else if (ref instanceof Element && this.elementOpMap.has(ref)) {
417 // Resolving the DOM node of an element in this template.
418 return this.resolveOp(this.elementOpMap.get(ref)!);
419 } else if (ref instanceof Component && this.componentNodeOpMap.has(ref)) {
420 return this.resolveOp(this.componentNodeOpMap.get(ref)!);
421 } else if (ref instanceof HostElement && this.hostElementOpMap.has(ref)) {
422 return this.resolveOp(this.hostElementOpMap.get(ref)!);
423 } else {
424 return null;
425 }
426 }
427
428 /**
429 * 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