@cplieger/deadset-ts 3.5.0 → 3.6.0

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.
Files changed (43) hide show
  1. package/dist/src/analysis.js +70 -14
  2. package/dist/src/components.js +5 -1
  3. package/dist/src/dependencies.js +493 -0
  4. package/dist/src/deprecation.js +83 -0
  5. package/dist/src/discover.js +1 -1
  6. package/dist/src/enum-group.js +217 -0
  7. package/dist/src/file-facts.js +101 -0
  8. package/dist/src/findings/boundary.js +1 -0
  9. package/dist/src/findings/completion.js +99 -0
  10. package/dist/src/findings/dependencies-and-module-machinery.js +65 -1
  11. package/dist/src/findings/emitters.js +8 -0
  12. package/dist/src/findings/interfaces.js +95 -2
  13. package/dist/src/findings/non-code-artifacts.js +97 -1
  14. package/dist/src/findings/reads-and-writes.js +199 -2
  15. package/dist/src/findings/unused-declarations.js +182 -1
  16. package/dist/src/findings/visibility-narrowing.js +239 -2
  17. package/dist/src/implementations.js +210 -0
  18. package/dist/src/inventory.js +2 -2
  19. package/dist/src/resolve.js +1 -1
  20. package/dist/src/stores.js +32 -0
  21. package/jsr.json +1 -1
  22. package/package.json +1 -1
  23. package/src/analysis.ts +113 -16
  24. package/src/components.ts +6 -1
  25. package/src/dependencies.ts +617 -0
  26. package/src/deprecation.ts +101 -0
  27. package/src/discover.ts +1 -1
  28. package/src/enum-group.ts +265 -0
  29. package/src/file-facts.ts +143 -0
  30. package/src/findings/boundary.ts +39 -0
  31. package/src/findings/completion.ts +151 -0
  32. package/src/findings/dependencies-and-module-machinery.ts +79 -1
  33. package/src/findings/emitter.ts +21 -1
  34. package/src/findings/emitters.ts +13 -1
  35. package/src/findings/interfaces.ts +149 -3
  36. package/src/findings/non-code-artifacts.ts +124 -2
  37. package/src/findings/reads-and-writes.ts +310 -3
  38. package/src/findings/unused-declarations.ts +223 -2
  39. package/src/findings/visibility-narrowing.ts +324 -3
  40. package/src/implementations.ts +286 -0
  41. package/src/inventory.ts +2 -2
  42. package/src/resolve.ts +1 -1
  43. package/src/stores.ts +77 -0
package/src/stores.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * What a run knows about the stores into its declarations and the reads of them, which
3
+ * a sweep does not keep: a sweep asks whether anything names a declaration, and a store
4
+ * names it as surely as a read does.
5
+ */
6
+
7
+ import {
8
+ isGetAccessorDeclaration,
9
+ isSetAccessorDeclaration,
10
+ type Node,
11
+ } from "@typescript/native/unstable/ast";
12
+ import { nodeKey, type Inventory } from "./inventory.ts";
13
+ import type { Reference } from "./references.ts";
14
+ import type { ProjectView } from "./session.ts";
15
+ import type { Exemption, Mode } from "./sweep.ts";
16
+
17
+ /** One run's stores and reads, over every configuration. */
18
+ export interface Stores {
19
+ /**
20
+ * Every reference the run's mode counts, each configuration's in the run's order, so
21
+ * one written at a position several configurations compile appears once per
22
+ * configuration. A production mode counts none a test file made.
23
+ */
24
+ readonly references: readonly Reference[];
25
+ /**
26
+ * The class members declared by a getter or a setter. A store into one runs the
27
+ * setter, which is code rather than state.
28
+ */
29
+ readonly accessors: ReadonlySet<string>;
30
+ /**
31
+ * The declarations an exemption record names, whether or not the record held back
32
+ * anything dead: a mechanism the analysis cannot see uses each of them.
33
+ */
34
+ readonly exempt: ReadonlySet<string>;
35
+ }
36
+
37
+ /** What one configuration contributes to the run's stores. */
38
+ export interface ConfigurationStores {
39
+ readonly references: readonly Reference[];
40
+ readonly accessors: readonly string[];
41
+ }
42
+
43
+ /** The class members one project's own files declare by a getter or a setter. */
44
+ export function accessorsOf<Brand>(
45
+ project: ProjectView<Brand>,
46
+ held: Inventory,
47
+ ): readonly string[] {
48
+ const found: string[] = [];
49
+ for (const file of project.ownSourceFiles()) {
50
+ const visit = (node: Node): void => {
51
+ if (isGetAccessorDeclaration(node) || isSetAccessorDeclaration(node)) {
52
+ const id = held.declarations.get(nodeKey(file, node));
53
+ if (id !== undefined) {
54
+ found.push(id);
55
+ }
56
+ }
57
+ node.forEachChild(visit);
58
+ };
59
+ file.forEachChild(visit);
60
+ }
61
+ return found;
62
+ }
63
+
64
+ /** The run's stores, from what each configuration contributed, the records and the mode. */
65
+ export function storesOf(
66
+ per: readonly ConfigurationStores[],
67
+ exempt: readonly Exemption[],
68
+ mode: Mode,
69
+ ): Stores {
70
+ return {
71
+ references: per.flatMap((one) =>
72
+ one.references.filter((reference) => !mode.production || !reference.test),
73
+ ),
74
+ accessors: new Set(per.flatMap((one) => one.accessors)),
75
+ exempt: new Set(exempt.map((record) => record.id)),
76
+ };
77
+ }