UNPKG

5.07 kBTypeScriptView Raw
1import type ts from "typescript";
2import { type Reflection } from "./abstract.js";
3import { ContainerReflection } from "./container.js";
4import type { DeclarationReflection } from "./declaration.js";
5import { type Type } from "../types.js";
6import { ReflectionKind } from "./kind.js";
7import { type CommentDisplayPart } from "../comments/index.js";
8import { ReflectionSymbolId } from "./ReflectionSymbolId.js";
9import type { Serializer } from "../../serialization/serializer.js";
10import type { Deserializer, JSONOutput } from "../../serialization/index.js";
11import type { FileRegistry } from "../FileRegistry.js";
12/**
13 * A reflection that represents the root of the project.
14 *
15 * The project reflection acts as a global index, one may receive all reflections
16 * and source files of the processed project through this reflection.
17 * @category Reflections
18 */
19export declare class ProjectReflection extends ContainerReflection {
20 readonly variant = "project";
21 private symbolToReflectionIdMap;
22 private reflectionIdToSymbolIdMap;
23 private reflectionIdToSymbolMap;
24 private removedSymbolIds;
25 private referenceGraph?;
26 private reflectionChildren;
27 /**
28 * A list of all reflections within the project. DO NOT MUTATE THIS OBJECT.
29 * All mutation should be done via {@link registerReflection} and {@link removeReflection}
30 * to ensure that links to reflections remain valid.
31 *
32 * This may be replaced with a `Map<number, Reflection>` someday.
33 */
34 reflections: {
35 [id: number]: Reflection;
36 };
37 /**
38 * The name of the package that this reflection documents according to package.json.
39 */
40 packageName?: string;
41 /**
42 * The version of the package that this reflection documents according to package.json.
43 */
44 packageVersion?: string;
45 /**
46 * The contents of the readme.md file of the project when found.
47 */
48 readme?: CommentDisplayPart[];
49 /**
50 * Object which describes where to find content for relative links.
51 */
52 readonly files: FileRegistry;
53 constructor(name: string, registry: FileRegistry);
54 /**
55 * Return whether this reflection is the root / project reflection.
56 */
57 isProject(): this is ProjectReflection;
58 /**
59 * Return a list of all reflections in this project of a certain kind.
60 *
61 * @param kind The desired kind of reflection.
62 * @returns An array containing all reflections with the desired kind.
63 */
64 getReflectionsByKind(kind: ReflectionKind): Reflection[];
65 /**
66 * Registers the given reflection so that it can be quickly looked up by helper methods.
67 * Should be called for *every* reflection added to the project.
68 */
69 registerReflection(reflection: Reflection, symbol: ts.Symbol | undefined, filePath: string | undefined): void;
70 /**
71 * Removes references to reflections contained within the provided type.
72 * Plugins which overwrite types on reflections should pass the type to this
73 * method before overwriting the property.
74 * @since 0.26.6
75 */
76 removeTypeReflections(type: Type | undefined): void;
77 /**
78 * Removes a reflection from the documentation. Can be used by plugins to filter reflections
79 * out of the generated documentation. Has no effect if the reflection is not present in the
80 * project.
81 */
82 removeReflection(reflection: Reflection): void;
83 /** @internal */
84 mergeModules(source: DeclarationReflection, target: DeclarationReflection | ProjectReflection): void;
85 /**
86 * Remove a reflection without updating the parent reflection to remove references to the removed reflection.
87 */
88 private _removeReflection;
89 /**
90 * Gets the reflection registered for the given reflection ID, or undefined if it is not present
91 * in the project.
92 */
93 getReflectionById(id: number): Reflection | undefined;
94 /**
95 * Gets the reflection associated with the given symbol, if it exists.
96 * @internal
97 */
98 getReflectionFromSymbol(symbol: ts.Symbol): Reflection | undefined;
99 /**
100 * Gets the reflection associated with the given symbol id, if it exists.
101 * If there are multiple reflections associated with this symbol, gets the first one.
102 * @internal
103 */
104 getReflectionFromSymbolId(symbolId: ReflectionSymbolId): Reflection | undefined;
105 /** @internal */
106 getReflectionsFromSymbolId(symbolId: ReflectionSymbolId): Reflection[];
107 /** @internal */
108 getSymbolIdFromReflection(reflection: Reflection): ReflectionSymbolId | undefined;
109 /** @internal */
110 registerSymbolId(reflection: Reflection, id: ReflectionSymbolId): void;
111 symbolIdHasBeenRemoved(id: ReflectionSymbolId): boolean;
112 /**
113 * THIS MAY NOT BE USED AFTER CONVERSION HAS FINISHED.
114 * @internal
115 */
116 getSymbolFromReflection(reflection: Reflection): ts.Symbol | undefined;
117 private getReferenceGraph;
118 toObject(serializer: Serializer): JSONOutput.ProjectReflection;
119 fromObject(de: Deserializer, obj: JSONOutput.ProjectReflection): void;
120}