fallow-type-aware 3.39.0 → 3.41.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.
- package/package.json +4 -4
- package/src/semantic.mjs +7 -8
- package/src/symbol-use-evidence.mjs +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fallow-type-aware",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.41.0",
|
|
4
4
|
"description": "Optional TypeScript-Go semantic refinement sidecar for Fallow",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"provenance": true
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@codspeed/tinybench-plugin": "
|
|
43
|
-
"tinybench": "6.
|
|
42
|
+
"@codspeed/tinybench-plugin": "6.1.0",
|
|
43
|
+
"tinybench": "6.2.2",
|
|
44
44
|
"tsrs": "0.20.1-ts7.1.0-beta",
|
|
45
|
-
"zod": "4.
|
|
45
|
+
"zod": "4.6.7"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/semantic.mjs
CHANGED
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
recordSymbolUncertainty,
|
|
48
48
|
targetName,
|
|
49
49
|
} from "./symbol-targets.mjs";
|
|
50
|
+
import { recordBoundedUse } from "./symbol-use-evidence.mjs";
|
|
50
51
|
import { analyzeTypeCoupling } from "./type-coupling.mjs";
|
|
51
52
|
import {
|
|
52
53
|
MODULE_SOURCE_EXTENSIONS,
|
|
@@ -79,7 +80,6 @@ const {
|
|
|
79
80
|
} = ast;
|
|
80
81
|
|
|
81
82
|
const ATTACHED_COMMENT_PATTERN = /\/\/|\/\*/u;
|
|
82
|
-
const MAX_SYMBOL_USE_EVIDENCE = 1;
|
|
83
83
|
const DECLARATION_KINDS = new Set([
|
|
84
84
|
"export",
|
|
85
85
|
"class",
|
|
@@ -265,12 +265,13 @@ const boundedResult = ({
|
|
|
265
265
|
evidenceLimit,
|
|
266
266
|
totalEvidenceCount,
|
|
267
267
|
omissions: extraOmissions = [],
|
|
268
|
+
evidenceLimitIsGap = true,
|
|
268
269
|
}) => {
|
|
269
270
|
const ordered = orderedEvidence(evidence);
|
|
270
271
|
const totalEvidence = totalEvidenceCount === undefined ? ordered.length : totalEvidenceCount;
|
|
271
272
|
const returnedEvidenceCount = Math.min(ordered.length, evidenceLimit);
|
|
272
273
|
const omissions = combineOmissions([
|
|
273
|
-
...evidenceLimitOmission(totalEvidence, returnedEvidenceCount),
|
|
274
|
+
...(evidenceLimitIsGap ? evidenceLimitOmission(totalEvidence, returnedEvidenceCount) : []),
|
|
274
275
|
...extraOmissions,
|
|
275
276
|
]).toSorted(compareOmissions);
|
|
276
277
|
const partial = omissions.length > 0;
|
|
@@ -284,7 +285,7 @@ const boundedResult = ({
|
|
|
284
285
|
actions: resultActions(omissions),
|
|
285
286
|
evidence: ordered.slice(0, evidenceLimit),
|
|
286
287
|
totalEvidenceCount: totalEvidence,
|
|
287
|
-
truncated,
|
|
288
|
+
truncated: truncated || totalEvidence > returnedEvidenceCount,
|
|
288
289
|
omissions,
|
|
289
290
|
data,
|
|
290
291
|
};
|
|
@@ -598,11 +599,7 @@ const recordSymbolUse = (root, state, project, entry, node, namespace) => {
|
|
|
598
599
|
state.aliasHopTotalByQuery.get(entry.query.id) + use.via.length,
|
|
599
600
|
);
|
|
600
601
|
}
|
|
601
|
-
|
|
602
|
-
entry.query.operation === "symbol-use" ? MAX_SYMBOL_USE_EVIDENCE : state.evidenceLimit;
|
|
603
|
-
if (evidence.length < limit) {
|
|
604
|
-
evidence.push(use);
|
|
605
|
-
}
|
|
602
|
+
recordBoundedUse(evidence, use, entry.query.operation, state.evidenceLimit);
|
|
606
603
|
};
|
|
607
604
|
|
|
608
605
|
const projectOwnsEntry = (project, entry) =>
|
|
@@ -1143,6 +1140,8 @@ const analyzeSymbolUse = (
|
|
|
1143
1140
|
evidenceLimit,
|
|
1144
1141
|
totalEvidenceCount,
|
|
1145
1142
|
omissions,
|
|
1143
|
+
// A capped use keeps one item per file. A negative assertion needs every reference.
|
|
1144
|
+
evidenceLimitIsGap: assertion !== "confirmed-used",
|
|
1146
1145
|
data: {
|
|
1147
1146
|
symbol: semanticQueryIdentity(root, query, resolved),
|
|
1148
1147
|
selected_project: resolved.state.config,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const isReExportUse = (use) => use.role.includes("re-export");
|
|
2
|
+
|
|
3
|
+
// The client credits a use only from a reachable file that reads the binding.
|
|
4
|
+
// One item for each file lets a capped result still show such a file.
|
|
5
|
+
const recordFileUse = (evidence, use, limit) => {
|
|
6
|
+
const index = evidence.findIndex((kept) => kept.path === use.path);
|
|
7
|
+
if (index === -1) {
|
|
8
|
+
if (evidence.length < limit) evidence.push(use);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (isReExportUse(evidence[index]) && !isReExportUse(use)) evidence[index] = use;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adds one reference to the bounded evidence of a query.
|
|
16
|
+
* A `symbol-use` query keeps one item for each file. Other queries keep the first items.
|
|
17
|
+
*/
|
|
18
|
+
export const recordBoundedUse = (evidence, use, operation, limit) => {
|
|
19
|
+
if (operation === "symbol-use") {
|
|
20
|
+
recordFileUse(evidence, use, limit);
|
|
21
|
+
} else if (evidence.length < limit) {
|
|
22
|
+
evidence.push(use);
|
|
23
|
+
}
|
|
24
|
+
};
|