import ts from 'typescript' ; import { Method } from '../Components/Method' ; import { Parameter } from '../Components/Parameter' ; import { ComponentFactory } from './ComponentFactory' ; import { ParameterFactory } from './ParameterFactory' ; export namespace MethodFactory { export function create ( signature , namedDeclaration , checker ) { const result = new Method ( signature . getName ( ) ) ; result . modifier = ComponentFactory . getMemberModifier ( namedDeclaration ) ; result . isAbstract = ComponentFactory . isAbstract ( namedDeclaration ) ; result . isOptional = ComponentFactory . isOptional ( < ts . MethodDeclaration > namedDeclaration ) ; result . isStatic = ComponentFactory . isStatic ( namedDeclaration ) ; const methodSignature = checker . getSignatureFromDeclaration ( < ts . MethodDeclaration > namedDeclaration ) ; if ( methodSignature !== undefined ) { result . returnType = checker . typeToString ( methodSignature . getReturnType ( ) , namedDeclaration ) ; result . parameters = methodSignature . parameters . map ( ( parameter ) : Parameter => ParameterFactory . create ( parameter , checker ) ) ; } return result ; } }