import { Transform , ClassDeclaration , NamespaceDeclaration , NodeKind , Parser , Statement , Source , } from "visitor-as/as" ; import { createAsonPutMethod } from "./createAsonPutMethod" ; export = class ASONTransform extends Transform { param { Parser } parser afterParse ( parser ) { let sources = ( parser as any ) . program ? ( parser as any ) . program . sources : parser . sources ; for ( const source of sources ) { traverseStatements ( source . statements ) ; } } } ; function traverseStatements ( statements ) { for ( const statement of statements ) { if ( statement . kind === NodeKind . CLASSDECLARATION ) { const classDeclaration = < ClassDeclaration > statement ; createAsonPutMethod ( classDeclaration ) ; } else if ( statement . kind === NodeKind . NAMESPACEDECLARATION ) { const namespaceDeclaration = < NamespaceDeclaration > statement ; traverseStatements ( namespaceDeclaration . members ) ; } } }