@cplieger/deadset-ts 8.0.0-dev.16 → 8.0.0-dev.17
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/src/alias-chain.js +0 -5
- package/dist/src/amd.js +81 -0
- package/dist/src/analysis.js +58 -22
- package/dist/src/augmentations.js +23 -24
- package/dist/src/bindings.js +382 -0
- package/dist/src/calls.js +25 -8
- package/dist/src/commands/tools.js +5 -9
- package/dist/src/component-files.js +3 -2
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +6 -9
- package/dist/src/contextual-uses.js +1 -17
- package/dist/src/contract/config.generated.js +4 -1
- package/dist/src/contract/report.generated.js +6 -2
- package/dist/src/dependencies.js +25 -29
- package/dist/src/destructuring.js +1 -19
- package/dist/src/element-access.js +179 -164
- package/dist/src/entries/build-scripts.js +2 -2
- package/dist/src/entries/configuration-files.js +3 -7
- package/dist/src/entries/conventions.js +2 -2
- package/dist/src/entries/html-entries.js +7 -10
- package/dist/src/entries/mdx-entries.js +2 -2
- package/dist/src/entries/static-module.js +2 -1
- package/dist/src/facts.js +4 -4
- package/dist/src/findings/completion.js +40 -4
- package/dist/src/{implementations.js → findings/implementations.js} +3 -3
- package/dist/src/{in-operands.js → findings/in-operands.js} +2 -2
- package/dist/src/framework-lifecycle.js +41 -14
- package/dist/src/graph.js +12 -4
- package/dist/src/import-bindings.js +73 -28
- package/dist/src/index/sites.js +557 -0
- package/dist/src/indexed-access.js +523 -478
- package/dist/src/interface-satisfaction.js +1 -1
- package/dist/src/keyof-comparisons.js +124 -103
- package/dist/src/load/expected-module.js +2 -2
- package/dist/src/load/specifiers.js +2 -4
- package/dist/src/load/synthesize.js +5 -0
- package/dist/src/load/workspace-resolution.js +2 -2
- package/dist/src/matrix.js +6 -4
- package/dist/src/module-declarations.js +70 -85
- package/dist/src/overrides.js +134 -112
- package/dist/src/paths.js +46 -7
- package/dist/src/platform-calls.js +2 -2
- package/dist/src/platform-symbols.js +13 -19
- package/dist/src/references/read-rule.js +1 -0
- package/dist/src/references/read-rules.js +48 -0
- package/dist/src/references/sink.js +151 -0
- package/dist/src/references/sources.js +450 -0
- package/dist/src/references.js +110 -1285
- package/dist/src/roots/configured-declarations.js +3 -0
- package/dist/src/roots/root-set.js +1 -1
- package/dist/src/roots/unseen-loads.js +38 -10
- package/dist/src/serialization-contract.js +8 -3
- package/dist/src/stores.js +4 -2
- package/dist/src/sweep.js +25 -13
- package/dist/src/symbol-keys.js +89 -83
- package/dist/src/tests/file-class.js +76 -0
- package/dist/src/{outside-tests.js → tests/outside.js} +7 -7
- package/dist/src/{test-support.js → tests/support.js} +2 -11
- package/dist/src/type-parameter-reads.js +178 -139
- package/dist/src/unimplemented-callees.js +262 -242
- package/dist/src/verbs/analyze.js +3 -3
- package/dist/src/verbs/explain.js +50 -28
- package/dist/src/verbs/print-retained.js +2 -2
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/alias-chain.ts +0 -7
- package/src/amd.ts +130 -0
- package/src/analysis.ts +86 -23
- package/src/augmentations.ts +41 -27
- package/src/bindings.ts +460 -0
- package/src/calls.ts +25 -7
- package/src/commands/tools.ts +5 -11
- package/src/component-files.ts +4 -2
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +8 -11
- package/src/contextual-uses.ts +2 -22
- package/src/contract/config.generated.ts +4 -1
- package/src/contract/report.generated.ts +6 -2
- package/src/dependencies.ts +27 -28
- package/src/destructuring.ts +1 -31
- package/src/element-access.ts +188 -182
- package/src/entries/build-scripts.ts +2 -2
- package/src/entries/configuration-files.ts +11 -8
- package/src/entries/conventions.ts +2 -1
- package/src/entries/html-entries.ts +15 -14
- package/src/entries/mdx-entries.ts +2 -2
- package/src/entries/static-module.ts +2 -1
- package/src/facts.ts +5 -3
- package/src/findings/boundary.ts +2 -0
- package/src/findings/completion.ts +43 -4
- package/src/findings/emitter.ts +1 -1
- package/src/{implementations.ts → findings/implementations.ts} +4 -4
- package/src/{in-operands.ts → findings/in-operands.ts} +3 -3
- package/src/framework-lifecycle.ts +42 -14
- package/src/graph.ts +24 -6
- package/src/import-bindings.ts +98 -29
- package/src/index/sites.ts +781 -0
- package/src/indexed-access.ts +570 -527
- package/src/interface-satisfaction.ts +1 -1
- package/src/keyof-comparisons.ts +131 -116
- package/src/load/expected-module.ts +8 -2
- package/src/load/specifiers.ts +8 -5
- package/src/load/synthesize.ts +6 -0
- package/src/load/workspace-resolution.ts +9 -2
- package/src/matrix.ts +6 -3
- package/src/module-declarations.ts +74 -98
- package/src/overrides.ts +162 -134
- package/src/paths.ts +54 -8
- package/src/platform-calls.ts +3 -3
- package/src/platform-symbols.ts +11 -27
- package/src/references/read-rule.ts +60 -0
- package/src/references/read-rules.ts +55 -0
- package/src/references/sink.ts +213 -0
- package/src/references/sources.ts +632 -0
- package/src/references.ts +168 -1733
- package/src/report.ts +1 -1
- package/src/roots/configured-declarations.ts +3 -0
- package/src/roots/root-set.ts +1 -1
- package/src/roots/unseen-loads.ts +49 -11
- package/src/serialization-contract.ts +8 -3
- package/src/stores.ts +13 -2
- package/src/sweep.ts +37 -14
- package/src/symbol-keys.ts +102 -102
- package/src/tests/file-class.ts +118 -0
- package/src/{outside-tests.ts → tests/outside.ts} +16 -10
- package/src/{test-support.ts → tests/support.ts} +9 -20
- package/src/type-parameter-reads.ts +187 -158
- package/src/unimplemented-callees.ts +297 -280
- package/src/verbs/analyze.ts +3 -2
- package/src/verbs/explain.ts +74 -31
- package/src/verbs/print-retained.ts +2 -2
package/src/contextual-uses.ts
CHANGED
|
@@ -56,16 +56,12 @@ interface ContextualUse {
|
|
|
56
56
|
readonly ids: readonly string[];
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
/** What the contextual types of one project's literals and values use
|
|
59
|
+
/** What the contextual types of one project's literals and values use. */
|
|
60
60
|
interface ContextualUses {
|
|
61
61
|
/** Each literal property that writes a member, by the property's node. */
|
|
62
62
|
readonly writes: readonly ContextualUse[];
|
|
63
63
|
/** Each value whose members a position typed by another object type reads. */
|
|
64
64
|
readonly reads: readonly ContextualUse[];
|
|
65
|
-
/** The batched lookups: contextual types and value types, one per capped run. */
|
|
66
|
-
readonly batches: number;
|
|
67
|
-
/** The per-type lookups: each distinct type's constituents, properties and declaring symbol. */
|
|
68
|
-
readonly lookups: number;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
/**
|
|
@@ -169,9 +165,6 @@ export function contextualUses<Brand>(
|
|
|
169
165
|
.filter((symbol) => symbol.visibility === "private-name")
|
|
170
166
|
.map((symbol) => symbol.id),
|
|
171
167
|
);
|
|
172
|
-
let batches = 0;
|
|
173
|
-
let lookups = 0;
|
|
174
|
-
const batchesOf = (count: number): number => Math.ceil(count / cap);
|
|
175
168
|
|
|
176
169
|
const parts = new Map<number, readonly Type[]>();
|
|
177
170
|
/** The object types one type is: itself, or its constituents at any depth. */
|
|
@@ -182,7 +175,6 @@ export function contextualUses<Brand>(
|
|
|
182
175
|
}
|
|
183
176
|
let found: readonly Type[] = [];
|
|
184
177
|
if (type.isUnionType() || type.isIntersectionType()) {
|
|
185
|
-
lookups += 1;
|
|
186
178
|
const constituents = queries.constituents(type);
|
|
187
179
|
found = isAnswered(constituents) ? constituents.flatMap(partsOf) : [];
|
|
188
180
|
} else if (type.isObjectType()) {
|
|
@@ -201,7 +193,6 @@ export function contextualUses<Brand>(
|
|
|
201
193
|
}
|
|
202
194
|
const table = new Map<string, Member>();
|
|
203
195
|
const read = properties.of(type);
|
|
204
|
-
lookups += read.asked ? 1 : 0;
|
|
205
196
|
for (const property of isAnswered(read.properties) ? read.properties : []) {
|
|
206
197
|
table.set(property.name, {
|
|
207
198
|
ids: chains
|
|
@@ -222,7 +213,6 @@ export function contextualUses<Brand>(
|
|
|
222
213
|
};
|
|
223
214
|
|
|
224
215
|
const writes: ContextualUse[] = [];
|
|
225
|
-
batches += batchesOf(literals.length);
|
|
226
216
|
const contexts = queries.contextualTypes(
|
|
227
217
|
literals.map((one) => one.literal),
|
|
228
218
|
cap,
|
|
@@ -238,7 +228,6 @@ export function contextualUses<Brand>(
|
|
|
238
228
|
return name !== undefined && name.text === undefined ? [name.node] : [];
|
|
239
229
|
}),
|
|
240
230
|
);
|
|
241
|
-
batches += batchesOf(computed.length);
|
|
242
231
|
const keys = new Map<Node, string>();
|
|
243
232
|
(computed.length === 0
|
|
244
233
|
? []
|
|
@@ -272,7 +261,6 @@ export function contextualUses<Brand>(
|
|
|
272
261
|
});
|
|
273
262
|
|
|
274
263
|
const carried = flows.filter((flow) => !isObjectLiteralExpression(flow.value));
|
|
275
|
-
batches += batchesOf(carried.length);
|
|
276
264
|
const types = queries.typesAt(
|
|
277
265
|
carried.map((flow) => flow.value),
|
|
278
266
|
cap,
|
|
@@ -327,11 +315,9 @@ export function contextualUses<Brand>(
|
|
|
327
315
|
if (elements.has(type.id)) {
|
|
328
316
|
return elements.get(type.id);
|
|
329
317
|
}
|
|
330
|
-
lookups += 1;
|
|
331
318
|
const isArray = queries.isArray(type);
|
|
332
319
|
let element: Type | undefined;
|
|
333
320
|
if (isAnswered(isArray) && isArray) {
|
|
334
|
-
lookups += 1;
|
|
335
321
|
const held = queries.typeArguments(type);
|
|
336
322
|
element = isAnswered(held) ? held[0] : undefined;
|
|
337
323
|
}
|
|
@@ -346,7 +332,6 @@ export function contextualUses<Brand>(
|
|
|
346
332
|
if (known !== undefined) {
|
|
347
333
|
return known;
|
|
348
334
|
}
|
|
349
|
-
lookups += type.isTypeReference() ? 1 : 0;
|
|
350
335
|
const held = queries.typeArguments(type);
|
|
351
336
|
const found = isAnswered(held) ? held : [];
|
|
352
337
|
argumentsOf.set(type.id, found);
|
|
@@ -363,11 +348,9 @@ export function contextualUses<Brand>(
|
|
|
363
348
|
if (known !== undefined) {
|
|
364
349
|
return known;
|
|
365
350
|
}
|
|
366
|
-
lookups += 1;
|
|
367
351
|
let kind = SignatureKind.Call;
|
|
368
352
|
let signatures = queries.signaturesOf(type, kind);
|
|
369
353
|
if (isAnswered(signatures) && signatures.length === 0) {
|
|
370
|
-
lookups += 1;
|
|
371
354
|
kind = SignatureKind.Construct;
|
|
372
355
|
signatures = queries.signaturesOf(type, kind);
|
|
373
356
|
}
|
|
@@ -376,7 +359,6 @@ export function contextualUses<Brand>(
|
|
|
376
359
|
queries.parameterType(signature, index),
|
|
377
360
|
);
|
|
378
361
|
const result = queries.returnTypeOf(signature);
|
|
379
|
-
lookups += parameters.length + 1;
|
|
380
362
|
return {
|
|
381
363
|
kind,
|
|
382
364
|
parameters: parameters.map((one) => (isAnswered(one) ? one : undefined)),
|
|
@@ -474,7 +456,6 @@ export function contextualUses<Brand>(
|
|
|
474
456
|
const type = types[index];
|
|
475
457
|
return type === undefined || !isAnswered(type) || !mayCarry(type) ? [] : [{ flow, type }];
|
|
476
458
|
});
|
|
477
|
-
batches += batchesOf(sourced.length);
|
|
478
459
|
const positions = queries.contextualTypes(
|
|
479
460
|
sourced.map((one) => one.flow.value),
|
|
480
461
|
cap,
|
|
@@ -556,7 +537,6 @@ export function contextualUses<Brand>(
|
|
|
556
537
|
isSpreadAssignment(property) ? [{ value: property.expression, from }] : [],
|
|
557
538
|
),
|
|
558
539
|
);
|
|
559
|
-
batches += batchesOf(spreads.length);
|
|
560
540
|
const spreadTypes = queries.typesAt(
|
|
561
541
|
spreads.map((one) => one.value),
|
|
562
542
|
cap,
|
|
@@ -583,5 +563,5 @@ export function contextualUses<Brand>(
|
|
|
583
563
|
reads.push({ at: value, from, ids });
|
|
584
564
|
}
|
|
585
565
|
});
|
|
586
|
-
return { writes, reads
|
|
566
|
+
return { writes, reads };
|
|
587
567
|
}
|
|
@@ -501,7 +501,10 @@ export const SETTINGS: readonly SettingRow[] = [
|
|
|
501
501
|
key: "provenance",
|
|
502
502
|
role: "ignored",
|
|
503
503
|
read: true,
|
|
504
|
-
value: {
|
|
504
|
+
value: {
|
|
505
|
+
type: "string",
|
|
506
|
+
pattern: "^(default|(repository|central|flag): ([^\\r\\n]|[\\r\\n])+)$",
|
|
507
|
+
},
|
|
505
508
|
keyPattern: "^[a-z][a-z_]*(\\.[A-Za-z0-9_]+)*$",
|
|
506
509
|
},
|
|
507
510
|
];
|
|
@@ -408,6 +408,11 @@ export const REPORT_SCHEMAS = {
|
|
|
408
408
|
},
|
|
409
409
|
else: { properties: { configurations: { minItems: 1 }, target: { required: ["kind"] } } },
|
|
410
410
|
},
|
|
411
|
+
{
|
|
412
|
+
if: { required: ["merged_from"], properties: { merged_from: { maxItems: 0 } } },
|
|
413
|
+
then: { properties: { analyzer: { properties: { languages: { maxItems: 0 } } } } },
|
|
414
|
+
else: { properties: { analyzer: { properties: { languages: { minItems: 1 } } } } },
|
|
415
|
+
},
|
|
411
416
|
],
|
|
412
417
|
properties: {
|
|
413
418
|
schema_version: { type: "string", pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
|
|
@@ -424,7 +429,6 @@ export const REPORT_SCHEMAS = {
|
|
|
424
429
|
},
|
|
425
430
|
languages: {
|
|
426
431
|
type: "array",
|
|
427
|
-
minItems: 1,
|
|
428
432
|
uniqueItems: true,
|
|
429
433
|
items: { type: "string", enum: ["go", "ts", "proto"] },
|
|
430
434
|
},
|
|
@@ -460,7 +464,7 @@ export const REPORT_SCHEMAS = {
|
|
|
460
464
|
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?(\\+[0-9A-Za-z.-]+)?$",
|
|
461
465
|
},
|
|
462
466
|
digest: { type: "string", pattern: "^sha256:[0-9a-f]{64}$" },
|
|
463
|
-
languages: { $ref: "#/properties/analyzer/properties/languages" },
|
|
467
|
+
languages: { $ref: "#/properties/analyzer/properties/languages", minItems: 1 },
|
|
464
468
|
totals: { $ref: "#/properties/totals" },
|
|
465
469
|
},
|
|
466
470
|
},
|
package/src/dependencies.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
type Node,
|
|
30
30
|
type SourceFile,
|
|
31
31
|
} from "@typescript/native/ast";
|
|
32
|
+
import { amdLoadOf, amdPlatform } from "./amd.ts";
|
|
32
33
|
import { automaticTypes, type AutomaticTypes } from "./automatic-types.ts";
|
|
33
34
|
import {
|
|
34
35
|
declaredIn as declaredBeside,
|
|
@@ -41,12 +42,13 @@ import {
|
|
|
41
42
|
} from "./entries/configuration-files.ts";
|
|
42
43
|
import type { FindingPosition } from "./finding.ts";
|
|
43
44
|
import type { Host } from "./host.ts";
|
|
45
|
+
import { declarationBindings } from "./import-bindings.ts";
|
|
44
46
|
import { nodeKey, type Inventory } from "./inventory.ts";
|
|
45
47
|
import { packageScope } from "./load/package-scope.ts";
|
|
46
48
|
import {
|
|
47
49
|
ancestors,
|
|
50
|
+
cannotStartPackageName,
|
|
48
51
|
dirnamePath,
|
|
49
|
-
isAbsolutePath,
|
|
50
52
|
joinPath,
|
|
51
53
|
relativePath,
|
|
52
54
|
resolvePath,
|
|
@@ -302,7 +304,7 @@ function configurationPackages(
|
|
|
302
304
|
}
|
|
303
305
|
seen.add(file);
|
|
304
306
|
for (const entry of extendsOf(host, file, parse)) {
|
|
305
|
-
if (
|
|
307
|
+
if (cannotStartPackageName(entry)) {
|
|
306
308
|
const local = resolvePath(dirnamePath(file), entry);
|
|
307
309
|
pending.push(local.endsWith(".json") ? local : `${local}.json`);
|
|
308
310
|
} else {
|
|
@@ -332,26 +334,9 @@ function importOf(specifier: Node): Node | undefined {
|
|
|
332
334
|
|
|
333
335
|
/** The local names one import declaration binds. */
|
|
334
336
|
function bindingsOf(node: Node | undefined): readonly Texted[] {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if (isImportEqualsDeclaration(node)) {
|
|
339
|
-
return [node.name];
|
|
340
|
-
}
|
|
341
|
-
if (!isImportDeclaration(node) || node.importClause === undefined) {
|
|
342
|
-
return [];
|
|
343
|
-
}
|
|
344
|
-
const clause = node.importClause;
|
|
345
|
-
const names: Texted[] = clause.name === undefined ? [] : [clause.name];
|
|
346
|
-
const bindings = clause.namedBindings;
|
|
347
|
-
if (bindings !== undefined) {
|
|
348
|
-
if (bindings.kind === SyntaxKind.NamespaceImport) {
|
|
349
|
-
names.push(bindings.name);
|
|
350
|
-
} else {
|
|
351
|
-
names.push(...bindings.elements.map((element) => element.name));
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return names;
|
|
337
|
+
return node !== undefined && (isImportDeclaration(node) || isImportEqualsDeclaration(node))
|
|
338
|
+
? declarationBindings(node).map((binding) => binding.name)
|
|
339
|
+
: [];
|
|
355
340
|
}
|
|
356
341
|
|
|
357
342
|
/**
|
|
@@ -653,6 +638,7 @@ function fileNeeds<Brand>(
|
|
|
653
638
|
}
|
|
654
639
|
const loads = runtimeLoads(file);
|
|
655
640
|
const callees = loads.flatMap((load) => load.callees);
|
|
641
|
+
const amdCallees = new Set(loads.flatMap((load) => (load.amd ? load.callees : [])));
|
|
656
642
|
|
|
657
643
|
const asked = [
|
|
658
644
|
...specifiers,
|
|
@@ -748,11 +734,13 @@ function fileNeeds<Brand>(
|
|
|
748
734
|
unansweredCallees.add(callee);
|
|
749
735
|
return;
|
|
750
736
|
}
|
|
751
|
-
// The decision reads the callee's symbol and its
|
|
752
|
-
const
|
|
737
|
+
// The decision reads the callee's symbol, its written name and its platform name, and nothing else.
|
|
738
|
+
const platform = amdCallees.has(callee) ? amdPlatform(callee) : "require";
|
|
739
|
+
const key =
|
|
740
|
+
symbol === undefined ? undefined : `${symbol.id}\u0000${platform}\u0000${callee.text}`;
|
|
753
741
|
const answer =
|
|
754
742
|
(key === undefined ? undefined : decided.get(key)) ??
|
|
755
|
-
callsPlatform(project,
|
|
743
|
+
callsPlatform(project, platform, callee, symbol);
|
|
756
744
|
if (key !== undefined) {
|
|
757
745
|
decided.set(key, answer);
|
|
758
746
|
}
|
|
@@ -779,6 +767,8 @@ interface RuntimeLoad {
|
|
|
779
767
|
readonly specifier: Texted;
|
|
780
768
|
readonly named: string;
|
|
781
769
|
readonly callees: readonly Identifier[];
|
|
770
|
+
/** Whether the specifier is an id of an AMD call's dependency list, its callee AMD's `define` or `require`. */
|
|
771
|
+
readonly amd: boolean;
|
|
782
772
|
}
|
|
783
773
|
|
|
784
774
|
/**
|
|
@@ -786,12 +776,21 @@ interface RuntimeLoad {
|
|
|
786
776
|
* argument is literal text naming a package: a `require()` call, which the compiler lists among
|
|
787
777
|
* a file's imports only in a JavaScript file and only through the bare name; a `.resolve` of
|
|
788
778
|
* another name, which needs it where that name is a `require`; and `import.meta.resolve` or
|
|
789
|
-
* a `.resolve` of the name `require`, whatever it names, a use where it stands
|
|
779
|
+
* a `.resolve` of the name `require`, whatever it names, a use where it stands; and each id of
|
|
780
|
+
* an AMD dependency list (references-ts.37), which needs it where the call is AMD's.
|
|
790
781
|
*/
|
|
791
782
|
function runtimeLoads(file: SourceFile): readonly RuntimeLoad[] {
|
|
792
783
|
const found: RuntimeLoad[] = [];
|
|
793
784
|
const visit = (node: Node): void => {
|
|
794
|
-
|
|
785
|
+
const amd = amdLoadOf(node);
|
|
786
|
+
if (amd !== undefined) {
|
|
787
|
+
for (const { id } of amd.ids) {
|
|
788
|
+
const named = packageOfSpecifier(id.text);
|
|
789
|
+
if (named !== undefined) {
|
|
790
|
+
found.push({ specifier: id, named, callees: [amd.callee], amd: true });
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
} else if (isCallExpression(node)) {
|
|
795
794
|
const [argument] = node.arguments;
|
|
796
795
|
if (argument !== undefined && isLiteralText(argument)) {
|
|
797
796
|
const named = packageOfSpecifier(argument.text);
|
|
@@ -811,7 +810,7 @@ function runtimeLoads(file: SourceFile): readonly RuntimeLoad[] {
|
|
|
811
810
|
receiver === undefined ? undefined : writtenName(receiver),
|
|
812
811
|
].filter((one) => one !== undefined);
|
|
813
812
|
if (named !== undefined && (stands || callees.length > 0)) {
|
|
814
|
-
found.push({ specifier: argument, named, callees });
|
|
813
|
+
found.push({ specifier: argument, named, callees, amd: false });
|
|
815
814
|
}
|
|
816
815
|
}
|
|
817
816
|
}
|
package/src/destructuring.ts
CHANGED
|
@@ -213,17 +213,6 @@ function sourceOf(target: Node): Source | undefined {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
/** What resolving one project's property reads cost at the client boundary. */
|
|
217
|
-
interface DestructuringCost {
|
|
218
|
-
/** Batched type lookups, one per capped run of a file's patterns and assigned values. */
|
|
219
|
-
readonly patternBatches: number;
|
|
220
|
-
/**
|
|
221
|
-
* Per-type lookups: one property table per distinct destructured type, and each step
|
|
222
|
-
* an assignment target takes into its assigned value.
|
|
223
|
-
*/
|
|
224
|
-
readonly patternLookups: number;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
216
|
/** Resolves property reads to the symbols the destructured values' types declare. */
|
|
228
217
|
interface Destructuring {
|
|
229
218
|
/**
|
|
@@ -232,7 +221,6 @@ interface Destructuring {
|
|
|
232
221
|
* {@link UNANSWERED} where a question about the value's type went unanswered.
|
|
233
222
|
*/
|
|
234
223
|
resolve(reads: readonly PropertyRead[]): readonly Answer<TSSymbol | undefined>[];
|
|
235
|
-
readonly cost: DestructuringCost;
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/** A type along a destructuring, or the mark that a question about it went unanswered. */
|
|
@@ -250,8 +238,6 @@ export function destructuring<Brand>(
|
|
|
250
238
|
): Destructuring {
|
|
251
239
|
const queries = project.queries;
|
|
252
240
|
const tables = new Map<number, Answer<ReadonlyMap<string, TSSymbol>>>();
|
|
253
|
-
let patternBatches = 0;
|
|
254
|
-
let patternLookups = 0;
|
|
255
241
|
|
|
256
242
|
const tableOf = (type: Type): Answer<ReadonlyMap<string, TSSymbol>> => {
|
|
257
243
|
const known = tables.get(type.id);
|
|
@@ -261,7 +247,6 @@ export function destructuring<Brand>(
|
|
|
261
247
|
let table: Answer<ReadonlyMap<string, TSSymbol>> = new Map<string, TSSymbol>();
|
|
262
248
|
if ((type.flags & TypeFlags.AnyOrUnknown) === 0) {
|
|
263
249
|
const read = properties.of(type);
|
|
264
|
-
patternLookups += read.asked ? 1 : 0;
|
|
265
250
|
table = isAnswered(read.properties)
|
|
266
251
|
? new Map(read.properties.map((property) => [property.name, property]))
|
|
267
252
|
: UNANSWERED;
|
|
@@ -274,7 +259,6 @@ export function destructuring<Brand>(
|
|
|
274
259
|
if ((type.flags & TypeFlags.Union) === 0) {
|
|
275
260
|
return type;
|
|
276
261
|
}
|
|
277
|
-
patternLookups += 1;
|
|
278
262
|
return queries.nonNullable(type);
|
|
279
263
|
};
|
|
280
264
|
|
|
@@ -290,11 +274,9 @@ export function destructuring<Brand>(
|
|
|
290
274
|
if (index === undefined) {
|
|
291
275
|
return undefined;
|
|
292
276
|
}
|
|
293
|
-
patternLookups += 1;
|
|
294
277
|
const elements = queries.typeArguments(type);
|
|
295
278
|
return isAnswered(elements) ? elements[index] : UNANSWERED;
|
|
296
279
|
}
|
|
297
|
-
patternLookups += 1;
|
|
298
280
|
const array = queries.isArray(type);
|
|
299
281
|
if (!isAnswered(array)) {
|
|
300
282
|
return UNANSWERED;
|
|
@@ -302,7 +284,6 @@ export function destructuring<Brand>(
|
|
|
302
284
|
if (!array) {
|
|
303
285
|
return undefined;
|
|
304
286
|
}
|
|
305
|
-
patternLookups += 1;
|
|
306
287
|
const elements = queries.typeArguments(type);
|
|
307
288
|
return isAnswered(elements) ? elements[0] : UNANSWERED;
|
|
308
289
|
};
|
|
@@ -320,7 +301,6 @@ export function destructuring<Brand>(
|
|
|
320
301
|
if (more.length > 0) {
|
|
321
302
|
return UNANSWERED;
|
|
322
303
|
}
|
|
323
|
-
patternLookups += 1;
|
|
324
304
|
return queries.typeOfSymbol(property);
|
|
325
305
|
};
|
|
326
306
|
|
|
@@ -328,7 +308,6 @@ export function destructuring<Brand>(
|
|
|
328
308
|
if (callee === undefined || callee === UNANSWERED) {
|
|
329
309
|
return callee;
|
|
330
310
|
}
|
|
331
|
-
patternLookups += 1;
|
|
332
311
|
const signatures = queries.signaturesOf(callee, SignatureKind.Call);
|
|
333
312
|
if (!isAnswered(signatures)) {
|
|
334
313
|
return UNANSWERED;
|
|
@@ -337,7 +316,6 @@ export function destructuring<Brand>(
|
|
|
337
316
|
if (signature === undefined) {
|
|
338
317
|
return undefined;
|
|
339
318
|
}
|
|
340
|
-
patternLookups += 1;
|
|
341
319
|
return queries.returnTypeOf(signature);
|
|
342
320
|
};
|
|
343
321
|
|
|
@@ -369,7 +347,6 @@ export function destructuring<Brand>(
|
|
|
369
347
|
if (result !== undefined && result !== UNANSWERED) {
|
|
370
348
|
let parts: Answer<readonly Type[]> = [result];
|
|
371
349
|
if (result.isUnionType()) {
|
|
372
|
-
patternLookups += 1;
|
|
373
350
|
parts = queries.constituents(result);
|
|
374
351
|
}
|
|
375
352
|
const values: readonly Found[] = isAnswered(parts)
|
|
@@ -403,7 +380,6 @@ export function destructuring<Brand>(
|
|
|
403
380
|
if (property === undefined) {
|
|
404
381
|
return undefined;
|
|
405
382
|
}
|
|
406
|
-
patternLookups += 1;
|
|
407
383
|
return queries.typeOfSymbol(property);
|
|
408
384
|
}
|
|
409
385
|
return elementOf(defined, next.index);
|
|
@@ -425,7 +401,6 @@ export function destructuring<Brand>(
|
|
|
425
401
|
}
|
|
426
402
|
}
|
|
427
403
|
const asked = [...asking];
|
|
428
|
-
patternBatches += Math.ceil(asked.length / cap);
|
|
429
404
|
const answered = new Map<Node, Found>();
|
|
430
405
|
queries.typesAt(asked, cap).forEach((type, index) => {
|
|
431
406
|
const node = asked[index];
|
|
@@ -456,10 +431,5 @@ export function destructuring<Brand>(
|
|
|
456
431
|
});
|
|
457
432
|
};
|
|
458
433
|
|
|
459
|
-
return {
|
|
460
|
-
resolve,
|
|
461
|
-
get cost() {
|
|
462
|
-
return { patternBatches, patternLookups };
|
|
463
|
-
},
|
|
464
|
-
};
|
|
434
|
+
return { resolve };
|
|
465
435
|
}
|