@cplieger/deadset-ts 7.2.0-dev.3 → 8.0.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/mapper-connection.js +7 -4
- package/dist/src/analysis.js +116 -16
- package/dist/src/augmentations.js +21 -8
- package/dist/src/automatic-types.js +189 -0
- package/dist/src/base-url.js +18 -0
- package/dist/src/component-files.js +96 -31
- package/dist/src/components.js +7 -6
- package/dist/src/config.js +1 -0
- package/dist/src/configuration-files.js +54 -15
- package/dist/src/configured-declarations.js +24 -2
- package/dist/src/conformance-record.js +2 -2
- package/dist/src/contextual-uses.js +26 -26
- package/dist/src/convention-rows.js +75 -0
- package/dist/src/conventions.js +101 -5
- package/dist/src/decorator.js +21 -18
- package/dist/src/dependencies.js +185 -30
- package/dist/src/destructuring.js +77 -2
- package/dist/src/discover.js +188 -85
- package/dist/src/edges.js +1 -1
- package/dist/src/entry-point-gaps.js +7 -10
- package/dist/src/entry-points.js +112 -11
- package/dist/src/findings/completion.js +116 -21
- package/dist/src/findings/dependencies-and-module-machinery.js +71 -25
- package/dist/src/findings/emitters.js +1 -1
- package/dist/src/findings/intra-function.js +44 -13
- package/dist/src/findings/non-code-artifacts.js +66 -33
- package/dist/src/findings/unused-declarations.js +21 -1
- package/dist/src/findings/visibility-narrowing.js +22 -3
- package/dist/src/generated-file.js +11 -0
- package/dist/src/git-ignore.js +86 -0
- package/dist/src/graph.js +4 -1
- package/dist/src/import-bindings.js +97 -0
- package/dist/src/indexed-access.js +130 -28
- package/dist/src/interface-satisfaction.js +30 -12
- package/dist/src/intra-function-parts.js +313 -50
- package/dist/src/inventory.js +63 -8
- package/dist/src/json-document.js +5 -5
- package/dist/src/kinds.js +13 -13
- package/dist/src/matrix.js +18 -9
- package/dist/src/mdx-entries.js +197 -0
- package/dist/src/module-declarations.js +9 -13
- package/dist/src/namespace-objects.js +28 -18
- package/dist/src/overrides.js +45 -9
- package/dist/src/paths.js +9 -0
- package/dist/src/print.js +1 -0
- package/dist/src/ref.js +10 -0
- package/dist/src/references.js +29 -13
- package/dist/src/reflective-lookup.js +8 -6
- package/dist/src/report.js +4 -2
- package/dist/src/reporters/template.js +22 -13
- package/dist/src/resolve.js +2 -0
- package/dist/src/roots.js +110 -38
- package/dist/src/schema.js +1 -0
- package/dist/src/serialization-contract.js +97 -20
- package/dist/src/session.js +26 -1
- package/dist/src/source-files.js +39 -14
- package/dist/src/spelled-names.js +58 -0
- package/dist/src/suppress-file.js +12 -4
- package/dist/src/suppress-inline.js +21 -3
- package/dist/src/suppress.js +7 -5
- package/dist/src/sweep.js +27 -10
- package/dist/src/symbol-keys.js +103 -2
- package/dist/src/template-field.js +9 -6
- package/dist/src/test-support.js +121 -17
- package/dist/src/type-errors.js +116 -35
- package/dist/src/type-parameter-reads.js +172 -0
- package/dist/src/value-reach.js +17 -5
- package/dist/src/verbs/analyze.js +19 -1
- package/dist/src/verbs/explain.js +4 -2
- package/dist/src/version-range.js +10 -5
- package/dist/src/version.js +1 -1
- package/dist/src/workflow-steps.js +119 -22
- package/dist/src/workspace-programs.js +7 -3
- package/dist/src/workspace-resolution.js +72 -13
- package/dist/src/workspace.js +1 -1
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/analysis.ts +175 -16
- package/src/augmentations.ts +21 -10
- package/src/automatic-types.ts +246 -0
- package/src/base-url.ts +24 -0
- package/src/component-files.ts +116 -31
- package/src/components.ts +7 -6
- package/src/config.ts +3 -0
- package/src/configuration-files.ts +80 -18
- package/src/configured-declarations.ts +33 -4
- package/src/conformance-record.ts +2 -2
- package/src/contextual-uses.ts +27 -27
- package/src/convention-rows.ts +103 -0
- package/src/conventions.ts +121 -7
- package/src/decorator.ts +28 -18
- package/src/dependencies.ts +249 -43
- package/src/destructuring.ts +93 -2
- package/src/discover.ts +234 -86
- package/src/edges.ts +1 -1
- package/src/entry-point-gaps.ts +8 -11
- package/src/entry-points.ts +133 -11
- package/src/finding.ts +10 -0
- package/src/findings/completion.ts +147 -24
- package/src/findings/dependencies-and-module-machinery.ts +90 -28
- package/src/findings/emitters.ts +1 -1
- package/src/findings/intra-function.ts +56 -14
- package/src/findings/non-code-artifacts.ts +81 -41
- package/src/findings/unused-declarations.ts +25 -1
- package/src/findings/visibility-narrowing.ts +32 -3
- package/src/generated-file.ts +16 -0
- package/src/git-ignore.ts +98 -0
- package/src/graph.ts +6 -0
- package/src/host.ts +5 -9
- package/src/import-bindings.ts +128 -0
- package/src/indexed-access.ts +152 -30
- package/src/interface-satisfaction.ts +33 -13
- package/src/intra-function-parts.ts +415 -64
- package/src/inventory.ts +83 -7
- package/src/json-document.ts +7 -7
- package/src/kinds.ts +13 -13
- package/src/matrix.ts +32 -14
- package/src/mdx-entries.ts +241 -0
- package/src/module-declarations.ts +11 -13
- package/src/namespace-objects.ts +34 -21
- package/src/overrides.ts +56 -9
- package/src/paths.ts +10 -0
- package/src/print.ts +1 -0
- package/src/ref.ts +12 -0
- package/src/references.ts +38 -17
- package/src/reflective-lookup.ts +9 -7
- package/src/report.ts +16 -3
- package/src/reporters/template.ts +21 -13
- package/src/resolve.ts +3 -0
- package/src/roots.ts +163 -45
- package/src/schema.ts +1 -0
- package/src/serialization-contract.ts +108 -17
- package/src/session.ts +29 -1
- package/src/source-files.ts +66 -16
- package/src/spelled-names.ts +102 -0
- package/src/suppress-file.ts +14 -3
- package/src/suppress-inline.ts +21 -2
- package/src/suppress.ts +9 -5
- package/src/sweep.ts +32 -11
- package/src/symbol-keys.ts +129 -2
- package/src/template-field.ts +9 -6
- package/src/test-support.ts +149 -16
- package/src/type-errors.ts +132 -41
- package/src/type-parameter-reads.ts +227 -0
- package/src/value-reach.ts +19 -6
- package/src/verbs/analyze.ts +28 -1
- package/src/verbs/explain.ts +5 -2
- package/src/version-range.ts +10 -5
- package/src/version.ts +1 -1
- package/src/workflow-steps.ts +127 -22
- package/src/workspace-programs.ts +7 -3
- package/src/workspace-resolution.ts +86 -14
- package/src/workspace.ts +1 -1
package/src/reflective-lookup.ts
CHANGED
|
@@ -120,8 +120,9 @@ export function reflectiveLookup<Brand>(input: DetectorInput<Brand>): readonly E
|
|
|
120
120
|
return [];
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
// Whether each written `Reflect` is the global one, asked in one batch: a
|
|
124
|
-
//
|
|
123
|
+
// Whether each written `Reflect` is the global one, asked in one batch: a name
|
|
124
|
+
// declared only in the project's own files shadows it, and an augmentation of the
|
|
125
|
+
// global merges into it, which keeps the library's declaration.
|
|
125
126
|
const ownFiles = project.ownPaths();
|
|
126
127
|
const reflects = lookups.flatMap((lookup) =>
|
|
127
128
|
lookup.reflect === undefined ? [] : [lookup.reflect],
|
|
@@ -131,11 +132,12 @@ export function reflectiveLookup<Brand>(input: DetectorInput<Brand>): readonly E
|
|
|
131
132
|
project.symbolsAt(reflects.map((node) => project.handle(node))).forEach((symbol, index) => {
|
|
132
133
|
const node = reflects[index];
|
|
133
134
|
// A name the checker did not answer for is read as the global, which retains.
|
|
134
|
-
const
|
|
135
|
-
symbol === UNANSWERED
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
const isGlobal =
|
|
136
|
+
symbol === UNANSWERED ||
|
|
137
|
+
(symbol !== undefined &&
|
|
138
|
+
(symbol.declarations.length === 0 ||
|
|
139
|
+
symbol.declarations.some((declaration) => !ownFiles.has(declaration.path))));
|
|
140
|
+
if (node !== undefined && isGlobal) {
|
|
139
141
|
global.add(node);
|
|
140
142
|
}
|
|
141
143
|
});
|
package/src/report.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type { StaleSuppression } from "./findings/self-check.ts";
|
|
|
19
19
|
import type { TestFileRule } from "./references.ts";
|
|
20
20
|
|
|
21
21
|
/** The version of the report schema this analyzer writes a report to. */
|
|
22
|
-
const SCHEMA_VERSION = "
|
|
22
|
+
const SCHEMA_VERSION = "9.0.0";
|
|
23
23
|
|
|
24
24
|
/** Every report schema version this analyzer reads: the one the Contract it implements admits. */
|
|
25
25
|
export const SCHEMA_VERSIONS_ACCEPTED: readonly string[] = [SCHEMA_VERSION];
|
|
@@ -224,12 +224,21 @@ export interface Report {
|
|
|
224
224
|
readonly excluded_by_cgo: readonly never[];
|
|
225
225
|
readonly test_file_rules: readonly TestFileRule[];
|
|
226
226
|
readonly type_error_skips: readonly TypeErrorSkip[];
|
|
227
|
-
readonly notes: readonly
|
|
227
|
+
readonly notes: readonly ReportNote[];
|
|
228
228
|
readonly unanswered_questions: readonly UnansweredCount[];
|
|
229
229
|
readonly conventions_applied: readonly AppliedConvention[];
|
|
230
230
|
readonly totals: WireTotals;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/** One hint about the run's setup, as the report schema's `notes` spells it. */
|
|
234
|
+
export interface ReportNote {
|
|
235
|
+
readonly kind: "unmapped-entry";
|
|
236
|
+
/** The directory of the manifest the note is about, below the target root. */
|
|
237
|
+
readonly path: string;
|
|
238
|
+
readonly key: "ts.entry_files";
|
|
239
|
+
readonly message: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
233
242
|
/** What one run answered, from which its report is built. */
|
|
234
243
|
export interface ReportInput {
|
|
235
244
|
readonly contractVersion: string;
|
|
@@ -247,6 +256,8 @@ export interface ReportInput {
|
|
|
247
256
|
readonly unanswered: readonly UnansweredCount[];
|
|
248
257
|
/** The convention rows the run applied, in the report's order. */
|
|
249
258
|
readonly conventionsApplied: readonly AppliedConvention[];
|
|
259
|
+
/** The notes the run states, in any order. */
|
|
260
|
+
readonly notes?: readonly ReportNote[];
|
|
250
261
|
}
|
|
251
262
|
|
|
252
263
|
/** Two strings ordered bytewise. */
|
|
@@ -510,7 +521,9 @@ export function buildReport(input: ReportInput): Report {
|
|
|
510
521
|
]
|
|
511
522
|
.sort(([a, x], [b, y]) => compare(x.path, y.path) || x.line - y.line || compare(a, b))
|
|
512
523
|
.map(([, skip]) => skip),
|
|
513
|
-
notes: [],
|
|
524
|
+
notes: [...new Map((input.notes ?? []).map((one) => [JSON.stringify(one), one])).entries()]
|
|
525
|
+
.sort(([a, x], [b, y]) => compare(x.kind, y.kind) || compare(x.path, y.path) || compare(a, b))
|
|
526
|
+
.map(([, note]) => note),
|
|
514
527
|
unanswered_questions: [...input.unanswered]
|
|
515
528
|
.sort(
|
|
516
529
|
(a, b) =>
|
|
@@ -912,7 +912,7 @@ class Execution {
|
|
|
912
912
|
case "lit":
|
|
913
913
|
return arg.value;
|
|
914
914
|
case "pipe":
|
|
915
|
-
return this.pipeline(arg.pipe, dot
|
|
915
|
+
return this.pipeline(arg.pipe, dot);
|
|
916
916
|
case "field":
|
|
917
917
|
return this.field(arg.recv === undefined ? dot : this.arg(arg.recv, dot), arg.names);
|
|
918
918
|
case "func":
|
|
@@ -958,18 +958,17 @@ class Execution {
|
|
|
958
958
|
return call(head.name, operands());
|
|
959
959
|
}
|
|
960
960
|
|
|
961
|
-
private pipeline(pipe: Pipeline, dot: Value
|
|
961
|
+
private pipeline(pipe: Pipeline, dot: Value): Value {
|
|
962
962
|
let value: Value | undefined;
|
|
963
963
|
for (const command of pipe.commands) {
|
|
964
964
|
value = this.command(command, dot, value);
|
|
965
965
|
}
|
|
966
966
|
const result = value ?? null;
|
|
967
|
-
const
|
|
968
|
-
if (only !== undefined && (declares || pipe.assign)) {
|
|
967
|
+
for (const name of pipe.vars) {
|
|
969
968
|
if (pipe.assign) {
|
|
970
|
-
this.assign(
|
|
969
|
+
this.assign(name, result);
|
|
971
970
|
} else {
|
|
972
|
-
this.scopes.at(-1)?.set(
|
|
971
|
+
this.scopes.at(-1)?.set(name, result);
|
|
973
972
|
}
|
|
974
973
|
}
|
|
975
974
|
return result;
|
|
@@ -982,7 +981,7 @@ class Execution {
|
|
|
982
981
|
this.write(node.text);
|
|
983
982
|
break;
|
|
984
983
|
case "action": {
|
|
985
|
-
const value = this.pipeline(node.pipe, dot
|
|
984
|
+
const value = this.pipeline(node.pipe, dot);
|
|
986
985
|
if (node.pipe.vars.length === 0) {
|
|
987
986
|
this.write(formatted(value, false));
|
|
988
987
|
}
|
|
@@ -995,7 +994,7 @@ class Execution {
|
|
|
995
994
|
case "with": {
|
|
996
995
|
this.scopes.push(new Map());
|
|
997
996
|
try {
|
|
998
|
-
const value = this.pipeline(node.pipe, dot
|
|
997
|
+
const value = this.pipeline(node.pipe, dot);
|
|
999
998
|
const taken = truthy(value);
|
|
1000
999
|
this.run(taken ? node.list : node.otherwise, taken && node.k === "with" ? value : dot);
|
|
1001
1000
|
} finally {
|
|
@@ -1013,7 +1012,9 @@ class Execution {
|
|
|
1013
1012
|
private range(node: Control, dot: Value): void {
|
|
1014
1013
|
this.scopes.push(new Map());
|
|
1015
1014
|
try {
|
|
1016
|
-
|
|
1015
|
+
// Go's `evalPipeline` gives every variable the range declares or assigns the whole value first:
|
|
1016
|
+
// https://github.com/golang/go/blob/go1.27.2/src/text/template/exec.go#L525
|
|
1017
|
+
const value = this.pipeline(node.pipe, dot);
|
|
1017
1018
|
let entries: [Value, Value][];
|
|
1018
1019
|
if (value === null) {
|
|
1019
1020
|
entries = [];
|
|
@@ -1031,13 +1032,20 @@ class Execution {
|
|
|
1031
1032
|
return;
|
|
1032
1033
|
}
|
|
1033
1034
|
const [first, second] = node.pipe.vars;
|
|
1035
|
+
const scope = this.scopes.at(-1);
|
|
1036
|
+
const bind = (name: string, held: Value): void => {
|
|
1037
|
+
if (node.pipe.assign) {
|
|
1038
|
+
this.assign(name, held);
|
|
1039
|
+
} else {
|
|
1040
|
+
scope?.set(name, held);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1034
1043
|
for (const [key, element] of entries) {
|
|
1035
|
-
const scope = this.scopes.at(-1);
|
|
1036
1044
|
if (second !== undefined && first !== undefined) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1045
|
+
bind(first, key);
|
|
1046
|
+
bind(second, element);
|
|
1039
1047
|
} else if (first !== undefined) {
|
|
1040
|
-
|
|
1048
|
+
bind(first, element);
|
|
1041
1049
|
}
|
|
1042
1050
|
try {
|
|
1043
1051
|
this.run(node.list, element);
|
package/src/resolve.ts
CHANGED
|
@@ -112,6 +112,7 @@ interface Doc {
|
|
|
112
112
|
readonly injectionRegistrations: readonly DeclarationEntry[] | undefined;
|
|
113
113
|
readonly lifecycleContracts: readonly LifecycleContract[] | undefined;
|
|
114
114
|
readonly serializers: readonly DeclarationEntry[] | undefined;
|
|
115
|
+
readonly rootsComplete: boolean | undefined;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
/** One document the resolution reads, with the origin its settings carry. */
|
|
@@ -894,6 +895,7 @@ function readDoc(value: unknown, label: string): Doc {
|
|
|
894
895
|
),
|
|
895
896
|
lifecycleContracts: readLifecycleContracts(ts, label),
|
|
896
897
|
serializers: readDeclarations(ts, "serializers", "ts.serializers", label),
|
|
898
|
+
rootsComplete: readBoolean(ts, "roots_complete", "ts.roots_complete", label),
|
|
897
899
|
};
|
|
898
900
|
}
|
|
899
901
|
|
|
@@ -1191,6 +1193,7 @@ function settleAll(inputs: Inputs): { config: Config; provenance: Map<string, Or
|
|
|
1191
1193
|
(doc) => doc.lifecycleContracts,
|
|
1192
1194
|
),
|
|
1193
1195
|
serializers: at("ts.serializers", defaults.ts.serializers, (doc) => doc.serializers),
|
|
1196
|
+
rootsComplete: at("ts.roots_complete", defaults.ts.rootsComplete, (doc) => doc.rootsComplete),
|
|
1194
1197
|
},
|
|
1195
1198
|
};
|
|
1196
1199
|
|
package/src/roots.ts
CHANGED
|
@@ -22,19 +22,24 @@ import {
|
|
|
22
22
|
type SourceFile,
|
|
23
23
|
} from "@typescript/native/ast";
|
|
24
24
|
import { aliasChains } from "./alias-chain.ts";
|
|
25
|
-
import
|
|
25
|
+
import {
|
|
26
|
+
filesNamedBy,
|
|
27
|
+
outsideChain,
|
|
28
|
+
relativeSpecifiers,
|
|
29
|
+
type ParseFile,
|
|
30
|
+
} from "./configuration-files.ts";
|
|
26
31
|
import { conventionEntries, type Conventions } from "./conventions.ts";
|
|
27
32
|
import { entryPoints, type EntryRule } from "./entry-points.ts";
|
|
28
33
|
import { globExpression } from "./glob.ts";
|
|
29
34
|
import type { Host } from "./host.ts";
|
|
30
35
|
import { nodeKey, type Inventory, type InventorySymbol } from "./inventory.ts";
|
|
31
36
|
import type { Manifest, ManifestEntry } from "./manifest.ts";
|
|
32
|
-
import { relativePath, resolvePath } from "./paths.ts";
|
|
37
|
+
import { dirnamePath, joinPath, relativePath, resolvePath } from "./paths.ts";
|
|
33
38
|
import { byPosition } from "./position.ts";
|
|
34
39
|
import { UNANSWERED } from "./query.ts";
|
|
35
40
|
import type { ProjectView } from "./session.ts";
|
|
36
41
|
import type { Symbol as TSSymbol, Type } from "@typescript/native/sync";
|
|
37
|
-
import { sourceFilesOf } from "./source-files.ts";
|
|
42
|
+
import { sourceFilesOf, type SourceFiles } from "./source-files.ts";
|
|
38
43
|
import { typeQueryAliases } from "./type-query-alias.ts";
|
|
39
44
|
|
|
40
45
|
/** Why one declaration is a root. */
|
|
@@ -104,6 +109,8 @@ export interface Roots {
|
|
|
104
109
|
* unknown; otherwise each one an unanswered published type name may name.
|
|
105
110
|
*/
|
|
106
111
|
readonly unanswered: readonly string[];
|
|
112
|
+
/** Every manifest entry naming a file to import or run that reads back to no file of this project. */
|
|
113
|
+
readonly unmappedEntries: readonly ManifestEntry[];
|
|
107
114
|
}
|
|
108
115
|
|
|
109
116
|
/** What decides the roots beside the declarations themselves. */
|
|
@@ -134,6 +141,8 @@ export interface RootOptions {
|
|
|
134
141
|
* inside the target whose entries are published API whatever the target's kind.
|
|
135
142
|
*/
|
|
136
143
|
readonly publishedMembers?: ReadonlySet<string> | undefined;
|
|
144
|
+
/** Every file a program of the run holds, so a file another configuration compiles is no outside file. */
|
|
145
|
+
readonly runFiles?: ReadonlySet<string> | undefined;
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
/** Whether one declaration is written below the directory of a published workspace member. */
|
|
@@ -171,11 +180,25 @@ const OUTPUT_EXTENSION = /\.(?:d\.ts|d\.mts|d\.cts|js|mjs|cjs|jsx)$/u;
|
|
|
171
180
|
/** The extension a source file's name drops. */
|
|
172
181
|
const SOURCE_EXTENSION = /\.(?:d\.)?[cm]?[jt]sx?$/u;
|
|
173
182
|
|
|
183
|
+
/** Whether no `package.json` sits between one file and the manifest's directory, which holds it. */
|
|
184
|
+
function ofPackage(host: Host, dir: string, file: string): boolean {
|
|
185
|
+
for (let at = dirnamePath(file); at !== dir; at = dirnamePath(at)) {
|
|
186
|
+
if (
|
|
187
|
+
relativePath(dir, at) === undefined ||
|
|
188
|
+
host.kindOf(joinPath(at, "package.json")) === "file"
|
|
189
|
+
) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
174
196
|
/**
|
|
175
197
|
* The rooted files one manifest target reads back to by name: its path below the
|
|
176
198
|
* manifest's directory, past its first directory where it names one, without its output
|
|
177
|
-
* extension, is the name, and a rooted file
|
|
178
|
-
* without its source extension, ends with that name at a
|
|
199
|
+
* extension, is the name, and a rooted file of the manifest's own package is one whose
|
|
200
|
+
* path below the same directory, without its source extension, ends with that name at a
|
|
201
|
+
* directory boundary.
|
|
179
202
|
*/
|
|
180
203
|
function readBackByName(
|
|
181
204
|
host: Host,
|
|
@@ -195,13 +218,52 @@ function readBackByName(
|
|
|
195
218
|
const found = new Map<string, SourceFile>();
|
|
196
219
|
for (const file of rooted) {
|
|
197
220
|
const path = relativePath(dir, file.fileName)?.replace(SOURCE_EXTENSION, "");
|
|
198
|
-
if (
|
|
221
|
+
if (
|
|
222
|
+
path !== undefined &&
|
|
223
|
+
(path === name || path.endsWith(`/${name}`)) &&
|
|
224
|
+
ofPackage(host, dir, file.fileName)
|
|
225
|
+
) {
|
|
199
226
|
found.set(file.fileName, file);
|
|
200
227
|
}
|
|
201
228
|
}
|
|
202
229
|
return [...found.values()];
|
|
203
230
|
}
|
|
204
231
|
|
|
232
|
+
/**
|
|
233
|
+
* The program files a manifest target no program holds reaches: the target is a file
|
|
234
|
+
* read as a configuration file outside the program is, and each file of the chain it
|
|
235
|
+
* starts loads the program files its relative specifiers name, read through the emit
|
|
236
|
+
* mapping, as a command's shim loads the compiled entry it runs.
|
|
237
|
+
*/
|
|
238
|
+
function throughOutside(
|
|
239
|
+
options: RootOptions,
|
|
240
|
+
targetRoot: string,
|
|
241
|
+
files: SourceFiles,
|
|
242
|
+
entry: ManifestEntry,
|
|
243
|
+
): readonly SourceFile[] {
|
|
244
|
+
const cwd = options.host.workingDirectory();
|
|
245
|
+
const path = resolvePath(cwd, entry.path);
|
|
246
|
+
if (
|
|
247
|
+
options.parse === undefined ||
|
|
248
|
+
options.runFiles?.has(path) === true ||
|
|
249
|
+
options.host.kindOf(path) !== "file"
|
|
250
|
+
) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
const chain = outsideChain(options.host, targetRoot, files, options.parse, [
|
|
254
|
+
{ path, manifestDir: resolvePath(cwd, entry.dir) },
|
|
255
|
+
]);
|
|
256
|
+
const found = new Map<string, SourceFile>();
|
|
257
|
+
for (const { file } of chain) {
|
|
258
|
+
for (const specifier of relativeSpecifiers(file)) {
|
|
259
|
+
for (const named of filesNamedBy(files, dirnamePath(file.fileName), specifier)) {
|
|
260
|
+
found.set(named.fileName, named);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return [...found.values()];
|
|
265
|
+
}
|
|
266
|
+
|
|
205
267
|
/** Whether a configured string carries either special character. */
|
|
206
268
|
function isPattern(text: string): boolean {
|
|
207
269
|
return text.includes("*") || text.includes("?");
|
|
@@ -307,9 +369,21 @@ export function roots<Brand>(
|
|
|
307
369
|
found.set([id, kind, source].join("\u0000"), { id, kind, source });
|
|
308
370
|
};
|
|
309
371
|
|
|
310
|
-
const entered: {
|
|
311
|
-
|
|
312
|
-
|
|
372
|
+
const entered: {
|
|
373
|
+
file: SourceFile;
|
|
374
|
+
kind: RootKind;
|
|
375
|
+
source: string;
|
|
376
|
+
exports: boolean;
|
|
377
|
+
names?: readonly string[];
|
|
378
|
+
}[] = [];
|
|
379
|
+
const enter = (
|
|
380
|
+
file: SourceFile,
|
|
381
|
+
kind: RootKind,
|
|
382
|
+
source: string,
|
|
383
|
+
exports: boolean,
|
|
384
|
+
names?: readonly string[],
|
|
385
|
+
): void => {
|
|
386
|
+
entered.push({ file, kind, source, exports, ...(names === undefined ? {} : { names }) });
|
|
313
387
|
};
|
|
314
388
|
|
|
315
389
|
const points = entryPoints(
|
|
@@ -344,11 +418,28 @@ export function roots<Brand>(
|
|
|
344
418
|
...scripted,
|
|
345
419
|
...points.filter((point) => READ_BACK_RULES.has(point.rule)).map((point) => point.file),
|
|
346
420
|
];
|
|
421
|
+
const entryFilesOf = new Map<ManifestEntry, readonly SourceFile[]>();
|
|
347
422
|
const entryFiles = (entry: ManifestEntry): readonly SourceFile[] => {
|
|
423
|
+
const known = entryFilesOf.get(entry);
|
|
424
|
+
if (known !== undefined) {
|
|
425
|
+
return known;
|
|
426
|
+
}
|
|
427
|
+
const found = readEntryFiles(entry);
|
|
428
|
+
entryFilesOf.set(entry, found);
|
|
429
|
+
return found;
|
|
430
|
+
};
|
|
431
|
+
const readEntryFiles = (entry: ManifestEntry): readonly SourceFile[] => {
|
|
348
432
|
const named = files.named(entry.path);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
433
|
+
if (named.length > 0 || entry.role === "script") {
|
|
434
|
+
return named;
|
|
435
|
+
}
|
|
436
|
+
const cwd = options.host.workingDirectory();
|
|
437
|
+
const shipped = files.namedAsOutput(resolvePath(cwd, entry.dir), resolvePath(cwd, entry.path));
|
|
438
|
+
if (shipped.length > 0) {
|
|
439
|
+
return shipped;
|
|
440
|
+
}
|
|
441
|
+
const byName = readBackByName(options.host, entry, readBackTo);
|
|
442
|
+
return byName.length > 0 ? byName : throughOutside(options, targetRoot, files, entry);
|
|
352
443
|
};
|
|
353
444
|
for (const { entry, publishes } of entries) {
|
|
354
445
|
if (publishes) {
|
|
@@ -356,27 +447,41 @@ export function roots<Brand>(
|
|
|
356
447
|
}
|
|
357
448
|
}
|
|
358
449
|
const publishedNames = new Set(published.map((file) => file.fileName));
|
|
359
|
-
|
|
360
|
-
for (const file of entryFiles(entry)) {
|
|
361
|
-
const kind = ENTRY_KINDS[entry.role];
|
|
362
|
-
enter(file, kind, entry.member, !publishedNames.has(file.fileName));
|
|
363
|
-
}
|
|
364
|
-
}
|
|
450
|
+
const patterned: { file: SourceFile; pattern: string }[] = [];
|
|
365
451
|
for (const pattern of options.entryFiles) {
|
|
366
452
|
const expression = globExpression(pattern);
|
|
367
453
|
for (const [path, file] of files.byPath) {
|
|
368
454
|
if (expression.test(path)) {
|
|
369
|
-
|
|
455
|
+
patterned.push({ file, pattern });
|
|
370
456
|
}
|
|
371
457
|
}
|
|
372
458
|
}
|
|
459
|
+
const unmapped: ManifestEntry[] = [];
|
|
460
|
+
const mapped = patterned.map(({ file }) => file);
|
|
461
|
+
for (const { entry } of entries) {
|
|
462
|
+
const named = entryFiles(entry);
|
|
463
|
+
if (named.length === 0 && entry.role !== "script") {
|
|
464
|
+
unmapped.push(entry);
|
|
465
|
+
}
|
|
466
|
+
mapped.push(...named);
|
|
467
|
+
for (const file of named) {
|
|
468
|
+
const kind = ENTRY_KINDS[entry.role];
|
|
469
|
+
enter(file, kind, entry.member, !publishedNames.has(file.fileName));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const unmappedEntries = unmapped.filter(
|
|
473
|
+
(entry) => readBackByName(options.host, entry, mapped).length === 0,
|
|
474
|
+
);
|
|
475
|
+
for (const { file, pattern } of patterned) {
|
|
476
|
+
enter(file, "entry-file", pattern, true);
|
|
477
|
+
}
|
|
373
478
|
for (const { file, row } of options.conventions === undefined
|
|
374
479
|
? []
|
|
375
480
|
: conventionEntries(options.conventions, files)) {
|
|
376
481
|
enter(file, "convention", row, true);
|
|
377
482
|
}
|
|
378
483
|
for (const point of points) {
|
|
379
|
-
enter(point.file, point.rule, point.source, point.exports);
|
|
484
|
+
enter(point.file, point.rule, point.source, point.exports, point.names);
|
|
380
485
|
}
|
|
381
486
|
for (const file of files.byPath.values()) {
|
|
382
487
|
for (const alias of typeQueryAliases(file)) {
|
|
@@ -390,7 +495,11 @@ export function roots<Brand>(
|
|
|
390
495
|
}
|
|
391
496
|
}
|
|
392
497
|
|
|
393
|
-
const {
|
|
498
|
+
const {
|
|
499
|
+
tables: exportsOf,
|
|
500
|
+
named,
|
|
501
|
+
answered,
|
|
502
|
+
} = exportTables(project, held, [
|
|
394
503
|
...entered.filter((entry) => entry.exports).map((entry) => entry.file),
|
|
395
504
|
...published,
|
|
396
505
|
]);
|
|
@@ -401,8 +510,13 @@ export function roots<Brand>(
|
|
|
401
510
|
}
|
|
402
511
|
add(id, entry.kind, entry.source);
|
|
403
512
|
if (entry.exports) {
|
|
404
|
-
|
|
405
|
-
|
|
513
|
+
const byName = named.get(entry.file.fileName);
|
|
514
|
+
const exported =
|
|
515
|
+
entry.names === undefined || byName === undefined
|
|
516
|
+
? (exportsOf.get(entry.file.fileName) ?? [])
|
|
517
|
+
: entry.names.flatMap((name) => byName.get(name) ?? []);
|
|
518
|
+
for (const one of exported) {
|
|
519
|
+
add(one, entry.kind, entry.source);
|
|
406
520
|
}
|
|
407
521
|
}
|
|
408
522
|
}
|
|
@@ -433,6 +547,7 @@ export function roots<Brand>(
|
|
|
433
547
|
liveUnderReachability: ordered,
|
|
434
548
|
unmatched,
|
|
435
549
|
unanswered: answered ? api.guessed : held.symbols.map((symbol) => symbol.id),
|
|
550
|
+
unmappedEntries,
|
|
436
551
|
};
|
|
437
552
|
}
|
|
438
553
|
|
|
@@ -448,12 +563,18 @@ function exportTables<Brand>(
|
|
|
448
563
|
project: ProjectView<Brand>,
|
|
449
564
|
held: Inventory,
|
|
450
565
|
wanted: readonly SourceFile[],
|
|
451
|
-
): {
|
|
566
|
+
): {
|
|
567
|
+
readonly tables: ReadonlyMap<string, readonly string[]>;
|
|
568
|
+
/** Per file whose table the checker answered, the declarations each export name reaches. */
|
|
569
|
+
readonly named: ReadonlyMap<string, ReadonlyMap<string, readonly string[]>>;
|
|
570
|
+
readonly answered: boolean;
|
|
571
|
+
} {
|
|
452
572
|
const unique = [...new Map(wanted.map((file) => [file.fileName, file])).values()];
|
|
453
573
|
const tables = new Map<string, readonly string[]>();
|
|
574
|
+
const named = new Map<string, Map<string, string[]>>();
|
|
454
575
|
let answered = true;
|
|
455
576
|
if (unique.length === 0) {
|
|
456
|
-
return { tables, answered };
|
|
577
|
+
return { tables, named, answered };
|
|
457
578
|
}
|
|
458
579
|
const modules = project.symbolsAt(unique.map((file) => project.handle(file)));
|
|
459
580
|
const chains = aliasChains(project, held);
|
|
@@ -475,15 +596,18 @@ function exportTables<Brand>(
|
|
|
475
596
|
return;
|
|
476
597
|
}
|
|
477
598
|
const ids = new Set<string>();
|
|
599
|
+
const byName = new Map<string, string[]>();
|
|
478
600
|
for (const exported of table) {
|
|
479
601
|
for (const target of chains.chainOf(exported)) {
|
|
480
602
|
answered &&= !target.guessed;
|
|
481
603
|
ids.add(target.id);
|
|
604
|
+
byName.set(exported.name, [...(byName.get(exported.name) ?? []), target.id]);
|
|
482
605
|
}
|
|
483
606
|
}
|
|
484
607
|
tables.set(file.fileName, [...ids]);
|
|
608
|
+
named.set(file.fileName, byName);
|
|
485
609
|
});
|
|
486
|
-
return { tables, answered };
|
|
610
|
+
return { tables, named, answered };
|
|
487
611
|
}
|
|
488
612
|
|
|
489
613
|
/** A release tag of a documentation comment: `@` and its name, between white space or the ends. */
|
|
@@ -553,11 +677,13 @@ function publishedAPI<Brand>(
|
|
|
553
677
|
const nodes = declarationNodes(held, byPath);
|
|
554
678
|
const chains = aliasChains(project, held);
|
|
555
679
|
const reached = new Set<string>();
|
|
680
|
+
const entered = new Set<string>();
|
|
556
681
|
const guessed = new Set<string>();
|
|
557
682
|
const pending: string[] = [];
|
|
558
683
|
const reach = (id: string): void => {
|
|
559
|
-
|
|
560
|
-
|
|
684
|
+
const file = byId.get(id)?.kind === "file";
|
|
685
|
+
if (!(file ? entered : reached).has(id)) {
|
|
686
|
+
(file ? entered : reached).add(id);
|
|
561
687
|
pending.push(id);
|
|
562
688
|
}
|
|
563
689
|
};
|
|
@@ -566,11 +692,7 @@ function publishedAPI<Brand>(
|
|
|
566
692
|
}
|
|
567
693
|
for (const file of published) {
|
|
568
694
|
for (const id of exportsOf.get(file.fileName) ?? []) {
|
|
569
|
-
|
|
570
|
-
pending.push(id);
|
|
571
|
-
} else {
|
|
572
|
-
reach(id);
|
|
573
|
-
}
|
|
695
|
+
reach(id);
|
|
574
696
|
}
|
|
575
697
|
}
|
|
576
698
|
while (pending.length > 0) {
|
|
@@ -595,8 +717,7 @@ function publishedAPI<Brand>(
|
|
|
595
717
|
project,
|
|
596
718
|
round.flatMap((id) => {
|
|
597
719
|
const symbol = byId.get(id);
|
|
598
|
-
|
|
599
|
-
return node === undefined ? [] : [node];
|
|
720
|
+
return symbol === undefined ? [] : nodes.nodesOf(symbol);
|
|
600
721
|
}),
|
|
601
722
|
)) {
|
|
602
723
|
for (const target of chains.chainOf(symbol)) {
|
|
@@ -625,24 +746,22 @@ function declarationNodes(
|
|
|
625
746
|
byPath: ReadonlyMap<string, SourceFile>,
|
|
626
747
|
): {
|
|
627
748
|
typeNamesOf(symbol: InventorySymbol): readonly Node[];
|
|
628
|
-
|
|
749
|
+
nodesOf(symbol: InventorySymbol): readonly Node[];
|
|
629
750
|
} {
|
|
630
|
-
const walked = new Map<string, { byId: Map<string, Node>; nodes: Set<Node> }>();
|
|
631
|
-
const nodesIn = (path: string): { byId: Map<string, Node>; nodes: Set<Node> } => {
|
|
751
|
+
const walked = new Map<string, { byId: Map<string, Node[]>; nodes: Set<Node> }>();
|
|
752
|
+
const nodesIn = (path: string): { byId: Map<string, Node[]>; nodes: Set<Node> } => {
|
|
632
753
|
const known = walked.get(path);
|
|
633
754
|
if (known !== undefined) {
|
|
634
755
|
return known;
|
|
635
756
|
}
|
|
636
|
-
const found = { byId: new Map<string, Node>(), nodes: new Set<Node>() };
|
|
757
|
+
const found = { byId: new Map<string, Node[]>(), nodes: new Set<Node>() };
|
|
637
758
|
const file = byPath.get(path);
|
|
638
759
|
if (file !== undefined) {
|
|
639
760
|
const visit = (node: Node): void => {
|
|
640
761
|
const id = held.declarations.get(nodeKey(file, node));
|
|
641
762
|
if (id !== undefined) {
|
|
642
763
|
found.nodes.add(node);
|
|
643
|
-
|
|
644
|
-
found.byId.set(id, node);
|
|
645
|
-
}
|
|
764
|
+
found.byId.set(id, [...(found.byId.get(id) ?? []), node]);
|
|
646
765
|
}
|
|
647
766
|
node.forEachChild(visit);
|
|
648
767
|
};
|
|
@@ -654,10 +773,9 @@ function declarationNodes(
|
|
|
654
773
|
return {
|
|
655
774
|
typeNamesOf: (symbol) => {
|
|
656
775
|
const { byId, nodes } = nodesIn(symbol.position.path);
|
|
657
|
-
|
|
658
|
-
return declaration === undefined ? [] : typeNamesOf(declaration, nodes);
|
|
776
|
+
return (byId.get(symbol.id) ?? []).flatMap((declaration) => typeNamesOf(declaration, nodes));
|
|
659
777
|
},
|
|
660
|
-
|
|
778
|
+
nodesOf: (symbol) => nodesIn(symbol.position.path).byId.get(symbol.id) ?? [],
|
|
661
779
|
};
|
|
662
780
|
}
|
|
663
781
|
|
package/src/schema.ts
CHANGED