import ts from 'typescript' ; import { Namespace } from '../Components/Namespace' ; import { ComponentFactory } from './ComponentFactory' ; export namespace NamespaceFactory { export function create ( namespaceSymbol , checker ) { const result = new Namespace ( namespaceSymbol . getName ( ) ) ; const namespaceDeclarations = < ts . NamespaceDeclaration [ ] | undefined > namespaceSymbol . getDeclarations ( ) ; if ( namespaceDeclarations === undefined ) { return result ; } const declaration = namespaceDeclarations [ namespaceDeclarations . length - 1 ] ; if ( declaration === undefined || declaration . body === undefined ) { return result ; } if ( declaration . body . kind === ts . SyntaxKind . ModuleDeclaration ) { const childSymbol = checker . getSymbolAtLocation ( declaration . body . name ) ; if ( childSymbol !== undefined ) { result . parts = [ create ( childSymbol , checker ) ] ; return result ; } } if ( ( < ts . ModuleBlock > declaration . body ) . statements === undefined ) { return result ; } result . parts = ComponentFactory . create ( declaration . body , checker ) ; return result ; } }