import ts from 'typescript' ; import { Enum } from '../Components/Enum' ; import { IComponentComposite } from '../Models/IComponentComposite' ; import { EnumValueFactory } from './EnumValueFactory' ; export namespace EnumFactory { export function create ( enumSymbol ) { const result = new Enum ( enumSymbol . getName ( ) ) ; if ( enumSymbol . exports !== undefined ) { result . values = serializeEnumProperties ( enumSymbol . exports ) ; } return result ; } function serializeEnumProperties ( memberSymbols ) { const result = [ ] ; if ( memberSymbols !== undefined ) { memberSymbols . forEach ( ( memberSymbol ) : void => { const memberDeclarations = memberSymbol . getDeclarations ( ) ; if ( memberDeclarations === undefined ) { return ; } memberDeclarations . forEach ( ( memberDeclaration ) : void => { if ( memberDeclaration . kind === ts . SyntaxKind . EnumMember ) { result . push ( EnumValueFactory . create ( memberSymbol ) ) ; } } ) ; } ) ; } return result ; } }