Skip to content

Commit 1f917bf

Browse files
committed
Clear comment cache between conversions
1 parent 192d1b5 commit 1f917bf

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/lib/converter/converter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
unique,
3737
} from "#utils";
3838
import type { DocumentationEntryPoint } from "../utils/entry-point.js";
39-
import type { CommentParserConfig } from "./comments/index.js";
39+
import { clearCommentCache, type CommentParserConfig } from "./comments/index.js";
4040
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration.js";
4141
import { parseCommentString } from "./comments/parser.js";
4242
import { lexCommentString } from "./comments/rawLexer.js";
@@ -343,6 +343,10 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
343343
delete this.excludeCache;
344344
delete this.externalPatternCache;
345345

346+
// Also clear the comment cache so if we convert this ts.Program again
347+
// later we will re-parse comments.
348+
clearCommentCache();
349+
346350
return project;
347351
}
348352

src/lib/models/ProjectReflection.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ import { ReflectionKind } from "./kind.js";
1010
import { Comment, type CommentDisplayPart } from "./Comment.js";
1111
import { ReflectionSymbolId } from "./ReflectionSymbolId.js";
1212
import type { Deserializer, JSONOutput, Serializer } from "#serialization";
13-
import { assertNever, DefaultMap, i18n, type NormalizedPath, removeIfPresent, StableKeyMap } from "#utils";
13+
import {
14+
assertNever,
15+
DefaultMap,
16+
i18n,
17+
NonEnumerable,
18+
type NormalizedPath,
19+
removeIfPresent,
20+
StableKeyMap,
21+
} from "#utils";
1422
import type { DocumentReflection } from "./DocumentReflection.js";
1523
import type { FileRegistry } from "./FileRegistry.js";
1624

@@ -28,18 +36,24 @@ export class ProjectReflection extends ContainerReflection {
2836
readonly variant = "project";
2937

3038
// Used to resolve references.
39+
@NonEnumerable
3140
private symbolToReflectionIdMap: Map<
3241
ReflectionSymbolId,
3342
number | number[]
3443
> = new StableKeyMap();
3544

45+
@NonEnumerable
3646
private reflectionIdToSymbolIdMap = new Map<number, ReflectionSymbolId>();
3747

48+
@NonEnumerable
3849
private removedSymbolIds = new StableKeyMap<ReflectionSymbolId, true>();
3950

4051
// Maps a reflection ID to all references eventually referring to it.
52+
@NonEnumerable
4153
private referenceGraph?: Map<number, number[]>;
54+
4255
// Maps a reflection ID to all reflections with it as their parent.
56+
@NonEnumerable
4357
private reflectionChildren = new DefaultMap<number, number[]>(() => []);
4458

4559
/**
@@ -49,6 +63,7 @@ export class ProjectReflection extends ContainerReflection {
4963
*
5064
* This may be replaced with a `Map<number, Reflection>` someday.
5165
*/
66+
@NonEnumerable
5267
reflections: { [id: number]: Reflection } = {};
5368

5469
/**

src/test/programs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
import type { ModelToObject } from "../lib/serialization/schema.js";
1414
import { createAppForTesting } from "../lib/application.js";
1515
import { existsSync } from "fs";
16-
import { clearCommentCache } from "../lib/converter/comments/index.js";
1716
import { diagnostics } from "../lib/utils/loggers.js";
1817
import { normalizePath, readFile, ValidatingFileRegistry } from "#node-utils";
1918

@@ -175,7 +174,6 @@ export function getConverter2Project(entries: string[], folder: string) {
175174

176175
app.options.setValue("entryPoints", entryPoints);
177176
app.files = new ValidatingFileRegistry();
178-
clearCommentCache();
179177
return app.converter.convert(
180178
files.map((file, index) => {
181179
return {

0 commit comments

Comments
 (0)