@suss/adapter-typescript 0.26.0 → 0.27.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 +792 -804
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +761 -774
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
GENERIC_TERMINALS: () => GENERIC_TERMINALS,
|
|
35
35
|
NO_BARRIERS: () => NO_BARRIERS,
|
|
36
36
|
ResolutionStore: () => ResolutionStore,
|
|
37
|
+
TSCONFIG_NAMES: () => TSCONFIG_NAMES,
|
|
37
38
|
TypeScriptWhySession: () => TypeScriptWhySession,
|
|
38
39
|
accessContextFor: () => accessContextFor,
|
|
39
40
|
buildProjectHelperIndex: () => buildProjectHelperIndex,
|
|
@@ -78,13 +79,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
78
79
|
|
|
79
80
|
// src/adapter.ts
|
|
80
81
|
var import_node_path11 = __toESM(require("path"), 1);
|
|
81
|
-
var
|
|
82
|
+
var import_ts_morph68 = require("ts-morph");
|
|
82
83
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
83
|
-
var
|
|
84
|
+
var import_datalog5 = require("@suss/datalog");
|
|
84
85
|
var import_extractor12 = require("@suss/extractor");
|
|
85
86
|
|
|
86
87
|
// src/assembly.ts
|
|
87
|
-
var
|
|
88
|
+
var import_ts_morph55 = require("ts-morph");
|
|
88
89
|
var import_extractor5 = require("@suss/extractor");
|
|
89
90
|
|
|
90
91
|
// src/conditions.ts
|
|
@@ -897,11 +898,11 @@ function tryExpandArrayIncludes(call) {
|
|
|
897
898
|
return {
|
|
898
899
|
type: "compound",
|
|
899
900
|
op: "or",
|
|
900
|
-
operands: literalValues.map((
|
|
901
|
+
operands: literalValues.map((lit5) => ({
|
|
901
902
|
type: "comparison",
|
|
902
903
|
left: subject,
|
|
903
904
|
op: "eq",
|
|
904
|
-
right:
|
|
905
|
+
right: lit5
|
|
905
906
|
}))
|
|
906
907
|
};
|
|
907
908
|
}
|
|
@@ -1544,7 +1545,7 @@ function degradedResult(func, terminalNodes, reason) {
|
|
|
1544
1545
|
}
|
|
1545
1546
|
|
|
1546
1547
|
// src/resolve/invocationEffects.ts
|
|
1547
|
-
var
|
|
1548
|
+
var import_ts_morph43 = require("ts-morph");
|
|
1548
1549
|
var import_extractor4 = require("@suss/extractor");
|
|
1549
1550
|
|
|
1550
1551
|
// src/lines.ts
|
|
@@ -2028,7 +2029,8 @@ function readFileText(project, filePath) {
|
|
|
2028
2029
|
return null;
|
|
2029
2030
|
}
|
|
2030
2031
|
}
|
|
2031
|
-
function parseTsconfig(tsConfigFilePath) {
|
|
2032
|
+
function parseTsconfig(tsConfigFilePath, seen = /* @__PURE__ */ new Set()) {
|
|
2033
|
+
seen.add(tsConfigFilePath);
|
|
2032
2034
|
const configFile = import_ts_morph10.ts.readConfigFile(tsConfigFilePath, import_ts_morph10.ts.sys.readFile);
|
|
2033
2035
|
if (configFile.error !== void 0) {
|
|
2034
2036
|
return { fileNames: [], options: {} };
|
|
@@ -2041,7 +2043,18 @@ function parseTsconfig(tsConfigFilePath) {
|
|
|
2041
2043
|
void 0,
|
|
2042
2044
|
tsConfigFilePath
|
|
2043
2045
|
);
|
|
2044
|
-
|
|
2046
|
+
if (parsed.fileNames.length > 0) {
|
|
2047
|
+
return { fileNames: parsed.fileNames, options: parsed.options };
|
|
2048
|
+
}
|
|
2049
|
+
const referenced = (parsed.projectReferences ?? []).map((reference) => import_ts_morph10.ts.resolveProjectReferencePath(reference)).filter((referencePath) => !seen.has(referencePath));
|
|
2050
|
+
const fileNames = [
|
|
2051
|
+
...new Set(
|
|
2052
|
+
referenced.flatMap(
|
|
2053
|
+
(referencePath) => parseTsconfig(referencePath, seen).fileNames
|
|
2054
|
+
)
|
|
2055
|
+
)
|
|
2056
|
+
];
|
|
2057
|
+
return { fileNames, options: parsed.options };
|
|
2045
2058
|
}
|
|
2046
2059
|
async function selectCandidateFiles(allFiles, packs, options) {
|
|
2047
2060
|
const ungatedExists = packs.some(packIsUngated);
|
|
@@ -2402,7 +2415,7 @@ function reportUnreadableExports(file) {
|
|
|
2402
2415
|
}
|
|
2403
2416
|
|
|
2404
2417
|
// src/resolve/callOps.ts
|
|
2405
|
-
var
|
|
2418
|
+
var import_ts_morph42 = require("ts-morph");
|
|
2406
2419
|
|
|
2407
2420
|
// src/configuredCall.ts
|
|
2408
2421
|
var import_ts_morph12 = require("ts-morph");
|
|
@@ -2460,10 +2473,10 @@ function rootIdentifier(node) {
|
|
|
2460
2473
|
}
|
|
2461
2474
|
|
|
2462
2475
|
// src/parameterReads.ts
|
|
2463
|
-
var
|
|
2476
|
+
var import_ts_morph40 = require("ts-morph");
|
|
2464
2477
|
|
|
2465
2478
|
// src/resolve/functionBehind.ts
|
|
2466
|
-
var
|
|
2479
|
+
var import_ts_morph39 = require("ts-morph");
|
|
2467
2480
|
|
|
2468
2481
|
// src/facts/store.ts
|
|
2469
2482
|
var import_ts_morph16 = require("ts-morph");
|
|
@@ -5244,6 +5257,7 @@ function literalValueOf(value, resolution, isWanted) {
|
|
|
5244
5257
|
}
|
|
5245
5258
|
|
|
5246
5259
|
// src/discovery/clientCall.ts
|
|
5260
|
+
var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["globalThis", "window", "self", "global"]);
|
|
5247
5261
|
function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
5248
5262
|
const results = [];
|
|
5249
5263
|
const isGlobal = match.importModule === "global";
|
|
@@ -5268,9 +5282,15 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
5268
5282
|
if (callee.getText() === match.importName) {
|
|
5269
5283
|
matched = true;
|
|
5270
5284
|
}
|
|
5285
|
+
} else if (isGlobal && import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5286
|
+
if (callee.getName() === match.importName && GLOBAL_OBJECTS.has(callee.getExpression().getText())) {
|
|
5287
|
+
matched = true;
|
|
5288
|
+
}
|
|
5289
|
+
} else if (match.callable === true && isClientItself(callee, match, clientVarNames, resolution)) {
|
|
5290
|
+
matched = true;
|
|
5271
5291
|
} else if (import_ts_morph19.Node.isPropertyAccessExpression(callee)) {
|
|
5272
5292
|
const subject = callee.getExpression();
|
|
5273
|
-
if (
|
|
5293
|
+
if (isClientItself(subject, match, clientVarNames, resolution)) {
|
|
5274
5294
|
methodName = callee.getName();
|
|
5275
5295
|
if (methodFilter === null || methodFilter.has(methodName)) {
|
|
5276
5296
|
matched = true;
|
|
@@ -5296,6 +5316,9 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
5296
5316
|
});
|
|
5297
5317
|
return results;
|
|
5298
5318
|
}
|
|
5319
|
+
function isClientItself(subject, match, clientVarNames, resolution) {
|
|
5320
|
+
return import_ts_morph19.Node.isIdentifier(subject) && (isClientImport(subject, match, resolution, true) || clientVarNames.has(subject.getText())) || resolvesToKnownInstance(subject, match, resolution);
|
|
5321
|
+
}
|
|
5299
5322
|
function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
5300
5323
|
const localName = resolveImportedLocalName(
|
|
5301
5324
|
sourceFile,
|
|
@@ -7717,7 +7740,7 @@ function discoverPackageImports(sourceFile, match, kind, resolution) {
|
|
|
7717
7740
|
}
|
|
7718
7741
|
|
|
7719
7742
|
// src/discovery/registrationCall.ts
|
|
7720
|
-
var
|
|
7743
|
+
var import_ts_morph35 = require("ts-morph");
|
|
7721
7744
|
var import_resolution3 = require("@suss/resolution");
|
|
7722
7745
|
|
|
7723
7746
|
// src/resolve/routePath.ts
|
|
@@ -7725,9 +7748,143 @@ var import_values4 = require("@suss/values");
|
|
|
7725
7748
|
function pathFromArgument(arg, resolution) {
|
|
7726
7749
|
return (0, import_values4.pathOf)(evaluatedValue(arg, resolution));
|
|
7727
7750
|
}
|
|
7751
|
+
function pathFromProperty(arg, property, resolution) {
|
|
7752
|
+
const record2 = evaluatedValue(arg, resolution);
|
|
7753
|
+
if (record2.kind !== "record") {
|
|
7754
|
+
return void 0;
|
|
7755
|
+
}
|
|
7756
|
+
const field = record2.fields.get(property);
|
|
7757
|
+
return field === void 0 ? void 0 : (0, import_values4.pathOf)((0, import_values4.force)(field.value));
|
|
7758
|
+
}
|
|
7759
|
+
|
|
7760
|
+
// src/discovery/wrapperFactory.ts
|
|
7761
|
+
var import_ts_morph34 = require("ts-morph");
|
|
7762
|
+
|
|
7763
|
+
// src/resolve/unfollowedCall.ts
|
|
7764
|
+
var import_ts_morph33 = require("ts-morph");
|
|
7765
|
+
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
7766
|
+
function isInExternalCode(sourceFile) {
|
|
7767
|
+
if (sourceFile.isDeclarationFile()) {
|
|
7768
|
+
return true;
|
|
7769
|
+
}
|
|
7770
|
+
return sourceFile.getFilePath().includes("/node_modules/");
|
|
7771
|
+
}
|
|
7772
|
+
function hasBody(fn) {
|
|
7773
|
+
if (import_ts_morph33.Node.isFunctionDeclaration(fn) || import_ts_morph33.Node.isMethodDeclaration(fn) || import_ts_morph33.Node.isFunctionExpression(fn)) {
|
|
7774
|
+
return fn.getBody?.() !== void 0;
|
|
7775
|
+
}
|
|
7776
|
+
return true;
|
|
7777
|
+
}
|
|
7778
|
+
function isDeclaredShape(declaration) {
|
|
7779
|
+
return (import_ts_morph33.Node.isMethodSignature(declaration) || import_ts_morph33.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
7780
|
+
}
|
|
7781
|
+
function isExternalDeclaration(declaration) {
|
|
7782
|
+
if (isInExternalCode(declaration.getSourceFile())) {
|
|
7783
|
+
return true;
|
|
7784
|
+
}
|
|
7785
|
+
if (import_ts_morph33.Node.isImportSpecifier(declaration) || import_ts_morph33.Node.isImportClause(declaration) || import_ts_morph33.Node.isNamespaceImport(declaration)) {
|
|
7786
|
+
const target = declaration.getFirstAncestorByKind(import_ts_morph33.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
7787
|
+
return target === void 0 || isInExternalCode(target);
|
|
7788
|
+
}
|
|
7789
|
+
return declaresAnotherModule(declaration);
|
|
7790
|
+
}
|
|
7791
|
+
function declaresAnotherModule(declaration) {
|
|
7792
|
+
const module2 = declaration.getFirstAncestorByKind(
|
|
7793
|
+
import_ts_morph33.SyntaxKind.ModuleDeclaration
|
|
7794
|
+
);
|
|
7795
|
+
return module2 !== void 0 && import_ts_morph33.Node.isStringLiteral(module2.getNameNode());
|
|
7796
|
+
}
|
|
7797
|
+
function statesShapeOnly(declaration) {
|
|
7798
|
+
if (isExternalDeclaration(declaration)) {
|
|
7799
|
+
return false;
|
|
7800
|
+
}
|
|
7801
|
+
if (import_ts_morph33.Node.isMethodSignature(declaration) || import_ts_morph33.Node.isPropertySignature(declaration)) {
|
|
7802
|
+
return true;
|
|
7803
|
+
}
|
|
7804
|
+
if (import_ts_morph33.Node.isFunctionDeclaration(declaration) || import_ts_morph33.Node.isMethodDeclaration(declaration)) {
|
|
7805
|
+
return declaration.getBody() === void 0;
|
|
7806
|
+
}
|
|
7807
|
+
return false;
|
|
7808
|
+
}
|
|
7809
|
+
function declarationsBehind(symbol) {
|
|
7810
|
+
if (symbol === void 0) {
|
|
7811
|
+
return [];
|
|
7812
|
+
}
|
|
7813
|
+
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
7814
|
+
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
7815
|
+
}
|
|
7816
|
+
function isParameterOf(declaration, scanning) {
|
|
7817
|
+
return import_ts_morph33.Node.isParameterDeclaration(declaration) && declaration.getParent() === scanning;
|
|
7818
|
+
}
|
|
7819
|
+
function parameterIndexOf(declarations, scanning) {
|
|
7820
|
+
if (scanning === void 0) {
|
|
7821
|
+
return void 0;
|
|
7822
|
+
}
|
|
7823
|
+
const params = scanning.getParameters();
|
|
7824
|
+
for (const declaration of declarations) {
|
|
7825
|
+
const index = params.findIndex((param) => param === declaration);
|
|
7826
|
+
if (index !== -1) {
|
|
7827
|
+
return index;
|
|
7828
|
+
}
|
|
7829
|
+
}
|
|
7830
|
+
return void 0;
|
|
7831
|
+
}
|
|
7832
|
+
function classifyStop(declarations, scanning) {
|
|
7833
|
+
if (declarations.length === 0) {
|
|
7834
|
+
return "noDeclaration";
|
|
7835
|
+
}
|
|
7836
|
+
for (const declaration of declarations) {
|
|
7837
|
+
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
7838
|
+
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
if (scanning !== void 0 && declarations.some((declaration) => isParameterOf(declaration, scanning))) {
|
|
7842
|
+
return "callerSupplied";
|
|
7843
|
+
}
|
|
7844
|
+
if (declarations.every(isExternalDeclaration)) {
|
|
7845
|
+
return "outsideRun";
|
|
7846
|
+
}
|
|
7847
|
+
if (declarations.some(statesShapeOnly)) {
|
|
7848
|
+
return "noBody";
|
|
7849
|
+
}
|
|
7850
|
+
return "unsettledValue";
|
|
7851
|
+
}
|
|
7852
|
+
|
|
7853
|
+
// src/discovery/wrapperFactory.ts
|
|
7854
|
+
function factoryNameOf(targetArg) {
|
|
7855
|
+
const written = factKeyOf(targetArg);
|
|
7856
|
+
if (!import_ts_morph34.Node.isCallExpression(written)) {
|
|
7857
|
+
return void 0;
|
|
7858
|
+
}
|
|
7859
|
+
const callee = written.getExpression();
|
|
7860
|
+
if (import_ts_morph34.Node.isIdentifier(callee)) {
|
|
7861
|
+
return callee.getText();
|
|
7862
|
+
}
|
|
7863
|
+
if (import_ts_morph34.Node.isPropertyAccessExpression(callee)) {
|
|
7864
|
+
return callee.getName();
|
|
7865
|
+
}
|
|
7866
|
+
return void 0;
|
|
7867
|
+
}
|
|
7868
|
+
function factoryStopOf(targetArg) {
|
|
7869
|
+
const written = factKeyOf(targetArg);
|
|
7870
|
+
if (!import_ts_morph34.Node.isCallExpression(written)) {
|
|
7871
|
+
return null;
|
|
7872
|
+
}
|
|
7873
|
+
const callee = factoryNameOf(targetArg);
|
|
7874
|
+
if (callee === void 0) {
|
|
7875
|
+
return null;
|
|
7876
|
+
}
|
|
7877
|
+
const reason = classifyStop(
|
|
7878
|
+
declarationsBehind(written.getExpression().getSymbol())
|
|
7879
|
+
);
|
|
7880
|
+
if (!(0, import_behavioral_ir2.worthRecording)(reason)) {
|
|
7881
|
+
return null;
|
|
7882
|
+
}
|
|
7883
|
+
return { callee, reason: "unresolvedWrapper" };
|
|
7884
|
+
}
|
|
7728
7885
|
|
|
7729
7886
|
// src/discovery/registrationCall.ts
|
|
7730
|
-
function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, resolution, mountPrefixes, expandedElsewhere) {
|
|
7887
|
+
function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, resolution, mountPrefixes, expandedElsewhere, routeWrapperPattern) {
|
|
7731
7888
|
const results = [];
|
|
7732
7889
|
const registrationSubjects = registrationSubjectsOf(
|
|
7733
7890
|
sourceFile,
|
|
@@ -7742,11 +7899,11 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7742
7899
|
return results;
|
|
7743
7900
|
}
|
|
7744
7901
|
sourceFile.forEachDescendant((node) => {
|
|
7745
|
-
if (!
|
|
7902
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
7746
7903
|
return;
|
|
7747
7904
|
}
|
|
7748
7905
|
const callee = node.getExpression();
|
|
7749
|
-
if (!
|
|
7906
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee)) {
|
|
7750
7907
|
return;
|
|
7751
7908
|
}
|
|
7752
7909
|
const methodName = callee.getName();
|
|
@@ -7783,12 +7940,12 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7783
7940
|
const registrationSubjectId = nodeId(subjectNode);
|
|
7784
7941
|
let foundObjectArg = false;
|
|
7785
7942
|
for (const arg of args) {
|
|
7786
|
-
if (!
|
|
7943
|
+
if (!import_ts_morph35.Node.isObjectLiteralExpression(arg)) {
|
|
7787
7944
|
continue;
|
|
7788
7945
|
}
|
|
7789
7946
|
foundObjectArg = true;
|
|
7790
7947
|
for (const prop of arg.getProperties()) {
|
|
7791
|
-
if (
|
|
7948
|
+
if (import_ts_morph35.Node.isMethodDeclaration(prop)) {
|
|
7792
7949
|
results.push({
|
|
7793
7950
|
func: prop,
|
|
7794
7951
|
kind,
|
|
@@ -7797,7 +7954,7 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7797
7954
|
});
|
|
7798
7955
|
continue;
|
|
7799
7956
|
}
|
|
7800
|
-
if (!
|
|
7957
|
+
if (!import_ts_morph35.Node.isPropertyAssignment(prop)) {
|
|
7801
7958
|
continue;
|
|
7802
7959
|
}
|
|
7803
7960
|
const propInit = prop.getInitializer();
|
|
@@ -7829,6 +7986,13 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7829
7986
|
mountPrefixes
|
|
7830
7987
|
);
|
|
7831
7988
|
if (handler !== null) {
|
|
7989
|
+
const chain = routeWrapperPattern === void 0 ? null : routeChainOf(
|
|
7990
|
+
args.slice(0, -1),
|
|
7991
|
+
routeWrapperPattern,
|
|
7992
|
+
methodName,
|
|
7993
|
+
routeInfo,
|
|
7994
|
+
resolution
|
|
7995
|
+
);
|
|
7832
7996
|
results.push({
|
|
7833
7997
|
func: handler,
|
|
7834
7998
|
kind,
|
|
@@ -7836,8 +8000,13 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
7836
8000
|
name: methodName,
|
|
7837
8001
|
nameKind: "label",
|
|
7838
8002
|
registrationSubjectId,
|
|
7839
|
-
...routeInfo !== null ? { routeInfo } : {}
|
|
8003
|
+
...routeInfo !== null ? { routeInfo } : {},
|
|
8004
|
+
...chain === null || chain.references.length === 0 ? {} : { routeWrappers: chain.references },
|
|
8005
|
+
...chain === null || chain.unfollowed.length === 0 ? {} : { routeUnfollowed: chain.unfollowed }
|
|
7840
8006
|
});
|
|
8007
|
+
if (chain !== null) {
|
|
8008
|
+
results.push(...chain.units);
|
|
8009
|
+
}
|
|
7841
8010
|
return;
|
|
7842
8011
|
}
|
|
7843
8012
|
if (routeInfo !== null && lastArg !== void 0 && namesAParameter(lastArg)) {
|
|
@@ -7883,6 +8052,47 @@ function declinedRegistration(call, callee, methodName, kind, receiver, resoluti
|
|
|
7883
8052
|
}
|
|
7884
8053
|
];
|
|
7885
8054
|
}
|
|
8055
|
+
function routeChainOf(listed, pattern, methodName, routeInfo, resolution) {
|
|
8056
|
+
const chain = { units: [], references: [], unfollowed: [] };
|
|
8057
|
+
const anonymousLabels = /* @__PURE__ */ new Map();
|
|
8058
|
+
for (const arg of listed) {
|
|
8059
|
+
const elements = import_ts_morph35.Node.isArrayLiteralExpression(arg) ? arg.getElements() : [arg];
|
|
8060
|
+
for (const element of elements) {
|
|
8061
|
+
const target = functionValueOf(element, resolution);
|
|
8062
|
+
if (target === null) {
|
|
8063
|
+
const stop = factoryStopOf(element);
|
|
8064
|
+
if (stop !== null) {
|
|
8065
|
+
chain.unfollowed.push(stop);
|
|
8066
|
+
}
|
|
8067
|
+
continue;
|
|
8068
|
+
}
|
|
8069
|
+
const ownName = functionNameOrAnon(target);
|
|
8070
|
+
const named2 = ownName !== "<anon>";
|
|
8071
|
+
const label = factoryNameOf(element) ?? methodName;
|
|
8072
|
+
const seen = anonymousLabels.get(label) ?? 0;
|
|
8073
|
+
if (!named2) {
|
|
8074
|
+
anonymousLabels.set(label, seen + 1);
|
|
8075
|
+
}
|
|
8076
|
+
const name = named2 ? ownName : routeWrapperLabel(label, routeInfo, element, seen);
|
|
8077
|
+
chain.units.push({
|
|
8078
|
+
func: target,
|
|
8079
|
+
kind: pattern.kind,
|
|
8080
|
+
name,
|
|
8081
|
+
pattern,
|
|
8082
|
+
...named2 ? {} : { nameKind: "label" }
|
|
8083
|
+
});
|
|
8084
|
+
chain.references.push({
|
|
8085
|
+
file: target.getSourceFile().getFilePath(),
|
|
8086
|
+
name
|
|
8087
|
+
});
|
|
8088
|
+
}
|
|
8089
|
+
}
|
|
8090
|
+
return chain;
|
|
8091
|
+
}
|
|
8092
|
+
function routeWrapperLabel(label, routeInfo, element, seen) {
|
|
8093
|
+
const where = routeInfo === null ? `L${element.getStartLineNumber()}` : `${routeInfo.method} ${routeInfo.path}`;
|
|
8094
|
+
return seen === 0 ? `${label}@${where}` : `${label}@${where}#${seen + 1}`;
|
|
8095
|
+
}
|
|
7886
8096
|
function withMountPrefix(routeInfo, subjectNode, mountPrefixes) {
|
|
7887
8097
|
if (routeInfo === null || mountPrefixes === void 0) {
|
|
7888
8098
|
return routeInfo;
|
|
@@ -7910,13 +8120,13 @@ function subjectNodeFor(subject, subjects, match, resolution) {
|
|
|
7910
8120
|
}
|
|
7911
8121
|
var NOT_A_ROUTABLE = { kind: "none" };
|
|
7912
8122
|
function receiverOf(subject, subjects, match, resolution) {
|
|
7913
|
-
if (
|
|
8123
|
+
if (import_ts_morph35.Node.isIdentifier(subject)) {
|
|
7914
8124
|
const known = subjects.get(subject.getText());
|
|
7915
8125
|
if (known !== void 0) {
|
|
7916
8126
|
return { kind: "routable", node: known };
|
|
7917
8127
|
}
|
|
7918
8128
|
}
|
|
7919
|
-
if (resolution === void 0 || !(
|
|
8129
|
+
if (resolution === void 0 || !(import_ts_morph35.Node.isIdentifier(subject) || import_ts_morph35.Node.isPropertyAccessExpression(subject))) {
|
|
7920
8130
|
return NOT_A_ROUTABLE;
|
|
7921
8131
|
}
|
|
7922
8132
|
const construction = resolution.subjectConstructionOf(
|
|
@@ -7956,18 +8166,18 @@ function collectMethodsCalledOnCallResults(sourceFile) {
|
|
|
7956
8166
|
const setToCalls = /* @__PURE__ */ new Set();
|
|
7957
8167
|
const calledOn = /* @__PURE__ */ new Map();
|
|
7958
8168
|
sourceFile.forEachDescendant((node) => {
|
|
7959
|
-
if (
|
|
8169
|
+
if (import_ts_morph35.Node.isVariableDeclaration(node)) {
|
|
7960
8170
|
const init = node.getInitializer();
|
|
7961
|
-
if (init !== void 0 &&
|
|
8171
|
+
if (init !== void 0 && import_ts_morph35.Node.isCallExpression(init)) {
|
|
7962
8172
|
setToCalls.add(node.getName());
|
|
7963
8173
|
}
|
|
7964
8174
|
return;
|
|
7965
8175
|
}
|
|
7966
|
-
if (!
|
|
8176
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
7967
8177
|
return;
|
|
7968
8178
|
}
|
|
7969
8179
|
const callee = node.getExpression();
|
|
7970
|
-
if (!
|
|
8180
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee) || !import_ts_morph35.Node.isIdentifier(callee.getExpression())) {
|
|
7971
8181
|
return;
|
|
7972
8182
|
}
|
|
7973
8183
|
const receiver = callee.getExpression().getText();
|
|
@@ -7994,18 +8204,18 @@ function registrationSubjectsOf(sourceFile, importModule, importName, resolution
|
|
|
7994
8204
|
return subjects;
|
|
7995
8205
|
}
|
|
7996
8206
|
sourceFile.forEachDescendant((node) => {
|
|
7997
|
-
if (
|
|
8207
|
+
if (import_ts_morph35.Node.isVariableDeclaration(node)) {
|
|
7998
8208
|
const init = node.getInitializer();
|
|
7999
8209
|
if (init === void 0) {
|
|
8000
8210
|
return;
|
|
8001
8211
|
}
|
|
8002
|
-
const calleeText =
|
|
8212
|
+
const calleeText = import_ts_morph35.Node.isCallExpression(init) || import_ts_morph35.Node.isNewExpression(init) ? init.getExpression().getText() : null;
|
|
8003
8213
|
if (calleeText !== null && spellings.includes(calleeText)) {
|
|
8004
8214
|
subjects.set(node.getName(), init);
|
|
8005
8215
|
}
|
|
8006
8216
|
return;
|
|
8007
8217
|
}
|
|
8008
|
-
if (!
|
|
8218
|
+
if (!import_ts_morph35.Node.isParameterDeclaration(node)) {
|
|
8009
8219
|
return;
|
|
8010
8220
|
}
|
|
8011
8221
|
const typeNode = node.getTypeNode();
|
|
@@ -8026,7 +8236,7 @@ function creationSiteBehind(parameter, resolution) {
|
|
|
8026
8236
|
return parameter;
|
|
8027
8237
|
}
|
|
8028
8238
|
const written = resolution.resolveWrittenValue(parameter);
|
|
8029
|
-
if (written === null || !(
|
|
8239
|
+
if (written === null || !(import_ts_morph35.Node.isCallExpression(written) || import_ts_morph35.Node.isNewExpression(written))) {
|
|
8030
8240
|
return parameter;
|
|
8031
8241
|
}
|
|
8032
8242
|
return written;
|
|
@@ -8069,7 +8279,7 @@ function unboundConstructionsOf(sourceFile, importModule, importName) {
|
|
|
8069
8279
|
}
|
|
8070
8280
|
const constructions = [];
|
|
8071
8281
|
sourceFile.forEachDescendant((node) => {
|
|
8072
|
-
if ((
|
|
8282
|
+
if ((import_ts_morph35.Node.isCallExpression(node) || import_ts_morph35.Node.isNewExpression(node)) && spellings.includes(node.getExpression().getText()) && !import_ts_morph35.Node.isVariableDeclaration(node.getParent())) {
|
|
8073
8283
|
constructions.push(node);
|
|
8074
8284
|
}
|
|
8075
8285
|
});
|
|
@@ -8087,11 +8297,11 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8087
8297
|
}
|
|
8088
8298
|
const edges = [];
|
|
8089
8299
|
sourceFile.forEachDescendant((node) => {
|
|
8090
|
-
if (!
|
|
8300
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
8091
8301
|
return;
|
|
8092
8302
|
}
|
|
8093
8303
|
const callee = node.getExpression();
|
|
8094
|
-
if (!
|
|
8304
|
+
if (!import_ts_morph35.Node.isPropertyAccessExpression(callee) || callee.getName() !== mount.method) {
|
|
8095
8305
|
return;
|
|
8096
8306
|
}
|
|
8097
8307
|
const subjectNode = subjectNodeFor(
|
|
@@ -8105,7 +8315,7 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
8105
8315
|
}
|
|
8106
8316
|
const args = node.getArguments();
|
|
8107
8317
|
const prefixArg = args[mount.prefixPosition];
|
|
8108
|
-
if (prefixArg === void 0 || !(
|
|
8318
|
+
if (prefixArg === void 0 || !(import_ts_morph35.Node.isStringLiteral(prefixArg) || import_ts_morph35.Node.isNoSubstitutionTemplateLiteral(prefixArg))) {
|
|
8109
8319
|
return;
|
|
8110
8320
|
}
|
|
8111
8321
|
const targetNodes = mountTargetsAmong(
|
|
@@ -8160,7 +8370,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8160
8370
|
} else {
|
|
8161
8371
|
const args = call.getArguments();
|
|
8162
8372
|
const arg = args[binding.method.position];
|
|
8163
|
-
if (arg === void 0 || !(
|
|
8373
|
+
if (arg === void 0 || !(import_ts_morph35.Node.isStringLiteral(arg) || import_ts_morph35.Node.isNoSubstitutionTemplateLiteral(arg))) {
|
|
8164
8374
|
return null;
|
|
8165
8375
|
}
|
|
8166
8376
|
method = arg.getLiteralValue().toUpperCase();
|
|
@@ -8171,7 +8381,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8171
8381
|
}
|
|
8172
8382
|
|
|
8173
8383
|
// src/discovery/registrationLoop.ts
|
|
8174
|
-
var
|
|
8384
|
+
var import_ts_morph36 = require("ts-morph");
|
|
8175
8385
|
function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
8176
8386
|
const results = [];
|
|
8177
8387
|
const guard = receiverGuard(sourceFile, match.receiver, resolution);
|
|
@@ -8179,7 +8389,7 @@ function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
|
8179
8389
|
return results;
|
|
8180
8390
|
}
|
|
8181
8391
|
sourceFile.forEachDescendant((node) => {
|
|
8182
|
-
if (!
|
|
8392
|
+
if (!import_ts_morph36.Node.isForOfStatement(node)) {
|
|
8183
8393
|
return;
|
|
8184
8394
|
}
|
|
8185
8395
|
const expanded = tryExpandLoop(node, match, kind, resolution, guard);
|
|
@@ -8242,13 +8452,13 @@ function tryExpandLoop(loop, match, kind, resolution, guard) {
|
|
|
8242
8452
|
}
|
|
8243
8453
|
function loopVariableName(loop) {
|
|
8244
8454
|
const initializer = loop.getInitializer();
|
|
8245
|
-
if (
|
|
8455
|
+
if (import_ts_morph36.Node.isVariableDeclarationList(initializer)) {
|
|
8246
8456
|
const decls = initializer.getDeclarations();
|
|
8247
8457
|
if (decls.length !== 1) {
|
|
8248
8458
|
return null;
|
|
8249
8459
|
}
|
|
8250
8460
|
const nameNode = decls[0]?.getNameNode();
|
|
8251
|
-
if (nameNode !== void 0 &&
|
|
8461
|
+
if (nameNode !== void 0 && import_ts_morph36.Node.isIdentifier(nameNode)) {
|
|
8252
8462
|
return nameNode.getText();
|
|
8253
8463
|
}
|
|
8254
8464
|
}
|
|
@@ -8261,14 +8471,14 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8261
8471
|
if (referenced) {
|
|
8262
8472
|
return;
|
|
8263
8473
|
}
|
|
8264
|
-
if (!
|
|
8474
|
+
if (!import_ts_morph36.Node.isCallExpression(node)) {
|
|
8265
8475
|
return;
|
|
8266
8476
|
}
|
|
8267
8477
|
node.forEachDescendant((inner) => {
|
|
8268
8478
|
if (referenced) {
|
|
8269
8479
|
return;
|
|
8270
8480
|
}
|
|
8271
|
-
if (
|
|
8481
|
+
if (import_ts_morph36.Node.isIdentifier(inner) && inner.getText() === name) {
|
|
8272
8482
|
referenced = true;
|
|
8273
8483
|
}
|
|
8274
8484
|
});
|
|
@@ -8278,11 +8488,11 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
8278
8488
|
function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
8279
8489
|
let found = false;
|
|
8280
8490
|
loop.getStatement().forEachDescendant((node) => {
|
|
8281
|
-
if (found || !
|
|
8491
|
+
if (found || !import_ts_morph36.Node.isCallExpression(node)) {
|
|
8282
8492
|
return;
|
|
8283
8493
|
}
|
|
8284
8494
|
const callee = node.getExpression();
|
|
8285
|
-
if (!
|
|
8495
|
+
if (!import_ts_morph36.Node.isPropertyAccessExpression(callee) && !import_ts_morph36.Node.isElementAccessExpression(callee)) {
|
|
8286
8496
|
return;
|
|
8287
8497
|
}
|
|
8288
8498
|
const subject = callee.getExpression();
|
|
@@ -8302,11 +8512,11 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8302
8512
|
let path15 = null;
|
|
8303
8513
|
let handler = null;
|
|
8304
8514
|
for (const prop of element.getProperties()) {
|
|
8305
|
-
if (
|
|
8515
|
+
if (import_ts_morph36.Node.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
8306
8516
|
handler = { func: prop, name: shape.handlerKey };
|
|
8307
8517
|
continue;
|
|
8308
8518
|
}
|
|
8309
|
-
if (!
|
|
8519
|
+
if (!import_ts_morph36.Node.isPropertyAssignment(prop)) {
|
|
8310
8520
|
continue;
|
|
8311
8521
|
}
|
|
8312
8522
|
const name = prop.getName();
|
|
@@ -8329,111 +8539,19 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8329
8539
|
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8330
8540
|
}
|
|
8331
8541
|
function readStringLiteralValue(node) {
|
|
8332
|
-
if (
|
|
8542
|
+
if (import_ts_morph36.Node.isStringLiteral(node) || import_ts_morph36.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8333
8543
|
return node.getLiteralValue();
|
|
8334
8544
|
}
|
|
8335
8545
|
return null;
|
|
8336
8546
|
}
|
|
8337
8547
|
function handlerName(value) {
|
|
8338
|
-
return
|
|
8548
|
+
return import_ts_morph36.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
8339
8549
|
}
|
|
8340
8550
|
|
|
8341
8551
|
// src/discovery/registrationTemplate.ts
|
|
8342
8552
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
8343
|
-
var
|
|
8553
|
+
var import_ts_morph37 = require("ts-morph");
|
|
8344
8554
|
var import_resolution4 = require("@suss/resolution");
|
|
8345
|
-
|
|
8346
|
-
// src/resolve/unfollowedCall.ts
|
|
8347
|
-
var import_ts_morph35 = require("ts-morph");
|
|
8348
|
-
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
8349
|
-
function isInExternalCode(sourceFile) {
|
|
8350
|
-
if (sourceFile.isDeclarationFile()) {
|
|
8351
|
-
return true;
|
|
8352
|
-
}
|
|
8353
|
-
return sourceFile.getFilePath().includes("/node_modules/");
|
|
8354
|
-
}
|
|
8355
|
-
function hasBody(fn) {
|
|
8356
|
-
if (import_ts_morph35.Node.isFunctionDeclaration(fn) || import_ts_morph35.Node.isMethodDeclaration(fn) || import_ts_morph35.Node.isFunctionExpression(fn)) {
|
|
8357
|
-
return fn.getBody?.() !== void 0;
|
|
8358
|
-
}
|
|
8359
|
-
return true;
|
|
8360
|
-
}
|
|
8361
|
-
function isDeclaredShape(declaration) {
|
|
8362
|
-
return (import_ts_morph35.Node.isMethodSignature(declaration) || import_ts_morph35.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
8363
|
-
}
|
|
8364
|
-
function isExternalDeclaration(declaration) {
|
|
8365
|
-
if (isInExternalCode(declaration.getSourceFile())) {
|
|
8366
|
-
return true;
|
|
8367
|
-
}
|
|
8368
|
-
if (import_ts_morph35.Node.isImportSpecifier(declaration) || import_ts_morph35.Node.isImportClause(declaration) || import_ts_morph35.Node.isNamespaceImport(declaration)) {
|
|
8369
|
-
const target = declaration.getFirstAncestorByKind(import_ts_morph35.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
8370
|
-
return target === void 0 || isInExternalCode(target);
|
|
8371
|
-
}
|
|
8372
|
-
return declaresAnotherModule(declaration);
|
|
8373
|
-
}
|
|
8374
|
-
function declaresAnotherModule(declaration) {
|
|
8375
|
-
const module2 = declaration.getFirstAncestorByKind(
|
|
8376
|
-
import_ts_morph35.SyntaxKind.ModuleDeclaration
|
|
8377
|
-
);
|
|
8378
|
-
return module2 !== void 0 && import_ts_morph35.Node.isStringLiteral(module2.getNameNode());
|
|
8379
|
-
}
|
|
8380
|
-
function statesShapeOnly(declaration) {
|
|
8381
|
-
if (isExternalDeclaration(declaration)) {
|
|
8382
|
-
return false;
|
|
8383
|
-
}
|
|
8384
|
-
if (import_ts_morph35.Node.isMethodSignature(declaration) || import_ts_morph35.Node.isPropertySignature(declaration)) {
|
|
8385
|
-
return true;
|
|
8386
|
-
}
|
|
8387
|
-
if (import_ts_morph35.Node.isFunctionDeclaration(declaration) || import_ts_morph35.Node.isMethodDeclaration(declaration)) {
|
|
8388
|
-
return declaration.getBody() === void 0;
|
|
8389
|
-
}
|
|
8390
|
-
return false;
|
|
8391
|
-
}
|
|
8392
|
-
function declarationsBehind(symbol) {
|
|
8393
|
-
if (symbol === void 0) {
|
|
8394
|
-
return [];
|
|
8395
|
-
}
|
|
8396
|
-
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
8397
|
-
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
8398
|
-
}
|
|
8399
|
-
function isParameterOf(declaration, scanning) {
|
|
8400
|
-
return import_ts_morph35.Node.isParameterDeclaration(declaration) && declaration.getParent() === scanning;
|
|
8401
|
-
}
|
|
8402
|
-
function parameterIndexOf(declarations, scanning) {
|
|
8403
|
-
if (scanning === void 0) {
|
|
8404
|
-
return void 0;
|
|
8405
|
-
}
|
|
8406
|
-
const params = scanning.getParameters();
|
|
8407
|
-
for (const declaration of declarations) {
|
|
8408
|
-
const index = params.findIndex((param) => param === declaration);
|
|
8409
|
-
if (index !== -1) {
|
|
8410
|
-
return index;
|
|
8411
|
-
}
|
|
8412
|
-
}
|
|
8413
|
-
return void 0;
|
|
8414
|
-
}
|
|
8415
|
-
function classifyStop(declarations, scanning) {
|
|
8416
|
-
if (declarations.length === 0) {
|
|
8417
|
-
return "noDeclaration";
|
|
8418
|
-
}
|
|
8419
|
-
for (const declaration of declarations) {
|
|
8420
|
-
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
8421
|
-
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
8422
|
-
}
|
|
8423
|
-
}
|
|
8424
|
-
if (scanning !== void 0 && declarations.some((declaration) => isParameterOf(declaration, scanning))) {
|
|
8425
|
-
return "callerSupplied";
|
|
8426
|
-
}
|
|
8427
|
-
if (declarations.every(isExternalDeclaration)) {
|
|
8428
|
-
return "outsideRun";
|
|
8429
|
-
}
|
|
8430
|
-
if (declarations.some(statesShapeOnly)) {
|
|
8431
|
-
return "noBody";
|
|
8432
|
-
}
|
|
8433
|
-
return "unsettledValue";
|
|
8434
|
-
}
|
|
8435
|
-
|
|
8436
|
-
// src/discovery/registrationTemplate.ts
|
|
8437
8555
|
function discoverRegistrationTemplates(sourceFile, match, kind, resolution, mountPrefixes) {
|
|
8438
8556
|
const results = [];
|
|
8439
8557
|
for (const node of helperCallsOf(sourceFile, match, resolution)) {
|
|
@@ -8494,15 +8612,15 @@ function helperCallsOf(sourceFile, match, resolution) {
|
|
|
8494
8612
|
return callsResolvingTo(sourceFile, store, {
|
|
8495
8613
|
module: module2,
|
|
8496
8614
|
name: match.helperName
|
|
8497
|
-
}).filter(
|
|
8615
|
+
}).filter(import_ts_morph37.Node.isCallExpression);
|
|
8498
8616
|
}
|
|
8499
8617
|
const calls = [];
|
|
8500
8618
|
sourceFile.forEachDescendant((node) => {
|
|
8501
|
-
if (!
|
|
8619
|
+
if (!import_ts_morph37.Node.isCallExpression(node)) {
|
|
8502
8620
|
return;
|
|
8503
8621
|
}
|
|
8504
8622
|
const callee = node.getExpression();
|
|
8505
|
-
if (!
|
|
8623
|
+
if (!import_ts_morph37.Node.isIdentifier(callee) || callee.getText() !== match.helperName) {
|
|
8506
8624
|
return;
|
|
8507
8625
|
}
|
|
8508
8626
|
if (module2 === void 0 || declaredInModule(callee, module2)) {
|
|
@@ -8546,7 +8664,7 @@ function substitutePath(template, args) {
|
|
|
8546
8664
|
return result;
|
|
8547
8665
|
}
|
|
8548
8666
|
function readStringLiteral(node) {
|
|
8549
|
-
if (
|
|
8667
|
+
if (import_ts_morph37.Node.isStringLiteral(node) || import_ts_morph37.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8550
8668
|
return node.getLiteralValue();
|
|
8551
8669
|
}
|
|
8552
8670
|
return null;
|
|
@@ -8569,7 +8687,7 @@ function resolveHandler(template, args, resolution) {
|
|
|
8569
8687
|
return readPropertyAsFunction(arg, prop, resolution);
|
|
8570
8688
|
}
|
|
8571
8689
|
function handlerName2(value) {
|
|
8572
|
-
return
|
|
8690
|
+
return import_ts_morph37.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
8573
8691
|
}
|
|
8574
8692
|
function readPropertyAsFunction(arg, prop, resolution) {
|
|
8575
8693
|
const obj = objectLiteralOf(arg, resolution);
|
|
@@ -8580,7 +8698,7 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
8580
8698
|
if (propertyName(property) !== prop) {
|
|
8581
8699
|
continue;
|
|
8582
8700
|
}
|
|
8583
|
-
if (
|
|
8701
|
+
if (import_ts_morph37.Node.isMethodDeclaration(property)) {
|
|
8584
8702
|
return { func: property, name: prop };
|
|
8585
8703
|
}
|
|
8586
8704
|
const held = propertyValueOf(property);
|
|
@@ -8588,19 +8706,19 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
8588
8706
|
return null;
|
|
8589
8707
|
}
|
|
8590
8708
|
const func = functionValueOf(held, resolution);
|
|
8591
|
-
return func === null ? null : { func, name:
|
|
8709
|
+
return func === null ? null : { func, name: import_ts_morph37.Node.isIdentifier(held) ? held.getText() : prop };
|
|
8592
8710
|
}
|
|
8593
8711
|
return null;
|
|
8594
8712
|
}
|
|
8595
8713
|
function propertyName(property) {
|
|
8596
|
-
if (
|
|
8714
|
+
if (import_ts_morph37.Node.isPropertyAssignment(property) || import_ts_morph37.Node.isShorthandPropertyAssignment(property) || import_ts_morph37.Node.isMethodDeclaration(property)) {
|
|
8597
8715
|
return property.getName();
|
|
8598
8716
|
}
|
|
8599
8717
|
return null;
|
|
8600
8718
|
}
|
|
8601
8719
|
|
|
8602
8720
|
// src/discovery/resolverMap.ts
|
|
8603
|
-
var
|
|
8721
|
+
var import_ts_morph38 = require("ts-morph");
|
|
8604
8722
|
function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
8605
8723
|
const store = resolution ?? new ResolutionStore();
|
|
8606
8724
|
const mapProperty = match.mapProperty;
|
|
@@ -8611,7 +8729,7 @@ function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
|
8611
8729
|
name: match.importName
|
|
8612
8730
|
})) {
|
|
8613
8731
|
const args = node.getArguments();
|
|
8614
|
-
if (args.length === 0 || !
|
|
8732
|
+
if (args.length === 0 || !import_ts_morph38.Node.isObjectLiteralExpression(args[0])) {
|
|
8615
8733
|
continue;
|
|
8616
8734
|
}
|
|
8617
8735
|
const config = args[0];
|
|
@@ -8665,7 +8783,7 @@ function resolverMapObject(prop, resolution) {
|
|
|
8665
8783
|
return held === null ? null : objectLiteralOf(held, resolution);
|
|
8666
8784
|
}
|
|
8667
8785
|
function extractTypeDefsSdl(config, resolution) {
|
|
8668
|
-
if (!
|
|
8786
|
+
if (!import_ts_morph38.Node.isObjectLiteralExpression(config)) {
|
|
8669
8787
|
return null;
|
|
8670
8788
|
}
|
|
8671
8789
|
const prop = config.getProperty("typeDefs");
|
|
@@ -8687,15 +8805,15 @@ function schemaSdlOf(expr, resolution) {
|
|
|
8687
8805
|
return resolved === null ? null : writtenSdl(resolved);
|
|
8688
8806
|
}
|
|
8689
8807
|
function writtenSdl(expr) {
|
|
8690
|
-
if (
|
|
8808
|
+
if (import_ts_morph38.Node.isStringLiteral(expr) || import_ts_morph38.Node.isNoSubstitutionTemplateLiteral(expr)) {
|
|
8691
8809
|
const value = expr.getLiteralValue();
|
|
8692
8810
|
return value === "" ? null : value;
|
|
8693
8811
|
}
|
|
8694
|
-
if (
|
|
8812
|
+
if (import_ts_morph38.Node.isTaggedTemplateExpression(expr)) {
|
|
8695
8813
|
const tag = expr.getTag();
|
|
8696
|
-
if (
|
|
8814
|
+
if (import_ts_morph38.Node.isIdentifier(tag) && tag.getText() === "gql") {
|
|
8697
8815
|
const template = expr.getTemplate();
|
|
8698
|
-
if (
|
|
8816
|
+
if (import_ts_morph38.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
8699
8817
|
return template.getLiteralValue();
|
|
8700
8818
|
}
|
|
8701
8819
|
}
|
|
@@ -8704,7 +8822,7 @@ function writtenSdl(expr) {
|
|
|
8704
8822
|
}
|
|
8705
8823
|
|
|
8706
8824
|
// src/discovery/index.ts
|
|
8707
|
-
function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElsewhere) {
|
|
8825
|
+
function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElsewhere, routeWrapperPattern) {
|
|
8708
8826
|
if (pattern.match.type === "namedExport") {
|
|
8709
8827
|
return discoverNamedExports(
|
|
8710
8828
|
sourceFile,
|
|
@@ -8721,7 +8839,8 @@ function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElse
|
|
|
8721
8839
|
pattern.bindingExtraction,
|
|
8722
8840
|
resolution,
|
|
8723
8841
|
mountPrefixes,
|
|
8724
|
-
expandedElsewhere
|
|
8842
|
+
expandedElsewhere,
|
|
8843
|
+
routeWrapperPattern
|
|
8725
8844
|
);
|
|
8726
8845
|
}
|
|
8727
8846
|
if (pattern.match.type === "registrationTemplate") {
|
|
@@ -8827,19 +8946,26 @@ function runPattern(sourceFile, pattern, resolution, mountPrefixes, expandedElse
|
|
|
8827
8946
|
}
|
|
8828
8947
|
return [];
|
|
8829
8948
|
}
|
|
8949
|
+
function routeWrapperPatternOf(patterns) {
|
|
8950
|
+
return patterns.find(
|
|
8951
|
+
(pattern) => pattern.wraps !== void 0 && "method" in pattern.wraps && pattern.wraps.continuationParam !== void 0 && pattern.wraps.throwParam === void 0 && pattern.wraps.arity === void 0 && pattern.wraps.scopePosition === void 0
|
|
8952
|
+
);
|
|
8953
|
+
}
|
|
8830
8954
|
function discoverUnits(sourceFile, patterns, resolution, mountPrefixes, expandedElsewhere) {
|
|
8831
8955
|
const store = resolution ?? new ResolutionStore();
|
|
8832
8956
|
const allResults = [];
|
|
8957
|
+
const routeWrapperPattern = routeWrapperPatternOf(patterns);
|
|
8833
8958
|
for (const pattern of patterns) {
|
|
8834
8959
|
const found = runPattern(
|
|
8835
8960
|
sourceFile,
|
|
8836
8961
|
pattern,
|
|
8837
8962
|
store,
|
|
8838
8963
|
mountPrefixes,
|
|
8839
|
-
expandedElsewhere
|
|
8964
|
+
expandedElsewhere,
|
|
8965
|
+
routeWrapperPattern
|
|
8840
8966
|
);
|
|
8841
8967
|
for (const unit of found) {
|
|
8842
|
-
unit.pattern
|
|
8968
|
+
unit.pattern ??= pattern;
|
|
8843
8969
|
}
|
|
8844
8970
|
allResults.push(...found);
|
|
8845
8971
|
}
|
|
@@ -8858,7 +8984,7 @@ function discoverUnits(sourceFile, patterns, resolution, mountPrefixes, expanded
|
|
|
8858
8984
|
// src/resolve/functionBehind.ts
|
|
8859
8985
|
function symbolBehind(node) {
|
|
8860
8986
|
const parent = node.getParent();
|
|
8861
|
-
if (parent !== void 0 &&
|
|
8987
|
+
if (parent !== void 0 && import_ts_morph39.Node.isShorthandPropertyAssignment(parent)) {
|
|
8862
8988
|
return parent.getValueSymbol();
|
|
8863
8989
|
}
|
|
8864
8990
|
return node.getSymbol();
|
|
@@ -8888,9 +9014,9 @@ function resolveDecl(decl, calleeName) {
|
|
|
8888
9014
|
}
|
|
8889
9015
|
return { func: fn, name: declName(decl) ?? calleeName };
|
|
8890
9016
|
}
|
|
8891
|
-
if (
|
|
9017
|
+
if (import_ts_morph39.Node.isVariableDeclaration(decl)) {
|
|
8892
9018
|
const init = decl.getInitializer();
|
|
8893
|
-
if (init !== void 0 && (
|
|
9019
|
+
if (init !== void 0 && (import_ts_morph39.Node.isArrowFunction(init) || import_ts_morph39.Node.isFunctionExpression(init))) {
|
|
8894
9020
|
return { func: init, name: decl.getName() };
|
|
8895
9021
|
}
|
|
8896
9022
|
return null;
|
|
@@ -8898,20 +9024,20 @@ function resolveDecl(decl, calleeName) {
|
|
|
8898
9024
|
return null;
|
|
8899
9025
|
}
|
|
8900
9026
|
function declName(decl) {
|
|
8901
|
-
if (
|
|
9027
|
+
if (import_ts_morph39.Node.isFunctionDeclaration(decl) || import_ts_morph39.Node.isMethodDeclaration(decl)) {
|
|
8902
9028
|
const n = decl.getName?.();
|
|
8903
9029
|
if (typeof n === "string" && n.length > 0) {
|
|
8904
9030
|
return n;
|
|
8905
9031
|
}
|
|
8906
9032
|
}
|
|
8907
|
-
if (
|
|
9033
|
+
if (import_ts_morph39.Node.isFunctionExpression(decl)) {
|
|
8908
9034
|
const n = decl.getName();
|
|
8909
9035
|
if (typeof n === "string" && n.length > 0) {
|
|
8910
9036
|
return n;
|
|
8911
9037
|
}
|
|
8912
9038
|
}
|
|
8913
9039
|
const parent = decl.getParent();
|
|
8914
|
-
if (parent !== void 0 &&
|
|
9040
|
+
if (parent !== void 0 && import_ts_morph39.Node.isVariableDeclaration(parent)) {
|
|
8915
9041
|
return parent.getName();
|
|
8916
9042
|
}
|
|
8917
9043
|
return null;
|
|
@@ -8923,14 +9049,14 @@ function pathAbove(reference) {
|
|
|
8923
9049
|
let current2 = reference;
|
|
8924
9050
|
for (; ; ) {
|
|
8925
9051
|
const parent = current2.getParent();
|
|
8926
|
-
if (parent !== void 0 &&
|
|
9052
|
+
if (parent !== void 0 && import_ts_morph40.Node.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
8927
9053
|
path15.push(parent.getName());
|
|
8928
9054
|
current2 = parent;
|
|
8929
9055
|
continue;
|
|
8930
9056
|
}
|
|
8931
|
-
if (parent !== void 0 &&
|
|
9057
|
+
if (parent !== void 0 && import_ts_morph40.Node.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
8932
9058
|
const argument = parent.getArgumentExpression();
|
|
8933
|
-
if (argument !== void 0 &&
|
|
9059
|
+
if (argument !== void 0 && import_ts_morph40.Node.isStringLiteral(argument)) {
|
|
8934
9060
|
path15.push(argument.getLiteralValue());
|
|
8935
9061
|
current2 = parent;
|
|
8936
9062
|
continue;
|
|
@@ -8940,11 +9066,11 @@ function pathAbove(reference) {
|
|
|
8940
9066
|
}
|
|
8941
9067
|
}
|
|
8942
9068
|
function declaresParameterOf(node, func) {
|
|
8943
|
-
if (
|
|
9069
|
+
if (import_ts_morph40.Node.isParameterDeclaration(node)) {
|
|
8944
9070
|
return node.getParent() === func;
|
|
8945
9071
|
}
|
|
8946
|
-
if (
|
|
8947
|
-
const parameter = node.getFirstAncestor(
|
|
9072
|
+
if (import_ts_morph40.Node.isBindingElement(node)) {
|
|
9073
|
+
const parameter = node.getFirstAncestor(import_ts_morph40.Node.isParameterDeclaration);
|
|
8948
9074
|
return parameter !== void 0 && parameter.getParent() === func;
|
|
8949
9075
|
}
|
|
8950
9076
|
return false;
|
|
@@ -8960,7 +9086,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
|
|
|
8960
9086
|
traversal.skip();
|
|
8961
9087
|
return;
|
|
8962
9088
|
}
|
|
8963
|
-
if (!
|
|
9089
|
+
if (!import_ts_morph40.Node.isIdentifier(node) || !wanted.has(node.getText())) {
|
|
8964
9090
|
return;
|
|
8965
9091
|
}
|
|
8966
9092
|
const declarations = symbolBehind(node)?.getDeclarations() ?? [];
|
|
@@ -8983,7 +9109,7 @@ function parameterReads(func, parameterNames2, barriers = NO_BARRIERS) {
|
|
|
8983
9109
|
}
|
|
8984
9110
|
|
|
8985
9111
|
// src/resolve/readName.ts
|
|
8986
|
-
var
|
|
9112
|
+
var import_ts_morph41 = require("ts-morph");
|
|
8987
9113
|
var import_behavioral_ir3 = require("@suss/behavioral-ir");
|
|
8988
9114
|
var MAX_HELPER_HOPS = 2;
|
|
8989
9115
|
var UNNAMED_HOLE = "param";
|
|
@@ -9018,11 +9144,11 @@ function referenceIn(expr) {
|
|
|
9018
9144
|
function parameterPath(expr) {
|
|
9019
9145
|
const fields = [];
|
|
9020
9146
|
let step = expr;
|
|
9021
|
-
while (
|
|
9147
|
+
while (import_ts_morph41.Node.isPropertyAccessExpression(step)) {
|
|
9022
9148
|
fields.unshift(step.getName());
|
|
9023
9149
|
step = step.getExpression();
|
|
9024
9150
|
}
|
|
9025
|
-
if (!
|
|
9151
|
+
if (!import_ts_morph41.Node.isIdentifier(step) || !isParameter(step)) {
|
|
9026
9152
|
return null;
|
|
9027
9153
|
}
|
|
9028
9154
|
return { root: step.getText(), fields };
|
|
@@ -9030,7 +9156,7 @@ function parameterPath(expr) {
|
|
|
9030
9156
|
function isParameter(identifier) {
|
|
9031
9157
|
const declarations = identifier.getSymbol()?.getDeclarations() ?? [];
|
|
9032
9158
|
return declarations.some(
|
|
9033
|
-
(declaration) =>
|
|
9159
|
+
(declaration) => import_ts_morph41.Node.isParameterDeclaration(declaration)
|
|
9034
9160
|
);
|
|
9035
9161
|
}
|
|
9036
9162
|
function read(expr, ctx) {
|
|
@@ -9039,25 +9165,25 @@ function read(expr, ctx) {
|
|
|
9039
9165
|
}
|
|
9040
9166
|
const seen = new Set(ctx.seen).add(expr);
|
|
9041
9167
|
const inner = { ...ctx, seen };
|
|
9042
|
-
if (
|
|
9168
|
+
if (import_ts_morph41.Node.isStringLiteral(expr) || import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(expr)) {
|
|
9043
9169
|
return expr.getLiteralValue();
|
|
9044
9170
|
}
|
|
9045
|
-
if (
|
|
9171
|
+
if (import_ts_morph41.Node.isNumericLiteral(expr)) {
|
|
9046
9172
|
return expr.getLiteralText();
|
|
9047
9173
|
}
|
|
9048
|
-
if (
|
|
9174
|
+
if (import_ts_morph41.Node.isTemplateExpression(expr)) {
|
|
9049
9175
|
return fromTemplate(expr, inner);
|
|
9050
9176
|
}
|
|
9051
|
-
if (
|
|
9177
|
+
if (import_ts_morph41.Node.isParenthesizedExpression(expr)) {
|
|
9052
9178
|
return read(peelParens(expr), inner);
|
|
9053
9179
|
}
|
|
9054
|
-
if (
|
|
9180
|
+
if (import_ts_morph41.Node.isBinaryExpression(expr)) {
|
|
9055
9181
|
return fromBinary(expr, inner);
|
|
9056
9182
|
}
|
|
9057
|
-
if (
|
|
9183
|
+
if (import_ts_morph41.Node.isCallExpression(expr)) {
|
|
9058
9184
|
return fromCall(expr, inner);
|
|
9059
9185
|
}
|
|
9060
|
-
if (
|
|
9186
|
+
if (import_ts_morph41.Node.isIdentifier(expr)) {
|
|
9061
9187
|
const only = boundOnce(expr, ctx);
|
|
9062
9188
|
if (only !== null) {
|
|
9063
9189
|
return read(only.node, { ...inner, bindings: only.scope });
|
|
@@ -9077,17 +9203,17 @@ function read(expr, ctx) {
|
|
|
9077
9203
|
}
|
|
9078
9204
|
function isFallbackBranch(node) {
|
|
9079
9205
|
let step = node.getParent();
|
|
9080
|
-
while (step !== void 0 &&
|
|
9206
|
+
while (step !== void 0 && import_ts_morph41.Node.isParenthesizedExpression(step)) {
|
|
9081
9207
|
step = step.getParent();
|
|
9082
9208
|
}
|
|
9083
|
-
if (step === void 0 || !
|
|
9209
|
+
if (step === void 0 || !import_ts_morph41.Node.isBinaryExpression(step)) {
|
|
9084
9210
|
return false;
|
|
9085
9211
|
}
|
|
9086
9212
|
const operator = step.getOperatorToken().getKind();
|
|
9087
|
-
return operator ===
|
|
9213
|
+
return operator === import_ts_morph41.SyntaxKind.BarBarToken || operator === import_ts_morph41.SyntaxKind.QuestionQuestionToken;
|
|
9088
9214
|
}
|
|
9089
9215
|
function fromTemplate(expr, ctx) {
|
|
9090
|
-
if (!
|
|
9216
|
+
if (!import_ts_morph41.Node.isTemplateExpression(expr)) {
|
|
9091
9217
|
return null;
|
|
9092
9218
|
}
|
|
9093
9219
|
let name = expr.getHead().getLiteralText();
|
|
@@ -9098,28 +9224,28 @@ function fromTemplate(expr, ctx) {
|
|
|
9098
9224
|
return name;
|
|
9099
9225
|
}
|
|
9100
9226
|
function fromBinary(expr, ctx) {
|
|
9101
|
-
if (!
|
|
9227
|
+
if (!import_ts_morph41.Node.isBinaryExpression(expr)) {
|
|
9102
9228
|
return null;
|
|
9103
9229
|
}
|
|
9104
9230
|
const operator = expr.getOperatorToken().getKind();
|
|
9105
|
-
if (operator ===
|
|
9231
|
+
if (operator === import_ts_morph41.SyntaxKind.BarBarToken || operator === import_ts_morph41.SyntaxKind.QuestionQuestionToken) {
|
|
9106
9232
|
return ctx.insideHole ? null : read(expr.getRight(), ctx);
|
|
9107
9233
|
}
|
|
9108
|
-
if (operator !==
|
|
9234
|
+
if (operator !== import_ts_morph41.SyntaxKind.PlusToken) {
|
|
9109
9235
|
return null;
|
|
9110
9236
|
}
|
|
9111
9237
|
const parts = { ...ctx, insideHole: true };
|
|
9112
9238
|
return readOrHole(expr.getLeft(), parts) + readOrHole(expr.getRight(), parts);
|
|
9113
9239
|
}
|
|
9114
9240
|
function fromCall(expr, ctx) {
|
|
9115
|
-
if (!
|
|
9241
|
+
if (!import_ts_morph41.Node.isCallExpression(expr)) {
|
|
9116
9242
|
return null;
|
|
9117
9243
|
}
|
|
9118
9244
|
const callee = expr.getExpression();
|
|
9119
|
-
if (
|
|
9245
|
+
if (import_ts_morph41.Node.isPropertyAccessExpression(callee) && callee.getName() === "join") {
|
|
9120
9246
|
return fromJoin(callee.getExpression(), expr.getArguments(), ctx);
|
|
9121
9247
|
}
|
|
9122
|
-
if (
|
|
9248
|
+
if (import_ts_morph41.Node.isIdentifier(callee) && callee.getText() === "String") {
|
|
9123
9249
|
const only = expr.getArguments()[0];
|
|
9124
9250
|
return only === void 0 ? null : readOrHole(only, ctx);
|
|
9125
9251
|
}
|
|
@@ -9138,7 +9264,7 @@ function fromCall(expr, ctx) {
|
|
|
9138
9264
|
}
|
|
9139
9265
|
function fromJoin(subject, args, ctx) {
|
|
9140
9266
|
const separator = args[0];
|
|
9141
|
-
if (separator === void 0 || !
|
|
9267
|
+
if (separator === void 0 || !import_ts_morph41.Node.isStringLiteral(separator)) {
|
|
9142
9268
|
return null;
|
|
9143
9269
|
}
|
|
9144
9270
|
const parts = elementsOf(subject, ctx);
|
|
@@ -9154,17 +9280,17 @@ function fromJoin(subject, args, ctx) {
|
|
|
9154
9280
|
).join(separator.getLiteralValue());
|
|
9155
9281
|
}
|
|
9156
9282
|
function elementsOf(subject, ctx) {
|
|
9157
|
-
if (
|
|
9283
|
+
if (import_ts_morph41.Node.isArrayLiteralExpression(subject)) {
|
|
9158
9284
|
return subject.getElements().map((element) => here(element, ctx));
|
|
9159
9285
|
}
|
|
9160
|
-
if (
|
|
9286
|
+
if (import_ts_morph41.Node.isCallExpression(subject)) {
|
|
9161
9287
|
const callee = subject.getExpression();
|
|
9162
|
-
if (
|
|
9288
|
+
if (import_ts_morph41.Node.isPropertyAccessExpression(callee) && callee.getName() === "map") {
|
|
9163
9289
|
return elementsOf(callee.getExpression(), ctx);
|
|
9164
9290
|
}
|
|
9165
9291
|
return null;
|
|
9166
9292
|
}
|
|
9167
|
-
if (!
|
|
9293
|
+
if (!import_ts_morph41.Node.isIdentifier(subject)) {
|
|
9168
9294
|
return null;
|
|
9169
9295
|
}
|
|
9170
9296
|
const bound = ctx.bindings.get(subject.getText());
|
|
@@ -9172,7 +9298,7 @@ function elementsOf(subject, ctx) {
|
|
|
9172
9298
|
return null;
|
|
9173
9299
|
}
|
|
9174
9300
|
const only = bound.length === 1 ? bound[0] : void 0;
|
|
9175
|
-
return only !== void 0 &&
|
|
9301
|
+
return only !== void 0 && import_ts_morph41.Node.isArrayLiteralExpression(only.node) ? only.node.getElements().map((element) => here(element, ctx)) : bound;
|
|
9176
9302
|
}
|
|
9177
9303
|
function singleReturnBody(callee, ctx) {
|
|
9178
9304
|
const declaration = declarationOf2(callee, ctx);
|
|
@@ -9187,22 +9313,22 @@ function singleReturnBody(callee, ctx) {
|
|
|
9187
9313
|
if (body === void 0) {
|
|
9188
9314
|
return null;
|
|
9189
9315
|
}
|
|
9190
|
-
if (
|
|
9316
|
+
if (import_ts_morph41.Node.isExpression(body)) {
|
|
9191
9317
|
return { parameters, returned: body };
|
|
9192
9318
|
}
|
|
9193
|
-
if (!
|
|
9319
|
+
if (!import_ts_morph41.Node.isBlock(body)) {
|
|
9194
9320
|
return null;
|
|
9195
9321
|
}
|
|
9196
9322
|
const statements = body.getStatements();
|
|
9197
9323
|
const only = statements[0];
|
|
9198
|
-
if (statements.length !== 1 || only === void 0 || !
|
|
9324
|
+
if (statements.length !== 1 || only === void 0 || !import_ts_morph41.Node.isReturnStatement(only)) {
|
|
9199
9325
|
return null;
|
|
9200
9326
|
}
|
|
9201
9327
|
const returned = only.getExpression();
|
|
9202
9328
|
return returned === void 0 ? null : { parameters, returned };
|
|
9203
9329
|
}
|
|
9204
9330
|
function declarationOf2(callee, ctx) {
|
|
9205
|
-
const symbol =
|
|
9331
|
+
const symbol = import_ts_morph41.Node.isPropertyAccessExpression(callee) ? callee.getNameNode().getSymbol() : callee.getSymbol();
|
|
9206
9332
|
const declarations = symbol?.getAliasedSymbol()?.getDeclarations() ?? symbol?.getDeclarations() ?? [];
|
|
9207
9333
|
for (const declaration of declarations) {
|
|
9208
9334
|
const callable = asCallable(declaration);
|
|
@@ -9214,14 +9340,14 @@ function declarationOf2(callee, ctx) {
|
|
|
9214
9340
|
return written === null || written === callee ? null : declarationOf2(written, { ...ctx, resolve: () => null });
|
|
9215
9341
|
}
|
|
9216
9342
|
function asCallable(declaration) {
|
|
9217
|
-
if (
|
|
9343
|
+
if (import_ts_morph41.Node.isFunctionDeclaration(declaration) || import_ts_morph41.Node.isMethodDeclaration(declaration) || import_ts_morph41.Node.isArrowFunction(declaration) || import_ts_morph41.Node.isFunctionExpression(declaration)) {
|
|
9218
9344
|
return declaration;
|
|
9219
9345
|
}
|
|
9220
|
-
if (!
|
|
9346
|
+
if (!import_ts_morph41.Node.isVariableDeclaration(declaration)) {
|
|
9221
9347
|
return null;
|
|
9222
9348
|
}
|
|
9223
9349
|
const initializer = declaration.getInitializer();
|
|
9224
|
-
if (initializer !== void 0 && (
|
|
9350
|
+
if (initializer !== void 0 && (import_ts_morph41.Node.isArrowFunction(initializer) || import_ts_morph41.Node.isFunctionExpression(initializer))) {
|
|
9225
9351
|
return initializer;
|
|
9226
9352
|
}
|
|
9227
9353
|
return null;
|
|
@@ -9243,7 +9369,7 @@ function here(node, ctx) {
|
|
|
9243
9369
|
return { node, scope: ctx.bindings };
|
|
9244
9370
|
}
|
|
9245
9371
|
function boundOnce(expr, ctx) {
|
|
9246
|
-
const bound =
|
|
9372
|
+
const bound = import_ts_morph41.Node.isIdentifier(expr) ? ctx.bindings.get(expr.getText()) : void 0;
|
|
9247
9373
|
return bound !== void 0 && bound.length === 1 ? bound[0] : null;
|
|
9248
9374
|
}
|
|
9249
9375
|
function readOrHole(expr, ctx) {
|
|
@@ -9255,10 +9381,10 @@ function holeName(expr, ctx) {
|
|
|
9255
9381
|
if (bound !== null) {
|
|
9256
9382
|
return holeName(bound.node, { ...ctx, bindings: bound.scope });
|
|
9257
9383
|
}
|
|
9258
|
-
if (
|
|
9384
|
+
if (import_ts_morph41.Node.isIdentifier(expr)) {
|
|
9259
9385
|
return expr.getText();
|
|
9260
9386
|
}
|
|
9261
|
-
if (
|
|
9387
|
+
if (import_ts_morph41.Node.isPropertyAccessExpression(expr)) {
|
|
9262
9388
|
return expr.getName();
|
|
9263
9389
|
}
|
|
9264
9390
|
return UNNAMED_HOLE;
|
|
@@ -9285,8 +9411,8 @@ function madeFromNamed(origin, made) {
|
|
|
9285
9411
|
return origin.named.includes(constructorName(made));
|
|
9286
9412
|
}
|
|
9287
9413
|
function constructorName(made) {
|
|
9288
|
-
const expression =
|
|
9289
|
-
return
|
|
9414
|
+
const expression = import_ts_morph42.Node.isNewExpression(made) || import_ts_morph42.Node.isCallExpression(made) ? made.getExpression() : made;
|
|
9415
|
+
return import_ts_morph42.Node.isPropertyAccessExpression(expression) ? expression.getName() : expression.getText();
|
|
9290
9416
|
}
|
|
9291
9417
|
var CALL_ORIGIN = {
|
|
9292
9418
|
declaredBy: ORIGIN.declaredBy,
|
|
@@ -9300,7 +9426,7 @@ var CALL_ORIGIN = {
|
|
|
9300
9426
|
};
|
|
9301
9427
|
function madeBy(receiver) {
|
|
9302
9428
|
const made = madeExpression(receiver);
|
|
9303
|
-
const expression =
|
|
9429
|
+
const expression = import_ts_morph42.Node.isNewExpression(made) || import_ts_morph42.Node.isCallExpression(made) ? made.getExpression() : made;
|
|
9304
9430
|
return rootIdentifier(expression) ?? expression;
|
|
9305
9431
|
}
|
|
9306
9432
|
function madeExpression(receiver) {
|
|
@@ -9308,7 +9434,7 @@ function madeExpression(receiver) {
|
|
|
9308
9434
|
return receiver.expression;
|
|
9309
9435
|
}
|
|
9310
9436
|
const written = receiver.resolve(receiver.callee.getExpression());
|
|
9311
|
-
if (written === null || !
|
|
9437
|
+
if (written === null || !import_ts_morph42.Node.isNewExpression(written) && !import_ts_morph42.Node.isCallExpression(written)) {
|
|
9312
9438
|
return receiver.callee;
|
|
9313
9439
|
}
|
|
9314
9440
|
return written;
|
|
@@ -9316,7 +9442,7 @@ function madeExpression(receiver) {
|
|
|
9316
9442
|
function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
9317
9443
|
const resolve2 = resolveWrittenValue ?? (() => null);
|
|
9318
9444
|
const expression = calleeOf3(call);
|
|
9319
|
-
const callee =
|
|
9445
|
+
const callee = import_ts_morph42.Node.isPropertyAccessExpression(expression) ? expression : null;
|
|
9320
9446
|
let args = null;
|
|
9321
9447
|
const argumentsOf = () => {
|
|
9322
9448
|
args ??= argumentsIn(call);
|
|
@@ -9339,7 +9465,7 @@ function callOpsFor(call, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
|
9339
9465
|
argumentCount: () => argumentsOf().length,
|
|
9340
9466
|
nameAt: (index, unsettled) => nameAt(argumentsOf()[index], unsettled, resolve2),
|
|
9341
9467
|
calleeText: () => expression.getText(),
|
|
9342
|
-
namedCallee: () =>
|
|
9468
|
+
namedCallee: () => import_ts_morph42.Node.isIdentifier(expression),
|
|
9343
9469
|
parameterReadsAt: (index) => selectorReadsOf(argumentsOf()[index]),
|
|
9344
9470
|
receiver: () => callee === null ? null : opsOverCall(callee.getExpression(), resolve2),
|
|
9345
9471
|
argument: (index) => opsOverCall(argumentsOf()[index], resolve2),
|
|
@@ -9364,7 +9490,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
|
|
|
9364
9490
|
return null;
|
|
9365
9491
|
}
|
|
9366
9492
|
const found = anchorCallsOf(subject, (candidate) => {
|
|
9367
|
-
if (!
|
|
9493
|
+
if (!import_ts_morph42.Node.isCallExpression(candidate) && !import_ts_morph42.Node.isNewExpression(candidate)) {
|
|
9368
9494
|
return false;
|
|
9369
9495
|
}
|
|
9370
9496
|
const candidateCallee = calleeOf3(candidate);
|
|
@@ -9379,7 +9505,7 @@ function anchorCallBehind(subject, origin, resolve2, originatesFrom, anchorCalls
|
|
|
9379
9505
|
if (distinct.length !== 1 || only === void 0) {
|
|
9380
9506
|
return null;
|
|
9381
9507
|
}
|
|
9382
|
-
if (!
|
|
9508
|
+
if (!import_ts_morph42.Node.isCallExpression(only) && !import_ts_morph42.Node.isNewExpression(only)) {
|
|
9383
9509
|
return null;
|
|
9384
9510
|
}
|
|
9385
9511
|
return callOpsFor(only, resolve2, originatesFrom, anchorCallsOf);
|
|
@@ -9399,7 +9525,7 @@ function valueOpsFor(value, resolve2) {
|
|
|
9399
9525
|
asArg: () => effectArgOf(written()),
|
|
9400
9526
|
property: (name) => {
|
|
9401
9527
|
const object = written();
|
|
9402
|
-
const inside =
|
|
9528
|
+
const inside = import_ts_morph42.Node.isObjectLiteralExpression(object) ? initializerOf(object, name) : null;
|
|
9403
9529
|
return inside === null ? null : valueOpsFor(inside, resolve2);
|
|
9404
9530
|
},
|
|
9405
9531
|
parts: () => literalParts(written()),
|
|
@@ -9412,7 +9538,7 @@ function literalParts(value) {
|
|
|
9412
9538
|
if (whole !== null) {
|
|
9413
9539
|
return [whole];
|
|
9414
9540
|
}
|
|
9415
|
-
if (!
|
|
9541
|
+
if (!import_ts_morph42.Node.isTemplateExpression(written)) {
|
|
9416
9542
|
return null;
|
|
9417
9543
|
}
|
|
9418
9544
|
return [
|
|
@@ -9422,26 +9548,26 @@ function literalParts(value) {
|
|
|
9422
9548
|
}
|
|
9423
9549
|
function templateHoles(value, resolve2) {
|
|
9424
9550
|
const written = untagged(value);
|
|
9425
|
-
if (!
|
|
9551
|
+
if (!import_ts_morph42.Node.isTemplateExpression(written)) {
|
|
9426
9552
|
return [];
|
|
9427
9553
|
}
|
|
9428
9554
|
return written.getTemplateSpans().map((span) => opsOverCall(span.getExpression(), resolve2));
|
|
9429
9555
|
}
|
|
9430
9556
|
function untagged(value) {
|
|
9431
|
-
return
|
|
9557
|
+
return import_ts_morph42.Node.isTaggedTemplateExpression(value) ? value.getTemplate() : value;
|
|
9432
9558
|
}
|
|
9433
9559
|
function entriesOf(value, unsettled, resolve2) {
|
|
9434
|
-
if (!
|
|
9560
|
+
if (!import_ts_morph42.Node.isObjectLiteralExpression(value)) {
|
|
9435
9561
|
return [];
|
|
9436
9562
|
}
|
|
9437
9563
|
const found = [];
|
|
9438
9564
|
for (const written of value.getProperties()) {
|
|
9439
|
-
if (
|
|
9565
|
+
if (import_ts_morph42.Node.isShorthandPropertyAssignment(written)) {
|
|
9440
9566
|
const name = written.getNameNode();
|
|
9441
9567
|
found.push({ key: name.getText(), value: valueOpsFor(name, resolve2) });
|
|
9442
9568
|
continue;
|
|
9443
9569
|
}
|
|
9444
|
-
if (!
|
|
9570
|
+
if (!import_ts_morph42.Node.isPropertyAssignment(written)) {
|
|
9445
9571
|
continue;
|
|
9446
9572
|
}
|
|
9447
9573
|
const stated = written.getInitializer();
|
|
@@ -9454,35 +9580,35 @@ function entriesOf(value, unsettled, resolve2) {
|
|
|
9454
9580
|
}
|
|
9455
9581
|
function entryKey(written, unsettled, resolve2) {
|
|
9456
9582
|
const name = written.getNameNode();
|
|
9457
|
-
if (
|
|
9583
|
+
if (import_ts_morph42.Node.isComputedPropertyName(name)) {
|
|
9458
9584
|
return readName(name.getExpression(), { resolve: resolve2, unsettled });
|
|
9459
9585
|
}
|
|
9460
9586
|
return unquoted(written.getName());
|
|
9461
9587
|
}
|
|
9462
9588
|
function itemsOf(value, resolve2) {
|
|
9463
|
-
if (!
|
|
9589
|
+
if (!import_ts_morph42.Node.isArrayLiteralExpression(value)) {
|
|
9464
9590
|
return [];
|
|
9465
9591
|
}
|
|
9466
9592
|
return value.getElements().map((element) => valueOpsFor(element, resolve2));
|
|
9467
9593
|
}
|
|
9468
9594
|
function literalText(value) {
|
|
9469
|
-
return
|
|
9595
|
+
return import_ts_morph42.Node.isStringLiteral(value) || import_ts_morph42.Node.isNoSubstitutionTemplateLiteral(value) ? value.getLiteralValue() : null;
|
|
9470
9596
|
}
|
|
9471
9597
|
function literalFlag(value) {
|
|
9472
|
-
if (
|
|
9473
|
-
return
|
|
9598
|
+
if (import_ts_morph42.Node.isTrueLiteral(value) || import_ts_morph42.Node.isFalseLiteral(value)) {
|
|
9599
|
+
return import_ts_morph42.Node.isTrueLiteral(value);
|
|
9474
9600
|
}
|
|
9475
|
-
return
|
|
9601
|
+
return import_ts_morph42.Node.isNumericLiteral(value) ? value.getLiteralValue() !== 0 : null;
|
|
9476
9602
|
}
|
|
9477
9603
|
function unquoted(name) {
|
|
9478
9604
|
return name.replace(/^["']|["']$/g, "");
|
|
9479
9605
|
}
|
|
9480
9606
|
function selectorReadsOf(argument) {
|
|
9481
|
-
if (argument === void 0 || !
|
|
9607
|
+
if (argument === void 0 || !import_ts_morph42.Node.isArrowFunction(argument) && !import_ts_morph42.Node.isFunctionExpression(argument)) {
|
|
9482
9608
|
return null;
|
|
9483
9609
|
}
|
|
9484
9610
|
const parameter = argument.getParameters()[0];
|
|
9485
|
-
if (parameter === void 0 || !
|
|
9611
|
+
if (parameter === void 0 || !import_ts_morph42.Node.isIdentifier(parameter.getNameNode())) {
|
|
9486
9612
|
return null;
|
|
9487
9613
|
}
|
|
9488
9614
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -9499,17 +9625,17 @@ function opsOverCall(value, resolve2) {
|
|
|
9499
9625
|
return callOpsFor(written, resolve2);
|
|
9500
9626
|
}
|
|
9501
9627
|
function isCalled(value) {
|
|
9502
|
-
return
|
|
9628
|
+
return import_ts_morph42.Node.isCallExpression(value) || import_ts_morph42.Node.isNewExpression(value) || import_ts_morph42.Node.isTaggedTemplateExpression(value);
|
|
9503
9629
|
}
|
|
9504
9630
|
function calleeOf3(call) {
|
|
9505
|
-
return
|
|
9631
|
+
return import_ts_morph42.Node.isTaggedTemplateExpression(call) ? call.getTag() : call.getExpression();
|
|
9506
9632
|
}
|
|
9507
9633
|
function argumentsIn(call) {
|
|
9508
|
-
return
|
|
9634
|
+
return import_ts_morph42.Node.isTaggedTemplateExpression(call) ? [call.getTemplate()] : call.getArguments();
|
|
9509
9635
|
}
|
|
9510
9636
|
function settled(value, resolve2) {
|
|
9511
9637
|
const step = unwrapped(value ?? null);
|
|
9512
|
-
if (step === null || !
|
|
9638
|
+
if (step === null || !import_ts_morph42.Node.isIdentifier(step)) {
|
|
9513
9639
|
return step;
|
|
9514
9640
|
}
|
|
9515
9641
|
return unwrapped(resolve2(step));
|
|
@@ -9536,11 +9662,11 @@ function objectAt(argument, resolve2) {
|
|
|
9536
9662
|
if (isCalled(written)) {
|
|
9537
9663
|
return objectAt(argumentsIn(written)[0], resolve2);
|
|
9538
9664
|
}
|
|
9539
|
-
return
|
|
9665
|
+
return import_ts_morph42.Node.isObjectLiteralExpression(written) ? written : null;
|
|
9540
9666
|
}
|
|
9541
9667
|
function initializerOf(object, property) {
|
|
9542
9668
|
for (const written of object.getProperties()) {
|
|
9543
|
-
if (
|
|
9669
|
+
if (import_ts_morph42.Node.isPropertyAssignment(written) && written.getName() === property) {
|
|
9544
9670
|
return written.getInitializer() ?? null;
|
|
9545
9671
|
}
|
|
9546
9672
|
}
|
|
@@ -9570,7 +9696,7 @@ function invocationContextFor(call, resolveWrittenValue, originatesFrom, anchorC
|
|
|
9570
9696
|
};
|
|
9571
9697
|
}
|
|
9572
9698
|
function isImportedFrom(identifier, expectedModule, originatesFrom) {
|
|
9573
|
-
if (!
|
|
9699
|
+
if (!import_ts_morph43.Node.isIdentifier(identifier)) {
|
|
9574
9700
|
return false;
|
|
9575
9701
|
}
|
|
9576
9702
|
const symbol = identifier.getSymbol();
|
|
@@ -9591,7 +9717,7 @@ function isImportedFrom(identifier, expectedModule, originatesFrom) {
|
|
|
9591
9717
|
);
|
|
9592
9718
|
}
|
|
9593
9719
|
function methodDeclaredIn(callee, expectedModule, resolve2, originatesFrom) {
|
|
9594
|
-
if (!
|
|
9720
|
+
if (!import_ts_morph43.Node.isPropertyAccessExpression(callee)) {
|
|
9595
9721
|
return false;
|
|
9596
9722
|
}
|
|
9597
9723
|
const declarations = callee.getNameNode().getSymbol()?.getDeclarations();
|
|
@@ -9611,37 +9737,37 @@ function maker(written) {
|
|
|
9611
9737
|
if (written === null) {
|
|
9612
9738
|
return null;
|
|
9613
9739
|
}
|
|
9614
|
-
if (
|
|
9740
|
+
if (import_ts_morph43.Node.isNewExpression(written) || import_ts_morph43.Node.isCallExpression(written)) {
|
|
9615
9741
|
return written.getExpression();
|
|
9616
9742
|
}
|
|
9617
9743
|
return null;
|
|
9618
9744
|
}
|
|
9619
9745
|
function rootIdentifier2(expression) {
|
|
9620
9746
|
let root = expression;
|
|
9621
|
-
while (
|
|
9747
|
+
while (import_ts_morph43.Node.isPropertyAccessExpression(root)) {
|
|
9622
9748
|
root = root.getExpression();
|
|
9623
9749
|
}
|
|
9624
9750
|
return root;
|
|
9625
9751
|
}
|
|
9626
9752
|
function importSpecifierMatches(decl, expectedModule) {
|
|
9627
|
-
if (
|
|
9753
|
+
if (import_ts_morph43.Node.isImportSpecifier(decl)) {
|
|
9628
9754
|
return decl.getImportDeclaration().getModuleSpecifierValue() === expectedModule;
|
|
9629
9755
|
}
|
|
9630
|
-
const owner =
|
|
9631
|
-
if (!
|
|
9756
|
+
const owner = import_ts_morph43.Node.isNamespaceImport(decl) ? decl.getParent() : decl;
|
|
9757
|
+
if (!import_ts_morph43.Node.isImportClause(owner)) {
|
|
9632
9758
|
return false;
|
|
9633
9759
|
}
|
|
9634
9760
|
const importDecl = owner.getParent();
|
|
9635
|
-
return
|
|
9761
|
+
return import_ts_morph43.Node.isImportDeclaration(importDecl) && importDecl.getModuleSpecifierValue() === expectedModule;
|
|
9636
9762
|
}
|
|
9637
9763
|
function extractInvocationEffects(func, barriers = NO_BARRIERS) {
|
|
9638
9764
|
const calls = [];
|
|
9639
9765
|
func.forEachDescendant((node, traversal) => {
|
|
9640
|
-
if (isDescentStop(node, func, barriers) ||
|
|
9766
|
+
if (isDescentStop(node, func, barriers) || import_ts_morph43.Node.isDecorator(node)) {
|
|
9641
9767
|
traversal.skip();
|
|
9642
9768
|
return;
|
|
9643
9769
|
}
|
|
9644
|
-
if (
|
|
9770
|
+
if (import_ts_morph43.Node.isCallExpression(node)) {
|
|
9645
9771
|
calls.push(node);
|
|
9646
9772
|
}
|
|
9647
9773
|
});
|
|
@@ -9665,10 +9791,10 @@ function invocationAt(call, func) {
|
|
|
9665
9791
|
}
|
|
9666
9792
|
function isAwaited(call) {
|
|
9667
9793
|
let current2 = call.getParent();
|
|
9668
|
-
while (current2 !== void 0 &&
|
|
9794
|
+
while (current2 !== void 0 && import_ts_morph43.Node.isParenthesizedExpression(current2)) {
|
|
9669
9795
|
current2 = current2.getParent();
|
|
9670
9796
|
}
|
|
9671
|
-
return current2 !== void 0 &&
|
|
9797
|
+
return current2 !== void 0 && import_ts_morph43.Node.isAwaitExpression(current2);
|
|
9672
9798
|
}
|
|
9673
9799
|
function runInvocationRecognizers(func, recognizers, barriers = NO_BARRIERS, resolveWrittenValue, originatesFrom, anchorCallsOf) {
|
|
9674
9800
|
if (recognizers.length === 0) {
|
|
@@ -9681,7 +9807,7 @@ function runInvocationRecognizers(func, recognizers, barriers = NO_BARRIERS, res
|
|
|
9681
9807
|
traversal.skip();
|
|
9682
9808
|
return;
|
|
9683
9809
|
}
|
|
9684
|
-
if (!
|
|
9810
|
+
if (!import_ts_morph43.Node.isCallExpression(node)) {
|
|
9685
9811
|
return;
|
|
9686
9812
|
}
|
|
9687
9813
|
const ctx = invocationContextFor(
|
|
@@ -9743,7 +9869,7 @@ function runAccessRecognizersAtModuleScope(sourceFile, recognizers, resolveWritt
|
|
|
9743
9869
|
}
|
|
9744
9870
|
function accessContextFor(node, sourceFile, resolveWrittenValue = () => null, originatesFrom, anchorCallsOf) {
|
|
9745
9871
|
const given = { access: node, sourceFile, resolveWrittenValue };
|
|
9746
|
-
if (
|
|
9872
|
+
if (import_ts_morph43.Node.isPropertyAccessExpression(node)) {
|
|
9747
9873
|
return given;
|
|
9748
9874
|
}
|
|
9749
9875
|
let ops;
|
|
@@ -9772,7 +9898,7 @@ function dispatchAccessRecognizers(root, recognizers, isStop, resolveWrittenValu
|
|
|
9772
9898
|
traversal.skip();
|
|
9773
9899
|
return;
|
|
9774
9900
|
}
|
|
9775
|
-
if (!
|
|
9901
|
+
if (!import_ts_morph43.Node.isPropertyAccessExpression(node) && !import_ts_morph43.Node.isCallExpression(node) && !import_ts_morph43.Node.isTaggedTemplateExpression(node)) {
|
|
9776
9902
|
return;
|
|
9777
9903
|
}
|
|
9778
9904
|
const ctx = accessContextFor(
|
|
@@ -9828,35 +9954,35 @@ function extractArg(node, depth) {
|
|
|
9828
9954
|
return extractArg(bare, depth);
|
|
9829
9955
|
}
|
|
9830
9956
|
}
|
|
9831
|
-
if (
|
|
9957
|
+
if (import_ts_morph43.Node.isStringLiteral(node) || import_ts_morph43.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
9832
9958
|
return { kind: "string", value: node.getLiteralValue() };
|
|
9833
9959
|
}
|
|
9834
|
-
if (
|
|
9960
|
+
if (import_ts_morph43.Node.isNumericLiteral(node)) {
|
|
9835
9961
|
return { kind: "number", value: node.getLiteralValue() };
|
|
9836
9962
|
}
|
|
9837
|
-
if (
|
|
9963
|
+
if (import_ts_morph43.Node.isTrueLiteral(node)) {
|
|
9838
9964
|
return { kind: "boolean", value: true };
|
|
9839
9965
|
}
|
|
9840
|
-
if (
|
|
9966
|
+
if (import_ts_morph43.Node.isFalseLiteral(node)) {
|
|
9841
9967
|
return { kind: "boolean", value: false };
|
|
9842
9968
|
}
|
|
9843
|
-
if (
|
|
9969
|
+
if (import_ts_morph43.Node.isTemplateExpression(node)) {
|
|
9844
9970
|
return { kind: "template", sourceText: node.getText() };
|
|
9845
9971
|
}
|
|
9846
|
-
if (
|
|
9972
|
+
if (import_ts_morph43.Node.isIdentifier(node)) {
|
|
9847
9973
|
const inlined = inlineModuleBinding(node, depth);
|
|
9848
9974
|
if (inlined !== null) {
|
|
9849
9975
|
return inlined;
|
|
9850
9976
|
}
|
|
9851
9977
|
return { kind: "identifier", name: node.getText() };
|
|
9852
9978
|
}
|
|
9853
|
-
if (
|
|
9979
|
+
if (import_ts_morph43.Node.isPropertyAccessExpression(node) || import_ts_morph43.Node.isElementAccessExpression(node)) {
|
|
9854
9980
|
return { kind: "identifier", name: node.getText() };
|
|
9855
9981
|
}
|
|
9856
9982
|
if (depth <= 0) {
|
|
9857
9983
|
return null;
|
|
9858
9984
|
}
|
|
9859
|
-
if (
|
|
9985
|
+
if (import_ts_morph43.Node.isCallExpression(node)) {
|
|
9860
9986
|
const element = mapCallbackReturn(node);
|
|
9861
9987
|
if (element !== null) {
|
|
9862
9988
|
return { kind: "array", items: [extractArg(element, depth - 1)] };
|
|
@@ -9867,19 +9993,19 @@ function extractArg(node, depth) {
|
|
|
9867
9993
|
args: node.getArguments().map((a) => extractArg(a, depth - 1))
|
|
9868
9994
|
};
|
|
9869
9995
|
}
|
|
9870
|
-
if (
|
|
9996
|
+
if (import_ts_morph43.Node.isNewExpression(node)) {
|
|
9871
9997
|
return {
|
|
9872
9998
|
kind: "call",
|
|
9873
9999
|
callee: node.getExpression().getText(),
|
|
9874
10000
|
args: node.getArguments().map((a) => extractArg(a, depth - 1))
|
|
9875
10001
|
};
|
|
9876
10002
|
}
|
|
9877
|
-
if (
|
|
10003
|
+
if (import_ts_morph43.Node.isObjectLiteralExpression(node)) {
|
|
9878
10004
|
const fields = {};
|
|
9879
10005
|
for (const prop of node.getProperties()) {
|
|
9880
|
-
if (
|
|
10006
|
+
if (import_ts_morph43.Node.isShorthandPropertyAssignment(prop)) {
|
|
9881
10007
|
const nameNode2 = prop.getNameNode();
|
|
9882
|
-
if (
|
|
10008
|
+
if (import_ts_morph43.Node.isIdentifier(nameNode2)) {
|
|
9883
10009
|
fields[nameNode2.getText()] = {
|
|
9884
10010
|
kind: "identifier",
|
|
9885
10011
|
name: nameNode2.getText()
|
|
@@ -9887,14 +10013,14 @@ function extractArg(node, depth) {
|
|
|
9887
10013
|
}
|
|
9888
10014
|
continue;
|
|
9889
10015
|
}
|
|
9890
|
-
if (!
|
|
10016
|
+
if (!import_ts_morph43.Node.isPropertyAssignment(prop)) {
|
|
9891
10017
|
continue;
|
|
9892
10018
|
}
|
|
9893
10019
|
const nameNode = prop.getNameNode();
|
|
9894
|
-
if (!
|
|
10020
|
+
if (!import_ts_morph43.Node.isIdentifier(nameNode) && !import_ts_morph43.Node.isStringLiteral(nameNode) && !import_ts_morph43.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
9895
10021
|
continue;
|
|
9896
10022
|
}
|
|
9897
|
-
const name =
|
|
10023
|
+
const name = import_ts_morph43.Node.isIdentifier(nameNode) ? nameNode.getText() : nameNode.getLiteralValue();
|
|
9898
10024
|
const initializer = prop.getInitializer();
|
|
9899
10025
|
if (initializer === void 0) {
|
|
9900
10026
|
continue;
|
|
@@ -9903,7 +10029,7 @@ function extractArg(node, depth) {
|
|
|
9903
10029
|
}
|
|
9904
10030
|
return { kind: "object", fields };
|
|
9905
10031
|
}
|
|
9906
|
-
if (
|
|
10032
|
+
if (import_ts_morph43.Node.isArrayLiteralExpression(node)) {
|
|
9907
10033
|
const items = node.getElements().map((el) => extractArg(el, depth - 1));
|
|
9908
10034
|
return { kind: "array", items };
|
|
9909
10035
|
}
|
|
@@ -9911,20 +10037,20 @@ function extractArg(node, depth) {
|
|
|
9911
10037
|
}
|
|
9912
10038
|
function mapCallbackReturn(call) {
|
|
9913
10039
|
const callee = call.getExpression();
|
|
9914
|
-
if (!
|
|
10040
|
+
if (!import_ts_morph43.Node.isPropertyAccessExpression(callee) || callee.getName() !== "map") {
|
|
9915
10041
|
return null;
|
|
9916
10042
|
}
|
|
9917
10043
|
const callback = call.getArguments()[0];
|
|
9918
|
-
if (callback === void 0 || !(
|
|
10044
|
+
if (callback === void 0 || !(import_ts_morph43.Node.isArrowFunction(callback) || import_ts_morph43.Node.isFunctionExpression(callback))) {
|
|
9919
10045
|
return null;
|
|
9920
10046
|
}
|
|
9921
10047
|
const body = callback.getBody();
|
|
9922
|
-
if (!
|
|
10048
|
+
if (!import_ts_morph43.Node.isBlock(body)) {
|
|
9923
10049
|
return body;
|
|
9924
10050
|
}
|
|
9925
10051
|
const statements = body.getStatements();
|
|
9926
10052
|
const only = statements.length === 1 ? statements[0] : void 0;
|
|
9927
|
-
return only !== void 0 &&
|
|
10053
|
+
return only !== void 0 && import_ts_morph43.Node.isReturnStatement(only) ? only.getExpression() ?? null : null;
|
|
9928
10054
|
}
|
|
9929
10055
|
function collectPreconditions(node, root) {
|
|
9930
10056
|
return collectAncestorConditionInfosBelow(node, root).map(
|
|
@@ -9935,7 +10061,7 @@ function runsOnEveryPath(node, root) {
|
|
|
9935
10061
|
let current2 = node;
|
|
9936
10062
|
while (current2 !== void 0 && current2 !== root) {
|
|
9937
10063
|
const parent = current2.getParent();
|
|
9938
|
-
if (parent !== void 0 &&
|
|
10064
|
+
if (parent !== void 0 && import_ts_morph43.Node.isTryStatement(parent) && parent.getFinallyBlock() === current2) {
|
|
9939
10065
|
return true;
|
|
9940
10066
|
}
|
|
9941
10067
|
current2 = parent;
|
|
@@ -9958,7 +10084,7 @@ function withPreconditions(effect, preconditions) {
|
|
|
9958
10084
|
};
|
|
9959
10085
|
}
|
|
9960
10086
|
function inlineModuleBinding(ident, depth) {
|
|
9961
|
-
if (!
|
|
10087
|
+
if (!import_ts_morph43.Node.isIdentifier(ident)) {
|
|
9962
10088
|
return null;
|
|
9963
10089
|
}
|
|
9964
10090
|
const symbol = ident.getSymbol();
|
|
@@ -9966,7 +10092,7 @@ function inlineModuleBinding(ident, depth) {
|
|
|
9966
10092
|
return null;
|
|
9967
10093
|
}
|
|
9968
10094
|
for (const decl of symbol.getDeclarations()) {
|
|
9969
|
-
if (!
|
|
10095
|
+
if (!import_ts_morph43.Node.isVariableDeclaration(decl)) {
|
|
9970
10096
|
continue;
|
|
9971
10097
|
}
|
|
9972
10098
|
if (!isModuleScoped(decl)) {
|
|
@@ -9987,10 +10113,10 @@ function inlineModuleBinding(ident, depth) {
|
|
|
9987
10113
|
function isModuleScoped(decl) {
|
|
9988
10114
|
let current2 = decl.getParent();
|
|
9989
10115
|
while (current2 !== void 0) {
|
|
9990
|
-
if (
|
|
10116
|
+
if (import_ts_morph43.Node.isSourceFile(current2)) {
|
|
9991
10117
|
return true;
|
|
9992
10118
|
}
|
|
9993
|
-
if (
|
|
10119
|
+
if (import_ts_morph43.Node.isVariableDeclarationList(current2) || import_ts_morph43.Node.isVariableStatement(current2)) {
|
|
9994
10120
|
current2 = current2.getParent();
|
|
9995
10121
|
continue;
|
|
9996
10122
|
}
|
|
@@ -10004,7 +10130,7 @@ function unwrapCasts(node) {
|
|
|
10004
10130
|
function enclosingStatementLine(node) {
|
|
10005
10131
|
let current2 = node;
|
|
10006
10132
|
while (current2 !== void 0) {
|
|
10007
|
-
if (
|
|
10133
|
+
if (import_ts_morph43.Node.isStatement(current2)) {
|
|
10008
10134
|
return startLineOf(current2);
|
|
10009
10135
|
}
|
|
10010
10136
|
current2 = current2.getParent();
|
|
@@ -10013,19 +10139,19 @@ function enclosingStatementLine(node) {
|
|
|
10013
10139
|
}
|
|
10014
10140
|
|
|
10015
10141
|
// src/terminals/index.ts
|
|
10016
|
-
var
|
|
10142
|
+
var import_ts_morph54 = require("ts-morph");
|
|
10017
10143
|
|
|
10018
10144
|
// src/terminals/continuation.ts
|
|
10019
|
-
var
|
|
10145
|
+
var import_ts_morph45 = require("ts-morph");
|
|
10020
10146
|
|
|
10021
10147
|
// src/terminals/shared.ts
|
|
10022
|
-
var
|
|
10148
|
+
var import_ts_morph44 = require("ts-morph");
|
|
10023
10149
|
function parameterPositionOf(identifier, func) {
|
|
10024
|
-
if (!
|
|
10150
|
+
if (!import_ts_morph44.Node.isIdentifier(identifier)) {
|
|
10025
10151
|
return null;
|
|
10026
10152
|
}
|
|
10027
10153
|
const declaration = identifier.getSymbol()?.getDeclarations()[0];
|
|
10028
|
-
if (declaration === void 0 || !
|
|
10154
|
+
if (declaration === void 0 || !import_ts_morph44.Node.isParameterDeclaration(declaration)) {
|
|
10029
10155
|
return null;
|
|
10030
10156
|
}
|
|
10031
10157
|
const params = func.getParameters();
|
|
@@ -10042,17 +10168,17 @@ function returnPositionOf(value) {
|
|
|
10042
10168
|
if (parent === void 0) {
|
|
10043
10169
|
return null;
|
|
10044
10170
|
}
|
|
10045
|
-
if (
|
|
10171
|
+
if (import_ts_morph44.Node.isReturnStatement(parent)) {
|
|
10046
10172
|
return parent;
|
|
10047
10173
|
}
|
|
10048
|
-
if (
|
|
10174
|
+
if (import_ts_morph44.Node.isArrowFunction(parent)) {
|
|
10049
10175
|
return parent.getBody() === current2 ? current2 : null;
|
|
10050
10176
|
}
|
|
10051
10177
|
if (passesValueThrough(parent)) {
|
|
10052
10178
|
current2 = parent;
|
|
10053
10179
|
continue;
|
|
10054
10180
|
}
|
|
10055
|
-
if (
|
|
10181
|
+
if (import_ts_morph44.Node.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
|
|
10056
10182
|
current2 = parent;
|
|
10057
10183
|
continue;
|
|
10058
10184
|
}
|
|
@@ -10062,7 +10188,7 @@ function returnPositionOf(value) {
|
|
|
10062
10188
|
|
|
10063
10189
|
// src/terminals/continuation.ts
|
|
10064
10190
|
function tryMatchParameterCall(node, func, pattern, match) {
|
|
10065
|
-
if (!
|
|
10191
|
+
if (!import_ts_morph45.Node.isCallExpression(node)) {
|
|
10066
10192
|
return null;
|
|
10067
10193
|
}
|
|
10068
10194
|
const callee = node.getExpression();
|
|
@@ -10085,15 +10211,15 @@ function tryMatchParameterCall(node, func, pattern, match) {
|
|
|
10085
10211
|
}
|
|
10086
10212
|
|
|
10087
10213
|
// src/terminals/extract.ts
|
|
10088
|
-
var
|
|
10214
|
+
var import_ts_morph48 = require("ts-morph");
|
|
10089
10215
|
var import_values5 = require("@suss/values");
|
|
10090
10216
|
|
|
10091
10217
|
// src/shapes/shapes.ts
|
|
10092
|
-
var
|
|
10218
|
+
var import_ts_morph47 = require("ts-morph");
|
|
10093
10219
|
|
|
10094
10220
|
// src/shapes/typeShapes.ts
|
|
10095
10221
|
var import_node_crypto = require("crypto");
|
|
10096
|
-
var
|
|
10222
|
+
var import_ts_morph46 = require("ts-morph");
|
|
10097
10223
|
|
|
10098
10224
|
// src/shapes/definitions.ts
|
|
10099
10225
|
var current = null;
|
|
@@ -10444,7 +10570,7 @@ function refFromType(type, ctx) {
|
|
|
10444
10570
|
}
|
|
10445
10571
|
return { type: "ref", name: withoutImportQualifiers(type.getText()) };
|
|
10446
10572
|
}
|
|
10447
|
-
var PRINTED_NAME_FLAGS =
|
|
10573
|
+
var PRINTED_NAME_FLAGS = import_ts_morph46.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | import_ts_morph46.TypeFormatFlags.UseTypeOfFunction | import_ts_morph46.TypeFormatFlags.NoTruncation | import_ts_morph46.TypeFormatFlags.WriteTypeArgumentsOfSignature;
|
|
10448
10574
|
function printedTypeName(type, ctx) {
|
|
10449
10575
|
return withoutImportQualifiers(
|
|
10450
10576
|
type.getText(ctx.enclosing, PRINTED_NAME_FLAGS)
|
|
@@ -10554,60 +10680,60 @@ function extractShapeWithArguments(node, substitutions) {
|
|
|
10554
10680
|
}
|
|
10555
10681
|
function extractShapeInner(node) {
|
|
10556
10682
|
const unwrapped2 = peelSyntax(node);
|
|
10557
|
-
if (boundArguments !== null &&
|
|
10683
|
+
if (boundArguments !== null && import_ts_morph47.Node.isIdentifier(unwrapped2)) {
|
|
10558
10684
|
const argument = boundArguments.get(unwrapped2.getText());
|
|
10559
10685
|
if (argument !== void 0 && argument !== unwrapped2) {
|
|
10560
10686
|
return extractShape(argument);
|
|
10561
10687
|
}
|
|
10562
10688
|
}
|
|
10563
|
-
if (
|
|
10689
|
+
if (import_ts_morph47.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
10564
10690
|
return shapeFromObjectLiteral(unwrapped2);
|
|
10565
10691
|
}
|
|
10566
|
-
if (
|
|
10692
|
+
if (import_ts_morph47.Node.isArrayLiteralExpression(unwrapped2)) {
|
|
10567
10693
|
return shapeFromArrayLiteral(unwrapped2);
|
|
10568
10694
|
}
|
|
10569
|
-
if (
|
|
10695
|
+
if (import_ts_morph47.Node.isStringLiteral(unwrapped2) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
10570
10696
|
return { type: "literal", value: unwrapped2.getLiteralValue() };
|
|
10571
10697
|
}
|
|
10572
|
-
if (
|
|
10698
|
+
if (import_ts_morph47.Node.isTemplateExpression(unwrapped2)) {
|
|
10573
10699
|
return { type: "text" };
|
|
10574
10700
|
}
|
|
10575
|
-
if (
|
|
10701
|
+
if (import_ts_morph47.Node.isNumericLiteral(unwrapped2)) {
|
|
10576
10702
|
return numericLiteralShape(
|
|
10577
10703
|
unwrapped2.getLiteralValue(),
|
|
10578
10704
|
unwrapped2.getText()
|
|
10579
10705
|
);
|
|
10580
10706
|
}
|
|
10581
|
-
if (
|
|
10707
|
+
if (import_ts_morph47.Node.isPrefixUnaryExpression(unwrapped2)) {
|
|
10582
10708
|
const op = unwrapped2.getOperatorToken();
|
|
10583
|
-
if (op ===
|
|
10709
|
+
if (op === import_ts_morph47.SyntaxKind.MinusToken || op === import_ts_morph47.SyntaxKind.PlusToken) {
|
|
10584
10710
|
const inner = unwrapped2.getOperand();
|
|
10585
|
-
if (
|
|
10711
|
+
if (import_ts_morph47.Node.isNumericLiteral(inner)) {
|
|
10586
10712
|
const v3 = inner.getLiteralValue();
|
|
10587
|
-
const signed = op ===
|
|
10713
|
+
const signed = op === import_ts_morph47.SyntaxKind.MinusToken ? -v3 : v3;
|
|
10588
10714
|
const rawBody = inner.getText();
|
|
10589
|
-
const raw = op ===
|
|
10715
|
+
const raw = op === import_ts_morph47.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
|
|
10590
10716
|
return numericLiteralShape(signed, raw);
|
|
10591
10717
|
}
|
|
10592
10718
|
}
|
|
10593
10719
|
}
|
|
10594
|
-
if (
|
|
10720
|
+
if (import_ts_morph47.Node.isBigIntLiteral(unwrapped2)) {
|
|
10595
10721
|
return { type: "ref", name: "bigint" };
|
|
10596
10722
|
}
|
|
10597
10723
|
const kind = unwrapped2.getKind();
|
|
10598
|
-
if (kind ===
|
|
10724
|
+
if (kind === import_ts_morph47.SyntaxKind.TrueKeyword) {
|
|
10599
10725
|
return { type: "literal", value: true };
|
|
10600
10726
|
}
|
|
10601
|
-
if (kind ===
|
|
10727
|
+
if (kind === import_ts_morph47.SyntaxKind.FalseKeyword) {
|
|
10602
10728
|
return { type: "literal", value: false };
|
|
10603
10729
|
}
|
|
10604
|
-
if (kind ===
|
|
10730
|
+
if (kind === import_ts_morph47.SyntaxKind.NullKeyword) {
|
|
10605
10731
|
return { type: "null" };
|
|
10606
10732
|
}
|
|
10607
|
-
if (
|
|
10733
|
+
if (import_ts_morph47.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
|
|
10608
10734
|
return { type: "undefined" };
|
|
10609
10735
|
}
|
|
10610
|
-
if (
|
|
10736
|
+
if (import_ts_morph47.Node.isConditionalExpression(unwrapped2)) {
|
|
10611
10737
|
const whenTrue = extractShape(unwrapped2.getWhenTrue());
|
|
10612
10738
|
const whenFalse = extractShape(unwrapped2.getWhenFalse());
|
|
10613
10739
|
const variants = [];
|
|
@@ -10638,7 +10764,7 @@ function shapeFromArrayLiteral(arr) {
|
|
|
10638
10764
|
}
|
|
10639
10765
|
const shapes = [];
|
|
10640
10766
|
for (const el of elements) {
|
|
10641
|
-
if (
|
|
10767
|
+
if (import_ts_morph47.Node.isSpreadElement(el)) {
|
|
10642
10768
|
const inner = el.getExpression();
|
|
10643
10769
|
const innerShape = extractShape(inner);
|
|
10644
10770
|
if (innerShape?.type === "array") {
|
|
@@ -10657,7 +10783,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10657
10783
|
const properties = {};
|
|
10658
10784
|
const unresolvedSpreads = [];
|
|
10659
10785
|
for (const prop of obj.getProperties()) {
|
|
10660
|
-
if (
|
|
10786
|
+
if (import_ts_morph47.Node.isPropertyAssignment(prop)) {
|
|
10661
10787
|
const name = propertyName2(prop);
|
|
10662
10788
|
if (name === null) {
|
|
10663
10789
|
continue;
|
|
@@ -10673,7 +10799,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10673
10799
|
};
|
|
10674
10800
|
continue;
|
|
10675
10801
|
}
|
|
10676
|
-
if (
|
|
10802
|
+
if (import_ts_morph47.Node.isShorthandPropertyAssignment(prop)) {
|
|
10677
10803
|
const name = prop.getName();
|
|
10678
10804
|
const valueExpr = prop.getNameNode();
|
|
10679
10805
|
properties[name] = extractShape(valueExpr) ?? {
|
|
@@ -10682,7 +10808,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10682
10808
|
};
|
|
10683
10809
|
continue;
|
|
10684
10810
|
}
|
|
10685
|
-
if (
|
|
10811
|
+
if (import_ts_morph47.Node.isSpreadAssignment(prop)) {
|
|
10686
10812
|
const expr = prop.getExpression();
|
|
10687
10813
|
const spreadShape = extractShape(expr);
|
|
10688
10814
|
if (spreadShape?.type === "record") {
|
|
@@ -10701,7 +10827,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
10701
10827
|
}
|
|
10702
10828
|
function propertyName2(prop) {
|
|
10703
10829
|
const nameNode = prop.getNameNode();
|
|
10704
|
-
if (
|
|
10830
|
+
if (import_ts_morph47.Node.isIdentifier(nameNode) || import_ts_morph47.Node.isStringLiteral(nameNode) || import_ts_morph47.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph47.Node.isNumericLiteral(nameNode)) {
|
|
10705
10831
|
return nameNode.getText().replace(/^["']|["']$/g, "");
|
|
10706
10832
|
}
|
|
10707
10833
|
return null;
|
|
@@ -10732,15 +10858,15 @@ function unwrapAs(node) {
|
|
|
10732
10858
|
}
|
|
10733
10859
|
function unwrapJsonStringify(node) {
|
|
10734
10860
|
const outer = unwrapAs(node);
|
|
10735
|
-
if (!
|
|
10861
|
+
if (!import_ts_morph48.Node.isCallExpression(outer)) {
|
|
10736
10862
|
return node;
|
|
10737
10863
|
}
|
|
10738
10864
|
const callee = outer.getExpression();
|
|
10739
|
-
if (!
|
|
10865
|
+
if (!import_ts_morph48.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
|
|
10740
10866
|
return node;
|
|
10741
10867
|
}
|
|
10742
10868
|
const receiver = callee.getExpression();
|
|
10743
|
-
if (!
|
|
10869
|
+
if (!import_ts_morph48.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
|
|
10744
10870
|
return node;
|
|
10745
10871
|
}
|
|
10746
10872
|
const args = outer.getArguments();
|
|
@@ -10750,7 +10876,7 @@ function unwrapJsonStringify(node) {
|
|
|
10750
10876
|
return unwrapAs(args[0]);
|
|
10751
10877
|
}
|
|
10752
10878
|
function substituted(value, ctx) {
|
|
10753
|
-
if (ctx.substitutions === void 0 || !
|
|
10879
|
+
if (ctx.substitutions === void 0 || !import_ts_morph48.Node.isIdentifier(value)) {
|
|
10754
10880
|
return value;
|
|
10755
10881
|
}
|
|
10756
10882
|
return ctx.substitutions.get(value.getText()) ?? value;
|
|
@@ -10794,10 +10920,10 @@ function statusFromProperty(obj, name, ctx) {
|
|
|
10794
10920
|
if (prop === void 0) {
|
|
10795
10921
|
return null;
|
|
10796
10922
|
}
|
|
10797
|
-
if (
|
|
10923
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
10798
10924
|
return { type: "dynamic", sourceText: prop.getName() };
|
|
10799
10925
|
}
|
|
10800
|
-
if (!
|
|
10926
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
10801
10927
|
return null;
|
|
10802
10928
|
}
|
|
10803
10929
|
const value = prop.getInitializer();
|
|
@@ -10820,7 +10946,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10820
10946
|
return null;
|
|
10821
10947
|
}
|
|
10822
10948
|
const first = ctx.throwCallArgs?.[0];
|
|
10823
|
-
if (first !== void 0 &&
|
|
10949
|
+
if (first !== void 0 && import_ts_morph48.Node.isNumericLiteral(first)) {
|
|
10824
10950
|
const value = first.getLiteralValue();
|
|
10825
10951
|
if (value >= 100 && value <= 599) {
|
|
10826
10952
|
return { type: "literal", value };
|
|
@@ -10833,7 +10959,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10833
10959
|
return null;
|
|
10834
10960
|
}
|
|
10835
10961
|
const arg = ctx.throwCallArgs[sc.position];
|
|
10836
|
-
if (arg === void 0 || !
|
|
10962
|
+
if (arg === void 0 || !import_ts_morph48.Node.isNewExpression(arg)) {
|
|
10837
10963
|
return null;
|
|
10838
10964
|
}
|
|
10839
10965
|
const ctorText = arg.getExpression().getText();
|
|
@@ -10842,7 +10968,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10842
10968
|
if (sc.from === "argumentProperty") {
|
|
10843
10969
|
const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
|
|
10844
10970
|
const arg = args?.[sc.position];
|
|
10845
|
-
if (arg === void 0 || !
|
|
10971
|
+
if (arg === void 0 || !import_ts_morph48.Node.isObjectLiteralExpression(arg)) {
|
|
10846
10972
|
return null;
|
|
10847
10973
|
}
|
|
10848
10974
|
return statusFromProperty(arg, sc.name, ctx);
|
|
@@ -10852,8 +10978,8 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
10852
10978
|
return null;
|
|
10853
10979
|
}
|
|
10854
10980
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
10855
|
-
if (!
|
|
10856
|
-
if (
|
|
10981
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
10982
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
10857
10983
|
if (prop.getName() === sc.name) {
|
|
10858
10984
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
10859
10985
|
if (resolved !== void 0) {
|
|
@@ -10911,8 +11037,8 @@ function extractBody(ctx) {
|
|
|
10911
11037
|
return null;
|
|
10912
11038
|
}
|
|
10913
11039
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
10914
|
-
if (!
|
|
10915
|
-
if (
|
|
11040
|
+
if (!import_ts_morph48.Node.isPropertyAssignment(prop)) {
|
|
11041
|
+
if (import_ts_morph48.Node.isShorthandPropertyAssignment(prop)) {
|
|
10916
11042
|
if (prop.getName() === b.name) {
|
|
10917
11043
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
10918
11044
|
if (resolved !== void 0) {
|
|
@@ -10967,16 +11093,16 @@ function extractBody(ctx) {
|
|
|
10967
11093
|
}
|
|
10968
11094
|
|
|
10969
11095
|
// src/terminals/jsx.ts
|
|
10970
|
-
var
|
|
11096
|
+
var import_ts_morph49 = require("ts-morph");
|
|
10971
11097
|
function tryMatchJsxReturn(node, pattern) {
|
|
10972
11098
|
let expr;
|
|
10973
11099
|
let source;
|
|
10974
|
-
if (
|
|
11100
|
+
if (import_ts_morph49.Node.isReturnStatement(node)) {
|
|
10975
11101
|
expr = node.getExpression();
|
|
10976
11102
|
source = node;
|
|
10977
|
-
} else if (
|
|
11103
|
+
} else if (import_ts_morph49.Node.isArrowFunction(node)) {
|
|
10978
11104
|
const body = node.getBody();
|
|
10979
|
-
if (body !== void 0 && !
|
|
11105
|
+
if (body !== void 0 && !import_ts_morph49.Node.isBlock(body)) {
|
|
10980
11106
|
expr = body;
|
|
10981
11107
|
source = body;
|
|
10982
11108
|
}
|
|
@@ -11007,14 +11133,14 @@ function tryMatchJsxReturn(node, pattern) {
|
|
|
11007
11133
|
return { node, source, terminal };
|
|
11008
11134
|
}
|
|
11009
11135
|
function componentTargetOf(tagNode) {
|
|
11010
|
-
if (!
|
|
11136
|
+
if (!import_ts_morph49.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
|
|
11011
11137
|
return null;
|
|
11012
11138
|
}
|
|
11013
11139
|
const target = functionTargetOf(tagNode);
|
|
11014
11140
|
return target === null ? null : { file: target.file, name: target.name };
|
|
11015
11141
|
}
|
|
11016
11142
|
function jsxToRenderNode(node) {
|
|
11017
|
-
if (
|
|
11143
|
+
if (import_ts_morph49.Node.isJsxElement(node)) {
|
|
11018
11144
|
const opening = node.getOpeningElement();
|
|
11019
11145
|
const tag = opening.getTagNameNode().getText();
|
|
11020
11146
|
const attrs = collectJsxAttributes(opening);
|
|
@@ -11028,7 +11154,7 @@ function jsxToRenderNode(node) {
|
|
|
11028
11154
|
...target !== null ? { target } : {}
|
|
11029
11155
|
};
|
|
11030
11156
|
}
|
|
11031
|
-
if (
|
|
11157
|
+
if (import_ts_morph49.Node.isJsxSelfClosingElement(node)) {
|
|
11032
11158
|
const tag = node.getTagNameNode().getText();
|
|
11033
11159
|
const attrs = collectJsxAttributes(node);
|
|
11034
11160
|
const target = componentTargetOf(node.getTagNameNode());
|
|
@@ -11040,11 +11166,11 @@ function jsxToRenderNode(node) {
|
|
|
11040
11166
|
...target !== null ? { target } : {}
|
|
11041
11167
|
};
|
|
11042
11168
|
}
|
|
11043
|
-
if (
|
|
11169
|
+
if (import_ts_morph49.Node.isJsxFragment(node)) {
|
|
11044
11170
|
const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
|
|
11045
11171
|
return { type: "element", tag: "Fragment", children };
|
|
11046
11172
|
}
|
|
11047
|
-
if (
|
|
11173
|
+
if (import_ts_morph49.Node.isParenthesizedExpression(node)) {
|
|
11048
11174
|
return jsxToRenderNode(node.getExpression());
|
|
11049
11175
|
}
|
|
11050
11176
|
return null;
|
|
@@ -11052,12 +11178,12 @@ function jsxToRenderNode(node) {
|
|
|
11052
11178
|
function collectJsxAttributes(opening) {
|
|
11053
11179
|
const entries = {};
|
|
11054
11180
|
for (const attr of opening.getAttributes()) {
|
|
11055
|
-
if (
|
|
11181
|
+
if (import_ts_morph49.Node.isJsxSpreadAttribute(attr)) {
|
|
11056
11182
|
const exprText = attr.getExpression().getText();
|
|
11057
11183
|
entries[`...${exprText}`] = exprText;
|
|
11058
11184
|
continue;
|
|
11059
11185
|
}
|
|
11060
|
-
if (!
|
|
11186
|
+
if (!import_ts_morph49.Node.isJsxAttribute(attr)) {
|
|
11061
11187
|
continue;
|
|
11062
11188
|
}
|
|
11063
11189
|
const name = attr.getNameNode().getText();
|
|
@@ -11066,7 +11192,7 @@ function collectJsxAttributes(opening) {
|
|
|
11066
11192
|
entries[name] = "";
|
|
11067
11193
|
continue;
|
|
11068
11194
|
}
|
|
11069
|
-
if (
|
|
11195
|
+
if (import_ts_morph49.Node.isJsxExpression(initializer)) {
|
|
11070
11196
|
const inner = initializer.getExpression();
|
|
11071
11197
|
entries[name] = inner !== void 0 ? inner.getText() : "";
|
|
11072
11198
|
continue;
|
|
@@ -11076,30 +11202,30 @@ function collectJsxAttributes(opening) {
|
|
|
11076
11202
|
return Object.keys(entries).length > 0 ? entries : null;
|
|
11077
11203
|
}
|
|
11078
11204
|
function jsxChildToRenderNode(child) {
|
|
11079
|
-
if (
|
|
11205
|
+
if (import_ts_morph49.Node.isJsxText(child)) {
|
|
11080
11206
|
const text = child.getLiteralText().trim();
|
|
11081
11207
|
if (text.length === 0) {
|
|
11082
11208
|
return null;
|
|
11083
11209
|
}
|
|
11084
11210
|
return { type: "text", value: text };
|
|
11085
11211
|
}
|
|
11086
|
-
if (
|
|
11212
|
+
if (import_ts_morph49.Node.isJsxExpression(child)) {
|
|
11087
11213
|
const inner = child.getExpression();
|
|
11088
11214
|
if (inner === void 0) {
|
|
11089
11215
|
return null;
|
|
11090
11216
|
}
|
|
11091
11217
|
return jsxExpressionToRenderNode(inner);
|
|
11092
11218
|
}
|
|
11093
|
-
if (
|
|
11219
|
+
if (import_ts_morph49.Node.isJsxElement(child) || import_ts_morph49.Node.isJsxSelfClosingElement(child) || import_ts_morph49.Node.isJsxFragment(child)) {
|
|
11094
11220
|
return jsxToRenderNode(child);
|
|
11095
11221
|
}
|
|
11096
11222
|
return null;
|
|
11097
11223
|
}
|
|
11098
11224
|
function jsxExpressionToRenderNode(expr) {
|
|
11099
|
-
if (
|
|
11225
|
+
if (import_ts_morph49.Node.isParenthesizedExpression(expr)) {
|
|
11100
11226
|
return jsxExpressionToRenderNode(expr.getExpression());
|
|
11101
11227
|
}
|
|
11102
|
-
if (
|
|
11228
|
+
if (import_ts_morph49.Node.isBinaryExpression(expr)) {
|
|
11103
11229
|
const op = expr.getOperatorToken().getText();
|
|
11104
11230
|
if (op === "&&") {
|
|
11105
11231
|
const right = renderAlternative(peelParens(expr.getRight()));
|
|
@@ -11113,7 +11239,7 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11113
11239
|
}
|
|
11114
11240
|
}
|
|
11115
11241
|
}
|
|
11116
|
-
if (
|
|
11242
|
+
if (import_ts_morph49.Node.isConditionalExpression(expr)) {
|
|
11117
11243
|
const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
|
|
11118
11244
|
const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
|
|
11119
11245
|
if (truthy.kind === "jsx") {
|
|
@@ -11136,16 +11262,16 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
11136
11262
|
return { type: "expression", sourceText: expr.getText() };
|
|
11137
11263
|
}
|
|
11138
11264
|
function renderAlternative(node) {
|
|
11139
|
-
if (
|
|
11265
|
+
if (import_ts_morph49.Node.isNullLiteral(node)) {
|
|
11140
11266
|
return { kind: "noRender" };
|
|
11141
11267
|
}
|
|
11142
|
-
if (
|
|
11268
|
+
if (import_ts_morph49.Node.isFalseLiteral(node)) {
|
|
11143
11269
|
return { kind: "noRender" };
|
|
11144
11270
|
}
|
|
11145
|
-
if (
|
|
11271
|
+
if (import_ts_morph49.Node.isIdentifier(node) && node.getText() === "undefined") {
|
|
11146
11272
|
return { kind: "noRender" };
|
|
11147
11273
|
}
|
|
11148
|
-
if (
|
|
11274
|
+
if (import_ts_morph49.Node.isJsxElement(node) || import_ts_morph49.Node.isJsxSelfClosingElement(node) || import_ts_morph49.Node.isJsxFragment(node)) {
|
|
11149
11275
|
const tree = jsxToRenderNode(node);
|
|
11150
11276
|
if (tree !== null) {
|
|
11151
11277
|
return { kind: "jsx", node: tree };
|
|
@@ -11155,13 +11281,13 @@ function renderAlternative(node) {
|
|
|
11155
11281
|
}
|
|
11156
11282
|
|
|
11157
11283
|
// src/terminals/returns.ts
|
|
11158
|
-
var
|
|
11284
|
+
var import_ts_morph52 = require("ts-morph");
|
|
11159
11285
|
|
|
11160
11286
|
// src/terminals/helperResolution.ts
|
|
11161
|
-
var
|
|
11287
|
+
var import_ts_morph50 = require("ts-morph");
|
|
11162
11288
|
function resolveHelperReturn(call, resolveCallee2) {
|
|
11163
11289
|
const callee = call.getExpression();
|
|
11164
|
-
if (!
|
|
11290
|
+
if (!import_ts_morph50.Node.isIdentifier(callee)) {
|
|
11165
11291
|
return { kind: "notLocal" };
|
|
11166
11292
|
}
|
|
11167
11293
|
const helper = memoizedLocalHelper(callee, resolveCallee2);
|
|
@@ -11191,16 +11317,16 @@ function guardsAbove(returnValue) {
|
|
|
11191
11317
|
let child = returnValue;
|
|
11192
11318
|
let current2 = returnValue.getParent();
|
|
11193
11319
|
while (current2 !== void 0) {
|
|
11194
|
-
if (
|
|
11320
|
+
if (import_ts_morph50.Node.isIfStatement(current2)) {
|
|
11195
11321
|
guards.push({
|
|
11196
11322
|
condition: current2.getExpression(),
|
|
11197
11323
|
whenTrue: current2.getThenStatement() === child
|
|
11198
11324
|
});
|
|
11199
11325
|
}
|
|
11200
|
-
if (
|
|
11326
|
+
if (import_ts_morph50.Node.isBlock(current2)) {
|
|
11201
11327
|
guards.push(...earlyReturnGuardsBefore(current2, child));
|
|
11202
11328
|
}
|
|
11203
|
-
if (
|
|
11329
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(current2) || import_ts_morph50.Node.isArrowFunction(current2) || import_ts_morph50.Node.isFunctionExpression(current2)) {
|
|
11204
11330
|
break;
|
|
11205
11331
|
}
|
|
11206
11332
|
child = current2;
|
|
@@ -11209,7 +11335,7 @@ function guardsAbove(returnValue) {
|
|
|
11209
11335
|
return guards;
|
|
11210
11336
|
}
|
|
11211
11337
|
function earlyReturnGuardsBefore(block, child) {
|
|
11212
|
-
if (!
|
|
11338
|
+
if (!import_ts_morph50.Node.isBlock(block)) {
|
|
11213
11339
|
return [];
|
|
11214
11340
|
}
|
|
11215
11341
|
const guards = [];
|
|
@@ -11217,7 +11343,7 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11217
11343
|
if (statement === child) {
|
|
11218
11344
|
break;
|
|
11219
11345
|
}
|
|
11220
|
-
if (!
|
|
11346
|
+
if (!import_ts_morph50.Node.isIfStatement(statement) || statement.getElseStatement()) {
|
|
11221
11347
|
continue;
|
|
11222
11348
|
}
|
|
11223
11349
|
if (alwaysReturns(statement.getThenStatement())) {
|
|
@@ -11227,10 +11353,10 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
11227
11353
|
return guards;
|
|
11228
11354
|
}
|
|
11229
11355
|
function alwaysReturns(statement) {
|
|
11230
|
-
if (
|
|
11356
|
+
if (import_ts_morph50.Node.isReturnStatement(statement) || import_ts_morph50.Node.isThrowStatement(statement)) {
|
|
11231
11357
|
return true;
|
|
11232
11358
|
}
|
|
11233
|
-
if (!
|
|
11359
|
+
if (!import_ts_morph50.Node.isBlock(statement)) {
|
|
11234
11360
|
return false;
|
|
11235
11361
|
}
|
|
11236
11362
|
const statements = statement.getStatements();
|
|
@@ -11248,7 +11374,7 @@ var COMPARISONS = {
|
|
|
11248
11374
|
"!=": (a, b) => a !== b
|
|
11249
11375
|
};
|
|
11250
11376
|
function evaluateComparison(condition, substitutions) {
|
|
11251
|
-
if (!
|
|
11377
|
+
if (!import_ts_morph50.Node.isBinaryExpression(condition)) {
|
|
11252
11378
|
return null;
|
|
11253
11379
|
}
|
|
11254
11380
|
const left = numberFor(condition.getLeft(), substitutions);
|
|
@@ -11260,8 +11386,8 @@ function evaluateComparison(condition, substitutions) {
|
|
|
11260
11386
|
return compare === void 0 ? null : compare(left, right);
|
|
11261
11387
|
}
|
|
11262
11388
|
function numberFor(node, substitutions) {
|
|
11263
|
-
const resolved =
|
|
11264
|
-
return
|
|
11389
|
+
const resolved = import_ts_morph50.Node.isIdentifier(node) && substitutions.has(node.getText()) ? substitutions.get(node.getText()) : node;
|
|
11390
|
+
return import_ts_morph50.Node.isNumericLiteral(resolved) ? Number(resolved.getText()) : null;
|
|
11265
11391
|
}
|
|
11266
11392
|
var helperBySymbol = /* @__PURE__ */ new WeakMap();
|
|
11267
11393
|
function memoizedLocalHelper(callee, resolveCallee2) {
|
|
@@ -11327,8 +11453,8 @@ function implementationBeside(declaration, name) {
|
|
|
11327
11453
|
return candidate;
|
|
11328
11454
|
}
|
|
11329
11455
|
}
|
|
11330
|
-
const
|
|
11331
|
-
const fn =
|
|
11456
|
+
const variable3 = source.getVariableDeclaration(name);
|
|
11457
|
+
const fn = variable3 === void 0 ? null : asFunctionLike(variable3);
|
|
11332
11458
|
if (fn !== null) {
|
|
11333
11459
|
return fn;
|
|
11334
11460
|
}
|
|
@@ -11348,12 +11474,12 @@ function declarationsFor(callee, resolveCallee2) {
|
|
|
11348
11474
|
return (aliased ?? symbol).getDeclarations();
|
|
11349
11475
|
}
|
|
11350
11476
|
function asFunctionLike(declaration) {
|
|
11351
|
-
if (
|
|
11477
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(declaration) || import_ts_morph50.Node.isArrowFunction(declaration) || import_ts_morph50.Node.isFunctionExpression(declaration)) {
|
|
11352
11478
|
return declaration;
|
|
11353
11479
|
}
|
|
11354
|
-
if (
|
|
11480
|
+
if (import_ts_morph50.Node.isVariableDeclaration(declaration)) {
|
|
11355
11481
|
const initializer = declaration.getInitializer();
|
|
11356
|
-
if (initializer !== void 0 && (
|
|
11482
|
+
if (initializer !== void 0 && (import_ts_morph50.Node.isArrowFunction(initializer) || import_ts_morph50.Node.isFunctionExpression(initializer))) {
|
|
11357
11483
|
return initializer;
|
|
11358
11484
|
}
|
|
11359
11485
|
}
|
|
@@ -11364,13 +11490,13 @@ function returnedObjects(fn) {
|
|
|
11364
11490
|
if (body === void 0) {
|
|
11365
11491
|
return [];
|
|
11366
11492
|
}
|
|
11367
|
-
if (!
|
|
11493
|
+
if (!import_ts_morph50.Node.isBlock(body)) {
|
|
11368
11494
|
const expression = peelParens(body);
|
|
11369
|
-
return
|
|
11495
|
+
return import_ts_morph50.Node.isObjectLiteralExpression(expression) ? [expression] : [];
|
|
11370
11496
|
}
|
|
11371
11497
|
const found = [];
|
|
11372
11498
|
for (const statement of body.getDescendantsOfKind(
|
|
11373
|
-
|
|
11499
|
+
import_ts_morph50.SyntaxKind.ReturnStatement
|
|
11374
11500
|
)) {
|
|
11375
11501
|
if (enclosingFunctionOf(statement) !== body) {
|
|
11376
11502
|
continue;
|
|
@@ -11380,7 +11506,7 @@ function returnedObjects(fn) {
|
|
|
11380
11506
|
continue;
|
|
11381
11507
|
}
|
|
11382
11508
|
const unwrapped2 = peelParens(expression);
|
|
11383
|
-
if (
|
|
11509
|
+
if (import_ts_morph50.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
11384
11510
|
found.push(unwrapped2);
|
|
11385
11511
|
}
|
|
11386
11512
|
}
|
|
@@ -11389,7 +11515,7 @@ function returnedObjects(fn) {
|
|
|
11389
11515
|
function enclosingFunctionOf(node) {
|
|
11390
11516
|
let current2 = node.getParent();
|
|
11391
11517
|
while (current2 !== void 0) {
|
|
11392
|
-
if (
|
|
11518
|
+
if (import_ts_morph50.Node.isFunctionDeclaration(current2) || import_ts_morph50.Node.isArrowFunction(current2) || import_ts_morph50.Node.isFunctionExpression(current2) || import_ts_morph50.Node.isMethodDeclaration(current2)) {
|
|
11393
11519
|
return current2.getBody();
|
|
11394
11520
|
}
|
|
11395
11521
|
current2 = current2.getParent();
|
|
@@ -11408,7 +11534,7 @@ function bindArguments(callArgs, params) {
|
|
|
11408
11534
|
}
|
|
11409
11535
|
|
|
11410
11536
|
// src/terminals/statusBranches.ts
|
|
11411
|
-
var
|
|
11537
|
+
var import_ts_morph51 = require("ts-morph");
|
|
11412
11538
|
var import_values6 = require("@suss/values");
|
|
11413
11539
|
function statusChoicesOf(argument, resolution) {
|
|
11414
11540
|
const chosen = asConditional(argument);
|
|
@@ -11432,10 +11558,10 @@ function asConditional(node) {
|
|
|
11432
11558
|
if (direct !== null) {
|
|
11433
11559
|
return direct;
|
|
11434
11560
|
}
|
|
11435
|
-
if (!
|
|
11561
|
+
if (!import_ts_morph51.Node.isIdentifier(node)) {
|
|
11436
11562
|
return null;
|
|
11437
11563
|
}
|
|
11438
|
-
const declaration = node.getSymbol()?.getDeclarations().find(
|
|
11564
|
+
const declaration = node.getSymbol()?.getDeclarations().find(import_ts_morph51.Node.isVariableDeclaration);
|
|
11439
11565
|
if (declaration === void 0) {
|
|
11440
11566
|
return null;
|
|
11441
11567
|
}
|
|
@@ -11446,7 +11572,7 @@ function asConditional(node) {
|
|
|
11446
11572
|
const only = written.values[0];
|
|
11447
11573
|
return only === void 0 ? null : toConditional(only);
|
|
11448
11574
|
}
|
|
11449
|
-
var toConditional = (node) =>
|
|
11575
|
+
var toConditional = (node) => import_ts_morph51.Node.isConditionalExpression(node) ? node : null;
|
|
11450
11576
|
function numberOf(node, resolution) {
|
|
11451
11577
|
const value = (0, import_values6.constantOf)(evaluatedValue(node, resolution));
|
|
11452
11578
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -11463,7 +11589,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11463
11589
|
for (let i = methodChain.length - 1; i >= 0; i--) {
|
|
11464
11590
|
const expectedMethod = methodChain[i];
|
|
11465
11591
|
const callee = current2.getExpression();
|
|
11466
|
-
if (!
|
|
11592
|
+
if (!import_ts_morph52.Node.isPropertyAccessExpression(callee)) {
|
|
11467
11593
|
return null;
|
|
11468
11594
|
}
|
|
11469
11595
|
if (callee.getName() !== expectedMethod) {
|
|
@@ -11479,7 +11605,7 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11479
11605
|
return null;
|
|
11480
11606
|
}
|
|
11481
11607
|
} else {
|
|
11482
|
-
if (!
|
|
11608
|
+
if (!import_ts_morph52.Node.isCallExpression(subject)) {
|
|
11483
11609
|
return null;
|
|
11484
11610
|
}
|
|
11485
11611
|
current2 = subject;
|
|
@@ -11489,9 +11615,9 @@ function unwrapMethodChain(call, match, func) {
|
|
|
11489
11615
|
}
|
|
11490
11616
|
function withoutPassThroughCalls(subject, passThrough) {
|
|
11491
11617
|
let current2 = subject;
|
|
11492
|
-
while (
|
|
11618
|
+
while (import_ts_morph52.Node.isCallExpression(current2)) {
|
|
11493
11619
|
const callee = current2.getExpression();
|
|
11494
|
-
if (!
|
|
11620
|
+
if (!import_ts_morph52.Node.isPropertyAccessExpression(callee) || !passThrough.includes(callee.getName())) {
|
|
11495
11621
|
break;
|
|
11496
11622
|
}
|
|
11497
11623
|
current2 = callee.getExpression();
|
|
@@ -11503,12 +11629,12 @@ function returnedValueOf(returnStatement) {
|
|
|
11503
11629
|
return written === void 0 ? null : unwrapValue(written);
|
|
11504
11630
|
}
|
|
11505
11631
|
function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
11506
|
-
if (
|
|
11632
|
+
if (import_ts_morph52.Node.isObjectLiteralExpression(node)) {
|
|
11507
11633
|
const source = returnPositionOf(node);
|
|
11508
11634
|
if (source === null) {
|
|
11509
11635
|
return [];
|
|
11510
11636
|
}
|
|
11511
|
-
if (
|
|
11637
|
+
if (import_ts_morph52.Node.isReturnStatement(source) && returnedValueOf(source) === node) {
|
|
11512
11638
|
return [];
|
|
11513
11639
|
}
|
|
11514
11640
|
const terminal = terminalFromReturnedObject(
|
|
@@ -11521,14 +11647,14 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11521
11647
|
);
|
|
11522
11648
|
return terminal === null ? [] : [{ ...terminal, source }];
|
|
11523
11649
|
}
|
|
11524
|
-
if (!
|
|
11650
|
+
if (!import_ts_morph52.Node.isReturnStatement(node)) {
|
|
11525
11651
|
return [];
|
|
11526
11652
|
}
|
|
11527
11653
|
const returned = returnedValueOf(node);
|
|
11528
11654
|
if (returned === null) {
|
|
11529
11655
|
return [];
|
|
11530
11656
|
}
|
|
11531
|
-
if (
|
|
11657
|
+
if (import_ts_morph52.Node.isObjectLiteralExpression(returned)) {
|
|
11532
11658
|
const terminal = terminalFromReturnedObject(
|
|
11533
11659
|
returned,
|
|
11534
11660
|
node,
|
|
@@ -11539,7 +11665,7 @@ function tryMatchReturnShape(node, pattern, match, resolution, resolveCallee2) {
|
|
|
11539
11665
|
);
|
|
11540
11666
|
return terminal === null ? [] : [terminal];
|
|
11541
11667
|
}
|
|
11542
|
-
if (!
|
|
11668
|
+
if (!import_ts_morph52.Node.isCallExpression(returned)) {
|
|
11543
11669
|
return [];
|
|
11544
11670
|
}
|
|
11545
11671
|
const resolved = resolveHelperReturn(returned, resolveCallee2);
|
|
@@ -11576,7 +11702,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11576
11702
|
if (required !== void 0 && required.length > 0) {
|
|
11577
11703
|
const presentNames = /* @__PURE__ */ new Set();
|
|
11578
11704
|
for (const prop of obj.getProperties()) {
|
|
11579
|
-
if (
|
|
11705
|
+
if (import_ts_morph52.Node.isPropertyAssignment(prop) || import_ts_morph52.Node.isShorthandPropertyAssignment(prop)) {
|
|
11580
11706
|
presentNames.add(prop.getName());
|
|
11581
11707
|
}
|
|
11582
11708
|
}
|
|
@@ -11602,7 +11728,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11602
11728
|
// When a helper built the value, the anchor is the caller's own
|
|
11603
11729
|
// return, so it doubles as the provenance. A value reached any other
|
|
11604
11730
|
// way leaves this unset and its caller fills it in.
|
|
11605
|
-
...
|
|
11731
|
+
...import_ts_morph52.Node.isReturnStatement(anchor) ? { source: anchor } : {},
|
|
11606
11732
|
terminal: {
|
|
11607
11733
|
kind: pattern.kind,
|
|
11608
11734
|
statusCode,
|
|
@@ -11621,7 +11747,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
11621
11747
|
};
|
|
11622
11748
|
}
|
|
11623
11749
|
function tryMatchParameterMethodCall(node, func, pattern, match, resolution) {
|
|
11624
|
-
if (!
|
|
11750
|
+
if (!import_ts_morph52.Node.isCallExpression(node)) {
|
|
11625
11751
|
return [];
|
|
11626
11752
|
}
|
|
11627
11753
|
const result = unwrapMethodChain(node, match, func);
|
|
@@ -11681,7 +11807,7 @@ function statusArgument(calls, extraction) {
|
|
|
11681
11807
|
}
|
|
11682
11808
|
function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
11683
11809
|
const current2 = unwrapValue(expr);
|
|
11684
|
-
if (!
|
|
11810
|
+
if (!import_ts_morph52.Node.isCallExpression(current2)) {
|
|
11685
11811
|
return false;
|
|
11686
11812
|
}
|
|
11687
11813
|
for (const pattern of patterns) {
|
|
@@ -11697,7 +11823,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
|
11697
11823
|
}
|
|
11698
11824
|
function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
11699
11825
|
const match = pattern.match.type === "returnStatement" ? pattern.match : null;
|
|
11700
|
-
if (
|
|
11826
|
+
if (import_ts_morph52.Node.isReturnStatement(node)) {
|
|
11701
11827
|
const expr = node.getExpression();
|
|
11702
11828
|
if (match?.excludeCallReturns === true) {
|
|
11703
11829
|
if (expr === void 0) {
|
|
@@ -11716,9 +11842,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
|
11716
11842
|
}
|
|
11717
11843
|
return buildReturnTerminal(node, pattern, body);
|
|
11718
11844
|
}
|
|
11719
|
-
if (
|
|
11845
|
+
if (import_ts_morph52.Node.isArrowFunction(node)) {
|
|
11720
11846
|
const body = node.getBody();
|
|
11721
|
-
if (body === void 0 ||
|
|
11847
|
+
if (body === void 0 || import_ts_morph52.Node.isBlock(body)) {
|
|
11722
11848
|
return null;
|
|
11723
11849
|
}
|
|
11724
11850
|
const shape = extractShape(body);
|
|
@@ -11776,20 +11902,20 @@ function unresolvedTerminal(kind, node) {
|
|
|
11776
11902
|
};
|
|
11777
11903
|
}
|
|
11778
11904
|
function calleeSubject(callee) {
|
|
11779
|
-
if (
|
|
11905
|
+
if (import_ts_morph52.Node.isIdentifier(callee)) {
|
|
11780
11906
|
return callee;
|
|
11781
11907
|
}
|
|
11782
|
-
if (
|
|
11908
|
+
if (import_ts_morph52.Node.isPropertyAccessExpression(callee)) {
|
|
11783
11909
|
const subject = callee.getExpression();
|
|
11784
|
-
return
|
|
11910
|
+
return import_ts_morph52.Node.isIdentifier(subject) ? subject : null;
|
|
11785
11911
|
}
|
|
11786
11912
|
return null;
|
|
11787
11913
|
}
|
|
11788
11914
|
function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom) {
|
|
11789
|
-
if (!
|
|
11915
|
+
if (!import_ts_morph52.Node.isCallExpression(node) && !import_ts_morph52.Node.isNewExpression(node)) {
|
|
11790
11916
|
return null;
|
|
11791
11917
|
}
|
|
11792
|
-
if (
|
|
11918
|
+
if (import_ts_morph52.Node.isNewExpression(node) && returnPositionOf(node) === null) {
|
|
11793
11919
|
return null;
|
|
11794
11920
|
}
|
|
11795
11921
|
const callee = node.getExpression();
|
|
@@ -11828,9 +11954,9 @@ function tryMatchFunctionCall(node, pattern, match, resolution, originatesFrom)
|
|
|
11828
11954
|
}
|
|
11829
11955
|
|
|
11830
11956
|
// src/terminals/throws.ts
|
|
11831
|
-
var
|
|
11957
|
+
var import_ts_morph53 = require("ts-morph");
|
|
11832
11958
|
function tryMatchThrowExpression(node, pattern, match, resolution) {
|
|
11833
|
-
if (!
|
|
11959
|
+
if (!import_ts_morph53.Node.isThrowStatement(node)) {
|
|
11834
11960
|
return null;
|
|
11835
11961
|
}
|
|
11836
11962
|
const thrownExpr = node.getExpression();
|
|
@@ -11872,17 +11998,17 @@ function extractThrowMessage(callArgs) {
|
|
|
11872
11998
|
return null;
|
|
11873
11999
|
}
|
|
11874
12000
|
for (const arg of callArgs) {
|
|
11875
|
-
if (
|
|
12001
|
+
if (import_ts_morph53.Node.isStringLiteral(arg) || import_ts_morph53.Node.isNoSubstitutionTemplateLiteral(arg)) {
|
|
11876
12002
|
return arg.getLiteralValue();
|
|
11877
12003
|
}
|
|
11878
|
-
if (
|
|
12004
|
+
if (import_ts_morph53.Node.isTemplateExpression(arg)) {
|
|
11879
12005
|
return arg.getText();
|
|
11880
12006
|
}
|
|
11881
12007
|
}
|
|
11882
12008
|
return null;
|
|
11883
12009
|
}
|
|
11884
12010
|
function classifyThrownExpression(thrown, constructorPattern) {
|
|
11885
|
-
if (
|
|
12011
|
+
if (import_ts_morph53.Node.isCallExpression(thrown) || import_ts_morph53.Node.isNewExpression(thrown)) {
|
|
11886
12012
|
const calleeText = thrown.getExpression().getText();
|
|
11887
12013
|
if (constructorPattern !== void 0 && !calleeText.startsWith(constructorPattern)) {
|
|
11888
12014
|
return null;
|
|
@@ -11969,9 +12095,9 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolution, origi
|
|
|
11969
12095
|
}
|
|
11970
12096
|
}
|
|
11971
12097
|
});
|
|
11972
|
-
if (results.length === 0 &&
|
|
12098
|
+
if (results.length === 0 && import_ts_morph54.Node.isArrowFunction(func)) {
|
|
11973
12099
|
const body = func.getBody();
|
|
11974
|
-
if (body !== void 0 && !
|
|
12100
|
+
if (body !== void 0 && !import_ts_morph54.Node.isBlock(body)) {
|
|
11975
12101
|
for (const pattern of patterns) {
|
|
11976
12102
|
let found = null;
|
|
11977
12103
|
if (pattern.match.type === "parameterMethodCall") {
|
|
@@ -12006,7 +12132,7 @@ function functionMayFallThrough(func) {
|
|
|
12006
12132
|
if (body === void 0) {
|
|
12007
12133
|
return false;
|
|
12008
12134
|
}
|
|
12009
|
-
if (!
|
|
12135
|
+
if (!import_ts_morph54.Node.isBlock(body)) {
|
|
12010
12136
|
return false;
|
|
12011
12137
|
}
|
|
12012
12138
|
const statements = body.getStatements();
|
|
@@ -12014,7 +12140,7 @@ function functionMayFallThrough(func) {
|
|
|
12014
12140
|
return true;
|
|
12015
12141
|
}
|
|
12016
12142
|
const last = statements[statements.length - 1];
|
|
12017
|
-
if (
|
|
12143
|
+
if (import_ts_morph54.Node.isReturnStatement(last) || import_ts_morph54.Node.isThrowStatement(last)) {
|
|
12018
12144
|
return false;
|
|
12019
12145
|
}
|
|
12020
12146
|
return true;
|
|
@@ -12062,7 +12188,7 @@ function writesTerminal(call, terminalNodes) {
|
|
|
12062
12188
|
}
|
|
12063
12189
|
}
|
|
12064
12190
|
function isReceiverOf(node, parent) {
|
|
12065
|
-
return (
|
|
12191
|
+
return (import_ts_morph55.Node.isPropertyAccessExpression(parent) || import_ts_morph55.Node.isElementAccessExpression(parent) || import_ts_morph55.Node.isCallExpression(parent)) && parent.getExpression() === node;
|
|
12066
12192
|
}
|
|
12067
12193
|
var isDefaultConditionList = (conditions) => conditions.length === 0 || conditions.every(
|
|
12068
12194
|
(c) => c.source === "earlyReturn" || c.source === "earlyThrow"
|
|
@@ -12072,7 +12198,7 @@ function bodyContentOf(func) {
|
|
|
12072
12198
|
if (body === void 0) {
|
|
12073
12199
|
return "absent";
|
|
12074
12200
|
}
|
|
12075
|
-
if (!
|
|
12201
|
+
if (!import_ts_morph55.Node.isBlock(body)) {
|
|
12076
12202
|
return "statements";
|
|
12077
12203
|
}
|
|
12078
12204
|
return body.getStatements().length === 0 ? "empty" : "statements";
|
|
@@ -12088,7 +12214,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12088
12214
|
claimed.add(source);
|
|
12089
12215
|
}
|
|
12090
12216
|
}
|
|
12091
|
-
if (
|
|
12217
|
+
if (import_ts_morph55.Node.isArrowFunction(func) && import_ts_morph55.Node.isExpression(body)) {
|
|
12092
12218
|
return claimed.has(body) ? 0 : 1;
|
|
12093
12219
|
}
|
|
12094
12220
|
let unmatched = 0;
|
|
@@ -12101,7 +12227,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
12101
12227
|
traversal.skip();
|
|
12102
12228
|
return;
|
|
12103
12229
|
}
|
|
12104
|
-
if (!
|
|
12230
|
+
if (!import_ts_morph55.Node.isReturnStatement(node)) {
|
|
12105
12231
|
return;
|
|
12106
12232
|
}
|
|
12107
12233
|
if (node.getExpression() === void 0) {
|
|
@@ -12254,7 +12380,7 @@ function accountFor(site, terminalNodes, branches) {
|
|
|
12254
12380
|
}
|
|
12255
12381
|
|
|
12256
12382
|
// src/bootstrap/sourceFileLookup.ts
|
|
12257
|
-
var
|
|
12383
|
+
var import_ts_morph56 = require("ts-morph");
|
|
12258
12384
|
function createSourceFileLookup(project) {
|
|
12259
12385
|
const all = project.getSourceFiles();
|
|
12260
12386
|
const byAbs = /* @__PURE__ */ new Map();
|
|
@@ -12316,7 +12442,7 @@ function spanKey(span) {
|
|
|
12316
12442
|
function indexFunctions(sf) {
|
|
12317
12443
|
const index = /* @__PURE__ */ new Map();
|
|
12318
12444
|
sf.forEachDescendant((node) => {
|
|
12319
|
-
if (!
|
|
12445
|
+
if (!import_ts_morph56.Node.isFunctionDeclaration(node) && !import_ts_morph56.Node.isFunctionExpression(node) && !import_ts_morph56.Node.isArrowFunction(node) && !import_ts_morph56.Node.isMethodDeclaration(node)) {
|
|
12320
12446
|
return;
|
|
12321
12447
|
}
|
|
12322
12448
|
const bySpan = spanKey({ start: node.getStart(), end: node.getEnd() });
|
|
@@ -12330,13 +12456,13 @@ function indexFunctions(sf) {
|
|
|
12330
12456
|
}
|
|
12331
12457
|
|
|
12332
12458
|
// src/contract.ts
|
|
12333
|
-
var
|
|
12459
|
+
var import_ts_morph57 = require("ts-morph");
|
|
12334
12460
|
var import_behavioral_ir4 = require("@suss/behavioral-ir");
|
|
12335
12461
|
function extractDeclaredBody(node) {
|
|
12336
12462
|
if (node === void 0) {
|
|
12337
12463
|
return null;
|
|
12338
12464
|
}
|
|
12339
|
-
if (!
|
|
12465
|
+
if (!import_ts_morph57.Node.isCallExpression(node)) {
|
|
12340
12466
|
return null;
|
|
12341
12467
|
}
|
|
12342
12468
|
const typeArgs = node.getTypeArguments();
|
|
@@ -12350,10 +12476,10 @@ function resolveHandlerPropNode(func) {
|
|
|
12350
12476
|
if (parent === void 0) {
|
|
12351
12477
|
return null;
|
|
12352
12478
|
}
|
|
12353
|
-
if (
|
|
12479
|
+
if (import_ts_morph57.Node.isPropertyAssignment(parent)) {
|
|
12354
12480
|
return parent;
|
|
12355
12481
|
}
|
|
12356
|
-
if (
|
|
12482
|
+
if (import_ts_morph57.Node.isMethodDeclaration(func)) {
|
|
12357
12483
|
return func;
|
|
12358
12484
|
}
|
|
12359
12485
|
return null;
|
|
@@ -12365,11 +12491,11 @@ function findRouterCall(unit) {
|
|
|
12365
12491
|
return null;
|
|
12366
12492
|
}
|
|
12367
12493
|
const handlersObj = propNode.getParent();
|
|
12368
|
-
if (handlersObj === void 0 || !
|
|
12494
|
+
if (handlersObj === void 0 || !import_ts_morph57.Node.isObjectLiteralExpression(handlersObj)) {
|
|
12369
12495
|
return null;
|
|
12370
12496
|
}
|
|
12371
12497
|
const routerCall = handlersObj.getParent();
|
|
12372
|
-
if (routerCall === void 0 || !
|
|
12498
|
+
if (routerCall === void 0 || !import_ts_morph57.Node.isCallExpression(routerCall)) {
|
|
12373
12499
|
return null;
|
|
12374
12500
|
}
|
|
12375
12501
|
const args = routerCall.getArguments();
|
|
@@ -12382,17 +12508,17 @@ function findRouterCall(unit) {
|
|
|
12382
12508
|
};
|
|
12383
12509
|
}
|
|
12384
12510
|
function resolveContractObject(contractArg, resolution) {
|
|
12385
|
-
if (
|
|
12511
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(contractArg)) {
|
|
12386
12512
|
return contractArg;
|
|
12387
12513
|
}
|
|
12388
|
-
if (
|
|
12514
|
+
if (import_ts_morph57.Node.isPropertyAccessExpression(contractArg)) {
|
|
12389
12515
|
const base = resolveContractObject(contractArg.getExpression(), resolution);
|
|
12390
|
-
if (base === null || !
|
|
12516
|
+
if (base === null || !import_ts_morph57.Node.isObjectLiteralExpression(base)) {
|
|
12391
12517
|
return null;
|
|
12392
12518
|
}
|
|
12393
12519
|
const propName = contractArg.getName();
|
|
12394
12520
|
for (const prop of base.getProperties()) {
|
|
12395
|
-
if (!
|
|
12521
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12396
12522
|
continue;
|
|
12397
12523
|
}
|
|
12398
12524
|
if (prop.getName() !== propName) {
|
|
@@ -12402,20 +12528,20 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12402
12528
|
if (value === void 0) {
|
|
12403
12529
|
return null;
|
|
12404
12530
|
}
|
|
12405
|
-
if (
|
|
12531
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(value)) {
|
|
12406
12532
|
return value;
|
|
12407
12533
|
}
|
|
12408
|
-
if (
|
|
12534
|
+
if (import_ts_morph57.Node.isIdentifier(value) || import_ts_morph57.Node.isPropertyAccessExpression(value)) {
|
|
12409
12535
|
return resolveContractObject(value, resolution);
|
|
12410
12536
|
}
|
|
12411
|
-
if (
|
|
12537
|
+
if (import_ts_morph57.Node.isCallExpression(value)) {
|
|
12412
12538
|
return unwrapContractInit(value);
|
|
12413
12539
|
}
|
|
12414
12540
|
return null;
|
|
12415
12541
|
}
|
|
12416
12542
|
return null;
|
|
12417
12543
|
}
|
|
12418
|
-
if (!
|
|
12544
|
+
if (!import_ts_morph57.Node.isIdentifier(contractArg)) {
|
|
12419
12545
|
return null;
|
|
12420
12546
|
}
|
|
12421
12547
|
const symbol = contractArg.getSymbol();
|
|
@@ -12427,7 +12553,7 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12427
12553
|
return null;
|
|
12428
12554
|
}
|
|
12429
12555
|
const decl = decls[0];
|
|
12430
|
-
if (
|
|
12556
|
+
if (import_ts_morph57.Node.isImportSpecifier(decl)) {
|
|
12431
12557
|
const importDecl = decl.getImportDeclaration();
|
|
12432
12558
|
const sourceFile = importDecl.getModuleSpecifierSourceFile();
|
|
12433
12559
|
if (sourceFile !== void 0 && resolution !== void 0) {
|
|
@@ -12436,14 +12562,14 @@ function resolveContractObject(contractArg, resolution) {
|
|
|
12436
12562
|
);
|
|
12437
12563
|
if (exported !== void 0 && exported.length > 0) {
|
|
12438
12564
|
const exportedDecl = exported[0];
|
|
12439
|
-
if (
|
|
12565
|
+
if (import_ts_morph57.Node.isVariableDeclaration(exportedDecl)) {
|
|
12440
12566
|
return unwrapContractInit(exportedDecl.getInitializer());
|
|
12441
12567
|
}
|
|
12442
12568
|
}
|
|
12443
12569
|
}
|
|
12444
12570
|
return null;
|
|
12445
12571
|
}
|
|
12446
|
-
if (
|
|
12572
|
+
if (import_ts_morph57.Node.isVariableDeclaration(decl)) {
|
|
12447
12573
|
return unwrapContractInit(decl.getInitializer());
|
|
12448
12574
|
}
|
|
12449
12575
|
return null;
|
|
@@ -12453,39 +12579,39 @@ function unwrapContractInit(init) {
|
|
|
12453
12579
|
return null;
|
|
12454
12580
|
}
|
|
12455
12581
|
const node = peelSyntax(init);
|
|
12456
|
-
if (
|
|
12582
|
+
if (import_ts_morph57.Node.isCallExpression(node)) {
|
|
12457
12583
|
const args = node.getArguments();
|
|
12458
|
-
if (args.length > 0 &&
|
|
12584
|
+
if (args.length > 0 && import_ts_morph57.Node.isObjectLiteralExpression(args[0])) {
|
|
12459
12585
|
return args[0];
|
|
12460
12586
|
}
|
|
12461
12587
|
return null;
|
|
12462
12588
|
}
|
|
12463
|
-
if (
|
|
12589
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(node)) {
|
|
12464
12590
|
return node;
|
|
12465
12591
|
}
|
|
12466
12592
|
return null;
|
|
12467
12593
|
}
|
|
12468
12594
|
function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
12469
|
-
if (!
|
|
12595
|
+
if (!import_ts_morph57.Node.isObjectLiteralExpression(endpointNode)) {
|
|
12470
12596
|
return null;
|
|
12471
12597
|
}
|
|
12472
12598
|
const responses = [];
|
|
12473
12599
|
let method;
|
|
12474
12600
|
let path15;
|
|
12475
12601
|
for (const prop of endpointNode.getProperties()) {
|
|
12476
|
-
if (!
|
|
12602
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12477
12603
|
continue;
|
|
12478
12604
|
}
|
|
12479
12605
|
const propName = prop.getName();
|
|
12480
12606
|
if (propName === pattern.methodProperty) {
|
|
12481
12607
|
const val = prop.getInitializer();
|
|
12482
|
-
if (val !== void 0 &&
|
|
12608
|
+
if (val !== void 0 && import_ts_morph57.Node.isStringLiteral(val)) {
|
|
12483
12609
|
method = val.getLiteralValue();
|
|
12484
12610
|
}
|
|
12485
12611
|
}
|
|
12486
12612
|
if (propName === pattern.pathProperty) {
|
|
12487
12613
|
const val = prop.getInitializer();
|
|
12488
|
-
if (val !== void 0 &&
|
|
12614
|
+
if (val !== void 0 && import_ts_morph57.Node.isStringLiteral(val)) {
|
|
12489
12615
|
path15 = val.getLiteralValue();
|
|
12490
12616
|
}
|
|
12491
12617
|
}
|
|
@@ -12494,7 +12620,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12494
12620
|
const val = written === void 0 ? null : objectLiteralOf(written, resolution);
|
|
12495
12621
|
if (val !== null) {
|
|
12496
12622
|
for (const respProp of propertiesOf(val, resolution)) {
|
|
12497
|
-
if (!
|
|
12623
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(respProp)) {
|
|
12498
12624
|
continue;
|
|
12499
12625
|
}
|
|
12500
12626
|
const statusStr = respProp.getName();
|
|
@@ -12544,11 +12670,11 @@ function readContract(unit, pattern, framework, resolution) {
|
|
|
12544
12670
|
return null;
|
|
12545
12671
|
}
|
|
12546
12672
|
const contractObj = resolveContractObject(routerInfo.contractArg, resolution);
|
|
12547
|
-
if (contractObj === null || !
|
|
12673
|
+
if (contractObj === null || !import_ts_morph57.Node.isObjectLiteralExpression(contractObj)) {
|
|
12548
12674
|
return null;
|
|
12549
12675
|
}
|
|
12550
12676
|
for (const prop of contractObj.getProperties()) {
|
|
12551
|
-
if (!
|
|
12677
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12552
12678
|
continue;
|
|
12553
12679
|
}
|
|
12554
12680
|
if (prop.getName() !== routerInfo.handlerName) {
|
|
@@ -12573,7 +12699,7 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12573
12699
|
return null;
|
|
12574
12700
|
}
|
|
12575
12701
|
const call = func.getParent();
|
|
12576
|
-
if (call === void 0 || !
|
|
12702
|
+
if (call === void 0 || !import_ts_morph57.Node.isCallExpression(call)) {
|
|
12577
12703
|
return null;
|
|
12578
12704
|
}
|
|
12579
12705
|
const args = call.getArguments();
|
|
@@ -12585,24 +12711,24 @@ function endpointFromRegistrationArgument(unit, position, resolution) {
|
|
|
12585
12711
|
return null;
|
|
12586
12712
|
}
|
|
12587
12713
|
let node = arg;
|
|
12588
|
-
while (
|
|
12714
|
+
while (import_ts_morph57.Node.isAsExpression(node)) {
|
|
12589
12715
|
node = node.getExpression();
|
|
12590
12716
|
}
|
|
12591
|
-
if (
|
|
12717
|
+
if (import_ts_morph57.Node.isObjectLiteralExpression(node)) {
|
|
12592
12718
|
return node;
|
|
12593
12719
|
}
|
|
12594
|
-
if (
|
|
12720
|
+
if (import_ts_morph57.Node.isCallExpression(node)) {
|
|
12595
12721
|
return unwrapContractInit(node);
|
|
12596
12722
|
}
|
|
12597
12723
|
return resolveContractObject(node, resolution);
|
|
12598
12724
|
}
|
|
12599
12725
|
function readContractForClientCall(callExpression, methodName, pattern, framework, resolution) {
|
|
12600
|
-
const callee =
|
|
12601
|
-
if (callee === null || !
|
|
12726
|
+
const callee = import_ts_morph57.Node.isCallExpression(callExpression) ? callExpression.getExpression() : null;
|
|
12727
|
+
if (callee === null || !import_ts_morph57.Node.isPropertyAccessExpression(callee)) {
|
|
12602
12728
|
return null;
|
|
12603
12729
|
}
|
|
12604
12730
|
const clientIdentifier = callee.getExpression();
|
|
12605
|
-
if (!
|
|
12731
|
+
if (!import_ts_morph57.Node.isIdentifier(clientIdentifier)) {
|
|
12606
12732
|
return null;
|
|
12607
12733
|
}
|
|
12608
12734
|
const symbol = clientIdentifier.getSymbol();
|
|
@@ -12614,11 +12740,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12614
12740
|
return null;
|
|
12615
12741
|
}
|
|
12616
12742
|
const decl = decls[0];
|
|
12617
|
-
if (!
|
|
12743
|
+
if (!import_ts_morph57.Node.isVariableDeclaration(decl)) {
|
|
12618
12744
|
return null;
|
|
12619
12745
|
}
|
|
12620
12746
|
const init = decl.getInitializer();
|
|
12621
|
-
if (init === void 0 || !
|
|
12747
|
+
if (init === void 0 || !import_ts_morph57.Node.isCallExpression(init)) {
|
|
12622
12748
|
return null;
|
|
12623
12749
|
}
|
|
12624
12750
|
const args = init.getArguments();
|
|
@@ -12626,11 +12752,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12626
12752
|
return null;
|
|
12627
12753
|
}
|
|
12628
12754
|
const contractObj = resolveContractObject(args[0], resolution);
|
|
12629
|
-
if (contractObj === null || !
|
|
12755
|
+
if (contractObj === null || !import_ts_morph57.Node.isObjectLiteralExpression(contractObj)) {
|
|
12630
12756
|
return null;
|
|
12631
12757
|
}
|
|
12632
12758
|
for (const prop of contractObj.getProperties()) {
|
|
12633
|
-
if (!
|
|
12759
|
+
if (!import_ts_morph57.Node.isPropertyAssignment(prop)) {
|
|
12634
12760
|
continue;
|
|
12635
12761
|
}
|
|
12636
12762
|
if (prop.getName() !== methodName) {
|
|
@@ -12652,26 +12778,26 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12652
12778
|
|
|
12653
12779
|
// src/diagnostics.ts
|
|
12654
12780
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
12655
|
-
var
|
|
12781
|
+
var import_ts_morph58 = require("ts-morph");
|
|
12656
12782
|
var import_extractor6 = require("@suss/extractor");
|
|
12657
12783
|
var DEFAULT_RESOLUTION = {
|
|
12658
|
-
moduleResolution:
|
|
12659
|
-
target:
|
|
12660
|
-
module:
|
|
12784
|
+
moduleResolution: import_ts_morph58.ts.ModuleResolutionKind.Bundler,
|
|
12785
|
+
target: import_ts_morph58.ts.ScriptTarget.ESNext,
|
|
12786
|
+
module: import_ts_morph58.ts.ModuleKind.ESNext
|
|
12661
12787
|
};
|
|
12662
12788
|
function resolutionContext(args) {
|
|
12663
12789
|
if (args.tsConfigFilePath !== void 0) {
|
|
12664
|
-
const configFile =
|
|
12790
|
+
const configFile = import_ts_morph58.ts.readConfigFile(
|
|
12665
12791
|
args.tsConfigFilePath,
|
|
12666
|
-
|
|
12792
|
+
import_ts_morph58.ts.sys.readFile
|
|
12667
12793
|
);
|
|
12668
12794
|
if (configFile.error !== void 0) {
|
|
12669
12795
|
return null;
|
|
12670
12796
|
}
|
|
12671
12797
|
const dir = import_node_path7.default.dirname(args.tsConfigFilePath);
|
|
12672
|
-
const parsed =
|
|
12798
|
+
const parsed = import_ts_morph58.ts.parseJsonConfigFileContent(
|
|
12673
12799
|
configFile.config,
|
|
12674
|
-
|
|
12800
|
+
import_ts_morph58.ts.sys,
|
|
12675
12801
|
dir,
|
|
12676
12802
|
/*existingOptions*/
|
|
12677
12803
|
void 0,
|
|
@@ -12700,11 +12826,11 @@ function unresolvedGatesFor(gates, args) {
|
|
|
12700
12826
|
}
|
|
12701
12827
|
const unresolved = [];
|
|
12702
12828
|
for (const gate of gates) {
|
|
12703
|
-
const resolved =
|
|
12829
|
+
const resolved = import_ts_morph58.ts.resolveModuleName(
|
|
12704
12830
|
gate,
|
|
12705
12831
|
context.containingFile,
|
|
12706
12832
|
context.options,
|
|
12707
|
-
|
|
12833
|
+
import_ts_morph58.ts.sys
|
|
12708
12834
|
);
|
|
12709
12835
|
if (resolved.resolvedModule === void 0) {
|
|
12710
12836
|
unresolved.push(gate);
|
|
@@ -12877,7 +13003,7 @@ var import_node_fs3 = __toESM(require("fs"), 1);
|
|
|
12877
13003
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
12878
13004
|
var import_graphql2 = require("graphql");
|
|
12879
13005
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
12880
|
-
var
|
|
13006
|
+
var import_ts_morph59 = require("ts-morph");
|
|
12881
13007
|
var import_behavioral_ir5 = require("@suss/behavioral-ir");
|
|
12882
13008
|
function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
12883
13009
|
const scopes = compileOperationScopes(packs);
|
|
@@ -12917,11 +13043,11 @@ function fragmentsRegisteredIn(sourceFiles) {
|
|
|
12917
13043
|
const registered = /* @__PURE__ */ new Set();
|
|
12918
13044
|
for (const sourceFile of sourceFiles) {
|
|
12919
13045
|
sourceFile.forEachDescendant((node) => {
|
|
12920
|
-
if (!
|
|
13046
|
+
if (!import_ts_morph59.Node.isCallExpression(node)) {
|
|
12921
13047
|
return;
|
|
12922
13048
|
}
|
|
12923
13049
|
const argument = node.getArguments()[0];
|
|
12924
|
-
if (argument === void 0 || !
|
|
13050
|
+
if (argument === void 0 || !import_ts_morph59.Node.isNoSubstitutionTemplateLiteral(argument)) {
|
|
12925
13051
|
return;
|
|
12926
13052
|
}
|
|
12927
13053
|
for (const name of fragmentOnlyDocumentNames(argument.getLiteralText())) {
|
|
@@ -13108,7 +13234,7 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13108
13234
|
if (cacheConstruction === null) {
|
|
13109
13235
|
return "unknown";
|
|
13110
13236
|
}
|
|
13111
|
-
if (!
|
|
13237
|
+
if (!import_ts_morph59.Node.isNewExpression(cacheConstruction) && !import_ts_morph59.Node.isCallExpression(cacheConstruction)) {
|
|
13112
13238
|
return "unknown";
|
|
13113
13239
|
}
|
|
13114
13240
|
const args = cacheConstruction.getArguments();
|
|
@@ -13122,15 +13248,15 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
13122
13248
|
if (cacheOptions.getProperty(spec.registryProperty) !== void 0) {
|
|
13123
13249
|
return "configured";
|
|
13124
13250
|
}
|
|
13125
|
-
const hasSpread = cacheOptions.getProperties().some((property) =>
|
|
13251
|
+
const hasSpread = cacheOptions.getProperties().some((property) => import_ts_morph59.Node.isSpreadAssignment(property));
|
|
13126
13252
|
return hasSpread ? "unknown" : "absent";
|
|
13127
13253
|
}
|
|
13128
13254
|
function firstArgumentObjectLiteral(construction) {
|
|
13129
|
-
if (!
|
|
13255
|
+
if (!import_ts_morph59.Node.isNewExpression(construction) && !import_ts_morph59.Node.isCallExpression(construction)) {
|
|
13130
13256
|
return null;
|
|
13131
13257
|
}
|
|
13132
13258
|
const arg = construction.getArguments()[0];
|
|
13133
|
-
if (arg === void 0 || !
|
|
13259
|
+
if (arg === void 0 || !import_ts_morph59.Node.isObjectLiteralExpression(arg)) {
|
|
13134
13260
|
return null;
|
|
13135
13261
|
}
|
|
13136
13262
|
return arg;
|
|
@@ -13140,10 +13266,10 @@ function propertyValueOf2(options, name) {
|
|
|
13140
13266
|
if (property === void 0) {
|
|
13141
13267
|
return null;
|
|
13142
13268
|
}
|
|
13143
|
-
if (
|
|
13269
|
+
if (import_ts_morph59.Node.isPropertyAssignment(property)) {
|
|
13144
13270
|
return property.getInitializer() ?? null;
|
|
13145
13271
|
}
|
|
13146
|
-
if (
|
|
13272
|
+
if (import_ts_morph59.Node.isShorthandPropertyAssignment(property)) {
|
|
13147
13273
|
const symbol = property.getProject().getTypeChecker().getShorthandAssignmentValueSymbol(property);
|
|
13148
13274
|
return symbol?.getValueDeclaration() ?? null;
|
|
13149
13275
|
}
|
|
@@ -13153,13 +13279,13 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13153
13279
|
let current2 = expression;
|
|
13154
13280
|
for (let hop = 0; hop < 4 && current2 !== void 0; hop += 1) {
|
|
13155
13281
|
current2 = unwrapExpression2(current2);
|
|
13156
|
-
if (
|
|
13282
|
+
if (import_ts_morph59.Node.isVariableDeclaration(current2)) {
|
|
13157
13283
|
current2 = current2.getInitializer();
|
|
13158
13284
|
continue;
|
|
13159
13285
|
}
|
|
13160
|
-
if (
|
|
13286
|
+
if (import_ts_morph59.Node.isNewExpression(current2) || import_ts_morph59.Node.isCallExpression(current2)) {
|
|
13161
13287
|
const callee = current2.getExpression();
|
|
13162
|
-
if (callee === void 0 || !
|
|
13288
|
+
if (callee === void 0 || !import_ts_morph59.Node.isIdentifier(callee)) {
|
|
13163
13289
|
return null;
|
|
13164
13290
|
}
|
|
13165
13291
|
const local = localImportName(
|
|
@@ -13169,11 +13295,11 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
13169
13295
|
);
|
|
13170
13296
|
return local !== null && callee.getText() === local ? current2 : null;
|
|
13171
13297
|
}
|
|
13172
|
-
if (!
|
|
13298
|
+
if (!import_ts_morph59.Node.isIdentifier(current2)) {
|
|
13173
13299
|
return null;
|
|
13174
13300
|
}
|
|
13175
13301
|
const declaration = current2.getSymbol()?.getValueDeclaration();
|
|
13176
|
-
if (declaration === void 0 || !
|
|
13302
|
+
if (declaration === void 0 || !import_ts_morph59.Node.isVariableDeclaration(declaration)) {
|
|
13177
13303
|
return null;
|
|
13178
13304
|
}
|
|
13179
13305
|
current2 = declaration.getInitializer();
|
|
@@ -13184,11 +13310,11 @@ function unwrapExpression2(node) {
|
|
|
13184
13310
|
return peelSyntax(node);
|
|
13185
13311
|
}
|
|
13186
13312
|
function isConstructionNamed(node, localName) {
|
|
13187
|
-
if (!
|
|
13313
|
+
if (!import_ts_morph59.Node.isNewExpression(node) && !import_ts_morph59.Node.isCallExpression(node)) {
|
|
13188
13314
|
return false;
|
|
13189
13315
|
}
|
|
13190
13316
|
const callee = node.getExpression();
|
|
13191
|
-
return callee !== void 0 &&
|
|
13317
|
+
return callee !== void 0 && import_ts_morph59.Node.isIdentifier(callee) && callee.getText() === localName;
|
|
13192
13318
|
}
|
|
13193
13319
|
function localImportName(sourceFile, importModule, importName) {
|
|
13194
13320
|
for (const one of namedImportsOf(sourceFile, [importModule], {
|
|
@@ -13202,11 +13328,11 @@ function localImportName(sourceFile, importModule, importName) {
|
|
|
13202
13328
|
}
|
|
13203
13329
|
function constructionRef(node, uriProperty, resolution) {
|
|
13204
13330
|
const optionsArg = node.getArguments()[0];
|
|
13205
|
-
if (optionsArg === void 0 || !
|
|
13331
|
+
if (optionsArg === void 0 || !import_ts_morph59.Node.isObjectLiteralExpression(optionsArg)) {
|
|
13206
13332
|
return null;
|
|
13207
13333
|
}
|
|
13208
13334
|
const property = optionsArg.getProperty(uriProperty);
|
|
13209
|
-
if (property === void 0 || !
|
|
13335
|
+
if (property === void 0 || !import_ts_morph59.Node.isPropertyAssignment(property)) {
|
|
13210
13336
|
return null;
|
|
13211
13337
|
}
|
|
13212
13338
|
const value = property.getInitializer();
|
|
@@ -13221,10 +13347,10 @@ function constructionRef(node, uriProperty, resolution) {
|
|
|
13221
13347
|
}
|
|
13222
13348
|
|
|
13223
13349
|
// src/discovery/helperIndex.ts
|
|
13224
|
-
var
|
|
13350
|
+
var import_ts_morph61 = require("ts-morph");
|
|
13225
13351
|
|
|
13226
13352
|
// src/discovery/helperReading.ts
|
|
13227
|
-
var
|
|
13353
|
+
var import_ts_morph60 = require("ts-morph");
|
|
13228
13354
|
var UNREAD = { as: "unread" };
|
|
13229
13355
|
function readHelperSinks(helper) {
|
|
13230
13356
|
const positions = parameterPositions(helper);
|
|
@@ -13234,11 +13360,11 @@ function readHelperSinks(helper) {
|
|
|
13234
13360
|
return sinks;
|
|
13235
13361
|
}
|
|
13236
13362
|
body.forEachDescendant((node) => {
|
|
13237
|
-
if (!
|
|
13363
|
+
if (!import_ts_morph60.Node.isCallExpression(node)) {
|
|
13238
13364
|
return;
|
|
13239
13365
|
}
|
|
13240
13366
|
const callee = node.getExpression();
|
|
13241
|
-
const [method, receiver] =
|
|
13367
|
+
const [method, receiver] = import_ts_morph60.Node.isPropertyAccessExpression(callee) ? [callee.getName(), readValue(callee.getExpression(), positions)] : [null, UNREAD];
|
|
13242
13368
|
sinks.push({
|
|
13243
13369
|
method,
|
|
13244
13370
|
receiver,
|
|
@@ -13258,25 +13384,25 @@ function parameterPositions(helper) {
|
|
|
13258
13384
|
return positions;
|
|
13259
13385
|
}
|
|
13260
13386
|
function readValue(node, positions) {
|
|
13261
|
-
if (
|
|
13387
|
+
if (import_ts_morph60.Node.isStringLiteral(node) || import_ts_morph60.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
13262
13388
|
return { as: "text", text: node.getLiteralValue() };
|
|
13263
13389
|
}
|
|
13264
|
-
if (
|
|
13390
|
+
if (import_ts_morph60.Node.isTemplateExpression(node)) {
|
|
13265
13391
|
return templateText(node, positions);
|
|
13266
13392
|
}
|
|
13267
|
-
if (
|
|
13393
|
+
if (import_ts_morph60.Node.isIdentifier(node)) {
|
|
13268
13394
|
const position = positions.get(node.getText());
|
|
13269
13395
|
return position === void 0 ? UNREAD : { as: "parameter", position };
|
|
13270
13396
|
}
|
|
13271
|
-
if (
|
|
13397
|
+
if (import_ts_morph60.Node.isPropertyAccessExpression(node)) {
|
|
13272
13398
|
const target = node.getExpression();
|
|
13273
|
-
const position =
|
|
13399
|
+
const position = import_ts_morph60.Node.isIdentifier(target) ? positions.get(target.getText()) : void 0;
|
|
13274
13400
|
return position === void 0 ? UNREAD : { as: "parameter", position, property: node.getName() };
|
|
13275
13401
|
}
|
|
13276
|
-
if (
|
|
13402
|
+
if (import_ts_morph60.Node.isObjectLiteralExpression(node)) {
|
|
13277
13403
|
return objectValue(node, positions);
|
|
13278
13404
|
}
|
|
13279
|
-
if (
|
|
13405
|
+
if (import_ts_morph60.Node.isCallExpression(node)) {
|
|
13280
13406
|
return {
|
|
13281
13407
|
as: "call",
|
|
13282
13408
|
callee: node.getExpression().getText(),
|
|
@@ -13286,13 +13412,13 @@ function readValue(node, positions) {
|
|
|
13286
13412
|
return UNREAD;
|
|
13287
13413
|
}
|
|
13288
13414
|
function templateText(node, positions) {
|
|
13289
|
-
if (!
|
|
13415
|
+
if (!import_ts_morph60.Node.isTemplateExpression(node)) {
|
|
13290
13416
|
return UNREAD;
|
|
13291
13417
|
}
|
|
13292
13418
|
let text = node.getHead().getLiteralText();
|
|
13293
13419
|
for (const span of node.getTemplateSpans()) {
|
|
13294
13420
|
const expression = span.getExpression();
|
|
13295
|
-
const position =
|
|
13421
|
+
const position = import_ts_morph60.Node.isIdentifier(expression) ? positions.get(expression.getText()) : void 0;
|
|
13296
13422
|
if (position === void 0) {
|
|
13297
13423
|
return UNREAD;
|
|
13298
13424
|
}
|
|
@@ -13301,12 +13427,12 @@ function templateText(node, positions) {
|
|
|
13301
13427
|
return { as: "text", text };
|
|
13302
13428
|
}
|
|
13303
13429
|
function objectValue(node, positions) {
|
|
13304
|
-
if (!
|
|
13430
|
+
if (!import_ts_morph60.Node.isObjectLiteralExpression(node)) {
|
|
13305
13431
|
return UNREAD;
|
|
13306
13432
|
}
|
|
13307
13433
|
const properties = {};
|
|
13308
13434
|
for (const property of node.getProperties()) {
|
|
13309
|
-
if (!
|
|
13435
|
+
if (!import_ts_morph60.Node.isPropertyAssignment(property)) {
|
|
13310
13436
|
continue;
|
|
13311
13437
|
}
|
|
13312
13438
|
const initializer = property.getInitializer();
|
|
@@ -13321,7 +13447,7 @@ function objectValue(node, positions) {
|
|
|
13321
13447
|
return { as: "object", properties };
|
|
13322
13448
|
}
|
|
13323
13449
|
function propertyKey(name) {
|
|
13324
|
-
return
|
|
13450
|
+
return import_ts_morph60.Node.isStringLiteral(name) ? name.getLiteralValue() : name.getText();
|
|
13325
13451
|
}
|
|
13326
13452
|
|
|
13327
13453
|
// src/discovery/helperIndex.ts
|
|
@@ -13451,11 +13577,11 @@ function registrationMatchesOf(pack) {
|
|
|
13451
13577
|
}
|
|
13452
13578
|
function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
13453
13579
|
sourceFile.forEachDescendant((node) => {
|
|
13454
|
-
if (!
|
|
13580
|
+
if (!import_ts_morph61.Node.isCallExpression(node)) {
|
|
13455
13581
|
return;
|
|
13456
13582
|
}
|
|
13457
13583
|
const callee = node.getExpression();
|
|
13458
|
-
if (!
|
|
13584
|
+
if (!import_ts_morph61.Node.isIdentifier(callee)) {
|
|
13459
13585
|
return;
|
|
13460
13586
|
}
|
|
13461
13587
|
const handedOver = subjectArgument(node, subjects, match, resolution);
|
|
@@ -13470,12 +13596,12 @@ function collectHandOffs(sourceFile, subjects, match, resolution, found) {
|
|
|
13470
13596
|
});
|
|
13471
13597
|
}
|
|
13472
13598
|
function subjectArgument(call, subjects, match, resolution) {
|
|
13473
|
-
if (!
|
|
13599
|
+
if (!import_ts_morph61.Node.isCallExpression(call)) {
|
|
13474
13600
|
return -1;
|
|
13475
13601
|
}
|
|
13476
13602
|
const args = call.getArguments();
|
|
13477
13603
|
for (const [position, argument] of args.entries()) {
|
|
13478
|
-
if (!
|
|
13604
|
+
if (!import_ts_morph61.Node.isIdentifier(argument) && !import_ts_morph61.Node.isPropertyAccessExpression(argument)) {
|
|
13479
13605
|
continue;
|
|
13480
13606
|
}
|
|
13481
13607
|
if (subjectNodeFor(argument, subjects, match, resolution) !== void 0) {
|
|
@@ -13534,10 +13660,10 @@ function declaredFunctions(sourceFile) {
|
|
|
13534
13660
|
found.push([name, declaration]);
|
|
13535
13661
|
}
|
|
13536
13662
|
}
|
|
13537
|
-
for (const
|
|
13538
|
-
const initializer =
|
|
13539
|
-
if (initializer !== void 0 && (
|
|
13540
|
-
found.push([
|
|
13663
|
+
for (const variable3 of sourceFile.getVariableDeclarations()) {
|
|
13664
|
+
const initializer = variable3.getInitializer();
|
|
13665
|
+
if (initializer !== void 0 && (import_ts_morph61.Node.isArrowFunction(initializer) || import_ts_morph61.Node.isFunctionExpression(initializer))) {
|
|
13666
|
+
found.push([variable3.getName(), initializer]);
|
|
13541
13667
|
}
|
|
13542
13668
|
}
|
|
13543
13669
|
return found;
|
|
@@ -13629,7 +13755,7 @@ function recordEdge(edgesByChild, candidate) {
|
|
|
13629
13755
|
}
|
|
13630
13756
|
|
|
13631
13757
|
// src/discovery/wrapperIndex.ts
|
|
13632
|
-
var
|
|
13758
|
+
var import_ts_morph62 = require("ts-morph");
|
|
13633
13759
|
var import_resolution6 = require("@suss/resolution");
|
|
13634
13760
|
var NO_WRAPPERS = {
|
|
13635
13761
|
wrappersFor: () => [],
|
|
@@ -13753,11 +13879,11 @@ function discoverWrapperRegistrations(sourceFile, pattern, match, wraps, resolut
|
|
|
13753
13879
|
const candidates = [];
|
|
13754
13880
|
const unresolved = [];
|
|
13755
13881
|
sourceFile.forEachDescendant((node) => {
|
|
13756
|
-
if (!
|
|
13882
|
+
if (!import_ts_morph62.Node.isCallExpression(node)) {
|
|
13757
13883
|
return;
|
|
13758
13884
|
}
|
|
13759
13885
|
const callee = node.getExpression();
|
|
13760
|
-
if (!
|
|
13886
|
+
if (!import_ts_morph62.Node.isPropertyAccessExpression(callee) || callee.getName() !== wraps.method) {
|
|
13761
13887
|
return;
|
|
13762
13888
|
}
|
|
13763
13889
|
const subjectNode = subjectNodeFor(
|
|
@@ -13852,7 +13978,7 @@ function discoverConstructorOptions(sourceFile, pattern, wraps, subjects, resolu
|
|
|
13852
13978
|
return { candidates, unresolved };
|
|
13853
13979
|
}
|
|
13854
13980
|
function constructorOptionOf(construction, wraps, resolution) {
|
|
13855
|
-
if (!(
|
|
13981
|
+
if (!(import_ts_morph62.Node.isNewExpression(construction) || import_ts_morph62.Node.isCallExpression(construction))) {
|
|
13856
13982
|
return void 0;
|
|
13857
13983
|
}
|
|
13858
13984
|
const optionsArg = construction.getArguments()[wraps.targetPosition];
|
|
@@ -13882,6 +14008,7 @@ function candidateOf(registration, pattern, sourceFile) {
|
|
|
13882
14008
|
reference: {
|
|
13883
14009
|
file: target.getSourceFile().getFilePath(),
|
|
13884
14010
|
name: named2 ? functionNameOrAnon(target) : label,
|
|
14011
|
+
...named2 ? {} : { line: target.getStartLineNumber() },
|
|
13885
14012
|
...onThrow ? { onThrow: true } : {},
|
|
13886
14013
|
...scope === void 0 ? {} : { scope }
|
|
13887
14014
|
}
|
|
@@ -13890,37 +14017,6 @@ function candidateOf(registration, pattern, sourceFile) {
|
|
|
13890
14017
|
function labelFor(targetArg, wraps) {
|
|
13891
14018
|
return factoryNameOf(targetArg) ?? wraps.method;
|
|
13892
14019
|
}
|
|
13893
|
-
function factoryNameOf(targetArg) {
|
|
13894
|
-
const written = factKeyOf(targetArg);
|
|
13895
|
-
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13896
|
-
return void 0;
|
|
13897
|
-
}
|
|
13898
|
-
const callee = written.getExpression();
|
|
13899
|
-
if (import_ts_morph61.Node.isIdentifier(callee)) {
|
|
13900
|
-
return callee.getText();
|
|
13901
|
-
}
|
|
13902
|
-
if (import_ts_morph61.Node.isPropertyAccessExpression(callee)) {
|
|
13903
|
-
return callee.getName();
|
|
13904
|
-
}
|
|
13905
|
-
return void 0;
|
|
13906
|
-
}
|
|
13907
|
-
function factoryStopOf(targetArg) {
|
|
13908
|
-
const written = factKeyOf(targetArg);
|
|
13909
|
-
if (!import_ts_morph61.Node.isCallExpression(written)) {
|
|
13910
|
-
return null;
|
|
13911
|
-
}
|
|
13912
|
-
const callee = factoryNameOf(targetArg);
|
|
13913
|
-
if (callee === void 0) {
|
|
13914
|
-
return null;
|
|
13915
|
-
}
|
|
13916
|
-
const reason = classifyStop(
|
|
13917
|
-
declarationsBehind(written.getExpression().getSymbol())
|
|
13918
|
-
);
|
|
13919
|
-
if (!(0, import_behavioral_ir2.worthRecording)(reason)) {
|
|
13920
|
-
return null;
|
|
13921
|
-
}
|
|
13922
|
-
return { callee, reason: "unresolvedWrapper" };
|
|
13923
|
-
}
|
|
13924
14020
|
function mountedAt(subjectId, mountPrefixes, scope) {
|
|
13925
14021
|
const prefix = mountPrefixes?.prefixForId?.(subjectId) ?? "";
|
|
13926
14022
|
return (0, import_resolution6.joinMountedPath)(prefix, scope);
|
|
@@ -13937,7 +14033,7 @@ function scopeOf(args, wraps, resolution) {
|
|
|
13937
14033
|
}
|
|
13938
14034
|
|
|
13939
14035
|
// src/discoveryContext.ts
|
|
13940
|
-
var
|
|
14036
|
+
var import_ts_morph63 = require("ts-morph");
|
|
13941
14037
|
function createTsDiscoveryContext(resolution) {
|
|
13942
14038
|
const store = resolution ?? new ResolutionStore();
|
|
13943
14039
|
return {
|
|
@@ -13972,7 +14068,7 @@ function exportedFunctions(sourceFile, resolution) {
|
|
|
13972
14068
|
return out;
|
|
13973
14069
|
}
|
|
13974
14070
|
function exportedFunction(decl, resolution) {
|
|
13975
|
-
const writtenAgain =
|
|
14071
|
+
const writtenAgain = import_ts_morph63.Node.isVariableDeclaration(decl) && isWrittenAgain(decl);
|
|
13976
14072
|
if (!writtenAgain) {
|
|
13977
14073
|
const declared = resolveDeclarationToFunction(decl);
|
|
13978
14074
|
if (declared !== null) {
|
|
@@ -13993,7 +14089,7 @@ function valueToAskAbout(decl, writtenAgain) {
|
|
|
13993
14089
|
if (writtenAgain) {
|
|
13994
14090
|
return decl;
|
|
13995
14091
|
}
|
|
13996
|
-
const value =
|
|
14092
|
+
const value = import_ts_morph63.Node.isVariableDeclaration(decl) ? decl.getInitializer() ?? decl : decl;
|
|
13997
14093
|
return couldStillNameAFunction(value) ? value : null;
|
|
13998
14094
|
}
|
|
13999
14095
|
function resolveDeclarationToFunction(decl) {
|
|
@@ -14001,18 +14097,18 @@ function resolveDeclarationToFunction(decl) {
|
|
|
14001
14097
|
if (fn !== null) {
|
|
14002
14098
|
return fn;
|
|
14003
14099
|
}
|
|
14004
|
-
if (
|
|
14100
|
+
if (import_ts_morph63.Node.isVariableDeclaration(decl)) {
|
|
14005
14101
|
const init = decl.getInitializer();
|
|
14006
|
-
if (init !== void 0 && (
|
|
14102
|
+
if (init !== void 0 && (import_ts_morph63.Node.isArrowFunction(init) || import_ts_morph63.Node.isFunctionExpression(init))) {
|
|
14007
14103
|
return init;
|
|
14008
14104
|
}
|
|
14009
14105
|
}
|
|
14010
14106
|
return null;
|
|
14011
14107
|
}
|
|
14012
14108
|
function hasJsxReturn(func) {
|
|
14013
|
-
if (
|
|
14109
|
+
if (import_ts_morph63.Node.isArrowFunction(func)) {
|
|
14014
14110
|
const body2 = func.getBody();
|
|
14015
|
-
if (
|
|
14111
|
+
if (import_ts_morph63.Node.isExpression(body2) && isJsxOrFragment(body2)) {
|
|
14016
14112
|
return true;
|
|
14017
14113
|
}
|
|
14018
14114
|
}
|
|
@@ -14026,11 +14122,11 @@ function hasJsxReturn(func) {
|
|
|
14026
14122
|
traversal.stop();
|
|
14027
14123
|
return;
|
|
14028
14124
|
}
|
|
14029
|
-
if (node !== func && (
|
|
14125
|
+
if (node !== func && (import_ts_morph63.Node.isFunctionDeclaration(node) || import_ts_morph63.Node.isFunctionExpression(node) || import_ts_morph63.Node.isArrowFunction(node) || import_ts_morph63.Node.isMethodDeclaration(node))) {
|
|
14030
14126
|
traversal.skip();
|
|
14031
14127
|
return;
|
|
14032
14128
|
}
|
|
14033
|
-
if (
|
|
14129
|
+
if (import_ts_morph63.Node.isReturnStatement(node)) {
|
|
14034
14130
|
const expr = node.getExpression();
|
|
14035
14131
|
if (expr !== void 0 && isJsxOrFragment(expr)) {
|
|
14036
14132
|
found = true;
|
|
@@ -14041,7 +14137,7 @@ function hasJsxReturn(func) {
|
|
|
14041
14137
|
}
|
|
14042
14138
|
function isJsxOrFragment(node) {
|
|
14043
14139
|
const current2 = peelParens(node);
|
|
14044
|
-
return
|
|
14140
|
+
return import_ts_morph63.Node.isJsxElement(current2) || import_ts_morph63.Node.isJsxSelfClosingElement(current2) || import_ts_morph63.Node.isJsxFragment(current2);
|
|
14045
14141
|
}
|
|
14046
14142
|
|
|
14047
14143
|
// src/graphqlContract.ts
|
|
@@ -14164,132 +14260,10 @@ function createReferenceIndex(sourceFiles) {
|
|
|
14164
14260
|
};
|
|
14165
14261
|
}
|
|
14166
14262
|
|
|
14167
|
-
// src/resolve/boundaryEffects.ts
|
|
14168
|
-
var import_datalog3 = require("@suss/datalog");
|
|
14169
|
-
var EFFECT_RULES = [
|
|
14170
|
-
(0, import_datalog3.rule)(
|
|
14171
|
-
"reachFrom",
|
|
14172
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("e")],
|
|
14173
|
-
[(0, import_datalog3.lit)("entry", (0, import_datalog3.variable)("e"))]
|
|
14174
|
-
),
|
|
14175
|
-
(0, import_datalog3.rule)(
|
|
14176
|
-
"reachFrom",
|
|
14177
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("v")],
|
|
14178
|
-
[
|
|
14179
|
-
(0, import_datalog3.lit)("reachFrom", (0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("u")),
|
|
14180
|
-
(0, import_datalog3.lit)("calls", (0, import_datalog3.variable)("u"), (0, import_datalog3.variable)("v"))
|
|
14181
|
-
]
|
|
14182
|
-
),
|
|
14183
|
-
(0, import_datalog3.rule)(
|
|
14184
|
-
"boundaryEffect",
|
|
14185
|
-
[(0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("kind"), (0, import_datalog3.variable)("target")],
|
|
14186
|
-
[
|
|
14187
|
-
(0, import_datalog3.lit)("reachFrom", (0, import_datalog3.variable)("e"), (0, import_datalog3.variable)("u")),
|
|
14188
|
-
(0, import_datalog3.lit)("unitEffect", (0, import_datalog3.variable)("u"), (0, import_datalog3.variable)("kind"), (0, import_datalog3.variable)("target"))
|
|
14189
|
-
]
|
|
14190
|
-
)
|
|
14191
|
-
];
|
|
14192
|
-
function bindingLabel(binding) {
|
|
14193
|
-
const semantics = binding.semantics;
|
|
14194
|
-
if (semantics.name === "rest") {
|
|
14195
|
-
return `${semantics.method} ${semantics.path}`;
|
|
14196
|
-
}
|
|
14197
|
-
if (semantics.name === "storage") {
|
|
14198
|
-
return `${semantics.storageSystem}:${semantics.container}`;
|
|
14199
|
-
}
|
|
14200
|
-
if (semantics.name === "message-bus") {
|
|
14201
|
-
return `${semantics.messageBus}:${semantics.channel}`;
|
|
14202
|
-
}
|
|
14203
|
-
if (semantics.name === "runtime-config") {
|
|
14204
|
-
return semantics.instanceName;
|
|
14205
|
-
}
|
|
14206
|
-
if (semantics.name === "graphql-resolver") {
|
|
14207
|
-
return `${semantics.typeName}.${semantics.fieldName}`;
|
|
14208
|
-
}
|
|
14209
|
-
if (semantics.name === "graphql-operation") {
|
|
14210
|
-
return `${semantics.operationType} ${semantics.operationName ?? ""}`.trim();
|
|
14211
|
-
}
|
|
14212
|
-
if ("exportName" in semantics || "module" in semantics) {
|
|
14213
|
-
return semantics.exportName ?? semantics.module ?? binding.recognition;
|
|
14214
|
-
}
|
|
14215
|
-
if ("instanceName" in semantics && semantics.instanceName !== null) {
|
|
14216
|
-
return `${semantics.deploymentTarget}:${semantics.instanceName}`;
|
|
14217
|
-
}
|
|
14218
|
-
return binding.recognition;
|
|
14219
|
-
}
|
|
14220
|
-
function effectFact(effect) {
|
|
14221
|
-
if (effect.type === "invocation") {
|
|
14222
|
-
return { kind: "invocation", target: effect.callee };
|
|
14223
|
-
}
|
|
14224
|
-
if (effect.type === "mutation") {
|
|
14225
|
-
return { kind: "mutation", target: `${effect.operation}:${effect.target}` };
|
|
14226
|
-
}
|
|
14227
|
-
if (effect.type === "emission") {
|
|
14228
|
-
return { kind: "emission", target: effect.event };
|
|
14229
|
-
}
|
|
14230
|
-
if (effect.type === "stateChange") {
|
|
14231
|
-
return { kind: "stateChange", target: effect.variable };
|
|
14232
|
-
}
|
|
14233
|
-
if (effect.type === "interaction") {
|
|
14234
|
-
return { kind: "interaction", target: bindingLabel(effect.binding) };
|
|
14235
|
-
}
|
|
14236
|
-
return null;
|
|
14237
|
-
}
|
|
14238
|
-
function deriveBoundaryEffects(summaries, facts) {
|
|
14239
|
-
const { db, unitKeyBySummary } = facts;
|
|
14240
|
-
for (const summary of summaries) {
|
|
14241
|
-
const key = unitKeyBySummary.get(summary);
|
|
14242
|
-
if (key === void 0) {
|
|
14243
|
-
continue;
|
|
14244
|
-
}
|
|
14245
|
-
for (const transition of summary.transitions) {
|
|
14246
|
-
for (const effect of transition.effects) {
|
|
14247
|
-
const fact2 = effectFact(effect);
|
|
14248
|
-
if (fact2 !== null) {
|
|
14249
|
-
db.add("unitEffect", [key, fact2.kind, fact2.target]);
|
|
14250
|
-
}
|
|
14251
|
-
}
|
|
14252
|
-
}
|
|
14253
|
-
}
|
|
14254
|
-
(0, import_datalog3.evaluate)(db, EFFECT_RULES);
|
|
14255
|
-
const ownByEntry = /* @__PURE__ */ new Map();
|
|
14256
|
-
for (const [unit, kind, target] of db.facts("unitEffect")) {
|
|
14257
|
-
const bucket = ownByEntry.get(String(unit)) ?? /* @__PURE__ */ new Set();
|
|
14258
|
-
bucket.add(`${kind}\0${target}`);
|
|
14259
|
-
ownByEntry.set(String(unit), bucket);
|
|
14260
|
-
}
|
|
14261
|
-
const closureByEntry = /* @__PURE__ */ new Map();
|
|
14262
|
-
for (const [entry, kind, target] of db.facts("boundaryEffect")) {
|
|
14263
|
-
const entryKey2 = String(entry);
|
|
14264
|
-
const bucket = closureByEntry.get(entryKey2) ?? [];
|
|
14265
|
-
bucket.push({
|
|
14266
|
-
kind: String(kind),
|
|
14267
|
-
target: String(target),
|
|
14268
|
-
transitive: !(ownByEntry.get(entryKey2)?.has(`${kind}\0${target}`) ?? false)
|
|
14269
|
-
});
|
|
14270
|
-
closureByEntry.set(entryKey2, bucket);
|
|
14271
|
-
}
|
|
14272
|
-
for (const summary of summaries) {
|
|
14273
|
-
const key = unitKeyBySummary.get(summary);
|
|
14274
|
-
if (key === void 0 || !db.has("entry", [key])) {
|
|
14275
|
-
continue;
|
|
14276
|
-
}
|
|
14277
|
-
const effects = closureByEntry.get(key);
|
|
14278
|
-
if (effects === void 0 || effects.length === 0) {
|
|
14279
|
-
continue;
|
|
14280
|
-
}
|
|
14281
|
-
const sorted = [...effects].sort(
|
|
14282
|
-
(a, b) => `${a.kind}:${a.target}`.localeCompare(`${b.kind}:${b.target}`)
|
|
14283
|
-
);
|
|
14284
|
-
summary.metadata = { ...summary.metadata, effectsClosure: sorted };
|
|
14285
|
-
}
|
|
14286
|
-
return summaries;
|
|
14287
|
-
}
|
|
14288
|
-
|
|
14289
14263
|
// src/resolve/reachableClosure.ts
|
|
14290
|
-
var
|
|
14264
|
+
var import_ts_morph64 = require("ts-morph");
|
|
14291
14265
|
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
14292
|
-
var
|
|
14266
|
+
var import_datalog3 = require("@suss/datalog");
|
|
14293
14267
|
var import_extractor8 = require("@suss/extractor");
|
|
14294
14268
|
var GENERIC_TERMINALS = [
|
|
14295
14269
|
{ kind: "return", match: { type: "returnStatement" }, extraction: {} },
|
|
@@ -14320,7 +14294,7 @@ function targetOf(node) {
|
|
|
14320
14294
|
};
|
|
14321
14295
|
}
|
|
14322
14296
|
function resolveCallee(call, calleeName, scan) {
|
|
14323
|
-
if (!
|
|
14297
|
+
if (!import_ts_morph64.Node.isCallExpression(call)) {
|
|
14324
14298
|
return null;
|
|
14325
14299
|
}
|
|
14326
14300
|
const callee = call.getExpression();
|
|
@@ -14333,7 +14307,7 @@ function resolveCallee(call, calleeName, scan) {
|
|
|
14333
14307
|
}
|
|
14334
14308
|
}
|
|
14335
14309
|
const resolveSources = scan.resolveCallableSources;
|
|
14336
|
-
if (resolveSources !== void 0 &&
|
|
14310
|
+
if (resolveSources !== void 0 && import_ts_morph64.Node.isPropertyAccessExpression(callee) && declarations.some(isDeclaredShape)) {
|
|
14337
14311
|
const sources = resolveSources(callee, scan.reachedFrom);
|
|
14338
14312
|
const only = sources.length === 1 ? sources[0] : void 0;
|
|
14339
14313
|
const resolved = only === void 0 ? null : resolveDecl(only, calleeName);
|
|
@@ -14379,11 +14353,11 @@ function passedPositionKey(target, position) {
|
|
|
14379
14353
|
return `${offsetKeyFor(target.file, target.span)}#${position}`;
|
|
14380
14354
|
}
|
|
14381
14355
|
function resolveJsxReference(node, scan) {
|
|
14382
|
-
if (!
|
|
14356
|
+
if (!import_ts_morph64.Node.isJsxOpeningElement(node) && !import_ts_morph64.Node.isJsxSelfClosingElement(node)) {
|
|
14383
14357
|
return null;
|
|
14384
14358
|
}
|
|
14385
14359
|
const tag = node.getTagNameNode();
|
|
14386
|
-
if (!
|
|
14360
|
+
if (!import_ts_morph64.Node.isIdentifier(tag) || !/^[A-Z]/.test(tag.getText())) {
|
|
14387
14361
|
return null;
|
|
14388
14362
|
}
|
|
14389
14363
|
const name = tag.getText();
|
|
@@ -14429,12 +14403,12 @@ function collectReachable(func, scan) {
|
|
|
14429
14403
|
candidates.push(outcome.candidate);
|
|
14430
14404
|
};
|
|
14431
14405
|
const recordPassedArgs = (call, calleeText, calleeOutcome) => {
|
|
14432
|
-
if (!
|
|
14406
|
+
if (!import_ts_morph64.Node.isCallExpression(call)) {
|
|
14433
14407
|
return;
|
|
14434
14408
|
}
|
|
14435
14409
|
const calleeTarget = declaredAtOf(calleeOutcome);
|
|
14436
14410
|
call.getArguments().forEach((arg, position) => {
|
|
14437
|
-
if (!
|
|
14411
|
+
if (!import_ts_morph64.Node.isIdentifier(arg)) {
|
|
14438
14412
|
return;
|
|
14439
14413
|
}
|
|
14440
14414
|
const resolved = functionTargetOf(arg);
|
|
@@ -14454,7 +14428,7 @@ function collectReachable(func, scan) {
|
|
|
14454
14428
|
record2(jsx.outcome);
|
|
14455
14429
|
return;
|
|
14456
14430
|
}
|
|
14457
|
-
if (!
|
|
14431
|
+
if (!import_ts_morph64.Node.isCallExpression(node)) {
|
|
14458
14432
|
return;
|
|
14459
14433
|
}
|
|
14460
14434
|
const calleeText = normalizeCallee(node.getExpression().getText());
|
|
@@ -14506,13 +14480,13 @@ function extractReachableSummary(candidate, options, recognizers) {
|
|
|
14506
14480
|
return (0, import_extractor8.assembleSummary)(raw, options);
|
|
14507
14481
|
}
|
|
14508
14482
|
var REACHABLE_RULES = [
|
|
14509
|
-
(0,
|
|
14510
|
-
(0,
|
|
14483
|
+
(0, import_datalog3.rule)("reachable", [(0, import_datalog3.variable)("f")], [(0, import_datalog3.lit)("entry", (0, import_datalog3.variable)("f"))]),
|
|
14484
|
+
(0, import_datalog3.rule)(
|
|
14511
14485
|
"reachable",
|
|
14512
|
-
[(0,
|
|
14486
|
+
[(0, import_datalog3.variable)("g")],
|
|
14513
14487
|
[
|
|
14514
|
-
(0,
|
|
14515
|
-
(0,
|
|
14488
|
+
(0, import_datalog3.lit)("reachable", (0, import_datalog3.variable)("f")),
|
|
14489
|
+
(0, import_datalog3.lit)("calls", (0, import_datalog3.variable)("f"), (0, import_datalog3.variable)("g"))
|
|
14516
14490
|
]
|
|
14517
14491
|
)
|
|
14518
14492
|
];
|
|
@@ -14540,7 +14514,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
14540
14514
|
}
|
|
14541
14515
|
for (const declaration of variableStatement.getDeclarations()) {
|
|
14542
14516
|
const init = declaration.getInitializer();
|
|
14543
|
-
if (init !== void 0 && (
|
|
14517
|
+
if (init !== void 0 && (import_ts_morph64.Node.isArrowFunction(init) || import_ts_morph64.Node.isFunctionExpression(init)) && hasBody(init)) {
|
|
14544
14518
|
roots.push({ func: init, name: declaration.getName() });
|
|
14545
14519
|
}
|
|
14546
14520
|
}
|
|
@@ -14550,7 +14524,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
14550
14524
|
}
|
|
14551
14525
|
function expandReachableClosure(seeds, project, options, projectFileSet, facts, recognizers = NO_RECOGNIZERS, alreadySummarized = [], extraRoots = []) {
|
|
14552
14526
|
const lookup = createSourceFileLookup(project);
|
|
14553
|
-
const db = facts?.db ?? new
|
|
14527
|
+
const db = facts?.db ?? new import_datalog3.Database();
|
|
14554
14528
|
const functionByKey = /* @__PURE__ */ new Map();
|
|
14555
14529
|
const seedKeys = /* @__PURE__ */ new Set();
|
|
14556
14530
|
const scanned = /* @__PURE__ */ new Set();
|
|
@@ -14589,7 +14563,7 @@ function expandReachableClosure(seeds, project, options, projectFileSet, facts,
|
|
|
14589
14563
|
}
|
|
14590
14564
|
}
|
|
14591
14565
|
for (; ; ) {
|
|
14592
|
-
(0,
|
|
14566
|
+
(0, import_datalog3.evaluate)(db, REACHABLE_RULES);
|
|
14593
14567
|
const frontier = db.facts("reachable").map(([key]) => String(key)).filter((key) => !scanned.has(key));
|
|
14594
14568
|
if (frontier.length === 0) {
|
|
14595
14569
|
break;
|
|
@@ -14794,21 +14768,21 @@ function recordParameterGaps(parameterCallsByKey, summariesByKey, passedPosition
|
|
|
14794
14768
|
}
|
|
14795
14769
|
|
|
14796
14770
|
// src/resolve/rethrowEnrichment.ts
|
|
14797
|
-
var
|
|
14798
|
-
var
|
|
14771
|
+
var import_ts_morph65 = require("ts-morph");
|
|
14772
|
+
var import_datalog4 = require("@suss/datalog");
|
|
14799
14773
|
var RETHROW_RULES = [
|
|
14800
|
-
(0,
|
|
14774
|
+
(0, import_datalog4.rule)(
|
|
14801
14775
|
"contributes",
|
|
14802
|
-
[(0,
|
|
14803
|
-
[(0,
|
|
14776
|
+
[(0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s")],
|
|
14777
|
+
[(0, import_datalog4.lit)("throwsDirect", (0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s"))]
|
|
14804
14778
|
),
|
|
14805
|
-
(0,
|
|
14779
|
+
(0, import_datalog4.rule)(
|
|
14806
14780
|
"contributes",
|
|
14807
|
-
[(0,
|
|
14781
|
+
[(0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("s")],
|
|
14808
14782
|
[
|
|
14809
|
-
(0,
|
|
14810
|
-
(0,
|
|
14811
|
-
(0,
|
|
14783
|
+
(0, import_datalog4.lit)("rethrowSite", (0, import_datalog4.variable)("u"), (0, import_datalog4.variable)("site")),
|
|
14784
|
+
(0, import_datalog4.lit)("siteCalls", (0, import_datalog4.variable)("site"), (0, import_datalog4.variable)("c")),
|
|
14785
|
+
(0, import_datalog4.lit)("contributes", (0, import_datalog4.variable)("c"), (0, import_datalog4.variable)("s"))
|
|
14812
14786
|
]
|
|
14813
14787
|
)
|
|
14814
14788
|
];
|
|
@@ -14820,7 +14794,7 @@ function enrichRethrows(summaries, project, facts) {
|
|
|
14820
14794
|
summary.location.range.start,
|
|
14821
14795
|
summary.location.range.end
|
|
14822
14796
|
));
|
|
14823
|
-
const db = facts?.db ?? new
|
|
14797
|
+
const db = facts?.db ?? new import_datalog4.Database();
|
|
14824
14798
|
const sourceById = /* @__PURE__ */ new Map();
|
|
14825
14799
|
const nameByUnit = /* @__PURE__ */ new Map();
|
|
14826
14800
|
const targets = [];
|
|
@@ -14870,7 +14844,7 @@ function enrichRethrows(summaries, project, facts) {
|
|
|
14870
14844
|
}
|
|
14871
14845
|
}
|
|
14872
14846
|
}
|
|
14873
|
-
(0,
|
|
14847
|
+
(0, import_datalog4.evaluate)(db, RETHROW_RULES);
|
|
14874
14848
|
const contributesByUnit = /* @__PURE__ */ new Map();
|
|
14875
14849
|
for (const [unit, sourceId] of db.facts("contributes")) {
|
|
14876
14850
|
const bucket = contributesByUnit.get(String(unit));
|
|
@@ -14931,7 +14905,7 @@ function findBareRethrow(func, location) {
|
|
|
14931
14905
|
traversal.stop();
|
|
14932
14906
|
return;
|
|
14933
14907
|
}
|
|
14934
|
-
if (!
|
|
14908
|
+
if (!import_ts_morph65.Node.isThrowStatement(node)) {
|
|
14935
14909
|
return;
|
|
14936
14910
|
}
|
|
14937
14911
|
if (startLineOf(node) !== location.start) {
|
|
@@ -14941,7 +14915,7 @@ function findBareRethrow(func, location) {
|
|
|
14941
14915
|
return;
|
|
14942
14916
|
}
|
|
14943
14917
|
const thrown = node.getExpression();
|
|
14944
|
-
if (thrown !== void 0 &&
|
|
14918
|
+
if (thrown !== void 0 && import_ts_morph65.Node.isIdentifier(thrown)) {
|
|
14945
14919
|
found = node;
|
|
14946
14920
|
}
|
|
14947
14921
|
});
|
|
@@ -14951,13 +14925,13 @@ function enclosingTry(throwStmt) {
|
|
|
14951
14925
|
let current2 = throwStmt.getParent();
|
|
14952
14926
|
let sawCatchClause = false;
|
|
14953
14927
|
while (current2 !== void 0) {
|
|
14954
|
-
if (
|
|
14928
|
+
if (import_ts_morph65.Node.isCatchClause(current2)) {
|
|
14955
14929
|
sawCatchClause = true;
|
|
14956
14930
|
}
|
|
14957
|
-
if (
|
|
14931
|
+
if (import_ts_morph65.Node.isTryStatement(current2)) {
|
|
14958
14932
|
return sawCatchClause ? current2 : null;
|
|
14959
14933
|
}
|
|
14960
|
-
if (
|
|
14934
|
+
if (import_ts_morph65.Node.isFunctionDeclaration(current2) || import_ts_morph65.Node.isFunctionExpression(current2) || import_ts_morph65.Node.isArrowFunction(current2) || import_ts_morph65.Node.isMethodDeclaration(current2)) {
|
|
14961
14935
|
return null;
|
|
14962
14936
|
}
|
|
14963
14937
|
current2 = current2.getParent();
|
|
@@ -14965,14 +14939,14 @@ function enclosingTry(throwStmt) {
|
|
|
14965
14939
|
return null;
|
|
14966
14940
|
}
|
|
14967
14941
|
function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
14968
|
-
if (!
|
|
14942
|
+
if (!import_ts_morph65.Node.isTryStatement(tryStmt)) {
|
|
14969
14943
|
return [];
|
|
14970
14944
|
}
|
|
14971
14945
|
const tryBlock = tryStmt.getTryBlock();
|
|
14972
14946
|
const callees = [];
|
|
14973
14947
|
const seen = /* @__PURE__ */ new Set();
|
|
14974
14948
|
tryBlock.forEachDescendant((node) => {
|
|
14975
|
-
if (!
|
|
14949
|
+
if (!import_ts_morph65.Node.isCallExpression(node)) {
|
|
14976
14950
|
return;
|
|
14977
14951
|
}
|
|
14978
14952
|
const calleeSummary = resolveCalleeSummary(node, index);
|
|
@@ -14989,7 +14963,7 @@ function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
|
14989
14963
|
return callees;
|
|
14990
14964
|
}
|
|
14991
14965
|
function resolveCalleeSummary(call, index) {
|
|
14992
|
-
if (!
|
|
14966
|
+
if (!import_ts_morph65.Node.isCallExpression(call)) {
|
|
14993
14967
|
return null;
|
|
14994
14968
|
}
|
|
14995
14969
|
const callee = call.getExpression();
|
|
@@ -15019,12 +14993,12 @@ function resolveCalleeSummary(call, index) {
|
|
|
15019
14993
|
return null;
|
|
15020
14994
|
}
|
|
15021
14995
|
function functionFromDecl(decl) {
|
|
15022
|
-
if (
|
|
14996
|
+
if (import_ts_morph65.Node.isFunctionDeclaration(decl) || import_ts_morph65.Node.isFunctionExpression(decl) || import_ts_morph65.Node.isArrowFunction(decl) || import_ts_morph65.Node.isMethodDeclaration(decl)) {
|
|
15023
14997
|
return decl;
|
|
15024
14998
|
}
|
|
15025
|
-
if (
|
|
14999
|
+
if (import_ts_morph65.Node.isVariableDeclaration(decl)) {
|
|
15026
15000
|
const init = decl.getInitializer();
|
|
15027
|
-
if (init !== void 0 && (
|
|
15001
|
+
if (init !== void 0 && (import_ts_morph65.Node.isArrowFunction(init) || import_ts_morph65.Node.isFunctionExpression(init))) {
|
|
15028
15002
|
return init;
|
|
15029
15003
|
}
|
|
15030
15004
|
}
|
|
@@ -15032,22 +15006,22 @@ function functionFromDecl(decl) {
|
|
|
15032
15006
|
}
|
|
15033
15007
|
|
|
15034
15008
|
// src/shapes/fieldAccesses.ts
|
|
15035
|
-
var
|
|
15009
|
+
var import_ts_morph66 = require("ts-morph");
|
|
15036
15010
|
function findResponseAccessor(callExpr) {
|
|
15037
15011
|
let current2 = callExpr;
|
|
15038
15012
|
const parent1 = current2.getParent();
|
|
15039
|
-
if (parent1 !== void 0 &&
|
|
15013
|
+
if (parent1 !== void 0 && import_ts_morph66.Node.isAwaitExpression(parent1)) {
|
|
15040
15014
|
current2 = parent1;
|
|
15041
15015
|
}
|
|
15042
15016
|
const parent2 = current2.getParent();
|
|
15043
|
-
if (parent2 === void 0 || !
|
|
15017
|
+
if (parent2 === void 0 || !import_ts_morph66.Node.isVariableDeclaration(parent2)) {
|
|
15044
15018
|
return null;
|
|
15045
15019
|
}
|
|
15046
15020
|
const nameNode = parent2.getNameNode();
|
|
15047
|
-
if (
|
|
15021
|
+
if (import_ts_morph66.Node.isIdentifier(nameNode)) {
|
|
15048
15022
|
return { kind: "identifier", name: nameNode.getText() };
|
|
15049
15023
|
}
|
|
15050
|
-
if (
|
|
15024
|
+
if (import_ts_morph66.Node.isObjectBindingPattern(nameNode)) {
|
|
15051
15025
|
const bindings = /* @__PURE__ */ new Map();
|
|
15052
15026
|
for (const element of nameNode.getElements()) {
|
|
15053
15027
|
if (element.getDotDotDotToken() !== void 0) {
|
|
@@ -15068,11 +15042,11 @@ function findResponseAccessor(callExpr) {
|
|
|
15068
15042
|
function buildThenChainAccessor(callExpr, func) {
|
|
15069
15043
|
const bindings = /* @__PURE__ */ new Map();
|
|
15070
15044
|
func.forEachDescendant((node) => {
|
|
15071
|
-
if (!
|
|
15045
|
+
if (!import_ts_morph66.Node.isParameterDeclaration(node)) {
|
|
15072
15046
|
return;
|
|
15073
15047
|
}
|
|
15074
15048
|
const nameNode = node.getNameNode();
|
|
15075
|
-
if (!
|
|
15049
|
+
if (!import_ts_morph66.Node.isIdentifier(nameNode)) {
|
|
15076
15050
|
return;
|
|
15077
15051
|
}
|
|
15078
15052
|
const prefix = prefixOfThenParam(node, callExpr, 0);
|
|
@@ -15104,7 +15078,7 @@ function prefixOfExpr(expr, responseCall, depth) {
|
|
|
15104
15078
|
if (node === responseCall) {
|
|
15105
15079
|
return [];
|
|
15106
15080
|
}
|
|
15107
|
-
if (
|
|
15081
|
+
if (import_ts_morph66.Node.isCallExpression(node)) {
|
|
15108
15082
|
const hop = thenLikeCall(node);
|
|
15109
15083
|
if (hop !== null) {
|
|
15110
15084
|
if (hop.method === "catch") {
|
|
@@ -15136,14 +15110,14 @@ function prefixOfMemberExpr(expr, responseCall, depth) {
|
|
|
15136
15110
|
return null;
|
|
15137
15111
|
}
|
|
15138
15112
|
const decl = chain.root.getSymbol()?.getDeclarations()?.[0];
|
|
15139
|
-
if (decl === void 0 || !
|
|
15113
|
+
if (decl === void 0 || !import_ts_morph66.Node.isParameterDeclaration(decl)) {
|
|
15140
15114
|
return null;
|
|
15141
15115
|
}
|
|
15142
15116
|
const base = prefixOfThenParam(decl, responseCall, depth + 1);
|
|
15143
15117
|
return base === null ? null : [...base, ...chain.segments];
|
|
15144
15118
|
}
|
|
15145
15119
|
function firstCallbackParamName(callback) {
|
|
15146
|
-
if (callback === void 0 || !(
|
|
15120
|
+
if (callback === void 0 || !(import_ts_morph66.Node.isArrowFunction(callback) || import_ts_morph66.Node.isFunctionExpression(callback))) {
|
|
15147
15121
|
return null;
|
|
15148
15122
|
}
|
|
15149
15123
|
const param = callback.getParameters()[0];
|
|
@@ -15151,11 +15125,11 @@ function firstCallbackParamName(callback) {
|
|
|
15151
15125
|
return null;
|
|
15152
15126
|
}
|
|
15153
15127
|
const nameNode = param.getNameNode();
|
|
15154
|
-
return
|
|
15128
|
+
return import_ts_morph66.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15155
15129
|
}
|
|
15156
15130
|
function unwrap(expr) {
|
|
15157
15131
|
let node = expr;
|
|
15158
|
-
while (
|
|
15132
|
+
while (import_ts_morph66.Node.isAwaitExpression(node) || import_ts_morph66.Node.isParenthesizedExpression(node) || import_ts_morph66.Node.isAsExpression(node)) {
|
|
15159
15133
|
node = node.getExpression();
|
|
15160
15134
|
}
|
|
15161
15135
|
return node;
|
|
@@ -15165,15 +15139,15 @@ function chainRootedAt(expr, rootName) {
|
|
|
15165
15139
|
if (chain === null) {
|
|
15166
15140
|
return null;
|
|
15167
15141
|
}
|
|
15168
|
-
return
|
|
15142
|
+
return import_ts_morph66.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
|
|
15169
15143
|
}
|
|
15170
15144
|
function memberChain(expr) {
|
|
15171
|
-
let node =
|
|
15172
|
-
if (
|
|
15145
|
+
let node = import_ts_morph66.Node.isExpression(expr) ? unwrap(expr) : expr;
|
|
15146
|
+
if (import_ts_morph66.Node.isCallExpression(node)) {
|
|
15173
15147
|
node = node.getExpression();
|
|
15174
15148
|
}
|
|
15175
15149
|
const segments = [];
|
|
15176
|
-
while (
|
|
15150
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(node)) {
|
|
15177
15151
|
segments.unshift(node.getName());
|
|
15178
15152
|
node = node.getExpression();
|
|
15179
15153
|
}
|
|
@@ -15192,16 +15166,16 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15192
15166
|
if (accessor.kind === "identifier") {
|
|
15193
15167
|
const varName = accessor.name;
|
|
15194
15168
|
subtree.forEachDescendant((node) => {
|
|
15195
|
-
if (!
|
|
15169
|
+
if (!import_ts_morph66.Node.isPropertyAccessExpression(node)) {
|
|
15196
15170
|
return;
|
|
15197
15171
|
}
|
|
15198
15172
|
const chain = [];
|
|
15199
15173
|
let current2 = node;
|
|
15200
|
-
while (
|
|
15174
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(current2)) {
|
|
15201
15175
|
chain.unshift(current2.getName());
|
|
15202
15176
|
current2 = current2.getExpression();
|
|
15203
15177
|
}
|
|
15204
|
-
if (
|
|
15178
|
+
if (import_ts_morph66.Node.isIdentifier(current2) && current2.getText() === varName) {
|
|
15205
15179
|
pushChain(chain);
|
|
15206
15180
|
}
|
|
15207
15181
|
});
|
|
@@ -15212,7 +15186,7 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15212
15186
|
return source === void 0 ? void 0 : [source];
|
|
15213
15187
|
} : (name) => accessor.bindings.get(name);
|
|
15214
15188
|
subtree.forEachDescendant((node) => {
|
|
15215
|
-
if (!
|
|
15189
|
+
if (!import_ts_morph66.Node.isIdentifier(node)) {
|
|
15216
15190
|
return;
|
|
15217
15191
|
}
|
|
15218
15192
|
const prefix = prefixOf(node.getText());
|
|
@@ -15224,13 +15198,13 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
15224
15198
|
}
|
|
15225
15199
|
let chainTop = node;
|
|
15226
15200
|
let parent = chainTop.getParent();
|
|
15227
|
-
while (parent !== void 0 &&
|
|
15201
|
+
while (parent !== void 0 && import_ts_morph66.Node.isPropertyAccessExpression(parent) && parent.getExpression() === chainTop) {
|
|
15228
15202
|
chainTop = parent;
|
|
15229
15203
|
parent = chainTop.getParent();
|
|
15230
15204
|
}
|
|
15231
15205
|
const segments = [];
|
|
15232
15206
|
let current2 = chainTop;
|
|
15233
|
-
while (
|
|
15207
|
+
while (import_ts_morph66.Node.isPropertyAccessExpression(current2)) {
|
|
15234
15208
|
segments.push(current2.getName());
|
|
15235
15209
|
current2 = current2.getExpression();
|
|
15236
15210
|
}
|
|
@@ -15244,15 +15218,15 @@ function isBindingDeclarationSite(node) {
|
|
|
15244
15218
|
return true;
|
|
15245
15219
|
}
|
|
15246
15220
|
const parent = node.getParent();
|
|
15247
|
-
return parent !== void 0 &&
|
|
15221
|
+
return parent !== void 0 && import_ts_morph66.Node.isParameterDeclaration(parent) && parent.getNameNode() === node;
|
|
15248
15222
|
}
|
|
15249
15223
|
function isInsideObjectBindingPattern(node) {
|
|
15250
15224
|
let current2 = node.getParent();
|
|
15251
15225
|
while (current2 !== void 0) {
|
|
15252
|
-
if (
|
|
15226
|
+
if (import_ts_morph66.Node.isObjectBindingPattern(current2)) {
|
|
15253
15227
|
return true;
|
|
15254
15228
|
}
|
|
15255
|
-
if (
|
|
15229
|
+
if (import_ts_morph66.Node.isFunctionLikeDeclaration(current2) || import_ts_morph66.Node.isVariableStatement(current2)) {
|
|
15256
15230
|
break;
|
|
15257
15231
|
}
|
|
15258
15232
|
current2 = current2.getParent();
|
|
@@ -15315,7 +15289,7 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
|
|
|
15315
15289
|
if (parent === void 0) {
|
|
15316
15290
|
break;
|
|
15317
15291
|
}
|
|
15318
|
-
if (
|
|
15292
|
+
if (import_ts_morph66.Node.isIfStatement(parent)) {
|
|
15319
15293
|
const ifStmt = parent;
|
|
15320
15294
|
const thenBlock = ifStmt.getThenStatement();
|
|
15321
15295
|
const elseBlock = ifStmt.getElseStatement();
|
|
@@ -15377,7 +15351,7 @@ function buildNonBodyPropertySet(semantics) {
|
|
|
15377
15351
|
}
|
|
15378
15352
|
|
|
15379
15353
|
// src/subUnitContext.ts
|
|
15380
|
-
var
|
|
15354
|
+
var import_ts_morph67 = require("ts-morph");
|
|
15381
15355
|
function createTsSubUnitContext() {
|
|
15382
15356
|
return {
|
|
15383
15357
|
findJsxAttributes,
|
|
@@ -15404,18 +15378,18 @@ function findJsxAttributes(parent) {
|
|
|
15404
15378
|
if (skip(node, traversal)) {
|
|
15405
15379
|
return;
|
|
15406
15380
|
}
|
|
15407
|
-
if (!
|
|
15381
|
+
if (!import_ts_morph67.Node.isJsxOpeningElement(node) && !import_ts_morph67.Node.isJsxSelfClosingElement(node)) {
|
|
15408
15382
|
return;
|
|
15409
15383
|
}
|
|
15410
15384
|
const tag = node.getTagNameNode().getText();
|
|
15411
15385
|
for (const attr of node.getAttributes()) {
|
|
15412
|
-
if (!
|
|
15386
|
+
if (!import_ts_morph67.Node.isJsxAttribute(attr)) {
|
|
15413
15387
|
continue;
|
|
15414
15388
|
}
|
|
15415
15389
|
const initializer = attr.getInitializer();
|
|
15416
15390
|
let valueExpression = null;
|
|
15417
15391
|
if (initializer !== void 0) {
|
|
15418
|
-
if (
|
|
15392
|
+
if (import_ts_morph67.Node.isJsxExpression(initializer)) {
|
|
15419
15393
|
const inner = initializer.getExpression();
|
|
15420
15394
|
valueExpression = inner ?? null;
|
|
15421
15395
|
} else {
|
|
@@ -15438,11 +15412,11 @@ function findCallExpressionsByName(parent, name) {
|
|
|
15438
15412
|
if (skip(node, traversal)) {
|
|
15439
15413
|
return;
|
|
15440
15414
|
}
|
|
15441
|
-
if (!
|
|
15415
|
+
if (!import_ts_morph67.Node.isCallExpression(node)) {
|
|
15442
15416
|
return;
|
|
15443
15417
|
}
|
|
15444
15418
|
const callee = node.getExpression();
|
|
15445
|
-
if (
|
|
15419
|
+
if (import_ts_morph67.Node.isIdentifier(callee) && callee.getText() === name) {
|
|
15446
15420
|
out.push(node);
|
|
15447
15421
|
}
|
|
15448
15422
|
});
|
|
@@ -15453,10 +15427,10 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15453
15427
|
if (expr === null) {
|
|
15454
15428
|
return null;
|
|
15455
15429
|
}
|
|
15456
|
-
if (
|
|
15430
|
+
if (import_ts_morph67.Node.isArrowFunction(expr) || import_ts_morph67.Node.isFunctionExpression(expr)) {
|
|
15457
15431
|
return { func: expr, localName: null };
|
|
15458
15432
|
}
|
|
15459
|
-
if (
|
|
15433
|
+
if (import_ts_morph67.Node.isIdentifier(expr)) {
|
|
15460
15434
|
const symbol = expr.getSymbol();
|
|
15461
15435
|
if (symbol === void 0) {
|
|
15462
15436
|
return null;
|
|
@@ -15475,15 +15449,15 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
15475
15449
|
return null;
|
|
15476
15450
|
}
|
|
15477
15451
|
function tryExtractFunction(decl) {
|
|
15478
|
-
if (
|
|
15452
|
+
if (import_ts_morph67.Node.isFunctionDeclaration(decl)) {
|
|
15479
15453
|
return decl;
|
|
15480
15454
|
}
|
|
15481
|
-
if (
|
|
15455
|
+
if (import_ts_morph67.Node.isVariableDeclaration(decl)) {
|
|
15482
15456
|
const init = decl.getInitializer();
|
|
15483
15457
|
if (init === void 0) {
|
|
15484
15458
|
return null;
|
|
15485
15459
|
}
|
|
15486
|
-
if (
|
|
15460
|
+
if (import_ts_morph67.Node.isArrowFunction(init) || import_ts_morph67.Node.isFunctionExpression(init)) {
|
|
15487
15461
|
return init;
|
|
15488
15462
|
}
|
|
15489
15463
|
}
|
|
@@ -15504,7 +15478,7 @@ function getCallArgumentFunction(call, position) {
|
|
|
15504
15478
|
if (arg === void 0) {
|
|
15505
15479
|
return null;
|
|
15506
15480
|
}
|
|
15507
|
-
if (
|
|
15481
|
+
if (import_ts_morph67.Node.isArrowFunction(arg) || import_ts_morph67.Node.isFunctionExpression(arg)) {
|
|
15508
15482
|
return arg;
|
|
15509
15483
|
}
|
|
15510
15484
|
return null;
|
|
@@ -15516,7 +15490,7 @@ function readArrayLiteralText(node) {
|
|
|
15516
15490
|
if (node === null) {
|
|
15517
15491
|
return null;
|
|
15518
15492
|
}
|
|
15519
|
-
if (
|
|
15493
|
+
if (import_ts_morph67.Node.isArrayLiteralExpression(node)) {
|
|
15520
15494
|
return node.getElements().map((e) => e.getText());
|
|
15521
15495
|
}
|
|
15522
15496
|
return [node.getText()];
|
|
@@ -15765,13 +15739,13 @@ var raise = (msg) => {
|
|
|
15765
15739
|
throw new Error(msg);
|
|
15766
15740
|
};
|
|
15767
15741
|
function bindingPatternNames(nameNode) {
|
|
15768
|
-
if (
|
|
15742
|
+
if (import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15769
15743
|
return nameNode.getElements().map((e) => e.getName());
|
|
15770
15744
|
}
|
|
15771
|
-
if (
|
|
15745
|
+
if (import_ts_morph68.Node.isArrayBindingPattern(nameNode)) {
|
|
15772
15746
|
const names = [];
|
|
15773
15747
|
for (const element of nameNode.getElements()) {
|
|
15774
|
-
if (
|
|
15748
|
+
if (import_ts_morph68.Node.isOmittedExpression(element)) {
|
|
15775
15749
|
continue;
|
|
15776
15750
|
}
|
|
15777
15751
|
names.push(element.getName());
|
|
@@ -15801,7 +15775,7 @@ function objectParamInputs(param, position, mapping) {
|
|
|
15801
15775
|
}
|
|
15802
15776
|
function componentPropsParameters(param, mapping) {
|
|
15803
15777
|
const nameNode = param.getNameNode();
|
|
15804
|
-
if (!
|
|
15778
|
+
if (!import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15805
15779
|
const type = param.getType();
|
|
15806
15780
|
return [
|
|
15807
15781
|
{
|
|
@@ -15831,7 +15805,7 @@ function bindingRole(element, name) {
|
|
|
15831
15805
|
if (property === void 0) {
|
|
15832
15806
|
return name;
|
|
15833
15807
|
}
|
|
15834
|
-
if (
|
|
15808
|
+
if (import_ts_morph68.Node.isStringLiteral(property)) {
|
|
15835
15809
|
return property.getLiteralValue();
|
|
15836
15810
|
}
|
|
15837
15811
|
return property.getText();
|
|
@@ -15863,7 +15837,7 @@ function extractParameters(func, inputMapping) {
|
|
|
15863
15837
|
const param = params[i];
|
|
15864
15838
|
const nameNode = param.getNameNode();
|
|
15865
15839
|
const boundNames = bindingPatternNames(nameNode);
|
|
15866
|
-
if (
|
|
15840
|
+
if (import_ts_morph68.Node.isObjectBindingPattern(nameNode)) {
|
|
15867
15841
|
for (const element of nameNode.getElements()) {
|
|
15868
15842
|
result.push({
|
|
15869
15843
|
name: element.getName(),
|
|
@@ -15930,7 +15904,7 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15930
15904
|
traversal.skip();
|
|
15931
15905
|
return;
|
|
15932
15906
|
}
|
|
15933
|
-
if (!
|
|
15907
|
+
if (!import_ts_morph68.Node.isVariableDeclaration(node)) {
|
|
15934
15908
|
return;
|
|
15935
15909
|
}
|
|
15936
15910
|
const init = node.getInitializer();
|
|
@@ -15939,19 +15913,19 @@ function extractDependencyCalls(func, barriers = NO_BARRIERS) {
|
|
|
15939
15913
|
}
|
|
15940
15914
|
let isAsync = false;
|
|
15941
15915
|
let callExpr = init;
|
|
15942
|
-
if (
|
|
15916
|
+
if (import_ts_morph68.Node.isAwaitExpression(init)) {
|
|
15943
15917
|
isAsync = true;
|
|
15944
15918
|
callExpr = init.getExpression();
|
|
15945
15919
|
}
|
|
15946
|
-
if (!
|
|
15920
|
+
if (!import_ts_morph68.Node.isCallExpression(callExpr)) {
|
|
15947
15921
|
return;
|
|
15948
15922
|
}
|
|
15949
15923
|
const calleeName = callExpr.getExpression().getText();
|
|
15950
15924
|
const nameNode = node.getNameNode();
|
|
15951
|
-
const assignedTo =
|
|
15925
|
+
const assignedTo = import_ts_morph68.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
15952
15926
|
const declList = node.getParent();
|
|
15953
15927
|
const varStmt = declList?.getParent();
|
|
15954
|
-
const locationNode = varStmt !== void 0 &&
|
|
15928
|
+
const locationNode = varStmt !== void 0 && import_ts_morph68.Node.isVariableStatement(varStmt) ? varStmt : node;
|
|
15955
15929
|
results.push({
|
|
15956
15930
|
name: calleeName,
|
|
15957
15931
|
assignedTo,
|
|
@@ -16310,6 +16284,10 @@ function extractBindingPath(binding, callSite, pack, resolution) {
|
|
|
16310
16284
|
const arg = callSite.callExpression.getArguments()[p.position];
|
|
16311
16285
|
return arg === void 0 ? void 0 : pathFromArgument(arg, resolution);
|
|
16312
16286
|
}
|
|
16287
|
+
if (p.type === "fromArgumentProperty") {
|
|
16288
|
+
const arg = callSite.callExpression.getArguments()[p.position];
|
|
16289
|
+
return arg === void 0 ? void 0 : pathFromProperty(arg, p.property, resolution);
|
|
16290
|
+
}
|
|
16313
16291
|
return void 0;
|
|
16314
16292
|
}
|
|
16315
16293
|
function resolveContractField(callSite, pack, field, resolution) {
|
|
@@ -16705,20 +16683,23 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16705
16683
|
return summaries;
|
|
16706
16684
|
}
|
|
16707
16685
|
function stampWrappers(raw, unit, wrappers) {
|
|
16708
|
-
|
|
16709
|
-
|
|
16710
|
-
|
|
16711
|
-
|
|
16686
|
+
const applied = [
|
|
16687
|
+
...wrappers === void 0 || unit.registrationSubjectId === void 0 ? [] : wrappers.wrappersFor(unit.registrationSubjectId),
|
|
16688
|
+
...unit.routeWrappers ?? []
|
|
16689
|
+
];
|
|
16712
16690
|
if (applied.length === 0) {
|
|
16713
16691
|
return;
|
|
16714
16692
|
}
|
|
16715
|
-
raw.wrappers =
|
|
16693
|
+
raw.wrappers = applied;
|
|
16716
16694
|
for (const wrapper of applied) {
|
|
16717
16695
|
recordFileDependency(wrapper.file);
|
|
16718
16696
|
}
|
|
16719
16697
|
}
|
|
16720
16698
|
function unfollowedStopsOf(unit, wrappers) {
|
|
16721
|
-
const stops =
|
|
16699
|
+
const stops = [
|
|
16700
|
+
...unit.unfollowed === void 0 ? [] : [unit.unfollowed],
|
|
16701
|
+
...unit.routeUnfollowed ?? []
|
|
16702
|
+
];
|
|
16722
16703
|
if (wrappers === void 0 || unit.registrationSubjectId === void 0) {
|
|
16723
16704
|
return stops;
|
|
16724
16705
|
}
|
|
@@ -16865,9 +16846,9 @@ function findWrapperPathParam(summary, lookup) {
|
|
|
16865
16846
|
if (names.length === 0) {
|
|
16866
16847
|
return null;
|
|
16867
16848
|
}
|
|
16868
|
-
for (const call of func.getDescendantsOfKind(
|
|
16849
|
+
for (const call of func.getDescendantsOfKind(import_ts_morph68.SyntaxKind.CallExpression)) {
|
|
16869
16850
|
const first = call.getArguments()[0];
|
|
16870
|
-
if (first === void 0 || !
|
|
16851
|
+
if (first === void 0 || !import_ts_morph68.Node.isIdentifier(first)) {
|
|
16871
16852
|
continue;
|
|
16872
16853
|
}
|
|
16873
16854
|
const at = names.indexOf(first.getText());
|
|
@@ -16916,16 +16897,16 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16916
16897
|
return out;
|
|
16917
16898
|
}
|
|
16918
16899
|
function wrapperNameNode(func) {
|
|
16919
|
-
if (
|
|
16900
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(func) || import_ts_morph68.Node.isMethodDeclaration(func)) {
|
|
16920
16901
|
const name = func.getNameNode();
|
|
16921
|
-
if (name !== void 0 &&
|
|
16902
|
+
if (name !== void 0 && import_ts_morph68.Node.isIdentifier(name)) {
|
|
16922
16903
|
return name;
|
|
16923
16904
|
}
|
|
16924
16905
|
}
|
|
16925
16906
|
const parent = func.getParent();
|
|
16926
|
-
if (parent !== void 0 &&
|
|
16907
|
+
if (parent !== void 0 && import_ts_morph68.Node.isVariableDeclaration(parent)) {
|
|
16927
16908
|
const nameNode = parent.getNameNode();
|
|
16928
|
-
if (
|
|
16909
|
+
if (import_ts_morph68.Node.isIdentifier(nameNode)) {
|
|
16929
16910
|
return nameNode;
|
|
16930
16911
|
}
|
|
16931
16912
|
}
|
|
@@ -16934,10 +16915,10 @@ function wrapperNameNode(func) {
|
|
|
16934
16915
|
function enclosingCall(node) {
|
|
16935
16916
|
let current2 = node.getParent();
|
|
16936
16917
|
while (current2 !== void 0) {
|
|
16937
|
-
if (
|
|
16918
|
+
if (import_ts_morph68.Node.isCallExpression(current2)) {
|
|
16938
16919
|
return current2;
|
|
16939
16920
|
}
|
|
16940
|
-
if (
|
|
16921
|
+
if (import_ts_morph68.Node.isPropertyAccessExpression(current2)) {
|
|
16941
16922
|
current2 = current2.getParent();
|
|
16942
16923
|
continue;
|
|
16943
16924
|
}
|
|
@@ -16948,7 +16929,7 @@ function enclosingCall(node) {
|
|
|
16948
16929
|
function enclosingFunction(node) {
|
|
16949
16930
|
let current2 = node.getParent();
|
|
16950
16931
|
while (current2 !== void 0) {
|
|
16951
|
-
if (
|
|
16932
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(current2) || import_ts_morph68.Node.isFunctionExpression(current2) || import_ts_morph68.Node.isArrowFunction(current2) || import_ts_morph68.Node.isMethodDeclaration(current2)) {
|
|
16952
16933
|
return current2;
|
|
16953
16934
|
}
|
|
16954
16935
|
current2 = current2.getParent();
|
|
@@ -16956,13 +16937,13 @@ function enclosingFunction(node) {
|
|
|
16956
16937
|
return null;
|
|
16957
16938
|
}
|
|
16958
16939
|
function callerName(func) {
|
|
16959
|
-
if (
|
|
16940
|
+
if (import_ts_morph68.Node.isFunctionDeclaration(func) || import_ts_morph68.Node.isMethodDeclaration(func)) {
|
|
16960
16941
|
return func.getName() ?? "anonymous";
|
|
16961
16942
|
}
|
|
16962
16943
|
const parent = func.getParent();
|
|
16963
|
-
if (parent !== void 0 &&
|
|
16944
|
+
if (parent !== void 0 && import_ts_morph68.Node.isVariableDeclaration(parent)) {
|
|
16964
16945
|
const nameNode = parent.getNameNode();
|
|
16965
|
-
if (
|
|
16946
|
+
if (import_ts_morph68.Node.isIdentifier(nameNode)) {
|
|
16966
16947
|
return nameNode.getText();
|
|
16967
16948
|
}
|
|
16968
16949
|
}
|
|
@@ -17061,7 +17042,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17061
17042
|
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? import_node_path11.default.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
17062
17043
|
)
|
|
17063
17044
|
};
|
|
17064
|
-
const project = config.project ?? new
|
|
17045
|
+
const project = config.project ?? new import_ts_morph68.Project(
|
|
17065
17046
|
config.tsConfigFilePath !== void 0 ? {
|
|
17066
17047
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
17067
17048
|
skipAddingFilesFromTsConfig: true
|
|
@@ -17108,7 +17089,11 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17108
17089
|
)
|
|
17109
17090
|
);
|
|
17110
17091
|
}
|
|
17111
|
-
return named(
|
|
17092
|
+
return named(
|
|
17093
|
+
(0, import_extractor12.composeWrappers)(summaries, config.extractorOptions ?? {}),
|
|
17094
|
+
config.workspace,
|
|
17095
|
+
runRoot
|
|
17096
|
+
);
|
|
17112
17097
|
},
|
|
17113
17098
|
async extractAll() {
|
|
17114
17099
|
const timer = (0, import_extractor9.createTimer)();
|
|
@@ -17319,7 +17304,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17319
17304
|
)
|
|
17320
17305
|
);
|
|
17321
17306
|
const closureFacts = {
|
|
17322
|
-
db: new
|
|
17307
|
+
db: new import_datalog5.Database(),
|
|
17323
17308
|
unitKeyBySummary: /* @__PURE__ */ new Map(),
|
|
17324
17309
|
...caching ? { filesByKey: /* @__PURE__ */ new Map() } : {}
|
|
17325
17310
|
};
|
|
@@ -17368,12 +17353,6 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17368
17353
|
"enrichRethrows",
|
|
17369
17354
|
() => enrichRethrows(merged.summaries, project, closureFacts)
|
|
17370
17355
|
);
|
|
17371
|
-
if (config.includeReachable !== false) {
|
|
17372
|
-
timer.time(
|
|
17373
|
-
"deriveBoundaryEffects",
|
|
17374
|
-
() => deriveBoundaryEffects(enriched, closureFacts)
|
|
17375
|
-
);
|
|
17376
|
-
}
|
|
17377
17356
|
timer.time(
|
|
17378
17357
|
"stampModuleImports",
|
|
17379
17358
|
() => (0, import_extractor12.stampModuleImports)(enriched, (file) => {
|
|
@@ -17777,7 +17756,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17777
17756
|
// src/bootstrap/noTsconfigProject.ts
|
|
17778
17757
|
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
17779
17758
|
var import_node_path12 = __toESM(require("path"), 1);
|
|
17780
|
-
var
|
|
17759
|
+
var import_ts_morph69 = require("ts-morph");
|
|
17781
17760
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17782
17761
|
".ts",
|
|
17783
17762
|
".tsx",
|
|
@@ -17825,12 +17804,12 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17825
17804
|
return found;
|
|
17826
17805
|
}
|
|
17827
17806
|
function createProjectWithoutTsconfig(rootDir) {
|
|
17828
|
-
const project = new
|
|
17807
|
+
const project = new import_ts_morph69.Project({
|
|
17829
17808
|
skipAddingFilesFromTsConfig: true,
|
|
17830
17809
|
compilerOptions: {
|
|
17831
|
-
target:
|
|
17832
|
-
module:
|
|
17833
|
-
moduleResolution:
|
|
17810
|
+
target: import_ts_morph69.ScriptTarget.ES2022,
|
|
17811
|
+
module: import_ts_morph69.ModuleKind.ESNext,
|
|
17812
|
+
moduleResolution: import_ts_morph69.ModuleResolutionKind.Bundler,
|
|
17834
17813
|
allowJs: true,
|
|
17835
17814
|
checkJs: false,
|
|
17836
17815
|
noEmit: true,
|
|
@@ -17852,10 +17831,18 @@ function createProjectWithoutTsconfig(rootDir) {
|
|
|
17852
17831
|
}
|
|
17853
17832
|
return { project, files };
|
|
17854
17833
|
}
|
|
17834
|
+
var TSCONFIG_NAMES = [
|
|
17835
|
+
"tsconfig.json",
|
|
17836
|
+
"jsconfig.json",
|
|
17837
|
+
"tsconfig.base.json"
|
|
17838
|
+
];
|
|
17839
|
+
var WALK_UP_TSCONFIG_NAMES = ["tsconfig.json", "jsconfig.json"];
|
|
17855
17840
|
function findNearestTsconfig(startDir) {
|
|
17856
|
-
|
|
17841
|
+
const start = import_node_path12.default.resolve(startDir);
|
|
17842
|
+
let dir = start;
|
|
17857
17843
|
while (true) {
|
|
17858
|
-
|
|
17844
|
+
const names = dir === start ? TSCONFIG_NAMES : WALK_UP_TSCONFIG_NAMES;
|
|
17845
|
+
for (const name of names) {
|
|
17859
17846
|
const candidate = import_node_path12.default.join(dir, name);
|
|
17860
17847
|
if (import_node_fs5.default.existsSync(candidate)) {
|
|
17861
17848
|
return candidate;
|
|
@@ -17871,7 +17858,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17871
17858
|
|
|
17872
17859
|
// src/facts/why.ts
|
|
17873
17860
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
17874
|
-
var
|
|
17861
|
+
var import_ts_morph70 = require("ts-morph");
|
|
17875
17862
|
var import_resolution7 = require("@suss/resolution");
|
|
17876
17863
|
var JS_PHRASES = {
|
|
17877
17864
|
bind: ({ tuple, describe }) => ({
|
|
@@ -17885,7 +17872,7 @@ var TypeScriptWhySession = class {
|
|
|
17885
17872
|
constructor(options) {
|
|
17886
17873
|
this.root = import_node_path13.default.resolve(options.dir);
|
|
17887
17874
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17888
|
-
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new
|
|
17875
|
+
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new import_ts_morph70.Project({ tsConfigFilePath: tsconfig });
|
|
17889
17876
|
this.store = new ResolutionStore();
|
|
17890
17877
|
}
|
|
17891
17878
|
/**
|
|
@@ -17900,7 +17887,7 @@ var TypeScriptWhySession = class {
|
|
|
17900
17887
|
}
|
|
17901
17888
|
let found = null;
|
|
17902
17889
|
sourceFile.forEachDescendant((node) => {
|
|
17903
|
-
if (
|
|
17890
|
+
if (import_ts_morph70.Node.isExpression(node) && node.getStartLineNumber() === line && node.getText() === text && (found === null || node.getWidth() <= found.getWidth())) {
|
|
17904
17891
|
found = node;
|
|
17905
17892
|
}
|
|
17906
17893
|
});
|
|
@@ -17918,7 +17905,7 @@ var TypeScriptWhySession = class {
|
|
|
17918
17905
|
return null;
|
|
17919
17906
|
}
|
|
17920
17907
|
for (const call of sourceFile.getDescendantsOfKind(
|
|
17921
|
-
|
|
17908
|
+
import_ts_morph70.SyntaxKind.CallExpression
|
|
17922
17909
|
)) {
|
|
17923
17910
|
const line = call.getStartLineNumber();
|
|
17924
17911
|
if (line < startLine || line > endLine) {
|
|
@@ -17992,21 +17979,21 @@ var TypeScriptWhySession = class {
|
|
|
17992
17979
|
}
|
|
17993
17980
|
};
|
|
17994
17981
|
function displayNameOf(node) {
|
|
17995
|
-
if (
|
|
17982
|
+
if (import_ts_morph70.Node.isIdentifier(node) || import_ts_morph70.Node.isPropertyAccessExpression(node)) {
|
|
17996
17983
|
return node.getText();
|
|
17997
17984
|
}
|
|
17998
|
-
if (
|
|
17985
|
+
if (import_ts_morph70.Node.isCallExpression(node) || import_ts_morph70.Node.isNewExpression(node)) {
|
|
17999
17986
|
return `${node.getExpression()?.getText() ?? "call"}(...)`;
|
|
18000
17987
|
}
|
|
18001
|
-
if (
|
|
17988
|
+
if (import_ts_morph70.Node.isFunctionDeclaration(node) || import_ts_morph70.Node.isClassDeclaration(node) || import_ts_morph70.Node.isMethodDeclaration(node) || import_ts_morph70.Node.isVariableDeclaration(node)) {
|
|
18002
17989
|
const name = node.getName();
|
|
18003
17990
|
if (name !== void 0) {
|
|
18004
17991
|
return name;
|
|
18005
17992
|
}
|
|
18006
17993
|
}
|
|
18007
|
-
if (
|
|
17994
|
+
if (import_ts_morph70.Node.isArrowFunction(node) || import_ts_morph70.Node.isFunctionExpression(node)) {
|
|
18008
17995
|
const parent = node.getParent();
|
|
18009
|
-
if (parent !== void 0 &&
|
|
17996
|
+
if (parent !== void 0 && import_ts_morph70.Node.isVariableDeclaration(parent)) {
|
|
18010
17997
|
return parent.getName();
|
|
18011
17998
|
}
|
|
18012
17999
|
}
|
|
@@ -18016,7 +18003,7 @@ function displayNameOf(node) {
|
|
|
18016
18003
|
|
|
18017
18004
|
// src/stubEvidence.ts
|
|
18018
18005
|
var import_node_path14 = __toESM(require("path"), 1);
|
|
18019
|
-
var
|
|
18006
|
+
var import_ts_morph71 = require("ts-morph");
|
|
18020
18007
|
function stubEvidenceIn(project, packageName, root) {
|
|
18021
18008
|
const resolution = new ResolutionStore();
|
|
18022
18009
|
const byExport = /* @__PURE__ */ new Map();
|
|
@@ -18043,7 +18030,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
18043
18030
|
);
|
|
18044
18031
|
}
|
|
18045
18032
|
function stubEvidence(options) {
|
|
18046
|
-
const project = new
|
|
18033
|
+
const project = new import_ts_morph71.Project(
|
|
18047
18034
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
18048
18035
|
);
|
|
18049
18036
|
const root = options.tsConfigFilePath !== void 0 ? import_node_path14.default.dirname(options.tsConfigFilePath) : import_node_path14.default.resolve(options.directory ?? process.cwd());
|
|
@@ -18061,6 +18048,7 @@ function stubEvidence(options) {
|
|
|
18061
18048
|
GENERIC_TERMINALS,
|
|
18062
18049
|
NO_BARRIERS,
|
|
18063
18050
|
ResolutionStore,
|
|
18051
|
+
TSCONFIG_NAMES,
|
|
18064
18052
|
TypeScriptWhySession,
|
|
18065
18053
|
accessContextFor,
|
|
18066
18054
|
buildProjectHelperIndex,
|