* A type check block operation which produces inline type check code for a particular directive.
| 703 | * A type check block operation which produces inline type check code for a particular directive. |
| 704 | */ |
| 705 | class InlineTcbOp implements Op { |
| 706 | constructor( |
| 707 | readonly ref: Reference<ClassDeclaration<ts.ClassDeclaration>>, |
| 708 | readonly meta: TypeCheckBlockMetadata, |
| 709 | readonly config: TypeCheckingConfig, |
| 710 | readonly reflector: ReflectionHost, |
| 711 | readonly domSchemaChecker: DomSchemaChecker<unknown>, |
| 712 | readonly oobRecorder: OutOfBandDiagnosticRecorder<unknown>, |
| 713 | ) {} |
| 714 | |
| 715 | /** |
| 716 | * Type check blocks are inserted immediately after the end of the directve class. |
| 717 | */ |
| 718 | get splitPoint(): number { |
| 719 | return this.ref.node.end + 1; |
| 720 | } |
| 721 | |
| 722 | execute(im: ImportManager, tcbSf: ts.SourceFile, refEmitter: ReferenceEmitter): string { |
| 723 | const env = new Environment(this.config, im, refEmitter, tcbSf); |
| 724 | const originalSf = this.ref.node.getSourceFile(); |
| 725 | if (tcbSf !== originalSf) { |
| 726 | env.copiedSourceOriginPath = absoluteFromSourceFile(originalSf); |
| 727 | } |
| 728 | const fnName = `_tcb_${this.ref.node.pos}`; |
| 729 | |
| 730 | const {tcbMeta, component} = adaptTypeCheckBlockMetadata( |
| 731 | this.ref, |
| 732 | this.meta, |
| 733 | env, |
| 734 | this.reflector, |
| 735 | TcbGenericContextBehavior.CopyClassNodes, |
| 736 | ); |
| 737 | |
| 738 | // Inline TCBs should copy any generic type parameter nodes directly, as the TCB code is |
| 739 | // inlined into the class in a context where that will always be legal. |
| 740 | const fn = generateTypeCheckBlock( |
| 741 | env, |
| 742 | component, |
| 743 | fnName, |
| 744 | tcbMeta, |
| 745 | this.domSchemaChecker, |
| 746 | this.oobRecorder, |
| 747 | ); |
| 748 | |
| 749 | return fn; |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | /** |
| 754 | * A type constructor operation which produces type constructor code for a particular directive. |
nothing calls this directly
no outgoing calls
no test coverage detected