import * as ts from "typescript" ; import { VisitResult } from "typescript" ; import type { MetadataEntry , TransformerVisitor } from "../declarations" ; import SourceFileContext from "./SourceFileContext" ; /**
 * Context of visitors
 */ export class Context { private readonly _sourceFileContext : SourceFileContext ; private readonly _visitor : ts . Visitor ; private readonly _transformerVisitor : TransformerVisitor ; /**
     * When visiting declaration bodies, names of generic types used in getType() are inserted into this array.
     */ public usedGenericParameters : Array < string > = [ ] ; get config ( ) { return this . _sourceFileContext . transformerContext . config ; } get visitor ( ) : ts . Visitor { return this . _visitor ; } get transformationContext ( ) : ts . TransformationContext { return this . _sourceFileContext . transformationContext ; } get typeChecker ( ) : ts . TypeChecker { return this . _sourceFileContext . checker ; } constructor ( sourceFileContext , visitor ) { this . _sourceFileContext = sourceFileContext ; this . _transformerVisitor = visitor ; this . _visitor = ( node ) => visitor ( node , this ) ; } visit ( node ) { return this . visitor ( node ) ; } addTypeMetadata ( metadataEntry ) { this . _sourceFileContext . typesMetadata . push ( metadataEntry ) ; } addTypeCtor ( typeCtor ) { this . _sourceFileContext . typesCtors . push ( typeCtor ) ; } visitFunctionLikeDeclaration ( node ) { ts . visitEachChild ( node , this . visitor , this . _sourceFileContext . transformationContext ) ; } createNestedContext < TReturn = undefined > ( visitor , contextAction ) { const context = new Context ( this . _sourceFileContext , visitor ) ; return contextAction ( context ) ; } /**
     * Get identifier of getType() function for current file.
     */ getGetTypeIdentifier ( ) { return this . _sourceFileContext . getGetTypeIdentifier ( ) ; } param identifier return trySetGetTypeIdentifier ( identifier ) { return this . _sourceFileContext . trySetGetTypeIdentifier ( identifier ) ; } }