UNPKG

10.7 kBSource Map (JSON)View Raw
1{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../../../../src/lib/models/reflections/declaration.ts"],"names":[],"mappings":";;AAAA,yCAA8H;AAC9H,0CAAsD;AACtD,2CAAkD;AAGlD,mCAAiC;AA8BjC,MAAa,qBAAsB,SAAQ,+BAAmB;IAwF1D,iBAAiB;QACb,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;IACtD,CAAC;IAED,gBAAgB;QACZ,IAAI,MAAM,GAA0B,EAAE,CAAC;QAEvC,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC3C;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACpC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAClC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAUD,QAAQ,CAAC,QAA0B;QAC/B,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,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,SAA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AI,EAAE;YACX,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;SACxC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAjOD,sDAiOC","sourcesContent":["import { DefaultValueContainer, TypeContainer, TypeParameterContainer, TraverseCallback, TraverseProperty } from './abstract';\nimport { Type, ReflectionType } from '../types/index';\nimport { ContainerReflection } from './container';\nimport { SignatureReflection } from './signature';\nimport { TypeParameterReflection } from './type-parameter';\nimport { toArray } from 'lodash';\n\n/**\n * Stores hierarchical type data.\n *\n * @see [[DeclarationReflection.typeHierarchy]]\n */\nexport interface DeclarationHierarchy {\n /**\n * The types represented by this node in the hierarchy.\n */\n types: Type[];\n\n /**\n * The next hierarchy level.\n */\n next?: DeclarationHierarchy;\n\n /**\n * Is this the entry containing the target type?\n */\n isTarget?: boolean;\n}\n\n/**\n * A reflection that represents a single declaration emitted by the TypeScript compiler.\n *\n * All parts of a project are represented by DeclarationReflection instances. The actual\n * kind of a reflection is stored in its ´kind´ member.\n */\nexport class DeclarationReflection extends ContainerReflection implements DefaultValueContainer, TypeContainer, TypeParameterContainer {\n /**\n * The type of the reflection.\n *\n * If the reflection represents a variable or a property, this is the value type.<br />\n * If the reflection represents a signature, this is the return type.\n */\n type?: Type;\n\n typeParameters?: TypeParameterReflection[];\n\n /**\n * A list of call signatures attached to this declaration.\n *\n * TypeDoc creates one declaration per function that may contain ore or more\n * signature reflections.\n */\n signatures?: SignatureReflection[];\n\n /**\n * The index signature of this declaration.\n */\n indexSignature?: SignatureReflection;\n\n /**\n * The get signature of this declaration.\n */\n getSignature?: SignatureReflection;\n\n /**\n * The set signature of this declaration.\n */\n setSignature?: SignatureReflection;\n\n /**\n * The default value of this reflection.\n *\n * Applies to function parameters.\n */\n defaultValue?: string;\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 * A list of all types this reflection extends (e.g. the parent classes).\n */\n extendedTypes?: Type[];\n\n /**\n * A list of all types that extend this reflection (e.g. the subclasses).\n */\n extendedBy?: Type[];\n\n /**\n * A list of all types this reflection implements.\n */\n implementedTypes?: Type[];\n\n /**\n * A list of all types that implement this reflection.\n */\n implementedBy?: Type[];\n\n /**\n * Contains a simplified representation of the type hierarchy suitable for being\n * rendered in templates.\n */\n typeHierarchy?: DeclarationHierarchy;\n\n hasGetterOrSetter(): boolean {\n return !!this.getSignature || !!this.setSignature;\n }\n\n getAllSignatures(): SignatureReflection[] {\n let result: SignatureReflection[] = [];\n\n if (this.signatures) {\n result = result.concat(this.signatures);\n }\n if (this.indexSignature) {\n result.push(this.indexSignature);\n }\n if (this.getSignature) {\n result.push(this.getSignature);\n }\n if (this.setSignature) {\n result.push(this.setSignature);\n }\n\n return result;\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 for (const parameter of toArray(this.typeParameters)) {\n if (callback(parameter, TraverseProperty.TypeParameter) === false) {\n return;\n }\n }\n\n if (this.type instanceof ReflectionType) {\n if (callback(this.type.declaration, TraverseProperty.TypeLiteral) === false) {\n return;\n }\n }\n\n for (const signature of toArray(this.signatures)) {\n if (callback(signature, TraverseProperty.Signatures) === false) {\n return;\n }\n }\n\n if (this.indexSignature) {\n if (callback(this.indexSignature, TraverseProperty.IndexSignature) === false) {\n return;\n }\n }\n\n if (this.getSignature) {\n if (callback(this.getSignature, TraverseProperty.GetSignature) === false) {\n return;\n }\n }\n\n if (this.setSignature) {\n if (callback(this.setSignature, TraverseProperty.SetSignature) === 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 let result = super.toObject();\n\n if (this.type) {\n result.type = this.type.toObject();\n }\n\n if (this.defaultValue) {\n result.defaultValue = this.defaultValue;\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.extendedTypes) {\n result.extendedTypes = this.extendedTypes.map((t) => t.toObject());\n }\n\n if (this.extendedBy) {\n result.extendedBy = this.extendedBy.map((t) => t.toObject());\n }\n\n if (this.implementedTypes) {\n result.implementedTypes = this.implementedTypes.map((t) => t.toObject());\n }\n\n if (this.implementedBy) {\n result.implementedBy = this.implementedBy.map((t) => t.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) => {\n parameters.push(parameter.name);\n });\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