import * as ts from "typescript" ; import { Context } from "./Context" ; import type { CtorsLibrary , MetadataLibrary } from "../declarations" ; import { mainVisitor } from "../visitors/mainVisitor" ; import TransformerContext from "./TransformerContext" ; export default class SourceFileContext { private private _getTypeIdentifier ? : ts . Identifier ; private _shouldGenerateGetTypeImport : boolean = false ; private _typesMetadata : MetadataLibrary = [ ] ; private _ctorsLibrary : CtorsLibrary = [ ] ; private readonly _context : Context ; public readonly transformationContext : ts . TransformationContext ; public readonly program : ts . Program ; public readonly checker : ts . TypeChecker ; public readonly transformerContext : TransformerContext ; get context ( ) : Context { return this . _context ; } get typesMetadata ( ) : MetadataLibrary { return this . _typesMetadata ; } get typesCtors ( ) : CtorsLibrary { return this . _ctorsLibrary ; } get shouldGenerateGetTypeImport ( ) : boolean { return this . _shouldGenerateGetTypeImport ; } param transformerContext param transformationContext param program param checker constructor ( transformerContext , transformationContext , program , checker ) { this . transformerContext = transformerContext ; this . transformationContext = transformationContext ; this . program = program ; this . checker = checker ; this . _context = new Context ( this , mainVisitor ) ; } /**
     * Get identifier of getType() function for current file.
     */ getGetTypeIdentifier ( ) { if ( ! this . _getTypeIdentifier ) { this . _shouldGenerateGetTypeImport = true ; this . _getTypeIdentifier = ts . factory . createIdentifier ( "_tst_getType" ) ; } return this . _getTypeIdentifier ; } param identifier return trySetGetTypeIdentifier ( identifier ) { if ( ! this . _getTypeIdentifier ) { this . _getTypeIdentifier = identifier ; return true ; } return false ; } }