@suss/adapter-typescript 0.27.0 → 0.28.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/dist/index.cjs +32 -65
- package/dist/index.js +36 -68
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -2595,22 +2595,15 @@ function writesToBindingUncached(declaration) {
|
|
|
2595
2595
|
}
|
|
2596
2596
|
return { values, inOrder: writesRunInOrder(declaration, writes) };
|
|
2597
2597
|
}
|
|
2598
|
-
function
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
}
|
|
2608
|
-
if (construction !== null && sourceOf(value) !== sourceOf(construction)) {
|
|
2609
|
-
return null;
|
|
2610
|
-
}
|
|
2611
|
-
construction = value;
|
|
2612
|
-
}
|
|
2613
|
-
return construction;
|
|
2598
|
+
function describeWrites(values) {
|
|
2599
|
+
return values.map((value, index) => ({
|
|
2600
|
+
value: String(index),
|
|
2601
|
+
placeholder: isNotYetPlaceholder(value),
|
|
2602
|
+
construction: isConstruction(value) ? sourceOf(value) : null,
|
|
2603
|
+
// Which name each value was written to does not reach here, and
|
|
2604
|
+
// that is what a narrowing write is compared against.
|
|
2605
|
+
narrowsName: false
|
|
2606
|
+
}));
|
|
2614
2607
|
}
|
|
2615
2608
|
function isNotYetPlaceholder(value) {
|
|
2616
2609
|
return value.getKind() === import_ts_morph14.SyntaxKind.NullKeyword || import_ts_morph14.Node.isIdentifier(value) && value.getText() === "undefined";
|
|
@@ -3101,6 +3094,13 @@ function emitValue(db, table, value) {
|
|
|
3101
3094
|
fact(db, "writtenValue", id);
|
|
3102
3095
|
return id;
|
|
3103
3096
|
}
|
|
3097
|
+
function settledWrite(values, inOrder) {
|
|
3098
|
+
const key = (0, import_resolution.valueLeftByWrites)(describeWrites(values), inOrder);
|
|
3099
|
+
if (key === null) {
|
|
3100
|
+
return null;
|
|
3101
|
+
}
|
|
3102
|
+
return values[Number(key)] ?? null;
|
|
3103
|
+
}
|
|
3104
3104
|
function emitBindingValues(db, table, declaration) {
|
|
3105
3105
|
const declarationId = nodeId(declaration);
|
|
3106
3106
|
if (!isWrittenAgain(declaration)) {
|
|
@@ -3111,17 +3111,12 @@ function emitBindingValues(db, table, declaration) {
|
|
|
3111
3111
|
return;
|
|
3112
3112
|
}
|
|
3113
3113
|
const { values, inOrder } = writesToBinding(declaration);
|
|
3114
|
-
const
|
|
3115
|
-
if (
|
|
3116
|
-
|
|
3117
|
-
return;
|
|
3118
|
-
}
|
|
3119
|
-
const construction = sameConstructionAcrossWrites(values);
|
|
3120
|
-
if (construction !== null) {
|
|
3121
|
-
fact(db, "endsHolding", declarationId, emitValue(db, table, construction));
|
|
3114
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3115
|
+
if (settled2 === null) {
|
|
3116
|
+
reassignedUnstated.add(declarationId);
|
|
3122
3117
|
return;
|
|
3123
3118
|
}
|
|
3124
|
-
|
|
3119
|
+
fact(db, "endsHolding", declarationId, emitValue(db, table, settled2));
|
|
3125
3120
|
}
|
|
3126
3121
|
var reassignedUnstated = /* @__PURE__ */ new Set();
|
|
3127
3122
|
function reassignedNamesUnstated() {
|
|
@@ -3132,32 +3127,24 @@ function forgetReassignedNamesUnstated() {
|
|
|
3132
3127
|
}
|
|
3133
3128
|
function emitFieldValues(db, table, declaration) {
|
|
3134
3129
|
const { values, inOrder } = writesToField(declaration);
|
|
3135
|
-
const
|
|
3136
|
-
if (
|
|
3137
|
-
fact(db, "binds", nodeId(declaration), emitValue(db, table, last));
|
|
3130
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3131
|
+
if (settled2 === null || !import_ts_morph15.Node.isExpression(settled2)) {
|
|
3138
3132
|
return;
|
|
3139
3133
|
}
|
|
3140
|
-
|
|
3141
|
-
if (construction !== null) {
|
|
3142
|
-
fact(db, "binds", nodeId(declaration), emitValue(db, table, construction));
|
|
3143
|
-
}
|
|
3134
|
+
fact(db, "binds", nodeId(declaration), emitValue(db, table, settled2));
|
|
3144
3135
|
}
|
|
3145
3136
|
function emitParameterPropertyRead(db, table, referenceId, declaration) {
|
|
3146
3137
|
const { values, inOrder } = writesToField(declaration);
|
|
3147
|
-
const
|
|
3148
|
-
if (
|
|
3149
|
-
fact(db, "binds", referenceId, emitValue(db, table, last));
|
|
3138
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3139
|
+
if (settled2 === null) {
|
|
3150
3140
|
return;
|
|
3151
3141
|
}
|
|
3152
|
-
if (
|
|
3153
|
-
|
|
3154
|
-
fact(db, "binds", referenceId, nodeId(last));
|
|
3142
|
+
if (import_ts_morph15.Node.isExpression(settled2)) {
|
|
3143
|
+
fact(db, "binds", referenceId, emitValue(db, table, settled2));
|
|
3155
3144
|
return;
|
|
3156
3145
|
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
fact(db, "binds", referenceId, emitValue(db, table, construction));
|
|
3160
|
-
}
|
|
3146
|
+
table.byId.set(nodeId(settled2), settled2);
|
|
3147
|
+
fact(db, "binds", referenceId, nodeId(settled2));
|
|
3161
3148
|
}
|
|
3162
3149
|
function emitBindingElementFacts(db, table, element) {
|
|
3163
3150
|
const id = nodeId(element);
|
|
@@ -3619,36 +3606,16 @@ var JS_RULES = [
|
|
|
3619
3606
|
"bind"
|
|
3620
3607
|
)
|
|
3621
3608
|
];
|
|
3622
|
-
var RESOLUTION_PROGRAM =
|
|
3623
|
-
rules: [...import_resolution2.RESOLUTION_RULES, ...JS_RULES, ...import_resolution2.RESOLUTION_QUESTIONS],
|
|
3624
|
-
demandDriven: [],
|
|
3625
|
-
demands: []
|
|
3626
|
-
} : (0, import_datalog2.deriveOnDemand)(
|
|
3627
|
-
[...import_resolution2.RESOLUTION_RULES, ...JS_RULES, ...import_resolution2.RESOLUTION_QUESTIONS],
|
|
3628
|
-
import_resolution2.ANSWER_RELATIONS
|
|
3629
|
-
);
|
|
3609
|
+
var RESOLUTION_PROGRAM = (0, import_resolution2.resolutionProgram)(JS_RULES);
|
|
3630
3610
|
var WITNESS_RULES = [...import_resolution2.RESOLUTION_RULES, ...JS_RULES];
|
|
3631
3611
|
var NOT_BASE_FACTS = /* @__PURE__ */ new Set([
|
|
3632
3612
|
...[...import_resolution2.RESOLUTION_RULES, ...JS_RULES, ...import_resolution2.RESOLUTION_QUESTIONS].map(
|
|
3633
3613
|
(r) => r.head.relation
|
|
3634
3614
|
),
|
|
3635
3615
|
...RESOLUTION_PROGRAM.rules.map((r) => r.head.relation),
|
|
3636
|
-
|
|
3637
|
-
"wantedOrigin",
|
|
3638
|
-
"wantedCallOrigin",
|
|
3639
|
-
"wantedExportsOf",
|
|
3640
|
-
"wantedAnchor",
|
|
3641
|
-
"wantedSubject"
|
|
3616
|
+
...import_resolution2.ASKING_RELATIONS
|
|
3642
3617
|
]);
|
|
3643
|
-
var QUERY_FACTS =
|
|
3644
|
-
...RESOLUTION_PROGRAM.demandDriven,
|
|
3645
|
-
"wanted",
|
|
3646
|
-
"wantedOrigin",
|
|
3647
|
-
"wantedCallOrigin",
|
|
3648
|
-
"wantedExportsOf",
|
|
3649
|
-
"wantedAnchor",
|
|
3650
|
-
"wantedSubject"
|
|
3651
|
-
];
|
|
3618
|
+
var QUERY_FACTS = (0, import_resolution2.queryFacts)(RESOLUTION_PROGRAM);
|
|
3652
3619
|
var MODULE_DEMANDS = RESOLUTION_PROGRAM.demands.filter(
|
|
3653
3620
|
(one) => (one.relation === "moduleExport" || one.relation === "moduleForwards") && one.bound[0] === true
|
|
3654
3621
|
).map((one) => one.demand);
|
package/dist/index.js
CHANGED
|
@@ -2441,7 +2441,6 @@ import { Node as Node15 } from "ts-morph";
|
|
|
2441
2441
|
import {
|
|
2442
2442
|
clearRelations,
|
|
2443
2443
|
Database as Database2,
|
|
2444
|
-
deriveOnDemand,
|
|
2445
2444
|
evaluate as evaluate2,
|
|
2446
2445
|
lit as lit2,
|
|
2447
2446
|
proofOf,
|
|
@@ -2452,8 +2451,10 @@ import {
|
|
|
2452
2451
|
witnesses
|
|
2453
2452
|
} from "@suss/datalog";
|
|
2454
2453
|
import {
|
|
2455
|
-
|
|
2454
|
+
ASKING_RELATIONS,
|
|
2455
|
+
queryFacts,
|
|
2456
2456
|
RESOLUTION_QUESTIONS,
|
|
2457
|
+
resolutionProgram,
|
|
2457
2458
|
RESOLUTION_RULES as SHARED_RULES,
|
|
2458
2459
|
VALUE_STEP
|
|
2459
2460
|
} from "@suss/resolution";
|
|
@@ -2537,7 +2538,7 @@ import {
|
|
|
2537
2538
|
SyntaxKind as SyntaxKind4,
|
|
2538
2539
|
ts as ts2
|
|
2539
2540
|
} from "ts-morph";
|
|
2540
|
-
import { NAMESPACE_IMPORT_NAME } from "@suss/resolution";
|
|
2541
|
+
import { NAMESPACE_IMPORT_NAME, valueLeftByWrites } from "@suss/resolution";
|
|
2541
2542
|
|
|
2542
2543
|
// src/facts/assignments.ts
|
|
2543
2544
|
import { Node as Node13, SyntaxKind as SyntaxKind3, VariableDeclarationKind } from "ts-morph";
|
|
@@ -2575,22 +2576,15 @@ function writesToBindingUncached(declaration) {
|
|
|
2575
2576
|
}
|
|
2576
2577
|
return { values, inOrder: writesRunInOrder(declaration, writes) };
|
|
2577
2578
|
}
|
|
2578
|
-
function
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
}
|
|
2588
|
-
if (construction !== null && sourceOf(value) !== sourceOf(construction)) {
|
|
2589
|
-
return null;
|
|
2590
|
-
}
|
|
2591
|
-
construction = value;
|
|
2592
|
-
}
|
|
2593
|
-
return construction;
|
|
2579
|
+
function describeWrites(values) {
|
|
2580
|
+
return values.map((value, index) => ({
|
|
2581
|
+
value: String(index),
|
|
2582
|
+
placeholder: isNotYetPlaceholder(value),
|
|
2583
|
+
construction: isConstruction(value) ? sourceOf(value) : null,
|
|
2584
|
+
// Which name each value was written to does not reach here, and
|
|
2585
|
+
// that is what a narrowing write is compared against.
|
|
2586
|
+
narrowsName: false
|
|
2587
|
+
}));
|
|
2594
2588
|
}
|
|
2595
2589
|
function isNotYetPlaceholder(value) {
|
|
2596
2590
|
return value.getKind() === SyntaxKind3.NullKeyword || Node13.isIdentifier(value) && value.getText() === "undefined";
|
|
@@ -3081,6 +3075,13 @@ function emitValue(db, table, value) {
|
|
|
3081
3075
|
fact(db, "writtenValue", id);
|
|
3082
3076
|
return id;
|
|
3083
3077
|
}
|
|
3078
|
+
function settledWrite(values, inOrder) {
|
|
3079
|
+
const key = valueLeftByWrites(describeWrites(values), inOrder);
|
|
3080
|
+
if (key === null) {
|
|
3081
|
+
return null;
|
|
3082
|
+
}
|
|
3083
|
+
return values[Number(key)] ?? null;
|
|
3084
|
+
}
|
|
3084
3085
|
function emitBindingValues(db, table, declaration) {
|
|
3085
3086
|
const declarationId = nodeId(declaration);
|
|
3086
3087
|
if (!isWrittenAgain(declaration)) {
|
|
@@ -3091,17 +3092,12 @@ function emitBindingValues(db, table, declaration) {
|
|
|
3091
3092
|
return;
|
|
3092
3093
|
}
|
|
3093
3094
|
const { values, inOrder } = writesToBinding(declaration);
|
|
3094
|
-
const
|
|
3095
|
-
if (
|
|
3096
|
-
|
|
3097
|
-
return;
|
|
3098
|
-
}
|
|
3099
|
-
const construction = sameConstructionAcrossWrites(values);
|
|
3100
|
-
if (construction !== null) {
|
|
3101
|
-
fact(db, "endsHolding", declarationId, emitValue(db, table, construction));
|
|
3095
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3096
|
+
if (settled2 === null) {
|
|
3097
|
+
reassignedUnstated.add(declarationId);
|
|
3102
3098
|
return;
|
|
3103
3099
|
}
|
|
3104
|
-
|
|
3100
|
+
fact(db, "endsHolding", declarationId, emitValue(db, table, settled2));
|
|
3105
3101
|
}
|
|
3106
3102
|
var reassignedUnstated = /* @__PURE__ */ new Set();
|
|
3107
3103
|
function reassignedNamesUnstated() {
|
|
@@ -3112,32 +3108,24 @@ function forgetReassignedNamesUnstated() {
|
|
|
3112
3108
|
}
|
|
3113
3109
|
function emitFieldValues(db, table, declaration) {
|
|
3114
3110
|
const { values, inOrder } = writesToField(declaration);
|
|
3115
|
-
const
|
|
3116
|
-
if (
|
|
3117
|
-
fact(db, "binds", nodeId(declaration), emitValue(db, table, last));
|
|
3111
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3112
|
+
if (settled2 === null || !Node14.isExpression(settled2)) {
|
|
3118
3113
|
return;
|
|
3119
3114
|
}
|
|
3120
|
-
|
|
3121
|
-
if (construction !== null) {
|
|
3122
|
-
fact(db, "binds", nodeId(declaration), emitValue(db, table, construction));
|
|
3123
|
-
}
|
|
3115
|
+
fact(db, "binds", nodeId(declaration), emitValue(db, table, settled2));
|
|
3124
3116
|
}
|
|
3125
3117
|
function emitParameterPropertyRead(db, table, referenceId, declaration) {
|
|
3126
3118
|
const { values, inOrder } = writesToField(declaration);
|
|
3127
|
-
const
|
|
3128
|
-
if (
|
|
3129
|
-
fact(db, "binds", referenceId, emitValue(db, table, last));
|
|
3119
|
+
const settled2 = settledWrite(values, inOrder);
|
|
3120
|
+
if (settled2 === null) {
|
|
3130
3121
|
return;
|
|
3131
3122
|
}
|
|
3132
|
-
if (
|
|
3133
|
-
|
|
3134
|
-
fact(db, "binds", referenceId, nodeId(last));
|
|
3123
|
+
if (Node14.isExpression(settled2)) {
|
|
3124
|
+
fact(db, "binds", referenceId, emitValue(db, table, settled2));
|
|
3135
3125
|
return;
|
|
3136
3126
|
}
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
fact(db, "binds", referenceId, emitValue(db, table, construction));
|
|
3140
|
-
}
|
|
3127
|
+
table.byId.set(nodeId(settled2), settled2);
|
|
3128
|
+
fact(db, "binds", referenceId, nodeId(settled2));
|
|
3141
3129
|
}
|
|
3142
3130
|
function emitBindingElementFacts(db, table, element) {
|
|
3143
3131
|
const id = nodeId(element);
|
|
@@ -3599,36 +3587,16 @@ var JS_RULES = [
|
|
|
3599
3587
|
"bind"
|
|
3600
3588
|
)
|
|
3601
3589
|
];
|
|
3602
|
-
var RESOLUTION_PROGRAM =
|
|
3603
|
-
rules: [...SHARED_RULES, ...JS_RULES, ...RESOLUTION_QUESTIONS],
|
|
3604
|
-
demandDriven: [],
|
|
3605
|
-
demands: []
|
|
3606
|
-
} : deriveOnDemand(
|
|
3607
|
-
[...SHARED_RULES, ...JS_RULES, ...RESOLUTION_QUESTIONS],
|
|
3608
|
-
ANSWER_RELATIONS
|
|
3609
|
-
);
|
|
3590
|
+
var RESOLUTION_PROGRAM = resolutionProgram(JS_RULES);
|
|
3610
3591
|
var WITNESS_RULES = [...SHARED_RULES, ...JS_RULES];
|
|
3611
3592
|
var NOT_BASE_FACTS = /* @__PURE__ */ new Set([
|
|
3612
3593
|
...[...SHARED_RULES, ...JS_RULES, ...RESOLUTION_QUESTIONS].map(
|
|
3613
3594
|
(r) => r.head.relation
|
|
3614
3595
|
),
|
|
3615
3596
|
...RESOLUTION_PROGRAM.rules.map((r) => r.head.relation),
|
|
3616
|
-
|
|
3617
|
-
"wantedOrigin",
|
|
3618
|
-
"wantedCallOrigin",
|
|
3619
|
-
"wantedExportsOf",
|
|
3620
|
-
"wantedAnchor",
|
|
3621
|
-
"wantedSubject"
|
|
3597
|
+
...ASKING_RELATIONS
|
|
3622
3598
|
]);
|
|
3623
|
-
var QUERY_FACTS = RESOLUTION_PROGRAM
|
|
3624
|
-
...RESOLUTION_PROGRAM.demandDriven,
|
|
3625
|
-
"wanted",
|
|
3626
|
-
"wantedOrigin",
|
|
3627
|
-
"wantedCallOrigin",
|
|
3628
|
-
"wantedExportsOf",
|
|
3629
|
-
"wantedAnchor",
|
|
3630
|
-
"wantedSubject"
|
|
3631
|
-
];
|
|
3599
|
+
var QUERY_FACTS = queryFacts(RESOLUTION_PROGRAM);
|
|
3632
3600
|
var MODULE_DEMANDS = RESOLUTION_PROGRAM.demands.filter(
|
|
3633
3601
|
(one) => (one.relation === "moduleExport" || one.relation === "moduleForwards") && one.bound[0] === true
|
|
3634
3602
|
).map((one) => one.demand);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/adapter-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Read a TypeScript or JavaScript codebase with suss and check what each handler returns against every caller, spec and template it can see.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@suss/behavioral-ir": "0.
|
|
52
|
-
"@suss/datalog": "0.
|
|
53
|
-
"@suss/extractor": "0.
|
|
54
|
-
"@suss/resolution": "0.
|
|
55
|
-
"@suss/values": "0.
|
|
51
|
+
"@suss/behavioral-ir": "0.28.0",
|
|
52
|
+
"@suss/datalog": "0.28.0",
|
|
53
|
+
"@suss/extractor": "0.28.0",
|
|
54
|
+
"@suss/resolution": "0.28.0",
|
|
55
|
+
"@suss/values": "0.28.0",
|
|
56
56
|
"graphql": "^16.8.0",
|
|
57
57
|
"picomatch": "^4.0.4",
|
|
58
58
|
"ts-morph": "^23.0.0",
|