UNPKG

5.68 kBSource Map (JSON)View Raw
1{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/signature.ts"],"names":[],"mappings":";;AAAA,0CAAsD;AACtD,yCAAmH;AAInH,mCAAiC;AAEjC,MAAa,mBAAoB,SAAQ,qBAAU;IAiC/C,iBAAiB;QACb,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,OAAO,EAAE,CAAC;SACb;QACD,SAAS,YAAY,CAAI,CAAgB;YACrC,OAAO,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACjF,CAAC;IAUD,QAAQ,CAAC,QAA0B;QAC/B,IAAI,IAAI,CAAC,IAAI,YAAY,sBAAc,EAAE;YACrC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,2BAAgB,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE;gBACzE,OAAO;aACV;SACJ;QAED,KAAK,MAAM,SAAS,IAAI,gBAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;YAClD,IAAI,QAAQ,CAAC,SAAS,EAAE,2BAAgB,CAAC,aAAa,CAAC,KAAK,KAAK,EAAE;gBAC/D,OAAO;aACV;SACJ;QAED,KAAK,MAAM,SAAS,IAAI,gBAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YAC9C,IAAI,QAAQ,CAAC,SAAS,EAAE,2BAAgB,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE;gBAC5D,OAAO;aACV;SACJ;QAED,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAMD,QAAQ;QACJ,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEhC,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACtC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;SAClD;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;SACxD;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;SAC9D;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAKD,QAAQ;QACJ,IAAI,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAE9B,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,MAAM,UAAU,GAAa,EAAE,CAAC;YAChC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5E,MAAM,IAAI,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;SAC/C;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACxC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AArHD,kDAqHC","sourcesContent":["import { Type, ReflectionType } from '../types/index';\nimport { Reflection, TypeContainer, TypeParameterContainer, TraverseProperty, TraverseCallback } from './abstract';\nimport { ContainerReflection } from './container';\nimport { ParameterReflection } from './parameter';\nimport { TypeParameterReflection } from './type-parameter';\nimport { toArray } from 'lodash';\n\nexport class SignatureReflection extends Reflection implements TypeContainer, TypeParameterContainer {\n parent?: ContainerReflection;\n\n parameters?: ParameterReflection[];\n\n typeParameters?: TypeParameterReflection[];\n\n type?: Type;\n\n /**\n * A type that points to the reflection that has been overwritten by this reflection.\n *\n * Applies to interface and class members.\n */\n overwrites?: Type;\n\n /**\n * A type that points to the reflection this reflection has been inherited from.\n *\n * Applies to interface and class members.\n */\n inheritedFrom?: Type;\n\n /**\n * A type that points to the reflection this reflection is the implementation of.\n *\n * Applies to class members.\n */\n implementationOf?: Type;\n\n /**\n * Return an array of the parameter types.\n */\n getParameterTypes(): Type[] {\n if (!this.parameters) {\n return [];\n }\n function notUndefined<T>(t: T | undefined): t is T {\n return !!t;\n }\n return this.parameters.map(parameter => parameter.type).filter(notUndefined);\n }\n\n /**\n * Traverse all potential child reflections of this reflection.\n *\n * The given callback will be invoked for all children, signatures and type parameters\n * attached to this reflection.\n *\n * @param callback The callback function that should be applied for each child reflection.\n */\n traverse(callback: TraverseCallback) {\n if (this.type instanceof ReflectionType) {\n if (callback(this.type.declaration, TraverseProperty.TypeLiteral) === false) {\n return;\n }\n }\n\n for (const parameter of toArray(this.typeParameters)) {\n if (callback(parameter, TraverseProperty.TypeParameter) === false) {\n return;\n }\n }\n\n for (const parameter of toArray(this.parameters)) {\n if (callback(parameter, TraverseProperty.Parameters) === false) {\n return;\n }\n }\n\n super.traverse(callback);\n }\n\n /**\n * Return a raw object representation of this reflection.\n * @deprecated Use serializers instead\n */\n toObject(): any {\n const result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n if (this.overwrites) {\n result.overwrites = this.overwrites.toObject();\n }\n\n if (this.inheritedFrom) {\n result.inheritedFrom = this.inheritedFrom.toObject();\n }\n\n if (this.implementationOf) {\n result.implementationOf = this.implementationOf.toObject();\n }\n\n return result;\n }\n\n /**\n * Return a string representation of this reflection.\n */\n toString(): string {\n let result = super.toString();\n\n if (this.typeParameters) {\n const parameters: string[] = [];\n this.typeParameters.forEach((parameter) => parameters.push(parameter.name));\n result += '<' + parameters.join(', ') + '>';\n }\n\n if (this.type) {\n result += ':' + this.type.toString();\n }\n\n return result;\n }\n}\n"]}
\No newline at end of file