@suss/adapter-typescript 0.16.0 → 0.18.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 +926 -767
- package/dist/index.js +912 -753
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -68,13 +68,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
68
68
|
|
|
69
69
|
// src/adapter.ts
|
|
70
70
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
71
|
-
var
|
|
71
|
+
var import_ts_morph61 = require("ts-morph");
|
|
72
72
|
var import_behavioral_ir8 = require("@suss/behavioral-ir");
|
|
73
73
|
var import_datalog6 = require("@suss/datalog");
|
|
74
74
|
var import_extractor5 = require("@suss/extractor");
|
|
75
75
|
|
|
76
76
|
// src/assembly.ts
|
|
77
|
-
var
|
|
77
|
+
var import_ts_morph27 = require("ts-morph");
|
|
78
78
|
|
|
79
79
|
// src/conditions.ts
|
|
80
80
|
var import_ts_morph6 = require("ts-morph");
|
|
@@ -3450,19 +3450,117 @@ function unwrapCall(node) {
|
|
|
3450
3450
|
}
|
|
3451
3451
|
|
|
3452
3452
|
// src/terminals/index.ts
|
|
3453
|
-
var
|
|
3453
|
+
var import_ts_morph26 = require("ts-morph");
|
|
3454
3454
|
|
|
3455
3455
|
// src/terminals/jsx.ts
|
|
3456
|
+
var import_ts_morph17 = require("ts-morph");
|
|
3457
|
+
|
|
3458
|
+
// src/resolve/unfollowedCall.ts
|
|
3456
3459
|
var import_ts_morph16 = require("ts-morph");
|
|
3460
|
+
function isInExternalCode(sourceFile) {
|
|
3461
|
+
if (sourceFile.isDeclarationFile()) {
|
|
3462
|
+
return true;
|
|
3463
|
+
}
|
|
3464
|
+
return sourceFile.getFilePath().includes("/node_modules/");
|
|
3465
|
+
}
|
|
3466
|
+
function hasBody(fn) {
|
|
3467
|
+
if (import_ts_morph16.Node.isFunctionDeclaration(fn) || import_ts_morph16.Node.isMethodDeclaration(fn) || import_ts_morph16.Node.isFunctionExpression(fn)) {
|
|
3468
|
+
return fn.getBody?.() !== void 0;
|
|
3469
|
+
}
|
|
3470
|
+
return true;
|
|
3471
|
+
}
|
|
3472
|
+
function isDeclaredShape(declaration) {
|
|
3473
|
+
return (import_ts_morph16.Node.isMethodSignature(declaration) || import_ts_morph16.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
3474
|
+
}
|
|
3475
|
+
function isExternalDeclaration(declaration) {
|
|
3476
|
+
if (isInExternalCode(declaration.getSourceFile())) {
|
|
3477
|
+
return true;
|
|
3478
|
+
}
|
|
3479
|
+
if (import_ts_morph16.Node.isImportSpecifier(declaration) || import_ts_morph16.Node.isImportClause(declaration) || import_ts_morph16.Node.isNamespaceImport(declaration)) {
|
|
3480
|
+
const target = declaration.getFirstAncestorByKind(import_ts_morph16.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
3481
|
+
return target === void 0 || isInExternalCode(target);
|
|
3482
|
+
}
|
|
3483
|
+
return declaresAnotherModule(declaration);
|
|
3484
|
+
}
|
|
3485
|
+
function declaresAnotherModule(declaration) {
|
|
3486
|
+
const module2 = declaration.getFirstAncestorByKind(
|
|
3487
|
+
import_ts_morph16.SyntaxKind.ModuleDeclaration
|
|
3488
|
+
);
|
|
3489
|
+
return module2 !== void 0 && import_ts_morph16.Node.isStringLiteral(module2.getNameNode());
|
|
3490
|
+
}
|
|
3491
|
+
function statesShapeOnly(declaration) {
|
|
3492
|
+
if (isExternalDeclaration(declaration)) {
|
|
3493
|
+
return false;
|
|
3494
|
+
}
|
|
3495
|
+
if (import_ts_morph16.Node.isMethodSignature(declaration) || import_ts_morph16.Node.isPropertySignature(declaration)) {
|
|
3496
|
+
return true;
|
|
3497
|
+
}
|
|
3498
|
+
if (import_ts_morph16.Node.isFunctionDeclaration(declaration) || import_ts_morph16.Node.isMethodDeclaration(declaration)) {
|
|
3499
|
+
return declaration.getBody() === void 0;
|
|
3500
|
+
}
|
|
3501
|
+
return false;
|
|
3502
|
+
}
|
|
3503
|
+
function declarationsBehind(symbol) {
|
|
3504
|
+
if (symbol === void 0) {
|
|
3505
|
+
return [];
|
|
3506
|
+
}
|
|
3507
|
+
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
3508
|
+
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
3509
|
+
}
|
|
3510
|
+
function classifyStop(declarations) {
|
|
3511
|
+
if (declarations.length === 0) {
|
|
3512
|
+
return "noDeclaration";
|
|
3513
|
+
}
|
|
3514
|
+
for (const declaration of declarations) {
|
|
3515
|
+
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
3516
|
+
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
if (declarations.every(isExternalDeclaration)) {
|
|
3520
|
+
return "outsideRun";
|
|
3521
|
+
}
|
|
3522
|
+
if (declarations.some(statesShapeOnly)) {
|
|
3523
|
+
return "noBody";
|
|
3524
|
+
}
|
|
3525
|
+
return "unsettledValue";
|
|
3526
|
+
}
|
|
3527
|
+
var RECORDED = {
|
|
3528
|
+
noBody: true,
|
|
3529
|
+
unsettledValue: true,
|
|
3530
|
+
multipleSources: true,
|
|
3531
|
+
outsideRun: false,
|
|
3532
|
+
noDeclaration: false
|
|
3533
|
+
};
|
|
3534
|
+
function worthRecording(reason) {
|
|
3535
|
+
return RECORDED[reason];
|
|
3536
|
+
}
|
|
3537
|
+
var STOP_SENTENCE = {
|
|
3538
|
+
noBody: (callee) => `The call to ${callee} lands on a declaration with no body, so whatever runs there is missing from this summary`,
|
|
3539
|
+
unsettledValue: (callee) => `The call to ${callee} goes through a value this run could not settle, so whatever runs there is missing from this summary`,
|
|
3540
|
+
multipleSources: (callee) => `The call to ${callee} reaches a value with more than one possible source, so whatever runs there is missing from this summary`,
|
|
3541
|
+
outsideRun: (callee) => `The call to ${callee} lands in a package whose source is not in this run, so whatever runs there is missing from this summary`,
|
|
3542
|
+
noDeclaration: (callee) => `The call to ${callee} has no declaration this run could find, so whatever runs there is missing from this summary`
|
|
3543
|
+
};
|
|
3544
|
+
function unfollowedCallGap(stop) {
|
|
3545
|
+
return {
|
|
3546
|
+
type: "unfollowedCall",
|
|
3547
|
+
conditions: [],
|
|
3548
|
+
consequence: "unknown",
|
|
3549
|
+
description: STOP_SENTENCE[stop.reason](stop.callee),
|
|
3550
|
+
callee: stop.callee
|
|
3551
|
+
};
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
// src/terminals/jsx.ts
|
|
3457
3555
|
function tryMatchJsxReturn(node, pattern) {
|
|
3458
3556
|
let expr;
|
|
3459
3557
|
let source;
|
|
3460
|
-
if (
|
|
3558
|
+
if (import_ts_morph17.Node.isReturnStatement(node)) {
|
|
3461
3559
|
expr = node.getExpression();
|
|
3462
3560
|
source = node;
|
|
3463
|
-
} else if (
|
|
3561
|
+
} else if (import_ts_morph17.Node.isArrowFunction(node)) {
|
|
3464
3562
|
const body = node.getBody();
|
|
3465
|
-
if (body !== void 0 && !
|
|
3563
|
+
if (body !== void 0 && !import_ts_morph17.Node.isBlock(body)) {
|
|
3466
3564
|
expr = body;
|
|
3467
3565
|
source = body;
|
|
3468
3566
|
}
|
|
@@ -3492,34 +3590,62 @@ function tryMatchJsxReturn(node, pattern) {
|
|
|
3492
3590
|
};
|
|
3493
3591
|
return { node, source, terminal };
|
|
3494
3592
|
}
|
|
3593
|
+
function componentTargetOf(tagNode) {
|
|
3594
|
+
if (!import_ts_morph17.Node.isIdentifier(tagNode) || !/^[A-Z]/.test(tagNode.getText())) {
|
|
3595
|
+
return null;
|
|
3596
|
+
}
|
|
3597
|
+
for (const decl of declarationsBehind(tagNode.getSymbol())) {
|
|
3598
|
+
if (isInExternalCode(decl.getSourceFile())) {
|
|
3599
|
+
continue;
|
|
3600
|
+
}
|
|
3601
|
+
const name = import_ts_morph17.Node.isFunctionDeclaration(decl) ? decl.getName() : void 0;
|
|
3602
|
+
if (name !== void 0) {
|
|
3603
|
+
return { file: decl.getSourceFile().getFilePath(), name };
|
|
3604
|
+
}
|
|
3605
|
+
if (import_ts_morph17.Node.isVariableDeclaration(decl)) {
|
|
3606
|
+
const init = decl.getInitializer();
|
|
3607
|
+
if (init !== void 0 && (import_ts_morph17.Node.isArrowFunction(init) || import_ts_morph17.Node.isFunctionExpression(init))) {
|
|
3608
|
+
return {
|
|
3609
|
+
file: decl.getSourceFile().getFilePath(),
|
|
3610
|
+
name: decl.getName()
|
|
3611
|
+
};
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
return null;
|
|
3616
|
+
}
|
|
3495
3617
|
function jsxToRenderNode(node) {
|
|
3496
|
-
if (
|
|
3618
|
+
if (import_ts_morph17.Node.isJsxElement(node)) {
|
|
3497
3619
|
const opening = node.getOpeningElement();
|
|
3498
3620
|
const tag = opening.getTagNameNode().getText();
|
|
3499
3621
|
const attrs = collectJsxAttributes(opening);
|
|
3622
|
+
const target = componentTargetOf(opening.getTagNameNode());
|
|
3500
3623
|
const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
|
|
3501
3624
|
return {
|
|
3502
3625
|
type: "element",
|
|
3503
3626
|
tag,
|
|
3504
3627
|
children,
|
|
3505
|
-
...attrs !== null ? { attrs } : {}
|
|
3628
|
+
...attrs !== null ? { attrs } : {},
|
|
3629
|
+
...target !== null ? { target } : {}
|
|
3506
3630
|
};
|
|
3507
3631
|
}
|
|
3508
|
-
if (
|
|
3632
|
+
if (import_ts_morph17.Node.isJsxSelfClosingElement(node)) {
|
|
3509
3633
|
const tag = node.getTagNameNode().getText();
|
|
3510
3634
|
const attrs = collectJsxAttributes(node);
|
|
3635
|
+
const target = componentTargetOf(node.getTagNameNode());
|
|
3511
3636
|
return {
|
|
3512
3637
|
type: "element",
|
|
3513
3638
|
tag,
|
|
3514
3639
|
children: [],
|
|
3515
|
-
...attrs !== null ? { attrs } : {}
|
|
3640
|
+
...attrs !== null ? { attrs } : {},
|
|
3641
|
+
...target !== null ? { target } : {}
|
|
3516
3642
|
};
|
|
3517
3643
|
}
|
|
3518
|
-
if (
|
|
3644
|
+
if (import_ts_morph17.Node.isJsxFragment(node)) {
|
|
3519
3645
|
const children = node.getJsxChildren().map(jsxChildToRenderNode).filter((n) => n !== null);
|
|
3520
3646
|
return { type: "element", tag: "Fragment", children };
|
|
3521
3647
|
}
|
|
3522
|
-
if (
|
|
3648
|
+
if (import_ts_morph17.Node.isParenthesizedExpression(node)) {
|
|
3523
3649
|
return jsxToRenderNode(node.getExpression());
|
|
3524
3650
|
}
|
|
3525
3651
|
return null;
|
|
@@ -3527,12 +3653,12 @@ function jsxToRenderNode(node) {
|
|
|
3527
3653
|
function collectJsxAttributes(opening) {
|
|
3528
3654
|
const entries = {};
|
|
3529
3655
|
for (const attr of opening.getAttributes()) {
|
|
3530
|
-
if (
|
|
3656
|
+
if (import_ts_morph17.Node.isJsxSpreadAttribute(attr)) {
|
|
3531
3657
|
const exprText = attr.getExpression().getText();
|
|
3532
3658
|
entries[`...${exprText}`] = exprText;
|
|
3533
3659
|
continue;
|
|
3534
3660
|
}
|
|
3535
|
-
if (!
|
|
3661
|
+
if (!import_ts_morph17.Node.isJsxAttribute(attr)) {
|
|
3536
3662
|
continue;
|
|
3537
3663
|
}
|
|
3538
3664
|
const name = attr.getNameNode().getText();
|
|
@@ -3541,7 +3667,7 @@ function collectJsxAttributes(opening) {
|
|
|
3541
3667
|
entries[name] = "";
|
|
3542
3668
|
continue;
|
|
3543
3669
|
}
|
|
3544
|
-
if (
|
|
3670
|
+
if (import_ts_morph17.Node.isJsxExpression(initializer)) {
|
|
3545
3671
|
const inner = initializer.getExpression();
|
|
3546
3672
|
entries[name] = inner !== void 0 ? inner.getText() : "";
|
|
3547
3673
|
continue;
|
|
@@ -3551,30 +3677,30 @@ function collectJsxAttributes(opening) {
|
|
|
3551
3677
|
return Object.keys(entries).length > 0 ? entries : null;
|
|
3552
3678
|
}
|
|
3553
3679
|
function jsxChildToRenderNode(child) {
|
|
3554
|
-
if (
|
|
3680
|
+
if (import_ts_morph17.Node.isJsxText(child)) {
|
|
3555
3681
|
const text = child.getLiteralText().trim();
|
|
3556
3682
|
if (text.length === 0) {
|
|
3557
3683
|
return null;
|
|
3558
3684
|
}
|
|
3559
3685
|
return { type: "text", value: text };
|
|
3560
3686
|
}
|
|
3561
|
-
if (
|
|
3687
|
+
if (import_ts_morph17.Node.isJsxExpression(child)) {
|
|
3562
3688
|
const inner = child.getExpression();
|
|
3563
3689
|
if (inner === void 0) {
|
|
3564
3690
|
return null;
|
|
3565
3691
|
}
|
|
3566
3692
|
return jsxExpressionToRenderNode(inner);
|
|
3567
3693
|
}
|
|
3568
|
-
if (
|
|
3694
|
+
if (import_ts_morph17.Node.isJsxElement(child) || import_ts_morph17.Node.isJsxSelfClosingElement(child) || import_ts_morph17.Node.isJsxFragment(child)) {
|
|
3569
3695
|
return jsxToRenderNode(child);
|
|
3570
3696
|
}
|
|
3571
3697
|
return null;
|
|
3572
3698
|
}
|
|
3573
3699
|
function jsxExpressionToRenderNode(expr) {
|
|
3574
|
-
if (
|
|
3700
|
+
if (import_ts_morph17.Node.isParenthesizedExpression(expr)) {
|
|
3575
3701
|
return jsxExpressionToRenderNode(expr.getExpression());
|
|
3576
3702
|
}
|
|
3577
|
-
if (
|
|
3703
|
+
if (import_ts_morph17.Node.isBinaryExpression(expr)) {
|
|
3578
3704
|
const op = expr.getOperatorToken().getText();
|
|
3579
3705
|
if (op === "&&") {
|
|
3580
3706
|
const right = renderAlternative(peelParens(expr.getRight()));
|
|
@@ -3588,7 +3714,7 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
3588
3714
|
}
|
|
3589
3715
|
}
|
|
3590
3716
|
}
|
|
3591
|
-
if (
|
|
3717
|
+
if (import_ts_morph17.Node.isConditionalExpression(expr)) {
|
|
3592
3718
|
const truthy = renderAlternative(peelParens(expr.getWhenTrue()));
|
|
3593
3719
|
const falsy = renderAlternative(peelParens(expr.getWhenFalse()));
|
|
3594
3720
|
if (truthy.kind === "jsx") {
|
|
@@ -3611,16 +3737,16 @@ function jsxExpressionToRenderNode(expr) {
|
|
|
3611
3737
|
return { type: "expression", sourceText: expr.getText() };
|
|
3612
3738
|
}
|
|
3613
3739
|
function renderAlternative(node) {
|
|
3614
|
-
if (
|
|
3740
|
+
if (import_ts_morph17.Node.isNullLiteral(node)) {
|
|
3615
3741
|
return { kind: "noRender" };
|
|
3616
3742
|
}
|
|
3617
|
-
if (
|
|
3743
|
+
if (import_ts_morph17.Node.isFalseLiteral(node)) {
|
|
3618
3744
|
return { kind: "noRender" };
|
|
3619
3745
|
}
|
|
3620
|
-
if (
|
|
3746
|
+
if (import_ts_morph17.Node.isIdentifier(node) && node.getText() === "undefined") {
|
|
3621
3747
|
return { kind: "noRender" };
|
|
3622
3748
|
}
|
|
3623
|
-
if (
|
|
3749
|
+
if (import_ts_morph17.Node.isJsxElement(node) || import_ts_morph17.Node.isJsxSelfClosingElement(node) || import_ts_morph17.Node.isJsxFragment(node)) {
|
|
3624
3750
|
const tree = jsxToRenderNode(node);
|
|
3625
3751
|
if (tree !== null) {
|
|
3626
3752
|
return { kind: "jsx", node: tree };
|
|
@@ -3630,10 +3756,10 @@ function renderAlternative(node) {
|
|
|
3630
3756
|
}
|
|
3631
3757
|
|
|
3632
3758
|
// src/terminals/returns.ts
|
|
3633
|
-
var
|
|
3759
|
+
var import_ts_morph24 = require("ts-morph");
|
|
3634
3760
|
|
|
3635
3761
|
// src/shapes/shapes.ts
|
|
3636
|
-
var
|
|
3762
|
+
var import_ts_morph18 = require("ts-morph");
|
|
3637
3763
|
|
|
3638
3764
|
// src/shapes/typeShapes.ts
|
|
3639
3765
|
var import_node_crypto = require("crypto");
|
|
@@ -4092,60 +4218,60 @@ function extractShapeWithArguments(node, substitutions) {
|
|
|
4092
4218
|
}
|
|
4093
4219
|
function extractShapeInner(node) {
|
|
4094
4220
|
const unwrapped2 = peelSyntax(node);
|
|
4095
|
-
if (boundArguments !== null &&
|
|
4221
|
+
if (boundArguments !== null && import_ts_morph18.Node.isIdentifier(unwrapped2)) {
|
|
4096
4222
|
const argument = boundArguments.get(unwrapped2.getText());
|
|
4097
4223
|
if (argument !== void 0 && argument !== unwrapped2) {
|
|
4098
4224
|
return extractShape(argument);
|
|
4099
4225
|
}
|
|
4100
4226
|
}
|
|
4101
|
-
if (
|
|
4227
|
+
if (import_ts_morph18.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
4102
4228
|
return shapeFromObjectLiteral(unwrapped2);
|
|
4103
4229
|
}
|
|
4104
|
-
if (
|
|
4230
|
+
if (import_ts_morph18.Node.isArrayLiteralExpression(unwrapped2)) {
|
|
4105
4231
|
return shapeFromArrayLiteral(unwrapped2);
|
|
4106
4232
|
}
|
|
4107
|
-
if (
|
|
4233
|
+
if (import_ts_morph18.Node.isStringLiteral(unwrapped2) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
4108
4234
|
return { type: "literal", value: unwrapped2.getLiteralValue() };
|
|
4109
4235
|
}
|
|
4110
|
-
if (
|
|
4236
|
+
if (import_ts_morph18.Node.isTemplateExpression(unwrapped2)) {
|
|
4111
4237
|
return { type: "text" };
|
|
4112
4238
|
}
|
|
4113
|
-
if (
|
|
4239
|
+
if (import_ts_morph18.Node.isNumericLiteral(unwrapped2)) {
|
|
4114
4240
|
return numericLiteralShape(
|
|
4115
4241
|
unwrapped2.getLiteralValue(),
|
|
4116
4242
|
unwrapped2.getText()
|
|
4117
4243
|
);
|
|
4118
4244
|
}
|
|
4119
|
-
if (
|
|
4245
|
+
if (import_ts_morph18.Node.isPrefixUnaryExpression(unwrapped2)) {
|
|
4120
4246
|
const op = unwrapped2.getOperatorToken();
|
|
4121
|
-
if (op ===
|
|
4247
|
+
if (op === import_ts_morph18.SyntaxKind.MinusToken || op === import_ts_morph18.SyntaxKind.PlusToken) {
|
|
4122
4248
|
const inner = unwrapped2.getOperand();
|
|
4123
|
-
if (
|
|
4249
|
+
if (import_ts_morph18.Node.isNumericLiteral(inner)) {
|
|
4124
4250
|
const v3 = inner.getLiteralValue();
|
|
4125
|
-
const signed = op ===
|
|
4251
|
+
const signed = op === import_ts_morph18.SyntaxKind.MinusToken ? -v3 : v3;
|
|
4126
4252
|
const rawBody = inner.getText();
|
|
4127
|
-
const raw = op ===
|
|
4253
|
+
const raw = op === import_ts_morph18.SyntaxKind.MinusToken ? `-${rawBody}` : rawBody;
|
|
4128
4254
|
return numericLiteralShape(signed, raw);
|
|
4129
4255
|
}
|
|
4130
4256
|
}
|
|
4131
4257
|
}
|
|
4132
|
-
if (
|
|
4258
|
+
if (import_ts_morph18.Node.isBigIntLiteral(unwrapped2)) {
|
|
4133
4259
|
return { type: "ref", name: "bigint" };
|
|
4134
4260
|
}
|
|
4135
4261
|
const kind = unwrapped2.getKind();
|
|
4136
|
-
if (kind ===
|
|
4262
|
+
if (kind === import_ts_morph18.SyntaxKind.TrueKeyword) {
|
|
4137
4263
|
return { type: "literal", value: true };
|
|
4138
4264
|
}
|
|
4139
|
-
if (kind ===
|
|
4265
|
+
if (kind === import_ts_morph18.SyntaxKind.FalseKeyword) {
|
|
4140
4266
|
return { type: "literal", value: false };
|
|
4141
4267
|
}
|
|
4142
|
-
if (kind ===
|
|
4268
|
+
if (kind === import_ts_morph18.SyntaxKind.NullKeyword) {
|
|
4143
4269
|
return { type: "null" };
|
|
4144
4270
|
}
|
|
4145
|
-
if (
|
|
4271
|
+
if (import_ts_morph18.Node.isIdentifier(unwrapped2) && unwrapped2.getText() === "undefined") {
|
|
4146
4272
|
return { type: "undefined" };
|
|
4147
4273
|
}
|
|
4148
|
-
if (
|
|
4274
|
+
if (import_ts_morph18.Node.isConditionalExpression(unwrapped2)) {
|
|
4149
4275
|
const whenTrue = extractShape(unwrapped2.getWhenTrue());
|
|
4150
4276
|
const whenFalse = extractShape(unwrapped2.getWhenFalse());
|
|
4151
4277
|
const variants = [];
|
|
@@ -4176,7 +4302,7 @@ function shapeFromArrayLiteral(arr) {
|
|
|
4176
4302
|
}
|
|
4177
4303
|
const shapes = [];
|
|
4178
4304
|
for (const el of elements) {
|
|
4179
|
-
if (
|
|
4305
|
+
if (import_ts_morph18.Node.isSpreadElement(el)) {
|
|
4180
4306
|
const inner = el.getExpression();
|
|
4181
4307
|
const innerShape = extractShape(inner);
|
|
4182
4308
|
if (innerShape?.type === "array") {
|
|
@@ -4195,7 +4321,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
4195
4321
|
const properties = {};
|
|
4196
4322
|
const unresolvedSpreads = [];
|
|
4197
4323
|
for (const prop of obj.getProperties()) {
|
|
4198
|
-
if (
|
|
4324
|
+
if (import_ts_morph18.Node.isPropertyAssignment(prop)) {
|
|
4199
4325
|
const name = propertyName(prop);
|
|
4200
4326
|
if (name === null) {
|
|
4201
4327
|
continue;
|
|
@@ -4211,7 +4337,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
4211
4337
|
};
|
|
4212
4338
|
continue;
|
|
4213
4339
|
}
|
|
4214
|
-
if (
|
|
4340
|
+
if (import_ts_morph18.Node.isShorthandPropertyAssignment(prop)) {
|
|
4215
4341
|
const name = prop.getName();
|
|
4216
4342
|
const valueExpr = prop.getNameNode();
|
|
4217
4343
|
properties[name] = extractShape(valueExpr) ?? {
|
|
@@ -4220,7 +4346,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
4220
4346
|
};
|
|
4221
4347
|
continue;
|
|
4222
4348
|
}
|
|
4223
|
-
if (
|
|
4349
|
+
if (import_ts_morph18.Node.isSpreadAssignment(prop)) {
|
|
4224
4350
|
const expr = prop.getExpression();
|
|
4225
4351
|
const spreadShape = extractShape(expr);
|
|
4226
4352
|
if (spreadShape?.type === "record") {
|
|
@@ -4239,7 +4365,7 @@ function shapeFromObjectLiteral(obj) {
|
|
|
4239
4365
|
}
|
|
4240
4366
|
function propertyName(prop) {
|
|
4241
4367
|
const nameNode = prop.getNameNode();
|
|
4242
|
-
if (
|
|
4368
|
+
if (import_ts_morph18.Node.isIdentifier(nameNode) || import_ts_morph18.Node.isStringLiteral(nameNode) || import_ts_morph18.Node.isNoSubstitutionTemplateLiteral(nameNode) || import_ts_morph18.Node.isNumericLiteral(nameNode)) {
|
|
4243
4369
|
return nameNode.getText().replace(/^["']|["']$/g, "");
|
|
4244
4370
|
}
|
|
4245
4371
|
return null;
|
|
@@ -4265,21 +4391,21 @@ function collapseVariants2(shapes) {
|
|
|
4265
4391
|
}
|
|
4266
4392
|
|
|
4267
4393
|
// src/terminals/extract.ts
|
|
4268
|
-
var
|
|
4394
|
+
var import_ts_morph19 = require("ts-morph");
|
|
4269
4395
|
function unwrapAs(node) {
|
|
4270
|
-
return
|
|
4396
|
+
return import_ts_morph19.Node.isAsExpression(node) ? unwrapAs(node.getExpression()) : node;
|
|
4271
4397
|
}
|
|
4272
4398
|
function unwrapJsonStringify(node) {
|
|
4273
4399
|
const outer = unwrapAs(node);
|
|
4274
|
-
if (!
|
|
4400
|
+
if (!import_ts_morph19.Node.isCallExpression(outer)) {
|
|
4275
4401
|
return node;
|
|
4276
4402
|
}
|
|
4277
4403
|
const callee = outer.getExpression();
|
|
4278
|
-
if (!
|
|
4404
|
+
if (!import_ts_morph19.Node.isPropertyAccessExpression(callee) || callee.getName() !== "stringify") {
|
|
4279
4405
|
return node;
|
|
4280
4406
|
}
|
|
4281
4407
|
const receiver = callee.getExpression();
|
|
4282
|
-
if (!
|
|
4408
|
+
if (!import_ts_morph19.Node.isIdentifier(receiver) || receiver.getText() !== "JSON") {
|
|
4283
4409
|
return node;
|
|
4284
4410
|
}
|
|
4285
4411
|
const args = outer.getArguments();
|
|
@@ -4289,7 +4415,7 @@ function unwrapJsonStringify(node) {
|
|
|
4289
4415
|
return unwrapAs(args[0]);
|
|
4290
4416
|
}
|
|
4291
4417
|
function substituted(value, ctx) {
|
|
4292
|
-
if (ctx.substitutions === void 0 || !
|
|
4418
|
+
if (ctx.substitutions === void 0 || !import_ts_morph19.Node.isIdentifier(value)) {
|
|
4293
4419
|
return value;
|
|
4294
4420
|
}
|
|
4295
4421
|
return ctx.substitutions.get(value.getText()) ?? value;
|
|
@@ -4323,11 +4449,11 @@ function matchConstructorCode(ctorText, codes) {
|
|
|
4323
4449
|
}
|
|
4324
4450
|
function statusOf(value, ctx) {
|
|
4325
4451
|
const unwrapped2 = unwrapAs(value);
|
|
4326
|
-
if (
|
|
4452
|
+
if (import_ts_morph19.Node.isNumericLiteral(unwrapped2)) {
|
|
4327
4453
|
return { type: "literal", value: Number(unwrapped2.getText()) };
|
|
4328
4454
|
}
|
|
4329
4455
|
const resolved = ctx.resolveWrittenValue?.(unwrapped2) ?? null;
|
|
4330
|
-
if (resolved !== null &&
|
|
4456
|
+
if (resolved !== null && import_ts_morph19.Node.isNumericLiteral(resolved)) {
|
|
4331
4457
|
return { type: "literal", value: Number(resolved.getText()) };
|
|
4332
4458
|
}
|
|
4333
4459
|
return { type: "dynamic", sourceText: unwrapped2.getText() };
|
|
@@ -4337,10 +4463,10 @@ function statusFromProperty(obj, name, ctx) {
|
|
|
4337
4463
|
if (prop === void 0) {
|
|
4338
4464
|
return null;
|
|
4339
4465
|
}
|
|
4340
|
-
if (
|
|
4466
|
+
if (import_ts_morph19.Node.isShorthandPropertyAssignment(prop)) {
|
|
4341
4467
|
return { type: "dynamic", sourceText: prop.getName() };
|
|
4342
4468
|
}
|
|
4343
|
-
if (!
|
|
4469
|
+
if (!import_ts_morph19.Node.isPropertyAssignment(prop)) {
|
|
4344
4470
|
return null;
|
|
4345
4471
|
}
|
|
4346
4472
|
const value = prop.getInitializer();
|
|
@@ -4363,7 +4489,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
4363
4489
|
return null;
|
|
4364
4490
|
}
|
|
4365
4491
|
const first = ctx.throwCallArgs?.[0];
|
|
4366
|
-
if (first !== void 0 &&
|
|
4492
|
+
if (first !== void 0 && import_ts_morph19.Node.isNumericLiteral(first)) {
|
|
4367
4493
|
const value = first.getLiteralValue();
|
|
4368
4494
|
if (value >= 100 && value <= 599) {
|
|
4369
4495
|
return { type: "literal", value };
|
|
@@ -4376,7 +4502,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
4376
4502
|
return null;
|
|
4377
4503
|
}
|
|
4378
4504
|
const arg = ctx.throwCallArgs[sc.position];
|
|
4379
|
-
if (arg === void 0 || !
|
|
4505
|
+
if (arg === void 0 || !import_ts_morph19.Node.isNewExpression(arg)) {
|
|
4380
4506
|
return null;
|
|
4381
4507
|
}
|
|
4382
4508
|
const ctorText = arg.getExpression().getText();
|
|
@@ -4385,7 +4511,7 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
4385
4511
|
if (sc.from === "argumentProperty") {
|
|
4386
4512
|
const args = ctx.throwCallArgs ?? ctx.calls?.[0]?.getArguments();
|
|
4387
4513
|
const arg = args?.[sc.position];
|
|
4388
|
-
if (arg === void 0 || !
|
|
4514
|
+
if (arg === void 0 || !import_ts_morph19.Node.isObjectLiteralExpression(arg)) {
|
|
4389
4515
|
return null;
|
|
4390
4516
|
}
|
|
4391
4517
|
return statusFromProperty(arg, sc.name, ctx);
|
|
@@ -4395,8 +4521,8 @@ function extractStatusCodeFromRule(ctx) {
|
|
|
4395
4521
|
return null;
|
|
4396
4522
|
}
|
|
4397
4523
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
4398
|
-
if (!
|
|
4399
|
-
if (
|
|
4524
|
+
if (!import_ts_morph19.Node.isPropertyAssignment(prop)) {
|
|
4525
|
+
if (import_ts_morph19.Node.isShorthandPropertyAssignment(prop)) {
|
|
4400
4526
|
if (prop.getName() === sc.name) {
|
|
4401
4527
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
4402
4528
|
if (resolved !== void 0) {
|
|
@@ -4454,8 +4580,8 @@ function extractBody(ctx) {
|
|
|
4454
4580
|
return null;
|
|
4455
4581
|
}
|
|
4456
4582
|
for (const prop of ctx.returnedObj.getProperties()) {
|
|
4457
|
-
if (!
|
|
4458
|
-
if (
|
|
4583
|
+
if (!import_ts_morph19.Node.isPropertyAssignment(prop)) {
|
|
4584
|
+
if (import_ts_morph19.Node.isShorthandPropertyAssignment(prop)) {
|
|
4459
4585
|
if (prop.getName() === b.name) {
|
|
4460
4586
|
const resolved = ctx.substitutions?.get(prop.getName());
|
|
4461
4587
|
if (resolved !== void 0) {
|
|
@@ -4510,10 +4636,10 @@ function extractBody(ctx) {
|
|
|
4510
4636
|
}
|
|
4511
4637
|
|
|
4512
4638
|
// src/terminals/helperResolution.ts
|
|
4513
|
-
var
|
|
4639
|
+
var import_ts_morph20 = require("ts-morph");
|
|
4514
4640
|
function resolveHelperReturn(call) {
|
|
4515
4641
|
const callee = call.getExpression();
|
|
4516
|
-
if (!
|
|
4642
|
+
if (!import_ts_morph20.Node.isIdentifier(callee)) {
|
|
4517
4643
|
return { kind: "notLocal" };
|
|
4518
4644
|
}
|
|
4519
4645
|
const helper = resolveLocalHelper(callee);
|
|
@@ -4543,16 +4669,16 @@ function guardsAbove(returnValue) {
|
|
|
4543
4669
|
let child = returnValue;
|
|
4544
4670
|
let current2 = returnValue.getParent();
|
|
4545
4671
|
while (current2 !== void 0) {
|
|
4546
|
-
if (
|
|
4672
|
+
if (import_ts_morph20.Node.isIfStatement(current2)) {
|
|
4547
4673
|
guards.push({
|
|
4548
4674
|
condition: current2.getExpression(),
|
|
4549
4675
|
whenTrue: current2.getThenStatement() === child
|
|
4550
4676
|
});
|
|
4551
4677
|
}
|
|
4552
|
-
if (
|
|
4678
|
+
if (import_ts_morph20.Node.isBlock(current2)) {
|
|
4553
4679
|
guards.push(...earlyReturnGuardsBefore(current2, child));
|
|
4554
4680
|
}
|
|
4555
|
-
if (
|
|
4681
|
+
if (import_ts_morph20.Node.isFunctionDeclaration(current2) || import_ts_morph20.Node.isArrowFunction(current2) || import_ts_morph20.Node.isFunctionExpression(current2)) {
|
|
4556
4682
|
break;
|
|
4557
4683
|
}
|
|
4558
4684
|
child = current2;
|
|
@@ -4561,7 +4687,7 @@ function guardsAbove(returnValue) {
|
|
|
4561
4687
|
return guards;
|
|
4562
4688
|
}
|
|
4563
4689
|
function earlyReturnGuardsBefore(block, child) {
|
|
4564
|
-
if (!
|
|
4690
|
+
if (!import_ts_morph20.Node.isBlock(block)) {
|
|
4565
4691
|
return [];
|
|
4566
4692
|
}
|
|
4567
4693
|
const guards = [];
|
|
@@ -4569,7 +4695,7 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
4569
4695
|
if (statement === child) {
|
|
4570
4696
|
break;
|
|
4571
4697
|
}
|
|
4572
|
-
if (!
|
|
4698
|
+
if (!import_ts_morph20.Node.isIfStatement(statement) || statement.getElseStatement()) {
|
|
4573
4699
|
continue;
|
|
4574
4700
|
}
|
|
4575
4701
|
if (alwaysReturns(statement.getThenStatement())) {
|
|
@@ -4579,10 +4705,10 @@ function earlyReturnGuardsBefore(block, child) {
|
|
|
4579
4705
|
return guards;
|
|
4580
4706
|
}
|
|
4581
4707
|
function alwaysReturns(statement) {
|
|
4582
|
-
if (
|
|
4708
|
+
if (import_ts_morph20.Node.isReturnStatement(statement) || import_ts_morph20.Node.isThrowStatement(statement)) {
|
|
4583
4709
|
return true;
|
|
4584
4710
|
}
|
|
4585
|
-
if (!
|
|
4711
|
+
if (!import_ts_morph20.Node.isBlock(statement)) {
|
|
4586
4712
|
return false;
|
|
4587
4713
|
}
|
|
4588
4714
|
const statements = statement.getStatements();
|
|
@@ -4600,7 +4726,7 @@ var COMPARISONS = {
|
|
|
4600
4726
|
"!=": (a, b) => a !== b
|
|
4601
4727
|
};
|
|
4602
4728
|
function evaluateComparison(condition, substitutions) {
|
|
4603
|
-
if (!
|
|
4729
|
+
if (!import_ts_morph20.Node.isBinaryExpression(condition)) {
|
|
4604
4730
|
return null;
|
|
4605
4731
|
}
|
|
4606
4732
|
const left = numberFor(condition.getLeft(), substitutions);
|
|
@@ -4612,8 +4738,8 @@ function evaluateComparison(condition, substitutions) {
|
|
|
4612
4738
|
return compare === void 0 ? null : compare(left, right);
|
|
4613
4739
|
}
|
|
4614
4740
|
function numberFor(node, substitutions) {
|
|
4615
|
-
const resolved =
|
|
4616
|
-
return
|
|
4741
|
+
const resolved = import_ts_morph20.Node.isIdentifier(node) && substitutions.has(node.getText()) ? substitutions.get(node.getText()) : node;
|
|
4742
|
+
return import_ts_morph20.Node.isNumericLiteral(resolved) ? Number(resolved.getText()) : null;
|
|
4617
4743
|
}
|
|
4618
4744
|
function resolveLocalHelper(callee) {
|
|
4619
4745
|
for (const declaration of declarationsFor(callee)) {
|
|
@@ -4682,12 +4808,12 @@ function declarationsFor(callee) {
|
|
|
4682
4808
|
return (aliased ?? symbol).getDeclarations();
|
|
4683
4809
|
}
|
|
4684
4810
|
function asFunctionLike(declaration) {
|
|
4685
|
-
if (
|
|
4811
|
+
if (import_ts_morph20.Node.isFunctionDeclaration(declaration) || import_ts_morph20.Node.isArrowFunction(declaration) || import_ts_morph20.Node.isFunctionExpression(declaration)) {
|
|
4686
4812
|
return declaration;
|
|
4687
4813
|
}
|
|
4688
|
-
if (
|
|
4814
|
+
if (import_ts_morph20.Node.isVariableDeclaration(declaration)) {
|
|
4689
4815
|
const initializer = declaration.getInitializer();
|
|
4690
|
-
if (initializer !== void 0 && (
|
|
4816
|
+
if (initializer !== void 0 && (import_ts_morph20.Node.isArrowFunction(initializer) || import_ts_morph20.Node.isFunctionExpression(initializer))) {
|
|
4691
4817
|
return initializer;
|
|
4692
4818
|
}
|
|
4693
4819
|
}
|
|
@@ -4698,13 +4824,13 @@ function returnedObjects(fn) {
|
|
|
4698
4824
|
if (body === void 0) {
|
|
4699
4825
|
return [];
|
|
4700
4826
|
}
|
|
4701
|
-
if (!
|
|
4827
|
+
if (!import_ts_morph20.Node.isBlock(body)) {
|
|
4702
4828
|
const expression = peelParens(body);
|
|
4703
|
-
return
|
|
4829
|
+
return import_ts_morph20.Node.isObjectLiteralExpression(expression) ? [expression] : [];
|
|
4704
4830
|
}
|
|
4705
4831
|
const found = [];
|
|
4706
4832
|
for (const statement of body.getDescendantsOfKind(
|
|
4707
|
-
|
|
4833
|
+
import_ts_morph20.SyntaxKind.ReturnStatement
|
|
4708
4834
|
)) {
|
|
4709
4835
|
if (enclosingFunctionOf(statement) !== body) {
|
|
4710
4836
|
continue;
|
|
@@ -4714,7 +4840,7 @@ function returnedObjects(fn) {
|
|
|
4714
4840
|
continue;
|
|
4715
4841
|
}
|
|
4716
4842
|
const unwrapped2 = peelParens(expression);
|
|
4717
|
-
if (
|
|
4843
|
+
if (import_ts_morph20.Node.isObjectLiteralExpression(unwrapped2)) {
|
|
4718
4844
|
found.push(unwrapped2);
|
|
4719
4845
|
}
|
|
4720
4846
|
}
|
|
@@ -4723,7 +4849,7 @@ function returnedObjects(fn) {
|
|
|
4723
4849
|
function enclosingFunctionOf(node) {
|
|
4724
4850
|
let current2 = node.getParent();
|
|
4725
4851
|
while (current2 !== void 0) {
|
|
4726
|
-
if (
|
|
4852
|
+
if (import_ts_morph20.Node.isFunctionDeclaration(current2) || import_ts_morph20.Node.isArrowFunction(current2) || import_ts_morph20.Node.isFunctionExpression(current2) || import_ts_morph20.Node.isMethodDeclaration(current2)) {
|
|
4727
4853
|
return current2.getBody();
|
|
4728
4854
|
}
|
|
4729
4855
|
current2 = current2.getParent();
|
|
@@ -4742,10 +4868,10 @@ function bindArguments(callArgs, params) {
|
|
|
4742
4868
|
}
|
|
4743
4869
|
|
|
4744
4870
|
// src/terminals/shared.ts
|
|
4745
|
-
var
|
|
4871
|
+
var import_ts_morph21 = require("ts-morph");
|
|
4746
4872
|
function unwrapValue(node) {
|
|
4747
4873
|
let current2 = node;
|
|
4748
|
-
while (
|
|
4874
|
+
while (import_ts_morph21.Node.isParenthesizedExpression(current2) || import_ts_morph21.Node.isAwaitExpression(current2) || import_ts_morph21.Node.isAsExpression(current2) || import_ts_morph21.Node.isNonNullExpression(current2) || import_ts_morph21.Node.isSatisfiesExpression(current2)) {
|
|
4749
4875
|
current2 = current2.getExpression();
|
|
4750
4876
|
}
|
|
4751
4877
|
return current2;
|
|
@@ -4757,17 +4883,17 @@ function returnPositionOf(value) {
|
|
|
4757
4883
|
if (parent === void 0) {
|
|
4758
4884
|
return null;
|
|
4759
4885
|
}
|
|
4760
|
-
if (
|
|
4886
|
+
if (import_ts_morph21.Node.isReturnStatement(parent)) {
|
|
4761
4887
|
return parent;
|
|
4762
4888
|
}
|
|
4763
|
-
if (
|
|
4889
|
+
if (import_ts_morph21.Node.isArrowFunction(parent)) {
|
|
4764
4890
|
return parent.getBody() === current2 ? current2 : null;
|
|
4765
4891
|
}
|
|
4766
|
-
if (
|
|
4892
|
+
if (import_ts_morph21.Node.isParenthesizedExpression(parent) || import_ts_morph21.Node.isAwaitExpression(parent) || import_ts_morph21.Node.isAsExpression(parent) || import_ts_morph21.Node.isNonNullExpression(parent) || import_ts_morph21.Node.isSatisfiesExpression(parent)) {
|
|
4767
4893
|
current2 = parent;
|
|
4768
4894
|
continue;
|
|
4769
4895
|
}
|
|
4770
|
-
if (
|
|
4896
|
+
if (import_ts_morph21.Node.isConditionalExpression(parent) && (parent.getWhenTrue() === current2 || parent.getWhenFalse() === current2)) {
|
|
4771
4897
|
current2 = parent;
|
|
4772
4898
|
continue;
|
|
4773
4899
|
}
|
|
@@ -4776,10 +4902,10 @@ function returnPositionOf(value) {
|
|
|
4776
4902
|
}
|
|
4777
4903
|
|
|
4778
4904
|
// src/terminals/statusBranches.ts
|
|
4779
|
-
var
|
|
4905
|
+
var import_ts_morph23 = require("ts-morph");
|
|
4780
4906
|
|
|
4781
4907
|
// src/facts/assignments.ts
|
|
4782
|
-
var
|
|
4908
|
+
var import_ts_morph22 = require("ts-morph");
|
|
4783
4909
|
var byFile = createPerFileCache();
|
|
4784
4910
|
var byDeclaration = /* @__PURE__ */ new WeakMap();
|
|
4785
4911
|
var byField = /* @__PURE__ */ new WeakMap();
|
|
@@ -4844,7 +4970,7 @@ function writesToFieldUncached(declaration) {
|
|
|
4844
4970
|
};
|
|
4845
4971
|
}
|
|
4846
4972
|
function startingValueOf(declaration) {
|
|
4847
|
-
return
|
|
4973
|
+
return import_ts_morph22.Node.isParameterDeclaration(declaration) ? declaration : declaration.getInitializer();
|
|
4848
4974
|
}
|
|
4849
4975
|
function writeRunsInConstructor(declaration, write) {
|
|
4850
4976
|
const statement = statementOf(write.node);
|
|
@@ -4852,24 +4978,24 @@ function writeRunsInConstructor(declaration, write) {
|
|
|
4852
4978
|
return false;
|
|
4853
4979
|
}
|
|
4854
4980
|
const body = statement.getParent();
|
|
4855
|
-
if (body === void 0 || !
|
|
4981
|
+
if (body === void 0 || !import_ts_morph22.Node.isBlock(body)) {
|
|
4856
4982
|
return false;
|
|
4857
4983
|
}
|
|
4858
4984
|
const owner = body.getParent();
|
|
4859
|
-
return owner !== void 0 &&
|
|
4985
|
+
return owner !== void 0 && import_ts_morph22.Node.isConstructorDeclaration(owner) && owner.getParent() === classHolding(declaration);
|
|
4860
4986
|
}
|
|
4861
4987
|
function classHolding(declaration) {
|
|
4862
|
-
return
|
|
4988
|
+
return import_ts_morph22.Node.isParameterDeclaration(declaration) ? declaration.getParent().getParent() : declaration.getParent();
|
|
4863
4989
|
}
|
|
4864
4990
|
function isWrittenAgain(declaration) {
|
|
4865
4991
|
return assignmentsTo(declaration).length > 0;
|
|
4866
4992
|
}
|
|
4867
4993
|
function assignmentsTo(declaration) {
|
|
4868
|
-
if (
|
|
4994
|
+
if (import_ts_morph22.Node.isPropertyDeclaration(declaration) || import_ts_morph22.Node.isParameterDeclaration(declaration)) {
|
|
4869
4995
|
const sourceFile2 = declaration.getSourceFile();
|
|
4870
4996
|
return sourceFile2.isDeclarationFile() ? [] : assignmentsInFile(sourceFile2).get(declaration) ?? [];
|
|
4871
4997
|
}
|
|
4872
|
-
if (declaration.getVariableStatement()?.getDeclarationKind() ===
|
|
4998
|
+
if (declaration.getVariableStatement()?.getDeclarationKind() === import_ts_morph22.VariableDeclarationKind.Const) {
|
|
4873
4999
|
return [];
|
|
4874
5000
|
}
|
|
4875
5001
|
const sourceFile = declaration.getSourceFile();
|
|
@@ -4902,39 +5028,39 @@ function assignmentsInFile(sourceFile) {
|
|
|
4902
5028
|
return found;
|
|
4903
5029
|
}
|
|
4904
5030
|
function isAssignmentOperator(kind) {
|
|
4905
|
-
return kind >=
|
|
5031
|
+
return kind >= import_ts_morph22.SyntaxKind.FirstAssignment && kind <= import_ts_morph22.SyntaxKind.LastAssignment;
|
|
4906
5032
|
}
|
|
4907
5033
|
function writeAt(node) {
|
|
4908
|
-
if (
|
|
5034
|
+
if (import_ts_morph22.Node.isBinaryExpression(node)) {
|
|
4909
5035
|
const operator = node.getOperatorToken().getKind();
|
|
4910
5036
|
const target = node.getLeft();
|
|
4911
|
-
if (!isAssignmentOperator(operator) || !(
|
|
5037
|
+
if (!isAssignmentOperator(operator) || !(import_ts_morph22.Node.isIdentifier(target) || import_ts_morph22.Node.isPropertyAccessExpression(target))) {
|
|
4912
5038
|
return null;
|
|
4913
5039
|
}
|
|
4914
|
-
const value = operator ===
|
|
5040
|
+
const value = operator === import_ts_morph22.SyntaxKind.EqualsToken ? node.getRight() : null;
|
|
4915
5041
|
return { target, write: { value, node } };
|
|
4916
5042
|
}
|
|
4917
|
-
if (
|
|
5043
|
+
if (import_ts_morph22.Node.isPrefixUnaryExpression(node) || import_ts_morph22.Node.isPostfixUnaryExpression(node)) {
|
|
4918
5044
|
const operator = node.getOperatorToken();
|
|
4919
|
-
if (operator !==
|
|
5045
|
+
if (operator !== import_ts_morph22.SyntaxKind.PlusPlusToken && operator !== import_ts_morph22.SyntaxKind.MinusMinusToken) {
|
|
4920
5046
|
return null;
|
|
4921
5047
|
}
|
|
4922
5048
|
const target = node.getOperand();
|
|
4923
|
-
return
|
|
5049
|
+
return import_ts_morph22.Node.isIdentifier(target) ? { target, write: { value: null, node } } : null;
|
|
4924
5050
|
}
|
|
4925
5051
|
return null;
|
|
4926
5052
|
}
|
|
4927
5053
|
function declarationsOf(name) {
|
|
4928
|
-
const nameNode =
|
|
5054
|
+
const nameNode = import_ts_morph22.Node.isPropertyAccessExpression(name) ? name.getNameNode() : name;
|
|
4929
5055
|
const symbol = nameNode.getSymbol();
|
|
4930
5056
|
if (symbol === void 0) {
|
|
4931
5057
|
return [];
|
|
4932
5058
|
}
|
|
4933
5059
|
const declarations = [];
|
|
4934
5060
|
for (const declaration of symbol.getDeclarations()) {
|
|
4935
|
-
if (
|
|
5061
|
+
if (import_ts_morph22.Node.isVariableDeclaration(declaration) || import_ts_morph22.Node.isPropertyDeclaration(declaration) || // A parameter property is the field's only declaration, so
|
|
4936
5062
|
// `this.dao = other` in the constructor writes to it.
|
|
4937
|
-
|
|
5063
|
+
import_ts_morph22.Node.isParameterDeclaration(declaration) && declaration.isParameterProperty()) {
|
|
4938
5064
|
declarations.push(declaration);
|
|
4939
5065
|
}
|
|
4940
5066
|
}
|
|
@@ -4954,7 +5080,7 @@ function writesRunInOrder(declaration, writes) {
|
|
|
4954
5080
|
function statementOf(node) {
|
|
4955
5081
|
let current2 = node;
|
|
4956
5082
|
while (current2 !== void 0) {
|
|
4957
|
-
if (
|
|
5083
|
+
if (import_ts_morph22.Node.isStatement(current2)) {
|
|
4958
5084
|
return current2;
|
|
4959
5085
|
}
|
|
4960
5086
|
current2 = current2.getParent();
|
|
@@ -4978,7 +5104,7 @@ function isReadBefore(declaration, position) {
|
|
|
4978
5104
|
traversal.skip();
|
|
4979
5105
|
return;
|
|
4980
5106
|
}
|
|
4981
|
-
if (!
|
|
5107
|
+
if (!import_ts_morph22.Node.isIdentifier(node) || node.getText() !== name) {
|
|
4982
5108
|
return;
|
|
4983
5109
|
}
|
|
4984
5110
|
if (node === declaration.getNameNode() || isWriteTarget(node)) {
|
|
@@ -4991,17 +5117,17 @@ function isReadBefore(declaration, position) {
|
|
|
4991
5117
|
return read2;
|
|
4992
5118
|
}
|
|
4993
5119
|
function startsItsOwnBody(node) {
|
|
4994
|
-
return
|
|
5120
|
+
return import_ts_morph22.Node.isFunctionDeclaration(node) || import_ts_morph22.Node.isFunctionExpression(node) || import_ts_morph22.Node.isArrowFunction(node) || import_ts_morph22.Node.isMethodDeclaration(node) || import_ts_morph22.Node.isClassDeclaration(node);
|
|
4995
5121
|
}
|
|
4996
5122
|
function isWriteTarget(name) {
|
|
4997
5123
|
const parent = name.getParent();
|
|
4998
5124
|
if (parent === void 0) {
|
|
4999
5125
|
return false;
|
|
5000
5126
|
}
|
|
5001
|
-
if (
|
|
5127
|
+
if (import_ts_morph22.Node.isBinaryExpression(parent)) {
|
|
5002
5128
|
return parent.getLeft() === name && isAssignmentOperator(parent.getOperatorToken().getKind());
|
|
5003
5129
|
}
|
|
5004
|
-
return (
|
|
5130
|
+
return (import_ts_morph22.Node.isPrefixUnaryExpression(parent) || import_ts_morph22.Node.isPostfixUnaryExpression(parent)) && parent.getOperand() === name;
|
|
5005
5131
|
}
|
|
5006
5132
|
|
|
5007
5133
|
// src/terminals/statusBranches.ts
|
|
@@ -5027,10 +5153,10 @@ function asConditional(node) {
|
|
|
5027
5153
|
if (direct !== null) {
|
|
5028
5154
|
return direct;
|
|
5029
5155
|
}
|
|
5030
|
-
if (!
|
|
5156
|
+
if (!import_ts_morph23.Node.isIdentifier(node)) {
|
|
5031
5157
|
return null;
|
|
5032
5158
|
}
|
|
5033
|
-
const declaration = node.getSymbol()?.getDeclarations().find(
|
|
5159
|
+
const declaration = node.getSymbol()?.getDeclarations().find(import_ts_morph23.Node.isVariableDeclaration);
|
|
5034
5160
|
if (declaration === void 0) {
|
|
5035
5161
|
return null;
|
|
5036
5162
|
}
|
|
@@ -5041,10 +5167,10 @@ function asConditional(node) {
|
|
|
5041
5167
|
const only = written.values[0];
|
|
5042
5168
|
return only === void 0 ? null : toConditional(only);
|
|
5043
5169
|
}
|
|
5044
|
-
var toConditional = (node) =>
|
|
5170
|
+
var toConditional = (node) => import_ts_morph23.Node.isConditionalExpression(node) ? node : null;
|
|
5045
5171
|
function numberOf(node) {
|
|
5046
5172
|
const inner = unwrap(node);
|
|
5047
|
-
if (!
|
|
5173
|
+
if (!import_ts_morph23.Node.isNumericLiteral(inner)) {
|
|
5048
5174
|
return null;
|
|
5049
5175
|
}
|
|
5050
5176
|
const value = Number(inner.getText());
|
|
@@ -5052,7 +5178,7 @@ function numberOf(node) {
|
|
|
5052
5178
|
}
|
|
5053
5179
|
function unwrap(node) {
|
|
5054
5180
|
let current2 = node;
|
|
5055
|
-
while (
|
|
5181
|
+
while (import_ts_morph23.Node.isParenthesizedExpression(current2) || import_ts_morph23.Node.isAsExpression(current2) || import_ts_morph23.Node.isNonNullExpression(current2)) {
|
|
5056
5182
|
current2 = current2.getExpression();
|
|
5057
5183
|
}
|
|
5058
5184
|
return current2;
|
|
@@ -5068,7 +5194,7 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
5068
5194
|
for (let i = methodChain.length - 1; i >= 0; i--) {
|
|
5069
5195
|
const expectedMethod = methodChain[i];
|
|
5070
5196
|
const callee = current2.getExpression();
|
|
5071
|
-
if (!
|
|
5197
|
+
if (!import_ts_morph24.Node.isPropertyAccessExpression(callee)) {
|
|
5072
5198
|
return null;
|
|
5073
5199
|
}
|
|
5074
5200
|
if (callee.getName() !== expectedMethod) {
|
|
@@ -5077,7 +5203,7 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
5077
5203
|
collected.unshift(current2);
|
|
5078
5204
|
const subject = callee.getExpression();
|
|
5079
5205
|
if (i === 0) {
|
|
5080
|
-
if (!
|
|
5206
|
+
if (!import_ts_morph24.Node.isIdentifier(subject)) {
|
|
5081
5207
|
return null;
|
|
5082
5208
|
}
|
|
5083
5209
|
const symbol = subject.getSymbol();
|
|
@@ -5089,7 +5215,7 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
5089
5215
|
return null;
|
|
5090
5216
|
}
|
|
5091
5217
|
const decl = decls[0];
|
|
5092
|
-
if (!
|
|
5218
|
+
if (!import_ts_morph24.Node.isParameterDeclaration(decl)) {
|
|
5093
5219
|
return null;
|
|
5094
5220
|
}
|
|
5095
5221
|
const params = func.getParameters();
|
|
@@ -5098,7 +5224,7 @@ function unwrapMethodChain(call, methodChain, func, paramPos) {
|
|
|
5098
5224
|
return null;
|
|
5099
5225
|
}
|
|
5100
5226
|
} else {
|
|
5101
|
-
if (!
|
|
5227
|
+
if (!import_ts_morph24.Node.isCallExpression(subject)) {
|
|
5102
5228
|
return null;
|
|
5103
5229
|
}
|
|
5104
5230
|
current2 = subject;
|
|
@@ -5111,12 +5237,12 @@ function returnedValueOf(returnStatement) {
|
|
|
5111
5237
|
return written === void 0 ? null : unwrapValue(written);
|
|
5112
5238
|
}
|
|
5113
5239
|
function tryMatchReturnShape(node, pattern, match, resolveWrittenValue) {
|
|
5114
|
-
if (
|
|
5240
|
+
if (import_ts_morph24.Node.isObjectLiteralExpression(node)) {
|
|
5115
5241
|
const source = returnPositionOf(node);
|
|
5116
5242
|
if (source === null) {
|
|
5117
5243
|
return [];
|
|
5118
5244
|
}
|
|
5119
|
-
if (
|
|
5245
|
+
if (import_ts_morph24.Node.isReturnStatement(source) && returnedValueOf(source) === node) {
|
|
5120
5246
|
return [];
|
|
5121
5247
|
}
|
|
5122
5248
|
const terminal = terminalFromReturnedObject(
|
|
@@ -5129,14 +5255,14 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue) {
|
|
|
5129
5255
|
);
|
|
5130
5256
|
return terminal === null ? [] : [{ ...terminal, source }];
|
|
5131
5257
|
}
|
|
5132
|
-
if (!
|
|
5258
|
+
if (!import_ts_morph24.Node.isReturnStatement(node)) {
|
|
5133
5259
|
return [];
|
|
5134
5260
|
}
|
|
5135
5261
|
const returned = returnedValueOf(node);
|
|
5136
5262
|
if (returned === null) {
|
|
5137
5263
|
return [];
|
|
5138
5264
|
}
|
|
5139
|
-
if (
|
|
5265
|
+
if (import_ts_morph24.Node.isObjectLiteralExpression(returned)) {
|
|
5140
5266
|
const terminal = terminalFromReturnedObject(
|
|
5141
5267
|
returned,
|
|
5142
5268
|
node,
|
|
@@ -5147,7 +5273,7 @@ function tryMatchReturnShape(node, pattern, match, resolveWrittenValue) {
|
|
|
5147
5273
|
);
|
|
5148
5274
|
return terminal === null ? [] : [terminal];
|
|
5149
5275
|
}
|
|
5150
|
-
if (!
|
|
5276
|
+
if (!import_ts_morph24.Node.isCallExpression(returned)) {
|
|
5151
5277
|
return [];
|
|
5152
5278
|
}
|
|
5153
5279
|
const resolved = resolveHelperReturn(returned);
|
|
@@ -5184,7 +5310,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
5184
5310
|
if (required !== void 0 && required.length > 0) {
|
|
5185
5311
|
const presentNames = /* @__PURE__ */ new Set();
|
|
5186
5312
|
for (const prop of obj.getProperties()) {
|
|
5187
|
-
if (
|
|
5313
|
+
if (import_ts_morph24.Node.isPropertyAssignment(prop) || import_ts_morph24.Node.isShorthandPropertyAssignment(prop)) {
|
|
5188
5314
|
presentNames.add(prop.getName());
|
|
5189
5315
|
}
|
|
5190
5316
|
}
|
|
@@ -5210,7 +5336,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
5210
5336
|
// When a helper built the value, the anchor is the caller's own
|
|
5211
5337
|
// return, so it doubles as the provenance. A value reached any other
|
|
5212
5338
|
// way leaves this unset and its caller fills it in.
|
|
5213
|
-
...
|
|
5339
|
+
...import_ts_morph24.Node.isReturnStatement(anchor) ? { source: anchor } : {},
|
|
5214
5340
|
terminal: {
|
|
5215
5341
|
kind: pattern.kind,
|
|
5216
5342
|
statusCode,
|
|
@@ -5229,7 +5355,7 @@ function terminalFromReturnedObject(obj, anchor, pattern, match, substitutions,
|
|
|
5229
5355
|
};
|
|
5230
5356
|
}
|
|
5231
5357
|
function tryMatchParameterMethodCall(node, func, pattern, match, resolveWrittenValue) {
|
|
5232
|
-
if (!
|
|
5358
|
+
if (!import_ts_morph24.Node.isCallExpression(node)) {
|
|
5233
5359
|
return [];
|
|
5234
5360
|
}
|
|
5235
5361
|
const result = unwrapMethodChain(
|
|
@@ -5294,7 +5420,7 @@ function statusArgument(calls, extraction) {
|
|
|
5294
5420
|
}
|
|
5295
5421
|
function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
5296
5422
|
const current2 = unwrapValue(expr);
|
|
5297
|
-
if (!
|
|
5423
|
+
if (!import_ts_morph24.Node.isCallExpression(current2)) {
|
|
5298
5424
|
return false;
|
|
5299
5425
|
}
|
|
5300
5426
|
for (const pattern of patterns) {
|
|
@@ -5315,7 +5441,7 @@ function returnCoveredByParameterMethodCall(expr, func, patterns) {
|
|
|
5315
5441
|
}
|
|
5316
5442
|
function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
5317
5443
|
const match = pattern.match.type === "returnStatement" ? pattern.match : null;
|
|
5318
|
-
if (
|
|
5444
|
+
if (import_ts_morph24.Node.isReturnStatement(node)) {
|
|
5319
5445
|
const expr = node.getExpression();
|
|
5320
5446
|
if (match?.excludeCallReturns === true) {
|
|
5321
5447
|
if (expr === void 0) {
|
|
@@ -5334,9 +5460,9 @@ function tryMatchReturnStatement(node, pattern, func, allPatterns) {
|
|
|
5334
5460
|
}
|
|
5335
5461
|
return buildReturnTerminal(node, pattern, body);
|
|
5336
5462
|
}
|
|
5337
|
-
if (
|
|
5463
|
+
if (import_ts_morph24.Node.isArrowFunction(node)) {
|
|
5338
5464
|
const body = node.getBody();
|
|
5339
|
-
if (body === void 0 ||
|
|
5465
|
+
if (body === void 0 || import_ts_morph24.Node.isBlock(body)) {
|
|
5340
5466
|
return null;
|
|
5341
5467
|
}
|
|
5342
5468
|
const shape = extractShape(body);
|
|
@@ -5403,20 +5529,20 @@ function unresolvedTerminal(kind, node) {
|
|
|
5403
5529
|
};
|
|
5404
5530
|
}
|
|
5405
5531
|
function calleeSubject(callee) {
|
|
5406
|
-
if (
|
|
5532
|
+
if (import_ts_morph24.Node.isIdentifier(callee)) {
|
|
5407
5533
|
return callee;
|
|
5408
5534
|
}
|
|
5409
|
-
if (
|
|
5535
|
+
if (import_ts_morph24.Node.isPropertyAccessExpression(callee)) {
|
|
5410
5536
|
const subject = callee.getExpression();
|
|
5411
|
-
return
|
|
5537
|
+
return import_ts_morph24.Node.isIdentifier(subject) ? subject : null;
|
|
5412
5538
|
}
|
|
5413
5539
|
return null;
|
|
5414
5540
|
}
|
|
5415
5541
|
function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue) {
|
|
5416
|
-
if (!
|
|
5542
|
+
if (!import_ts_morph24.Node.isCallExpression(node) && !import_ts_morph24.Node.isNewExpression(node)) {
|
|
5417
5543
|
return null;
|
|
5418
5544
|
}
|
|
5419
|
-
if (
|
|
5545
|
+
if (import_ts_morph24.Node.isNewExpression(node) && returnPositionOf(node) === null) {
|
|
5420
5546
|
return null;
|
|
5421
5547
|
}
|
|
5422
5548
|
const callee = node.getExpression();
|
|
@@ -5455,9 +5581,9 @@ function tryMatchFunctionCall(node, pattern, match, resolveWrittenValue) {
|
|
|
5455
5581
|
}
|
|
5456
5582
|
|
|
5457
5583
|
// src/terminals/throws.ts
|
|
5458
|
-
var
|
|
5584
|
+
var import_ts_morph25 = require("ts-morph");
|
|
5459
5585
|
function tryMatchThrowExpression(node, pattern, match, resolveWrittenValue) {
|
|
5460
|
-
if (!
|
|
5586
|
+
if (!import_ts_morph25.Node.isThrowStatement(node)) {
|
|
5461
5587
|
return null;
|
|
5462
5588
|
}
|
|
5463
5589
|
const thrownExpr = node.getExpression();
|
|
@@ -5499,17 +5625,17 @@ function extractThrowMessage(callArgs) {
|
|
|
5499
5625
|
return null;
|
|
5500
5626
|
}
|
|
5501
5627
|
for (const arg of callArgs) {
|
|
5502
|
-
if (
|
|
5628
|
+
if (import_ts_morph25.Node.isStringLiteral(arg) || import_ts_morph25.Node.isNoSubstitutionTemplateLiteral(arg)) {
|
|
5503
5629
|
return arg.getLiteralValue();
|
|
5504
5630
|
}
|
|
5505
|
-
if (
|
|
5631
|
+
if (import_ts_morph25.Node.isTemplateExpression(arg)) {
|
|
5506
5632
|
return arg.getText();
|
|
5507
5633
|
}
|
|
5508
5634
|
}
|
|
5509
5635
|
return null;
|
|
5510
5636
|
}
|
|
5511
5637
|
function classifyThrownExpression(thrown, constructorPattern) {
|
|
5512
|
-
if (
|
|
5638
|
+
if (import_ts_morph25.Node.isCallExpression(thrown) || import_ts_morph25.Node.isNewExpression(thrown)) {
|
|
5513
5639
|
const calleeText = thrown.getExpression().getText();
|
|
5514
5640
|
if (constructorPattern !== void 0 && !calleeText.startsWith(constructorPattern)) {
|
|
5515
5641
|
return null;
|
|
@@ -5592,9 +5718,9 @@ function findTerminals(func, patterns, barriers = NO_BARRIERS, resolveWrittenVal
|
|
|
5592
5718
|
}
|
|
5593
5719
|
}
|
|
5594
5720
|
});
|
|
5595
|
-
if (results.length === 0 &&
|
|
5721
|
+
if (results.length === 0 && import_ts_morph26.Node.isArrowFunction(func)) {
|
|
5596
5722
|
const body = func.getBody();
|
|
5597
|
-
if (body !== void 0 && !
|
|
5723
|
+
if (body !== void 0 && !import_ts_morph26.Node.isBlock(body)) {
|
|
5598
5724
|
for (const pattern of patterns) {
|
|
5599
5725
|
let found = null;
|
|
5600
5726
|
if (pattern.match.type === "parameterMethodCall") {
|
|
@@ -5629,7 +5755,7 @@ function functionMayFallThrough(func) {
|
|
|
5629
5755
|
if (body === void 0) {
|
|
5630
5756
|
return false;
|
|
5631
5757
|
}
|
|
5632
|
-
if (!
|
|
5758
|
+
if (!import_ts_morph26.Node.isBlock(body)) {
|
|
5633
5759
|
return false;
|
|
5634
5760
|
}
|
|
5635
5761
|
const statements = body.getStatements();
|
|
@@ -5637,7 +5763,7 @@ function functionMayFallThrough(func) {
|
|
|
5637
5763
|
return true;
|
|
5638
5764
|
}
|
|
5639
5765
|
const last = statements[statements.length - 1];
|
|
5640
|
-
if (
|
|
5766
|
+
if (import_ts_morph26.Node.isReturnStatement(last) || import_ts_morph26.Node.isThrowStatement(last)) {
|
|
5641
5767
|
return false;
|
|
5642
5768
|
}
|
|
5643
5769
|
return true;
|
|
@@ -5672,7 +5798,7 @@ function bodyContentOf(func) {
|
|
|
5672
5798
|
if (body === void 0) {
|
|
5673
5799
|
return "absent";
|
|
5674
5800
|
}
|
|
5675
|
-
if (!
|
|
5801
|
+
if (!import_ts_morph27.Node.isBlock(body)) {
|
|
5676
5802
|
return "statements";
|
|
5677
5803
|
}
|
|
5678
5804
|
return body.getStatements().length === 0 ? "empty" : "statements";
|
|
@@ -5688,7 +5814,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
5688
5814
|
claimed.add(source);
|
|
5689
5815
|
}
|
|
5690
5816
|
}
|
|
5691
|
-
if (
|
|
5817
|
+
if (import_ts_morph27.Node.isArrowFunction(func) && import_ts_morph27.Node.isExpression(body)) {
|
|
5692
5818
|
return claimed.has(body) ? 0 : 1;
|
|
5693
5819
|
}
|
|
5694
5820
|
let unmatched = 0;
|
|
@@ -5701,7 +5827,7 @@ function countUnmatchedReturns(func, terminals, barriers = NO_BARRIERS) {
|
|
|
5701
5827
|
traversal.skip();
|
|
5702
5828
|
return;
|
|
5703
5829
|
}
|
|
5704
|
-
if (!
|
|
5830
|
+
if (!import_ts_morph27.Node.isReturnStatement(node)) {
|
|
5705
5831
|
return;
|
|
5706
5832
|
}
|
|
5707
5833
|
if (node.getExpression() === void 0) {
|
|
@@ -5820,7 +5946,7 @@ function extractRawBranches(func, terminalPatterns, invocationRecognizers = [],
|
|
|
5820
5946
|
}
|
|
5821
5947
|
|
|
5822
5948
|
// src/bootstrap/sourceFileLookup.ts
|
|
5823
|
-
var
|
|
5949
|
+
var import_ts_morph28 = require("ts-morph");
|
|
5824
5950
|
function createSourceFileLookup(project) {
|
|
5825
5951
|
const all = project.getSourceFiles();
|
|
5826
5952
|
const byAbs = /* @__PURE__ */ new Map();
|
|
@@ -5873,7 +5999,7 @@ function rangeKey(range) {
|
|
|
5873
5999
|
function indexFunctions(sf) {
|
|
5874
6000
|
const index = /* @__PURE__ */ new Map();
|
|
5875
6001
|
sf.forEachDescendant((node) => {
|
|
5876
|
-
if (!
|
|
6002
|
+
if (!import_ts_morph28.Node.isFunctionDeclaration(node) && !import_ts_morph28.Node.isFunctionExpression(node) && !import_ts_morph28.Node.isArrowFunction(node) && !import_ts_morph28.Node.isMethodDeclaration(node)) {
|
|
5877
6003
|
return;
|
|
5878
6004
|
}
|
|
5879
6005
|
const key = rangeKey({ start: startLineOf(node), end: endLineOf(node) });
|
|
@@ -6235,13 +6361,13 @@ function fileStampEquals(a, b) {
|
|
|
6235
6361
|
}
|
|
6236
6362
|
|
|
6237
6363
|
// src/contract.ts
|
|
6238
|
-
var
|
|
6364
|
+
var import_ts_morph29 = require("ts-morph");
|
|
6239
6365
|
var import_behavioral_ir2 = require("@suss/behavioral-ir");
|
|
6240
6366
|
function extractDeclaredBody(node) {
|
|
6241
6367
|
if (node === void 0) {
|
|
6242
6368
|
return null;
|
|
6243
6369
|
}
|
|
6244
|
-
if (!
|
|
6370
|
+
if (!import_ts_morph29.Node.isCallExpression(node)) {
|
|
6245
6371
|
return null;
|
|
6246
6372
|
}
|
|
6247
6373
|
const typeArgs = node.getTypeArguments();
|
|
@@ -6255,10 +6381,10 @@ function resolveHandlerPropNode(func) {
|
|
|
6255
6381
|
if (parent === void 0) {
|
|
6256
6382
|
return null;
|
|
6257
6383
|
}
|
|
6258
|
-
if (
|
|
6384
|
+
if (import_ts_morph29.Node.isPropertyAssignment(parent)) {
|
|
6259
6385
|
return parent;
|
|
6260
6386
|
}
|
|
6261
|
-
if (
|
|
6387
|
+
if (import_ts_morph29.Node.isMethodDeclaration(func)) {
|
|
6262
6388
|
return func;
|
|
6263
6389
|
}
|
|
6264
6390
|
return null;
|
|
@@ -6270,11 +6396,11 @@ function findRouterCall(unit) {
|
|
|
6270
6396
|
return null;
|
|
6271
6397
|
}
|
|
6272
6398
|
const handlersObj = propNode.getParent();
|
|
6273
|
-
if (handlersObj === void 0 || !
|
|
6399
|
+
if (handlersObj === void 0 || !import_ts_morph29.Node.isObjectLiteralExpression(handlersObj)) {
|
|
6274
6400
|
return null;
|
|
6275
6401
|
}
|
|
6276
6402
|
const routerCall = handlersObj.getParent();
|
|
6277
|
-
if (routerCall === void 0 || !
|
|
6403
|
+
if (routerCall === void 0 || !import_ts_morph29.Node.isCallExpression(routerCall)) {
|
|
6278
6404
|
return null;
|
|
6279
6405
|
}
|
|
6280
6406
|
const args = routerCall.getArguments();
|
|
@@ -6287,17 +6413,17 @@ function findRouterCall(unit) {
|
|
|
6287
6413
|
};
|
|
6288
6414
|
}
|
|
6289
6415
|
function resolveContractObject(contractArg) {
|
|
6290
|
-
if (
|
|
6416
|
+
if (import_ts_morph29.Node.isObjectLiteralExpression(contractArg)) {
|
|
6291
6417
|
return contractArg;
|
|
6292
6418
|
}
|
|
6293
|
-
if (
|
|
6419
|
+
if (import_ts_morph29.Node.isPropertyAccessExpression(contractArg)) {
|
|
6294
6420
|
const base = resolveContractObject(contractArg.getExpression());
|
|
6295
|
-
if (base === null || !
|
|
6421
|
+
if (base === null || !import_ts_morph29.Node.isObjectLiteralExpression(base)) {
|
|
6296
6422
|
return null;
|
|
6297
6423
|
}
|
|
6298
6424
|
const propName = contractArg.getName();
|
|
6299
6425
|
for (const prop of base.getProperties()) {
|
|
6300
|
-
if (!
|
|
6426
|
+
if (!import_ts_morph29.Node.isPropertyAssignment(prop)) {
|
|
6301
6427
|
continue;
|
|
6302
6428
|
}
|
|
6303
6429
|
if (prop.getName() !== propName) {
|
|
@@ -6307,20 +6433,20 @@ function resolveContractObject(contractArg) {
|
|
|
6307
6433
|
if (value === void 0) {
|
|
6308
6434
|
return null;
|
|
6309
6435
|
}
|
|
6310
|
-
if (
|
|
6436
|
+
if (import_ts_morph29.Node.isObjectLiteralExpression(value)) {
|
|
6311
6437
|
return value;
|
|
6312
6438
|
}
|
|
6313
|
-
if (
|
|
6439
|
+
if (import_ts_morph29.Node.isIdentifier(value) || import_ts_morph29.Node.isPropertyAccessExpression(value)) {
|
|
6314
6440
|
return resolveContractObject(value);
|
|
6315
6441
|
}
|
|
6316
|
-
if (
|
|
6442
|
+
if (import_ts_morph29.Node.isCallExpression(value)) {
|
|
6317
6443
|
return unwrapContractInit(value);
|
|
6318
6444
|
}
|
|
6319
6445
|
return null;
|
|
6320
6446
|
}
|
|
6321
6447
|
return null;
|
|
6322
6448
|
}
|
|
6323
|
-
if (!
|
|
6449
|
+
if (!import_ts_morph29.Node.isIdentifier(contractArg)) {
|
|
6324
6450
|
return null;
|
|
6325
6451
|
}
|
|
6326
6452
|
const symbol = contractArg.getSymbol();
|
|
@@ -6332,21 +6458,21 @@ function resolveContractObject(contractArg) {
|
|
|
6332
6458
|
return null;
|
|
6333
6459
|
}
|
|
6334
6460
|
const decl = decls[0];
|
|
6335
|
-
if (
|
|
6461
|
+
if (import_ts_morph29.Node.isImportSpecifier(decl)) {
|
|
6336
6462
|
const importDecl = decl.getImportDeclaration();
|
|
6337
6463
|
const sourceFile = importDecl.getModuleSpecifierSourceFile();
|
|
6338
6464
|
if (sourceFile !== void 0) {
|
|
6339
6465
|
const exported = exportedDeclarationsOf(sourceFile).get(decl.getName());
|
|
6340
6466
|
if (exported !== void 0 && exported.length > 0) {
|
|
6341
6467
|
const exportedDecl = exported[0];
|
|
6342
|
-
if (
|
|
6468
|
+
if (import_ts_morph29.Node.isVariableDeclaration(exportedDecl)) {
|
|
6343
6469
|
return unwrapContractInit(exportedDecl.getInitializer());
|
|
6344
6470
|
}
|
|
6345
6471
|
}
|
|
6346
6472
|
}
|
|
6347
6473
|
return null;
|
|
6348
6474
|
}
|
|
6349
|
-
if (
|
|
6475
|
+
if (import_ts_morph29.Node.isVariableDeclaration(decl)) {
|
|
6350
6476
|
return unwrapContractInit(decl.getInitializer());
|
|
6351
6477
|
}
|
|
6352
6478
|
return null;
|
|
@@ -6356,50 +6482,50 @@ function unwrapContractInit(init) {
|
|
|
6356
6482
|
return null;
|
|
6357
6483
|
}
|
|
6358
6484
|
let node = init;
|
|
6359
|
-
while (
|
|
6485
|
+
while (import_ts_morph29.Node.isAsExpression(node)) {
|
|
6360
6486
|
node = node.getExpression();
|
|
6361
6487
|
}
|
|
6362
|
-
if (
|
|
6488
|
+
if (import_ts_morph29.Node.isCallExpression(node)) {
|
|
6363
6489
|
const args = node.getArguments();
|
|
6364
|
-
if (args.length > 0 &&
|
|
6490
|
+
if (args.length > 0 && import_ts_morph29.Node.isObjectLiteralExpression(args[0])) {
|
|
6365
6491
|
return args[0];
|
|
6366
6492
|
}
|
|
6367
6493
|
return null;
|
|
6368
6494
|
}
|
|
6369
|
-
if (
|
|
6495
|
+
if (import_ts_morph29.Node.isObjectLiteralExpression(node)) {
|
|
6370
6496
|
return node;
|
|
6371
6497
|
}
|
|
6372
6498
|
return null;
|
|
6373
6499
|
}
|
|
6374
6500
|
function extractEndpointContract(endpointNode, pattern, framework) {
|
|
6375
|
-
if (!
|
|
6501
|
+
if (!import_ts_morph29.Node.isObjectLiteralExpression(endpointNode)) {
|
|
6376
6502
|
return null;
|
|
6377
6503
|
}
|
|
6378
6504
|
const responses = [];
|
|
6379
6505
|
let method;
|
|
6380
6506
|
let path13;
|
|
6381
6507
|
for (const prop of endpointNode.getProperties()) {
|
|
6382
|
-
if (!
|
|
6508
|
+
if (!import_ts_morph29.Node.isPropertyAssignment(prop)) {
|
|
6383
6509
|
continue;
|
|
6384
6510
|
}
|
|
6385
6511
|
const propName = prop.getName();
|
|
6386
6512
|
if (propName === pattern.methodProperty) {
|
|
6387
6513
|
const val = prop.getInitializer();
|
|
6388
|
-
if (val !== void 0 &&
|
|
6514
|
+
if (val !== void 0 && import_ts_morph29.Node.isStringLiteral(val)) {
|
|
6389
6515
|
method = val.getLiteralValue();
|
|
6390
6516
|
}
|
|
6391
6517
|
}
|
|
6392
6518
|
if (propName === pattern.pathProperty) {
|
|
6393
6519
|
const val = prop.getInitializer();
|
|
6394
|
-
if (val !== void 0 &&
|
|
6520
|
+
if (val !== void 0 && import_ts_morph29.Node.isStringLiteral(val)) {
|
|
6395
6521
|
path13 = val.getLiteralValue();
|
|
6396
6522
|
}
|
|
6397
6523
|
}
|
|
6398
6524
|
if (propName === pattern.responseExtraction.property) {
|
|
6399
6525
|
const val = prop.getInitializer();
|
|
6400
|
-
if (val !== void 0 &&
|
|
6526
|
+
if (val !== void 0 && import_ts_morph29.Node.isObjectLiteralExpression(val)) {
|
|
6401
6527
|
for (const respProp of val.getProperties()) {
|
|
6402
|
-
if (!
|
|
6528
|
+
if (!import_ts_morph29.Node.isPropertyAssignment(respProp)) {
|
|
6403
6529
|
continue;
|
|
6404
6530
|
}
|
|
6405
6531
|
const statusStr = respProp.getName();
|
|
@@ -6443,11 +6569,11 @@ function readContract(unit, pattern, framework) {
|
|
|
6443
6569
|
return null;
|
|
6444
6570
|
}
|
|
6445
6571
|
const contractObj = resolveContractObject(routerInfo.contractArg);
|
|
6446
|
-
if (contractObj === null || !
|
|
6572
|
+
if (contractObj === null || !import_ts_morph29.Node.isObjectLiteralExpression(contractObj)) {
|
|
6447
6573
|
return null;
|
|
6448
6574
|
}
|
|
6449
6575
|
for (const prop of contractObj.getProperties()) {
|
|
6450
|
-
if (!
|
|
6576
|
+
if (!import_ts_morph29.Node.isPropertyAssignment(prop)) {
|
|
6451
6577
|
continue;
|
|
6452
6578
|
}
|
|
6453
6579
|
if (prop.getName() !== routerInfo.handlerName) {
|
|
@@ -6467,7 +6593,7 @@ function endpointFromRegistrationArgument(unit, position) {
|
|
|
6467
6593
|
return null;
|
|
6468
6594
|
}
|
|
6469
6595
|
const call = func.getParent();
|
|
6470
|
-
if (call === void 0 || !
|
|
6596
|
+
if (call === void 0 || !import_ts_morph29.Node.isCallExpression(call)) {
|
|
6471
6597
|
return null;
|
|
6472
6598
|
}
|
|
6473
6599
|
const args = call.getArguments();
|
|
@@ -6479,24 +6605,24 @@ function endpointFromRegistrationArgument(unit, position) {
|
|
|
6479
6605
|
return null;
|
|
6480
6606
|
}
|
|
6481
6607
|
let node = arg;
|
|
6482
|
-
while (
|
|
6608
|
+
while (import_ts_morph29.Node.isAsExpression(node)) {
|
|
6483
6609
|
node = node.getExpression();
|
|
6484
6610
|
}
|
|
6485
|
-
if (
|
|
6611
|
+
if (import_ts_morph29.Node.isObjectLiteralExpression(node)) {
|
|
6486
6612
|
return node;
|
|
6487
6613
|
}
|
|
6488
|
-
if (
|
|
6614
|
+
if (import_ts_morph29.Node.isCallExpression(node)) {
|
|
6489
6615
|
return unwrapContractInit(node);
|
|
6490
6616
|
}
|
|
6491
6617
|
return resolveContractObject(node);
|
|
6492
6618
|
}
|
|
6493
6619
|
function readContractForClientCall(callExpression, methodName, pattern, framework) {
|
|
6494
|
-
const callee =
|
|
6495
|
-
if (callee === null || !
|
|
6620
|
+
const callee = import_ts_morph29.Node.isCallExpression(callExpression) ? callExpression.getExpression() : null;
|
|
6621
|
+
if (callee === null || !import_ts_morph29.Node.isPropertyAccessExpression(callee)) {
|
|
6496
6622
|
return null;
|
|
6497
6623
|
}
|
|
6498
6624
|
const clientIdentifier = callee.getExpression();
|
|
6499
|
-
if (!
|
|
6625
|
+
if (!import_ts_morph29.Node.isIdentifier(clientIdentifier)) {
|
|
6500
6626
|
return null;
|
|
6501
6627
|
}
|
|
6502
6628
|
const symbol = clientIdentifier.getSymbol();
|
|
@@ -6508,11 +6634,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
6508
6634
|
return null;
|
|
6509
6635
|
}
|
|
6510
6636
|
const decl = decls[0];
|
|
6511
|
-
if (!
|
|
6637
|
+
if (!import_ts_morph29.Node.isVariableDeclaration(decl)) {
|
|
6512
6638
|
return null;
|
|
6513
6639
|
}
|
|
6514
6640
|
const init = decl.getInitializer();
|
|
6515
|
-
if (init === void 0 || !
|
|
6641
|
+
if (init === void 0 || !import_ts_morph29.Node.isCallExpression(init)) {
|
|
6516
6642
|
return null;
|
|
6517
6643
|
}
|
|
6518
6644
|
const args = init.getArguments();
|
|
@@ -6520,11 +6646,11 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
6520
6646
|
return null;
|
|
6521
6647
|
}
|
|
6522
6648
|
const contractObj = resolveContractObject(args[0]);
|
|
6523
|
-
if (contractObj === null || !
|
|
6649
|
+
if (contractObj === null || !import_ts_morph29.Node.isObjectLiteralExpression(contractObj)) {
|
|
6524
6650
|
return null;
|
|
6525
6651
|
}
|
|
6526
6652
|
for (const prop of contractObj.getProperties()) {
|
|
6527
|
-
if (!
|
|
6653
|
+
if (!import_ts_morph29.Node.isPropertyAssignment(prop)) {
|
|
6528
6654
|
continue;
|
|
6529
6655
|
}
|
|
6530
6656
|
if (prop.getName() !== methodName) {
|
|
@@ -6541,7 +6667,7 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
6541
6667
|
|
|
6542
6668
|
// src/diagnostics.ts
|
|
6543
6669
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
6544
|
-
var
|
|
6670
|
+
var import_ts_morph30 = require("ts-morph");
|
|
6545
6671
|
var import_behavioral_ir3 = require("@suss/behavioral-ir");
|
|
6546
6672
|
var emptyTally = () => ({
|
|
6547
6673
|
candidateFiles: 0,
|
|
@@ -6589,23 +6715,23 @@ function commonDirectoryOf(files) {
|
|
|
6589
6715
|
return joined.length > 1 ? joined : void 0;
|
|
6590
6716
|
}
|
|
6591
6717
|
var DEFAULT_RESOLUTION = {
|
|
6592
|
-
moduleResolution:
|
|
6593
|
-
target:
|
|
6594
|
-
module:
|
|
6718
|
+
moduleResolution: import_ts_morph30.ts.ModuleResolutionKind.Bundler,
|
|
6719
|
+
target: import_ts_morph30.ts.ScriptTarget.ESNext,
|
|
6720
|
+
module: import_ts_morph30.ts.ModuleKind.ESNext
|
|
6595
6721
|
};
|
|
6596
6722
|
function resolutionContext(args) {
|
|
6597
6723
|
if (args.tsConfigFilePath !== void 0) {
|
|
6598
|
-
const configFile =
|
|
6724
|
+
const configFile = import_ts_morph30.ts.readConfigFile(
|
|
6599
6725
|
args.tsConfigFilePath,
|
|
6600
|
-
|
|
6726
|
+
import_ts_morph30.ts.sys.readFile
|
|
6601
6727
|
);
|
|
6602
6728
|
if (configFile.error !== void 0) {
|
|
6603
6729
|
return null;
|
|
6604
6730
|
}
|
|
6605
6731
|
const dir = import_node_path3.default.dirname(args.tsConfigFilePath);
|
|
6606
|
-
const parsed =
|
|
6732
|
+
const parsed = import_ts_morph30.ts.parseJsonConfigFileContent(
|
|
6607
6733
|
configFile.config,
|
|
6608
|
-
|
|
6734
|
+
import_ts_morph30.ts.sys,
|
|
6609
6735
|
dir,
|
|
6610
6736
|
/*existingOptions*/
|
|
6611
6737
|
void 0,
|
|
@@ -6634,11 +6760,11 @@ function unresolvedGatesFor(gates, args) {
|
|
|
6634
6760
|
}
|
|
6635
6761
|
const unresolved = [];
|
|
6636
6762
|
for (const gate of gates) {
|
|
6637
|
-
const resolved =
|
|
6763
|
+
const resolved = import_ts_morph30.ts.resolveModuleName(
|
|
6638
6764
|
gate,
|
|
6639
6765
|
context.containingFile,
|
|
6640
6766
|
context.options,
|
|
6641
|
-
|
|
6767
|
+
import_ts_morph30.ts.sys
|
|
6642
6768
|
);
|
|
6643
6769
|
if (resolved.resolvedModule === void 0) {
|
|
6644
6770
|
unresolved.push(gate);
|
|
@@ -6804,17 +6930,17 @@ function parameterName(segment, convention) {
|
|
|
6804
6930
|
|
|
6805
6931
|
// src/discovery/graphqlClientConstruction.ts
|
|
6806
6932
|
var import_picomatch = __toESM(require("picomatch"), 1);
|
|
6807
|
-
var
|
|
6933
|
+
var import_ts_morph34 = require("ts-morph");
|
|
6808
6934
|
var import_behavioral_ir4 = require("@suss/behavioral-ir");
|
|
6809
6935
|
|
|
6810
6936
|
// src/discovery/resolveValue.ts
|
|
6811
|
-
var
|
|
6937
|
+
var import_ts_morph33 = require("ts-morph");
|
|
6812
6938
|
|
|
6813
6939
|
// src/facts/extract.ts
|
|
6814
|
-
var
|
|
6940
|
+
var import_ts_morph32 = require("ts-morph");
|
|
6815
6941
|
|
|
6816
6942
|
// src/discovery/shared.ts
|
|
6817
|
-
var
|
|
6943
|
+
var import_ts_morph31 = require("ts-morph");
|
|
6818
6944
|
function unitNode(unit) {
|
|
6819
6945
|
return unit.func ?? unit.announcedAt ?? null;
|
|
6820
6946
|
}
|
|
@@ -6838,37 +6964,37 @@ function unitDedupKey(unit) {
|
|
|
6838
6964
|
return parts.join("-");
|
|
6839
6965
|
}
|
|
6840
6966
|
function isFunctionRoot(node) {
|
|
6841
|
-
return
|
|
6967
|
+
return import_ts_morph31.Node.isFunctionDeclaration(node) || import_ts_morph31.Node.isFunctionExpression(node) || import_ts_morph31.Node.isArrowFunction(node) || import_ts_morph31.Node.isMethodDeclaration(node);
|
|
6842
6968
|
}
|
|
6843
6969
|
function declarationCarryingTheBody(declaration) {
|
|
6844
|
-
if (!
|
|
6970
|
+
if (!import_ts_morph31.Node.isFunctionDeclaration(declaration) && !import_ts_morph31.Node.isMethodDeclaration(declaration)) {
|
|
6845
6971
|
return declaration;
|
|
6846
6972
|
}
|
|
6847
6973
|
return declaration.getImplementation() ?? declaration;
|
|
6848
6974
|
}
|
|
6849
6975
|
function couldResolveToFunction(value) {
|
|
6850
|
-
return
|
|
6976
|
+
return import_ts_morph31.Node.isCallExpression(value) || import_ts_morph31.Node.isIdentifier(value) || import_ts_morph31.Node.isPropertyAccessExpression(value) || import_ts_morph31.Node.isExportSpecifier(value) || import_ts_morph31.Node.isImportSpecifier(value) || import_ts_morph31.Node.isImportClause(value) || import_ts_morph31.Node.isBindingElement(value);
|
|
6851
6977
|
}
|
|
6852
6978
|
function couldStillNameAFunction(value) {
|
|
6853
6979
|
if (!couldResolveToFunction(value)) {
|
|
6854
6980
|
return false;
|
|
6855
6981
|
}
|
|
6856
|
-
if (!
|
|
6982
|
+
if (!import_ts_morph31.Node.isIdentifier(value)) {
|
|
6857
6983
|
return true;
|
|
6858
6984
|
}
|
|
6859
6985
|
const declaration = value.getSymbol()?.getDeclarations()?.[0];
|
|
6860
|
-
if (declaration === void 0 || !
|
|
6986
|
+
if (declaration === void 0 || !import_ts_morph31.Node.isVariableDeclaration(declaration)) {
|
|
6861
6987
|
return true;
|
|
6862
6988
|
}
|
|
6863
6989
|
const written = declaration.getInitializer();
|
|
6864
6990
|
return written === void 0 || isFunctionRoot(written) || couldResolveToFunction(written);
|
|
6865
6991
|
}
|
|
6866
6992
|
function namesAParameter(value) {
|
|
6867
|
-
if (!
|
|
6993
|
+
if (!import_ts_morph31.Node.isIdentifier(value)) {
|
|
6868
6994
|
return false;
|
|
6869
6995
|
}
|
|
6870
6996
|
const declaration = value.getSymbol()?.getDeclarations()?.[0];
|
|
6871
|
-
return declaration !== void 0 &&
|
|
6997
|
+
return declaration !== void 0 && import_ts_morph31.Node.isParameterDeclaration(declaration);
|
|
6872
6998
|
}
|
|
6873
6999
|
function toFunctionRoot(node) {
|
|
6874
7000
|
return isFunctionRoot(node) ? declarationCarryingTheBody(node) : null;
|
|
@@ -6876,7 +7002,7 @@ function toFunctionRoot(node) {
|
|
|
6876
7002
|
function findEnclosingFunction(node) {
|
|
6877
7003
|
let current2 = node.getParent();
|
|
6878
7004
|
while (current2 !== void 0) {
|
|
6879
|
-
if (
|
|
7005
|
+
if (import_ts_morph31.Node.isFunctionDeclaration(current2) || import_ts_morph31.Node.isFunctionExpression(current2) || import_ts_morph31.Node.isArrowFunction(current2) || import_ts_morph31.Node.isMethodDeclaration(current2)) {
|
|
6880
7006
|
return current2;
|
|
6881
7007
|
}
|
|
6882
7008
|
current2 = current2.getParent();
|
|
@@ -6909,10 +7035,10 @@ function moduleKeyOf(declaration) {
|
|
|
6909
7035
|
}
|
|
6910
7036
|
function importOriginsOf(callee) {
|
|
6911
7037
|
let root = callee;
|
|
6912
|
-
while (
|
|
7038
|
+
while (import_ts_morph32.Node.isPropertyAccessExpression(root)) {
|
|
6913
7039
|
root = root.getExpression();
|
|
6914
7040
|
}
|
|
6915
|
-
if (!
|
|
7041
|
+
if (!import_ts_morph32.Node.isIdentifier(root)) {
|
|
6916
7042
|
return [];
|
|
6917
7043
|
}
|
|
6918
7044
|
const symbol = root.getSymbol();
|
|
@@ -6927,7 +7053,7 @@ function importOriginsOf(callee) {
|
|
|
6927
7053
|
origins.add(packagePartOf(specifier));
|
|
6928
7054
|
}
|
|
6929
7055
|
}
|
|
6930
|
-
const named2 =
|
|
7056
|
+
const named2 = import_ts_morph32.Node.isPropertyAccessExpression(callee) ? callee.getNameNode().getSymbol() : void 0;
|
|
6931
7057
|
for (const candidate of [named2 ?? symbol, symbol]) {
|
|
6932
7058
|
const aliased = resolveAliasedSymbol(candidate) ?? candidate;
|
|
6933
7059
|
for (const declaration of aliased.getDeclarations()) {
|
|
@@ -6944,17 +7070,17 @@ function importOriginsOf(callee) {
|
|
|
6944
7070
|
return [...origins];
|
|
6945
7071
|
}
|
|
6946
7072
|
function importSpecifierOf(declaration) {
|
|
6947
|
-
if (
|
|
7073
|
+
if (import_ts_morph32.Node.isImportSpecifier(declaration)) {
|
|
6948
7074
|
return declaration.getImportDeclaration().getModuleSpecifierValue();
|
|
6949
7075
|
}
|
|
6950
|
-
if (
|
|
7076
|
+
if (import_ts_morph32.Node.isImportEqualsDeclaration(declaration)) {
|
|
6951
7077
|
const reference = declaration.getModuleReference();
|
|
6952
|
-
return
|
|
7078
|
+
return import_ts_morph32.Node.isExternalModuleReference(reference) ? reference.getExpression()?.getText().slice(1, -1) ?? null : null;
|
|
6953
7079
|
}
|
|
6954
|
-
const owner =
|
|
6955
|
-
if (
|
|
7080
|
+
const owner = import_ts_morph32.Node.isNamespaceImport(declaration) ? declaration.getParent() : declaration;
|
|
7081
|
+
if (import_ts_morph32.Node.isImportClause(owner)) {
|
|
6956
7082
|
const importDecl = owner.getParent();
|
|
6957
|
-
if (
|
|
7083
|
+
if (import_ts_morph32.Node.isImportDeclaration(importDecl)) {
|
|
6958
7084
|
return importDecl.getModuleSpecifierValue();
|
|
6959
7085
|
}
|
|
6960
7086
|
}
|
|
@@ -6966,7 +7092,7 @@ function packagePartOf(specifier) {
|
|
|
6966
7092
|
return parts.slice(0, take).join("/");
|
|
6967
7093
|
}
|
|
6968
7094
|
function declaresAValue(declaration) {
|
|
6969
|
-
return !
|
|
7095
|
+
return !import_ts_morph32.Node.isPropertySignature(declaration) && !import_ts_morph32.Node.isMethodSignature(declaration);
|
|
6970
7096
|
}
|
|
6971
7097
|
function packagesDeclaring(filePath) {
|
|
6972
7098
|
const marker = "/node_modules/";
|
|
@@ -6990,39 +7116,39 @@ function packagesDescribedByTypes(owner) {
|
|
|
6990
7116
|
return scoped.length === 2 ? [name, `@${scoped[0]}/${scoped[1]}`] : [name];
|
|
6991
7117
|
}
|
|
6992
7118
|
function factKeyOf(value) {
|
|
6993
|
-
return
|
|
7119
|
+
return import_ts_morph32.Node.isExpression(value) ? unwrapExpression(value) : value;
|
|
6994
7120
|
}
|
|
6995
7121
|
function literalIndexOf(index) {
|
|
6996
7122
|
if (index === void 0) {
|
|
6997
7123
|
return null;
|
|
6998
7124
|
}
|
|
6999
|
-
if (
|
|
7125
|
+
if (import_ts_morph32.Node.isNumericLiteral(index)) {
|
|
7000
7126
|
return String(index.getLiteralValue());
|
|
7001
7127
|
}
|
|
7002
|
-
if (
|
|
7128
|
+
if (import_ts_morph32.Node.isStringLiteral(index) || import_ts_morph32.Node.isNoSubstitutionTemplateLiteral(index)) {
|
|
7003
7129
|
return index.getLiteralValue();
|
|
7004
7130
|
}
|
|
7005
7131
|
return null;
|
|
7006
7132
|
}
|
|
7007
7133
|
function asFallbackExpression(expression) {
|
|
7008
|
-
if (!
|
|
7134
|
+
if (!import_ts_morph32.Node.isBinaryExpression(expression)) {
|
|
7009
7135
|
return null;
|
|
7010
7136
|
}
|
|
7011
7137
|
const operator = expression.getOperatorToken().getKind();
|
|
7012
|
-
return operator ===
|
|
7138
|
+
return operator === import_ts_morph32.SyntaxKind.BarBarToken || operator === import_ts_morph32.SyntaxKind.QuestionQuestionToken ? expression : null;
|
|
7013
7139
|
}
|
|
7014
7140
|
function unwrapExpression(expression) {
|
|
7015
7141
|
let current2 = expression;
|
|
7016
7142
|
for (; ; ) {
|
|
7017
|
-
if (
|
|
7143
|
+
if (import_ts_morph32.Node.isAwaitExpression(current2)) {
|
|
7018
7144
|
current2 = current2.getExpression();
|
|
7019
7145
|
continue;
|
|
7020
7146
|
}
|
|
7021
|
-
if (
|
|
7147
|
+
if (import_ts_morph32.Node.isParenthesizedExpression(current2)) {
|
|
7022
7148
|
current2 = current2.getExpression();
|
|
7023
7149
|
continue;
|
|
7024
7150
|
}
|
|
7025
|
-
if (
|
|
7151
|
+
if (import_ts_morph32.Node.isAsExpression(current2) || import_ts_morph32.Node.isSatisfiesExpression(current2)) {
|
|
7026
7152
|
current2 = current2.getExpression();
|
|
7027
7153
|
continue;
|
|
7028
7154
|
}
|
|
@@ -7042,7 +7168,7 @@ function emitValue(db, table, value) {
|
|
|
7042
7168
|
emitFunctionFacts(db, table, expression);
|
|
7043
7169
|
return id;
|
|
7044
7170
|
}
|
|
7045
|
-
if (
|
|
7171
|
+
if (import_ts_morph32.Node.isPropertyAccessExpression(expression)) {
|
|
7046
7172
|
fact(
|
|
7047
7173
|
db,
|
|
7048
7174
|
"readsProperty",
|
|
@@ -7053,11 +7179,11 @@ function emitValue(db, table, value) {
|
|
|
7053
7179
|
emitReferenceFacts(db, table, expression);
|
|
7054
7180
|
return id;
|
|
7055
7181
|
}
|
|
7056
|
-
if (
|
|
7182
|
+
if (import_ts_morph32.Node.isIdentifier(expression)) {
|
|
7057
7183
|
emitReferenceFacts(db, table, expression);
|
|
7058
7184
|
return id;
|
|
7059
7185
|
}
|
|
7060
|
-
if (
|
|
7186
|
+
if (import_ts_morph32.Node.isElementAccessExpression(expression)) {
|
|
7061
7187
|
const index = literalIndexOf(expression.getArgumentExpression());
|
|
7062
7188
|
if (index !== null) {
|
|
7063
7189
|
fact(
|
|
@@ -7072,7 +7198,7 @@ function emitValue(db, table, value) {
|
|
|
7072
7198
|
fact(db, "writtenValue", id);
|
|
7073
7199
|
return id;
|
|
7074
7200
|
}
|
|
7075
|
-
if (
|
|
7201
|
+
if (import_ts_morph32.Node.isArrayLiteralExpression(expression)) {
|
|
7076
7202
|
fact(db, "objectValue", id);
|
|
7077
7203
|
const elements = expression.getElements();
|
|
7078
7204
|
for (let position = 0; position < elements.length; position++) {
|
|
@@ -7090,10 +7216,10 @@ function emitValue(db, table, value) {
|
|
|
7090
7216
|
}
|
|
7091
7217
|
return id;
|
|
7092
7218
|
}
|
|
7093
|
-
if (
|
|
7219
|
+
if (import_ts_morph32.Node.isObjectLiteralExpression(expression)) {
|
|
7094
7220
|
fact(db, "objectValue", id);
|
|
7095
7221
|
for (const property of expression.getProperties()) {
|
|
7096
|
-
if (
|
|
7222
|
+
if (import_ts_morph32.Node.isPropertyAssignment(property)) {
|
|
7097
7223
|
const held = property.getInitializer();
|
|
7098
7224
|
if (held !== void 0) {
|
|
7099
7225
|
fact(
|
|
@@ -7104,7 +7230,7 @@ function emitValue(db, table, value) {
|
|
|
7104
7230
|
emitValue(db, table, held)
|
|
7105
7231
|
);
|
|
7106
7232
|
}
|
|
7107
|
-
} else if (
|
|
7233
|
+
} else if (import_ts_morph32.Node.isShorthandPropertyAssignment(property)) {
|
|
7108
7234
|
fact(
|
|
7109
7235
|
db,
|
|
7110
7236
|
"holdsProperty",
|
|
@@ -7112,7 +7238,7 @@ function emitValue(db, table, value) {
|
|
|
7112
7238
|
property.getName(),
|
|
7113
7239
|
emitValue(db, table, property.getNameNode())
|
|
7114
7240
|
);
|
|
7115
|
-
} else if (
|
|
7241
|
+
} else if (import_ts_morph32.Node.isMethodDeclaration(property)) {
|
|
7116
7242
|
const methodId = nodeId(property);
|
|
7117
7243
|
table.byId.set(methodId, property);
|
|
7118
7244
|
fact(db, "func", methodId);
|
|
@@ -7128,7 +7254,7 @@ function emitValue(db, table, value) {
|
|
|
7128
7254
|
fact(db, "fallbackBranch", id, emitValue(db, table, fallback.getRight()));
|
|
7129
7255
|
return id;
|
|
7130
7256
|
}
|
|
7131
|
-
if (
|
|
7257
|
+
if (import_ts_morph32.Node.isCallExpression(expression) || import_ts_morph32.Node.isNewExpression(expression)) {
|
|
7132
7258
|
emitCallFacts(db, table, expression);
|
|
7133
7259
|
fact(db, "writtenValue", id);
|
|
7134
7260
|
return id;
|
|
@@ -7155,7 +7281,7 @@ function emitBindingValues(db, table, declaration) {
|
|
|
7155
7281
|
function emitFieldValues(db, table, declaration) {
|
|
7156
7282
|
const { values, inOrder } = writesToField(declaration);
|
|
7157
7283
|
const last = values[values.length - 1];
|
|
7158
|
-
if (!inOrder || last === void 0 || !
|
|
7284
|
+
if (!inOrder || last === void 0 || !import_ts_morph32.Node.isExpression(last)) {
|
|
7159
7285
|
return;
|
|
7160
7286
|
}
|
|
7161
7287
|
fact(db, "binds", nodeId(declaration), emitValue(db, table, last));
|
|
@@ -7166,7 +7292,7 @@ function emitParameterPropertyRead(db, table, referenceId, declaration) {
|
|
|
7166
7292
|
if (!inOrder || last === void 0) {
|
|
7167
7293
|
return;
|
|
7168
7294
|
}
|
|
7169
|
-
if (!
|
|
7295
|
+
if (!import_ts_morph32.Node.isExpression(last)) {
|
|
7170
7296
|
table.byId.set(nodeId(last), last);
|
|
7171
7297
|
fact(db, "binds", referenceId, nodeId(last));
|
|
7172
7298
|
return;
|
|
@@ -7181,7 +7307,7 @@ function emitBindingElementFacts(db, table, element) {
|
|
|
7181
7307
|
}
|
|
7182
7308
|
table.seenBindings.add(element);
|
|
7183
7309
|
const pattern = element.getParent();
|
|
7184
|
-
const container =
|
|
7310
|
+
const container = import_ts_morph32.Node.isObjectBindingPattern(pattern) ? containerOfBindingPattern(pattern) : void 0;
|
|
7185
7311
|
if (container !== void 0) {
|
|
7186
7312
|
const property = element.getPropertyNameNode() ?? element.getNameNode();
|
|
7187
7313
|
fact(
|
|
@@ -7200,11 +7326,11 @@ function emitBindingElementFacts(db, table, element) {
|
|
|
7200
7326
|
}
|
|
7201
7327
|
function containerOfBindingPattern(pattern) {
|
|
7202
7328
|
const declaration = pattern.getParent();
|
|
7203
|
-
return
|
|
7329
|
+
return import_ts_morph32.Node.isVariableDeclaration(declaration) ? declaration.getInitializer() : void 0;
|
|
7204
7330
|
}
|
|
7205
7331
|
function referencedSymbol(nameNode) {
|
|
7206
7332
|
const parent = nameNode.getParent();
|
|
7207
|
-
if (parent !== void 0 &&
|
|
7333
|
+
if (parent !== void 0 && import_ts_morph32.Node.isShorthandPropertyAssignment(parent) && parent.getNameNode() === nameNode) {
|
|
7208
7334
|
return parent.getValueSymbol();
|
|
7209
7335
|
}
|
|
7210
7336
|
return nameNode.getSymbol();
|
|
@@ -7212,7 +7338,7 @@ function referencedSymbol(nameNode) {
|
|
|
7212
7338
|
function emitReferenceFacts(db, table, reference) {
|
|
7213
7339
|
const referenceId = nodeId(reference);
|
|
7214
7340
|
table.byId.set(referenceId, reference);
|
|
7215
|
-
const nameNode =
|
|
7341
|
+
const nameNode = import_ts_morph32.Node.isPropertyAccessExpression(reference) ? reference.getNameNode() : reference;
|
|
7216
7342
|
const symbol = referencedSymbol(nameNode);
|
|
7217
7343
|
if (symbol === void 0) {
|
|
7218
7344
|
return;
|
|
@@ -7221,7 +7347,7 @@ function emitReferenceFacts(db, table, reference) {
|
|
|
7221
7347
|
const declaration = declarationCarryingTheBody(spelling);
|
|
7222
7348
|
const declarationId = nodeId(declaration);
|
|
7223
7349
|
table.byId.set(declarationId, declaration);
|
|
7224
|
-
if (
|
|
7350
|
+
if (import_ts_morph32.Node.isImportSpecifier(declaration)) {
|
|
7225
7351
|
const importDecl = declaration.getImportDeclaration();
|
|
7226
7352
|
const moduleKey = moduleKeyOf(importDecl);
|
|
7227
7353
|
if (moduleKey !== null) {
|
|
@@ -7230,9 +7356,9 @@ function emitReferenceFacts(db, table, reference) {
|
|
|
7230
7356
|
}
|
|
7231
7357
|
continue;
|
|
7232
7358
|
}
|
|
7233
|
-
if (
|
|
7359
|
+
if (import_ts_morph32.Node.isImportClause(declaration)) {
|
|
7234
7360
|
const importDecl = declaration.getParentIfKind(
|
|
7235
|
-
|
|
7361
|
+
import_ts_morph32.SyntaxKind.ImportDeclaration
|
|
7236
7362
|
);
|
|
7237
7363
|
if (importDecl !== void 0) {
|
|
7238
7364
|
const moduleKey = moduleKeyOf(importDecl);
|
|
@@ -7243,30 +7369,30 @@ function emitReferenceFacts(db, table, reference) {
|
|
|
7243
7369
|
}
|
|
7244
7370
|
continue;
|
|
7245
7371
|
}
|
|
7246
|
-
if (
|
|
7372
|
+
if (import_ts_morph32.Node.isVariableDeclaration(declaration)) {
|
|
7247
7373
|
fact(db, "binds", referenceId, declarationId);
|
|
7248
7374
|
emitBindingValues(db, table, declaration);
|
|
7249
7375
|
continue;
|
|
7250
7376
|
}
|
|
7251
|
-
if (
|
|
7377
|
+
if (import_ts_morph32.Node.isPropertyDeclaration(declaration)) {
|
|
7252
7378
|
fact(db, "binds", referenceId, declarationId);
|
|
7253
7379
|
emitFieldValues(db, table, declaration);
|
|
7254
7380
|
continue;
|
|
7255
7381
|
}
|
|
7256
|
-
if (
|
|
7257
|
-
if (declaration.isParameterProperty() &&
|
|
7382
|
+
if (import_ts_morph32.Node.isParameterDeclaration(declaration)) {
|
|
7383
|
+
if (declaration.isParameterProperty() && import_ts_morph32.Node.isPropertyAccessExpression(reference)) {
|
|
7258
7384
|
emitParameterPropertyRead(db, table, referenceId, declaration);
|
|
7259
7385
|
} else {
|
|
7260
7386
|
fact(db, "binds", referenceId, declarationId);
|
|
7261
7387
|
}
|
|
7262
7388
|
continue;
|
|
7263
7389
|
}
|
|
7264
|
-
if (
|
|
7390
|
+
if (import_ts_morph32.Node.isClassDeclaration(declaration)) {
|
|
7265
7391
|
fact(db, "binds", referenceId, declarationId);
|
|
7266
7392
|
emitClassFacts(db, table, declaration);
|
|
7267
7393
|
continue;
|
|
7268
7394
|
}
|
|
7269
|
-
if (
|
|
7395
|
+
if (import_ts_morph32.Node.isBindingElement(declaration)) {
|
|
7270
7396
|
fact(db, "binds", referenceId, declarationId);
|
|
7271
7397
|
emitBindingElementFacts(db, table, declaration);
|
|
7272
7398
|
continue;
|
|
@@ -7282,7 +7408,7 @@ function emitCallFacts(db, table, call) {
|
|
|
7282
7408
|
const callId = nodeId(call);
|
|
7283
7409
|
table.byId.set(callId, call);
|
|
7284
7410
|
const callee = unwrapExpression(call.getExpression());
|
|
7285
|
-
if (
|
|
7411
|
+
if (import_ts_morph32.Node.isPropertyAccessExpression(callee) && callee.getName() === "bind") {
|
|
7286
7412
|
const target = unwrapExpression(callee.getExpression());
|
|
7287
7413
|
fact(db, "bindCall", callId, emitValue(db, table, target));
|
|
7288
7414
|
return;
|
|
@@ -7295,7 +7421,7 @@ function emitCallFacts(db, table, call) {
|
|
|
7295
7421
|
const args = call.getArguments();
|
|
7296
7422
|
for (let position = 0; position < args.length; position++) {
|
|
7297
7423
|
const argument = args[position];
|
|
7298
|
-
if (!
|
|
7424
|
+
if (!import_ts_morph32.Node.isExpression(argument)) {
|
|
7299
7425
|
continue;
|
|
7300
7426
|
}
|
|
7301
7427
|
fact(
|
|
@@ -7362,11 +7488,11 @@ function emitFunctionFacts(db, table, fn) {
|
|
|
7362
7488
|
table.seenFunctions.add(fn);
|
|
7363
7489
|
const fnId = nodeId(fn);
|
|
7364
7490
|
table.byId.set(fnId, fn);
|
|
7365
|
-
if (
|
|
7491
|
+
if (import_ts_morph32.Node.isFunctionDeclaration(fn) || import_ts_morph32.Node.isFunctionExpression(fn) || import_ts_morph32.Node.isArrowFunction(fn) || import_ts_morph32.Node.isMethodDeclaration(fn)) {
|
|
7366
7492
|
emitParameters(db, table, fnId, fn.getParameters());
|
|
7367
7493
|
const body = fn.getBody?.();
|
|
7368
7494
|
if (body !== void 0) {
|
|
7369
|
-
if (
|
|
7495
|
+
if (import_ts_morph32.Node.isExpression(body)) {
|
|
7370
7496
|
fact(db, "returnsValue", fnId, emitValue(db, table, body));
|
|
7371
7497
|
recordBodyNode(db, table, fnId, body);
|
|
7372
7498
|
}
|
|
@@ -7388,20 +7514,20 @@ function recordBodyNode(db, table, fnId, node) {
|
|
|
7388
7514
|
fact(db, "containsFn", fnId, nodeId(node));
|
|
7389
7515
|
return true;
|
|
7390
7516
|
}
|
|
7391
|
-
if (
|
|
7517
|
+
if (import_ts_morph32.Node.isReturnStatement(node)) {
|
|
7392
7518
|
const returned = node.getExpression();
|
|
7393
7519
|
if (returned !== void 0) {
|
|
7394
7520
|
fact(db, "returnsValue", fnId, emitValue(db, table, returned));
|
|
7395
7521
|
}
|
|
7396
7522
|
return false;
|
|
7397
7523
|
}
|
|
7398
|
-
if (!
|
|
7524
|
+
if (!import_ts_morph32.Node.isExpression(node)) {
|
|
7399
7525
|
return false;
|
|
7400
7526
|
}
|
|
7401
7527
|
const call = unwrapExpression(node);
|
|
7402
|
-
if (
|
|
7528
|
+
if (import_ts_morph32.Node.isCallExpression(call)) {
|
|
7403
7529
|
const callee = unwrapExpression(call.getExpression());
|
|
7404
|
-
if (
|
|
7530
|
+
if (import_ts_morph32.Node.isIdentifier(callee) || import_ts_morph32.Node.isPropertyAccessExpression(callee)) {
|
|
7405
7531
|
fact(db, "bodyCalls", fnId, emitValue(db, table, callee));
|
|
7406
7532
|
}
|
|
7407
7533
|
}
|
|
@@ -7410,10 +7536,10 @@ function recordBodyNode(db, table, fnId, node) {
|
|
|
7410
7536
|
function descendantIsReturned(fn) {
|
|
7411
7537
|
let current2 = fn.getParent();
|
|
7412
7538
|
while (current2 !== void 0) {
|
|
7413
|
-
if (
|
|
7539
|
+
if (import_ts_morph32.Node.isReturnStatement(current2)) {
|
|
7414
7540
|
return true;
|
|
7415
7541
|
}
|
|
7416
|
-
if (
|
|
7542
|
+
if (import_ts_morph32.Node.isParenthesizedExpression(current2) || import_ts_morph32.Node.isAsExpression(current2) || import_ts_morph32.Node.isSatisfiesExpression(current2)) {
|
|
7417
7543
|
current2 = current2.getParent();
|
|
7418
7544
|
continue;
|
|
7419
7545
|
}
|
|
@@ -7460,19 +7586,19 @@ function extractFileFacts(db, table, sourceFile) {
|
|
|
7460
7586
|
fact(db, "exportsAs", filePath, name, id);
|
|
7461
7587
|
continue;
|
|
7462
7588
|
}
|
|
7463
|
-
if (
|
|
7589
|
+
if (import_ts_morph32.Node.isClassDeclaration(declaration)) {
|
|
7464
7590
|
emitClassFacts(db, table, declaration);
|
|
7465
7591
|
fact(db, "exportsAs", filePath, name, nodeId(declaration));
|
|
7466
7592
|
continue;
|
|
7467
7593
|
}
|
|
7468
|
-
if (
|
|
7594
|
+
if (import_ts_morph32.Node.isVariableDeclaration(declaration)) {
|
|
7469
7595
|
const declarationId = nodeId(declaration);
|
|
7470
7596
|
table.byId.set(declarationId, declaration);
|
|
7471
7597
|
fact(db, "exportsAs", filePath, name, declarationId);
|
|
7472
7598
|
emitBindingValues(db, table, declaration);
|
|
7473
7599
|
continue;
|
|
7474
7600
|
}
|
|
7475
|
-
if (
|
|
7601
|
+
if (import_ts_morph32.Node.isBindingElement(declaration)) {
|
|
7476
7602
|
fact(
|
|
7477
7603
|
db,
|
|
7478
7604
|
"exportsAs",
|
|
@@ -7482,7 +7608,7 @@ function extractFileFacts(db, table, sourceFile) {
|
|
|
7482
7608
|
);
|
|
7483
7609
|
continue;
|
|
7484
7610
|
}
|
|
7485
|
-
if (
|
|
7611
|
+
if (import_ts_morph32.Node.isExpression(declaration)) {
|
|
7486
7612
|
fact(
|
|
7487
7613
|
db,
|
|
7488
7614
|
"exportsAs",
|
|
@@ -7497,13 +7623,13 @@ function extractFileFacts(db, table, sourceFile) {
|
|
|
7497
7623
|
|
|
7498
7624
|
// src/discovery/resolveValue.ts
|
|
7499
7625
|
function couldNameAValue(value) {
|
|
7500
|
-
return
|
|
7626
|
+
return import_ts_morph33.Node.isIdentifier(value) || import_ts_morph33.Node.isPropertyAccessExpression(value) || import_ts_morph33.Node.isElementAccessExpression(value) || import_ts_morph33.Node.isCallExpression(value);
|
|
7501
7627
|
}
|
|
7502
7628
|
function propertyValueOf(property) {
|
|
7503
|
-
if (
|
|
7629
|
+
if (import_ts_morph33.Node.isPropertyAssignment(property)) {
|
|
7504
7630
|
return property.getInitializer() ?? null;
|
|
7505
7631
|
}
|
|
7506
|
-
if (
|
|
7632
|
+
if (import_ts_morph33.Node.isShorthandPropertyAssignment(property)) {
|
|
7507
7633
|
return property.getNameNode();
|
|
7508
7634
|
}
|
|
7509
7635
|
return null;
|
|
@@ -7524,7 +7650,7 @@ function objectLiteralOf(value, resolution) {
|
|
|
7524
7650
|
return literalValueOf(
|
|
7525
7651
|
value,
|
|
7526
7652
|
resolution,
|
|
7527
|
-
(node) =>
|
|
7653
|
+
(node) => import_ts_morph33.Node.isObjectLiteralExpression(node)
|
|
7528
7654
|
);
|
|
7529
7655
|
}
|
|
7530
7656
|
function propertiesOf(object, resolution) {
|
|
@@ -7536,7 +7662,7 @@ function propertiesReached(object, resolution, seen) {
|
|
|
7536
7662
|
}
|
|
7537
7663
|
seen.add(object);
|
|
7538
7664
|
return object.getProperties().flatMap((property) => {
|
|
7539
|
-
if (!
|
|
7665
|
+
if (!import_ts_morph33.Node.isSpreadAssignment(property)) {
|
|
7540
7666
|
return [property];
|
|
7541
7667
|
}
|
|
7542
7668
|
const spread = objectLiteralOf(property.getExpression(), resolution);
|
|
@@ -7545,7 +7671,7 @@ function propertiesReached(object, resolution, seen) {
|
|
|
7545
7671
|
}
|
|
7546
7672
|
function writtenNodeOf(value, resolution) {
|
|
7547
7673
|
const written = factKeyOf(value);
|
|
7548
|
-
if (
|
|
7674
|
+
if (import_ts_morph33.Node.isCallExpression(written) || import_ts_morph33.Node.isNewExpression(written)) {
|
|
7549
7675
|
return written;
|
|
7550
7676
|
}
|
|
7551
7677
|
if (resolution === void 0 || !couldNameAValue(written)) {
|
|
@@ -7565,13 +7691,13 @@ function stringValueOf(value, resolution) {
|
|
|
7565
7691
|
return resolved !== null && isStringNode(resolved) ? resolved.getLiteralValue() : null;
|
|
7566
7692
|
}
|
|
7567
7693
|
function isStringNode(node) {
|
|
7568
|
-
return
|
|
7694
|
+
return import_ts_morph33.Node.isStringLiteral(node) || import_ts_morph33.Node.isNoSubstitutionTemplateLiteral(node);
|
|
7569
7695
|
}
|
|
7570
7696
|
function arrayLiteralOf(value, resolution) {
|
|
7571
7697
|
return literalValueOf(
|
|
7572
7698
|
value,
|
|
7573
7699
|
resolution,
|
|
7574
|
-
(node) =>
|
|
7700
|
+
(node) => import_ts_morph33.Node.isArrayLiteralExpression(node)
|
|
7575
7701
|
);
|
|
7576
7702
|
}
|
|
7577
7703
|
function literalValueOf(value, resolution, isWanted) {
|
|
@@ -7728,7 +7854,7 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
7728
7854
|
if (cacheConstruction === null) {
|
|
7729
7855
|
return "unknown";
|
|
7730
7856
|
}
|
|
7731
|
-
if (!
|
|
7857
|
+
if (!import_ts_morph34.Node.isNewExpression(cacheConstruction) && !import_ts_morph34.Node.isCallExpression(cacheConstruction)) {
|
|
7732
7858
|
return "unknown";
|
|
7733
7859
|
}
|
|
7734
7860
|
const args = cacheConstruction.getArguments();
|
|
@@ -7742,15 +7868,15 @@ function constructionRegistryStatus(construction, spec) {
|
|
|
7742
7868
|
if (cacheOptions.getProperty(spec.registryProperty) !== void 0) {
|
|
7743
7869
|
return "configured";
|
|
7744
7870
|
}
|
|
7745
|
-
const hasSpread = cacheOptions.getProperties().some((property) =>
|
|
7871
|
+
const hasSpread = cacheOptions.getProperties().some((property) => import_ts_morph34.Node.isSpreadAssignment(property));
|
|
7746
7872
|
return hasSpread ? "unknown" : "absent";
|
|
7747
7873
|
}
|
|
7748
7874
|
function firstArgumentObjectLiteral(construction) {
|
|
7749
|
-
if (!
|
|
7875
|
+
if (!import_ts_morph34.Node.isNewExpression(construction) && !import_ts_morph34.Node.isCallExpression(construction)) {
|
|
7750
7876
|
return null;
|
|
7751
7877
|
}
|
|
7752
7878
|
const arg = construction.getArguments()[0];
|
|
7753
|
-
if (arg === void 0 || !
|
|
7879
|
+
if (arg === void 0 || !import_ts_morph34.Node.isObjectLiteralExpression(arg)) {
|
|
7754
7880
|
return null;
|
|
7755
7881
|
}
|
|
7756
7882
|
return arg;
|
|
@@ -7760,10 +7886,10 @@ function propertyValueOf2(options, name) {
|
|
|
7760
7886
|
if (property === void 0) {
|
|
7761
7887
|
return null;
|
|
7762
7888
|
}
|
|
7763
|
-
if (
|
|
7889
|
+
if (import_ts_morph34.Node.isPropertyAssignment(property)) {
|
|
7764
7890
|
return property.getInitializer() ?? null;
|
|
7765
7891
|
}
|
|
7766
|
-
if (
|
|
7892
|
+
if (import_ts_morph34.Node.isShorthandPropertyAssignment(property)) {
|
|
7767
7893
|
const symbol = property.getProject().getTypeChecker().getShorthandAssignmentValueSymbol(property);
|
|
7768
7894
|
return symbol?.getValueDeclaration() ?? null;
|
|
7769
7895
|
}
|
|
@@ -7773,13 +7899,13 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
7773
7899
|
let current2 = expression;
|
|
7774
7900
|
for (let hop = 0; hop < 4 && current2 !== void 0; hop += 1) {
|
|
7775
7901
|
current2 = unwrapExpression2(current2);
|
|
7776
|
-
if (
|
|
7902
|
+
if (import_ts_morph34.Node.isVariableDeclaration(current2)) {
|
|
7777
7903
|
current2 = current2.getInitializer();
|
|
7778
7904
|
continue;
|
|
7779
7905
|
}
|
|
7780
|
-
if (
|
|
7906
|
+
if (import_ts_morph34.Node.isNewExpression(current2) || import_ts_morph34.Node.isCallExpression(current2)) {
|
|
7781
7907
|
const callee = current2.getExpression();
|
|
7782
|
-
if (callee === void 0 || !
|
|
7908
|
+
if (callee === void 0 || !import_ts_morph34.Node.isIdentifier(callee)) {
|
|
7783
7909
|
return null;
|
|
7784
7910
|
}
|
|
7785
7911
|
const local = localImportName(
|
|
@@ -7789,11 +7915,11 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
7789
7915
|
);
|
|
7790
7916
|
return local !== null && callee.getText() === local ? current2 : null;
|
|
7791
7917
|
}
|
|
7792
|
-
if (!
|
|
7918
|
+
if (!import_ts_morph34.Node.isIdentifier(current2)) {
|
|
7793
7919
|
return null;
|
|
7794
7920
|
}
|
|
7795
7921
|
const declaration = current2.getSymbol()?.getValueDeclaration();
|
|
7796
|
-
if (declaration === void 0 || !
|
|
7922
|
+
if (declaration === void 0 || !import_ts_morph34.Node.isVariableDeclaration(declaration)) {
|
|
7797
7923
|
return null;
|
|
7798
7924
|
}
|
|
7799
7925
|
current2 = declaration.getInitializer();
|
|
@@ -7802,17 +7928,17 @@ function resolveToConstructionOf(expression, cacheClass) {
|
|
|
7802
7928
|
}
|
|
7803
7929
|
function unwrapExpression2(node) {
|
|
7804
7930
|
let current2 = node;
|
|
7805
|
-
while (
|
|
7931
|
+
while (import_ts_morph34.Node.isParenthesizedExpression(current2) || import_ts_morph34.Node.isAsExpression(current2) || import_ts_morph34.Node.isNonNullExpression(current2)) {
|
|
7806
7932
|
current2 = current2.getExpression();
|
|
7807
7933
|
}
|
|
7808
7934
|
return current2;
|
|
7809
7935
|
}
|
|
7810
7936
|
function isConstructionNamed(node, localName) {
|
|
7811
|
-
if (!
|
|
7937
|
+
if (!import_ts_morph34.Node.isNewExpression(node) && !import_ts_morph34.Node.isCallExpression(node)) {
|
|
7812
7938
|
return false;
|
|
7813
7939
|
}
|
|
7814
7940
|
const callee = node.getExpression();
|
|
7815
|
-
return callee !== void 0 &&
|
|
7941
|
+
return callee !== void 0 && import_ts_morph34.Node.isIdentifier(callee) && callee.getText() === localName;
|
|
7816
7942
|
}
|
|
7817
7943
|
function localImportName(sourceFile, importModule, importName) {
|
|
7818
7944
|
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
@@ -7848,11 +7974,11 @@ function localNamesFor(sourceFile, specs) {
|
|
|
7848
7974
|
return names;
|
|
7849
7975
|
}
|
|
7850
7976
|
function constructionRef(node, localNames, resolution) {
|
|
7851
|
-
if (!
|
|
7977
|
+
if (!import_ts_morph34.Node.isNewExpression(node) && !import_ts_morph34.Node.isCallExpression(node)) {
|
|
7852
7978
|
return null;
|
|
7853
7979
|
}
|
|
7854
7980
|
const callee = node.getExpression();
|
|
7855
|
-
if (callee === void 0 || !
|
|
7981
|
+
if (callee === void 0 || !import_ts_morph34.Node.isIdentifier(callee)) {
|
|
7856
7982
|
return null;
|
|
7857
7983
|
}
|
|
7858
7984
|
const uriProperty = localNames.get(callee.getText());
|
|
@@ -7860,11 +7986,11 @@ function constructionRef(node, localNames, resolution) {
|
|
|
7860
7986
|
return null;
|
|
7861
7987
|
}
|
|
7862
7988
|
const optionsArg = node.getArguments()[0];
|
|
7863
|
-
if (optionsArg === void 0 || !
|
|
7989
|
+
if (optionsArg === void 0 || !import_ts_morph34.Node.isObjectLiteralExpression(optionsArg)) {
|
|
7864
7990
|
return null;
|
|
7865
7991
|
}
|
|
7866
7992
|
const property = optionsArg.getProperty(uriProperty);
|
|
7867
|
-
if (property === void 0 || !
|
|
7993
|
+
if (property === void 0 || !import_ts_morph34.Node.isPropertyAssignment(property)) {
|
|
7868
7994
|
return null;
|
|
7869
7995
|
}
|
|
7870
7996
|
const value = property.getInitializer();
|
|
@@ -7880,7 +8006,7 @@ function constructionRef(node, localNames, resolution) {
|
|
|
7880
8006
|
|
|
7881
8007
|
// src/discovery/clientCall.ts
|
|
7882
8008
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
7883
|
-
var
|
|
8009
|
+
var import_ts_morph35 = require("ts-morph");
|
|
7884
8010
|
|
|
7885
8011
|
// src/discovery/resolveImport.ts
|
|
7886
8012
|
function resolveImportedLocalName(sourceFile, importModule, importName) {
|
|
@@ -7924,26 +8050,26 @@ function discoverClientCalls(sourceFile, match, kind, resolution) {
|
|
|
7924
8050
|
if (!isGlobal && importedLocalName !== null) {
|
|
7925
8051
|
for (const varDecl of sourceFile.getVariableDeclarations()) {
|
|
7926
8052
|
const init = varDecl.getInitializer();
|
|
7927
|
-
if (init !== void 0 && (
|
|
8053
|
+
if (init !== void 0 && (import_ts_morph35.Node.isCallExpression(init) || import_ts_morph35.Node.isNewExpression(init)) && isInstanceCreationCall(init, importedLocalName, match.factoryMethods)) {
|
|
7928
8054
|
clientVarNames.add(varDecl.getName());
|
|
7929
8055
|
}
|
|
7930
8056
|
}
|
|
7931
8057
|
}
|
|
7932
8058
|
const methodFilter = match.methodFilter !== void 0 ? new Set(match.methodFilter) : null;
|
|
7933
8059
|
sourceFile.forEachDescendant((node) => {
|
|
7934
|
-
if (!
|
|
8060
|
+
if (!import_ts_morph35.Node.isCallExpression(node)) {
|
|
7935
8061
|
return;
|
|
7936
8062
|
}
|
|
7937
8063
|
const callee = node.getExpression();
|
|
7938
8064
|
let methodName = null;
|
|
7939
8065
|
let matched = false;
|
|
7940
|
-
if (isGlobal &&
|
|
8066
|
+
if (isGlobal && import_ts_morph35.Node.isIdentifier(callee)) {
|
|
7941
8067
|
if (callee.getText() === importedLocalName) {
|
|
7942
8068
|
matched = true;
|
|
7943
8069
|
}
|
|
7944
|
-
} else if (
|
|
8070
|
+
} else if (import_ts_morph35.Node.isPropertyAccessExpression(callee)) {
|
|
7945
8071
|
const subject = callee.getExpression();
|
|
7946
|
-
if (
|
|
8072
|
+
if (import_ts_morph35.Node.isIdentifier(subject) && (importedLocalName !== null && subject.getText() === importedLocalName || clientVarNames.has(subject.getText()) || resolvesToKnownInstance(subject, match, resolution))) {
|
|
7947
8073
|
methodName = callee.getName();
|
|
7948
8074
|
if (methodFilter === null || methodFilter.has(methodName)) {
|
|
7949
8075
|
matched = true;
|
|
@@ -7978,16 +8104,16 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
7978
8104
|
const constructedHere = /* @__PURE__ */ new Set();
|
|
7979
8105
|
if (localName !== null) {
|
|
7980
8106
|
sourceFile.forEachDescendant((node) => {
|
|
7981
|
-
if (
|
|
8107
|
+
if (import_ts_morph35.Node.isVariableDeclaration(node)) {
|
|
7982
8108
|
const init = node.getInitializer();
|
|
7983
|
-
if (init !== void 0 && (
|
|
8109
|
+
if (init !== void 0 && (import_ts_morph35.Node.isCallExpression(init) || import_ts_morph35.Node.isNewExpression(init)) && isInstanceCreationCall(init, localName, match.factoryMethods) || typedAsClient(node.getTypeNode(), localName)) {
|
|
7984
8110
|
constructedHere.add(node.getName());
|
|
7985
8111
|
}
|
|
7986
8112
|
return;
|
|
7987
8113
|
}
|
|
7988
|
-
if (
|
|
8114
|
+
if (import_ts_morph35.Node.isParameterDeclaration(node) && typedAsClient(node.getTypeNode(), localName)) {
|
|
7989
8115
|
const written = node.getNameNode();
|
|
7990
|
-
if (
|
|
8116
|
+
if (import_ts_morph35.Node.isIdentifier(written)) {
|
|
7991
8117
|
constructedHere.add(written.getText());
|
|
7992
8118
|
}
|
|
7993
8119
|
}
|
|
@@ -7999,10 +8125,10 @@ function clientReceiverCheckFor(sourceFile, match, resolution) {
|
|
|
7999
8125
|
importName: match.importName,
|
|
8000
8126
|
...match.factoryMethods === void 0 ? {} : { factoryMethods: match.factoryMethods }
|
|
8001
8127
|
};
|
|
8002
|
-
return (subject) => localName !== null &&
|
|
8128
|
+
return (subject) => localName !== null && import_ts_morph35.Node.isIdentifier(subject) && subject.getText() === localName || import_ts_morph35.Node.isIdentifier(subject) && constructedHere.has(subject.getText()) || resolvesToKnownInstance(subject, full, resolution);
|
|
8003
8129
|
}
|
|
8004
8130
|
function typedAsClient(typeNode, localName) {
|
|
8005
|
-
if (typeNode === void 0 || !
|
|
8131
|
+
if (typeNode === void 0 || !import_ts_morph35.Node.isTypeReference(typeNode)) {
|
|
8006
8132
|
return false;
|
|
8007
8133
|
}
|
|
8008
8134
|
return typeNode.getTypeName().getText() === localName;
|
|
@@ -8012,7 +8138,7 @@ function resolvesToKnownInstance(subject, match, resolution) {
|
|
|
8012
8138
|
return false;
|
|
8013
8139
|
}
|
|
8014
8140
|
const written = writtenNodeOf(subject, resolution);
|
|
8015
|
-
if (written === null || !
|
|
8141
|
+
if (written === null || !import_ts_morph35.Node.isCallExpression(written) && !import_ts_morph35.Node.isNewExpression(written)) {
|
|
8016
8142
|
return false;
|
|
8017
8143
|
}
|
|
8018
8144
|
const writtenLocalName = resolvedImportLocalName(
|
|
@@ -8093,31 +8219,31 @@ function withoutSourceExtension(filePath) {
|
|
|
8093
8219
|
return filePath.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/, "").replace(/\/index$/, "");
|
|
8094
8220
|
}
|
|
8095
8221
|
function clientUnitName(enclosingFunc, methodName) {
|
|
8096
|
-
if (
|
|
8222
|
+
if (import_ts_morph35.Node.isFunctionDeclaration(enclosingFunc)) {
|
|
8097
8223
|
return enclosingFunc.getName() ?? methodName ?? "anonymous";
|
|
8098
8224
|
}
|
|
8099
|
-
if (
|
|
8225
|
+
if (import_ts_morph35.Node.isMethodDeclaration(enclosingFunc)) {
|
|
8100
8226
|
return enclosingFunc.getName();
|
|
8101
8227
|
}
|
|
8102
8228
|
const parent = enclosingFunc.getParent();
|
|
8103
|
-
if (parent !== void 0 &&
|
|
8229
|
+
if (parent !== void 0 && import_ts_morph35.Node.isVariableDeclaration(parent)) {
|
|
8104
8230
|
return parent.getName();
|
|
8105
8231
|
}
|
|
8106
|
-
if (parent !== void 0 &&
|
|
8232
|
+
if (parent !== void 0 && import_ts_morph35.Node.isPropertyAssignment(parent)) {
|
|
8107
8233
|
return parent.getName();
|
|
8108
8234
|
}
|
|
8109
8235
|
return methodName ?? "anonymous";
|
|
8110
8236
|
}
|
|
8111
8237
|
|
|
8112
8238
|
// src/discovery/decoratedMethod.ts
|
|
8113
|
-
var
|
|
8239
|
+
var import_ts_morph38 = require("ts-morph");
|
|
8114
8240
|
|
|
8115
8241
|
// src/discovery/decoratedMembers.ts
|
|
8116
|
-
var
|
|
8242
|
+
var import_ts_morph36 = require("ts-morph");
|
|
8117
8243
|
function decoratedCallablesOf(cls, decoratorNames) {
|
|
8118
8244
|
const callables = [];
|
|
8119
8245
|
for (const member of cls.getMembers()) {
|
|
8120
|
-
if (!
|
|
8246
|
+
if (!import_ts_morph36.Node.isMethodDeclaration(member) && !import_ts_morph36.Node.isPropertyDeclaration(member)) {
|
|
8121
8247
|
continue;
|
|
8122
8248
|
}
|
|
8123
8249
|
const func = callableOf(member);
|
|
@@ -8141,7 +8267,7 @@ function decoratedCallablesOf(cls, decoratorNames) {
|
|
|
8141
8267
|
return callables;
|
|
8142
8268
|
}
|
|
8143
8269
|
function callableOf(member) {
|
|
8144
|
-
if (
|
|
8270
|
+
if (import_ts_morph36.Node.isMethodDeclaration(member)) {
|
|
8145
8271
|
return toFunctionRoot(member);
|
|
8146
8272
|
}
|
|
8147
8273
|
const held = member.getInitializer();
|
|
@@ -8149,7 +8275,7 @@ function callableOf(member) {
|
|
|
8149
8275
|
}
|
|
8150
8276
|
|
|
8151
8277
|
// src/discovery/decoratorComposition.ts
|
|
8152
|
-
var
|
|
8278
|
+
var import_ts_morph37 = require("ts-morph");
|
|
8153
8279
|
function classDecoratorStandingFor(cls, names, modules, resolution) {
|
|
8154
8280
|
for (const candidate of names) {
|
|
8155
8281
|
const decorator = cls.getDecorator(candidate);
|
|
@@ -8187,7 +8313,7 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
8187
8313
|
if (wrapper === null) {
|
|
8188
8314
|
return atClass;
|
|
8189
8315
|
}
|
|
8190
|
-
for (const call of wrapper.getDescendantsOfKind(
|
|
8316
|
+
for (const call of wrapper.getDescendantsOfKind(import_ts_morph37.SyntaxKind.CallExpression)) {
|
|
8191
8317
|
const names = resolution.importedNamesOf(call.getExpression(), modules);
|
|
8192
8318
|
if (!names.includes(standsFor)) {
|
|
8193
8319
|
continue;
|
|
@@ -8198,10 +8324,10 @@ function frameworkArgs(decorator, standsFor, modules, resolution) {
|
|
|
8198
8324
|
return atClass;
|
|
8199
8325
|
}
|
|
8200
8326
|
function statesAValue(arg, wrapper) {
|
|
8201
|
-
const identifiers =
|
|
8327
|
+
const identifiers = import_ts_morph37.Node.isIdentifier(arg) ? [arg] : arg.getDescendantsOfKind(import_ts_morph37.SyntaxKind.Identifier);
|
|
8202
8328
|
return !identifiers.some(
|
|
8203
8329
|
(identifier) => identifier.getSymbol()?.getDeclarations().some(
|
|
8204
|
-
(declaration) =>
|
|
8330
|
+
(declaration) => import_ts_morph37.Node.isParameterDeclaration(declaration) && isWithin(declaration, wrapper)
|
|
8205
8331
|
)
|
|
8206
8332
|
);
|
|
8207
8333
|
}
|
|
@@ -8221,39 +8347,39 @@ function resolverTypeName(args) {
|
|
|
8221
8347
|
return args.typeMap[args.decoratorName] ?? args.classTypeName ?? null;
|
|
8222
8348
|
}
|
|
8223
8349
|
function resolveResolverClassTypeName(decoratorArg) {
|
|
8224
|
-
if (
|
|
8350
|
+
if (import_ts_morph38.Node.isArrowFunction(decoratorArg)) {
|
|
8225
8351
|
const body = decoratorArg.getBody();
|
|
8226
|
-
if (
|
|
8352
|
+
if (import_ts_morph38.Node.isIdentifier(body)) {
|
|
8227
8353
|
return body.getText();
|
|
8228
8354
|
}
|
|
8229
8355
|
return null;
|
|
8230
8356
|
}
|
|
8231
|
-
if (
|
|
8357
|
+
if (import_ts_morph38.Node.isStringLiteral(decoratorArg)) {
|
|
8232
8358
|
return decoratorArg.getLiteralValue();
|
|
8233
8359
|
}
|
|
8234
|
-
if (
|
|
8360
|
+
if (import_ts_morph38.Node.isIdentifier(decoratorArg)) {
|
|
8235
8361
|
return decoratorArg.getText();
|
|
8236
8362
|
}
|
|
8237
8363
|
return null;
|
|
8238
8364
|
}
|
|
8239
8365
|
function resolveOperationNameOverride(decorator) {
|
|
8240
|
-
if (!
|
|
8366
|
+
if (!import_ts_morph38.Node.isDecorator(decorator)) {
|
|
8241
8367
|
return null;
|
|
8242
8368
|
}
|
|
8243
8369
|
const args = decorator.getArguments();
|
|
8244
8370
|
for (const arg of args) {
|
|
8245
|
-
if (!
|
|
8371
|
+
if (!import_ts_morph38.Node.isObjectLiteralExpression(arg)) {
|
|
8246
8372
|
continue;
|
|
8247
8373
|
}
|
|
8248
8374
|
const prop = arg.getProperty("name");
|
|
8249
|
-
if (prop === void 0 || !
|
|
8375
|
+
if (prop === void 0 || !import_ts_morph38.Node.isPropertyAssignment(prop)) {
|
|
8250
8376
|
continue;
|
|
8251
8377
|
}
|
|
8252
8378
|
const init = prop.getInitializer();
|
|
8253
8379
|
if (init === void 0) {
|
|
8254
8380
|
continue;
|
|
8255
8381
|
}
|
|
8256
|
-
if (
|
|
8382
|
+
if (import_ts_morph38.Node.isStringLiteral(init) || import_ts_morph38.Node.isNoSubstitutionTemplateLiteral(init)) {
|
|
8257
8383
|
return init.getLiteralValue();
|
|
8258
8384
|
}
|
|
8259
8385
|
}
|
|
@@ -8311,9 +8437,9 @@ function discoverDecoratedMethods(sourceFile, match, kind, resolution) {
|
|
|
8311
8437
|
}
|
|
8312
8438
|
|
|
8313
8439
|
// src/discovery/decoratedRoute.ts
|
|
8314
|
-
var
|
|
8440
|
+
var import_ts_morph39 = require("ts-morph");
|
|
8315
8441
|
function resolveRoutePathArg(decorator, resolution) {
|
|
8316
|
-
if (!
|
|
8442
|
+
if (!import_ts_morph39.Node.isDecorator(decorator)) {
|
|
8317
8443
|
return "";
|
|
8318
8444
|
}
|
|
8319
8445
|
return routePathOf(decorator.getArguments(), resolution);
|
|
@@ -8341,7 +8467,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
8341
8467
|
if (source.from === "unstated") {
|
|
8342
8468
|
return null;
|
|
8343
8469
|
}
|
|
8344
|
-
if (!
|
|
8470
|
+
if (!import_ts_morph39.Node.isDecorator(decorator)) {
|
|
8345
8471
|
return null;
|
|
8346
8472
|
}
|
|
8347
8473
|
const arg = decorator.getArguments()[source.position];
|
|
@@ -8352,7 +8478,7 @@ function declaredChannelOf(source, decorator, resolution) {
|
|
|
8352
8478
|
return text === null || text === "" ? null : text;
|
|
8353
8479
|
}
|
|
8354
8480
|
function literalStringOf(node, resolution) {
|
|
8355
|
-
if (
|
|
8481
|
+
if (import_ts_morph39.Node.isStringLiteral(node) || import_ts_morph39.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
8356
8482
|
return node.getLiteralValue();
|
|
8357
8483
|
}
|
|
8358
8484
|
const written = resolution?.resolveWrittenValue(node) ?? null;
|
|
@@ -8427,31 +8553,31 @@ function discoverDecoratedRoutes(sourceFile, match, kind, resolution, binding) {
|
|
|
8427
8553
|
var import_picomatch2 = __toESM(require("picomatch"), 1);
|
|
8428
8554
|
|
|
8429
8555
|
// src/discovery/namedExport.ts
|
|
8430
|
-
var
|
|
8556
|
+
var import_ts_morph40 = require("ts-morph");
|
|
8431
8557
|
function nameWrittenAt(expression) {
|
|
8432
|
-
if (
|
|
8558
|
+
if (import_ts_morph40.Node.isIdentifier(expression)) {
|
|
8433
8559
|
return expression.getText();
|
|
8434
8560
|
}
|
|
8435
|
-
if (
|
|
8561
|
+
if (import_ts_morph40.Node.isPropertyAccessExpression(expression)) {
|
|
8436
8562
|
return expression.getName();
|
|
8437
8563
|
}
|
|
8438
8564
|
return null;
|
|
8439
8565
|
}
|
|
8440
8566
|
function resolveDefaultExportName(decl, fn) {
|
|
8441
|
-
if (
|
|
8567
|
+
if (import_ts_morph40.Node.isFunctionDeclaration(fn) || import_ts_morph40.Node.isFunctionExpression(fn)) {
|
|
8442
8568
|
const n = fn.getName?.();
|
|
8443
8569
|
if (typeof n === "string" && n.length > 0) {
|
|
8444
8570
|
return n;
|
|
8445
8571
|
}
|
|
8446
8572
|
}
|
|
8447
|
-
if (
|
|
8573
|
+
if (import_ts_morph40.Node.isVariableDeclaration(decl)) {
|
|
8448
8574
|
const name = decl.getName();
|
|
8449
8575
|
if (name.length > 0) {
|
|
8450
8576
|
return name;
|
|
8451
8577
|
}
|
|
8452
8578
|
}
|
|
8453
8579
|
const binding = fn.getParent();
|
|
8454
|
-
if (binding !== void 0 &&
|
|
8580
|
+
if (binding !== void 0 && import_ts_morph40.Node.isVariableDeclaration(binding)) {
|
|
8455
8581
|
const name = binding.getName();
|
|
8456
8582
|
if (name.length > 0) {
|
|
8457
8583
|
return name;
|
|
@@ -8506,7 +8632,7 @@ function discoverNamedExports(sourceFile, match, kind, resolution) {
|
|
|
8506
8632
|
}
|
|
8507
8633
|
continue;
|
|
8508
8634
|
}
|
|
8509
|
-
if (
|
|
8635
|
+
if (import_ts_morph40.Node.isArrowFunction(init) || import_ts_morph40.Node.isFunctionExpression(init)) {
|
|
8510
8636
|
results.push({
|
|
8511
8637
|
func: init,
|
|
8512
8638
|
kind,
|
|
@@ -8612,13 +8738,13 @@ function discoverFileConventions(sourceFile, match, kind, resolution) {
|
|
|
8612
8738
|
}
|
|
8613
8739
|
|
|
8614
8740
|
// src/discovery/graphqlHookCall.ts
|
|
8615
|
-
var
|
|
8741
|
+
var import_ts_morph42 = require("ts-morph");
|
|
8616
8742
|
|
|
8617
8743
|
// src/discovery/graphqlShared.ts
|
|
8618
8744
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
8619
8745
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
8620
8746
|
var import_graphql = require("graphql");
|
|
8621
|
-
var
|
|
8747
|
+
var import_ts_morph41 = require("ts-morph");
|
|
8622
8748
|
var DOCUMENT_TAGS = /* @__PURE__ */ new Set(["gql", "graphql"]);
|
|
8623
8749
|
var UNQUALIFIED_DOCUMENT_TAG = "gql";
|
|
8624
8750
|
function parseGraphqlOperation(source) {
|
|
@@ -8684,10 +8810,10 @@ function startAssembly(resolution) {
|
|
|
8684
8810
|
};
|
|
8685
8811
|
}
|
|
8686
8812
|
function assembledTemplateText(template, assembly) {
|
|
8687
|
-
if (
|
|
8813
|
+
if (import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
8688
8814
|
return innerTemplateText(template);
|
|
8689
8815
|
}
|
|
8690
|
-
if (!
|
|
8816
|
+
if (!import_ts_morph41.Node.isTemplateExpression(template)) {
|
|
8691
8817
|
return null;
|
|
8692
8818
|
}
|
|
8693
8819
|
let text = template.getHead().getLiteralText();
|
|
@@ -8823,7 +8949,7 @@ function collectDanglingSpreads(selectionSet, defined, dangling) {
|
|
|
8823
8949
|
}
|
|
8824
8950
|
}
|
|
8825
8951
|
function documentTextFromExpression(node, assembly) {
|
|
8826
|
-
if (
|
|
8952
|
+
if (import_ts_morph41.Node.isTaggedTemplateExpression(node)) {
|
|
8827
8953
|
if (!isDocumentTag(node.getTag())) {
|
|
8828
8954
|
return null;
|
|
8829
8955
|
}
|
|
@@ -8833,7 +8959,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
8833
8959
|
assembly.seen.add(node);
|
|
8834
8960
|
return assembledTemplateText(node.getTemplate(), assembly);
|
|
8835
8961
|
}
|
|
8836
|
-
if (!
|
|
8962
|
+
if (!import_ts_morph41.Node.isCallExpression(node)) {
|
|
8837
8963
|
return null;
|
|
8838
8964
|
}
|
|
8839
8965
|
if (!isDocumentTag(node.getExpression())) {
|
|
@@ -8844,7 +8970,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
8844
8970
|
return null;
|
|
8845
8971
|
}
|
|
8846
8972
|
const template = stripDocumentNodeCasts(first);
|
|
8847
|
-
if (!
|
|
8973
|
+
if (!import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(template) && !import_ts_morph41.Node.isTemplateExpression(template)) {
|
|
8848
8974
|
return null;
|
|
8849
8975
|
}
|
|
8850
8976
|
if (assembly.seen.has(node)) {
|
|
@@ -8854,7 +8980,7 @@ function documentTextFromExpression(node, assembly) {
|
|
|
8854
8980
|
return assembledTemplateText(template, assembly);
|
|
8855
8981
|
}
|
|
8856
8982
|
function isDocumentTag(tag) {
|
|
8857
|
-
if (!
|
|
8983
|
+
if (!import_ts_morph41.Node.isIdentifier(tag)) {
|
|
8858
8984
|
return false;
|
|
8859
8985
|
}
|
|
8860
8986
|
if (tag.getText() === UNQUALIFIED_DOCUMENT_TAG) {
|
|
@@ -8865,14 +8991,14 @@ function isDocumentTag(tag) {
|
|
|
8865
8991
|
return false;
|
|
8866
8992
|
}
|
|
8867
8993
|
for (const declaration of symbol.getDeclarations()) {
|
|
8868
|
-
if (
|
|
8994
|
+
if (import_ts_morph41.Node.isImportSpecifier(declaration) && DOCUMENT_TAGS.has(declaration.getName())) {
|
|
8869
8995
|
return true;
|
|
8870
8996
|
}
|
|
8871
8997
|
}
|
|
8872
8998
|
return false;
|
|
8873
8999
|
}
|
|
8874
9000
|
function resolveThroughFacts(arg, assembly) {
|
|
8875
|
-
if (assembly.resolution === void 0 || !
|
|
9001
|
+
if (assembly.resolution === void 0 || !import_ts_morph41.Node.isIdentifier(arg)) {
|
|
8876
9002
|
return null;
|
|
8877
9003
|
}
|
|
8878
9004
|
const written = assembly.resolution.resolveWrittenValue(arg);
|
|
@@ -8921,7 +9047,7 @@ function singleLine(text) {
|
|
|
8921
9047
|
return collapsed.length > 80 ? `${collapsed.slice(0, 79)}\u2026` : collapsed;
|
|
8922
9048
|
}
|
|
8923
9049
|
function importedVariableInitializers(identifier) {
|
|
8924
|
-
if (!
|
|
9050
|
+
if (!import_ts_morph41.Node.isIdentifier(identifier)) {
|
|
8925
9051
|
return [];
|
|
8926
9052
|
}
|
|
8927
9053
|
const symbol = identifier.getSymbol();
|
|
@@ -8931,7 +9057,7 @@ function importedVariableInitializers(identifier) {
|
|
|
8931
9057
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
8932
9058
|
const inits = [];
|
|
8933
9059
|
for (const decl of resolved.getDeclarations()) {
|
|
8934
|
-
if (
|
|
9060
|
+
if (import_ts_morph41.Node.isVariableDeclaration(decl)) {
|
|
8935
9061
|
const init = decl.getInitializer();
|
|
8936
9062
|
if (init !== void 0) {
|
|
8937
9063
|
inits.push(init);
|
|
@@ -8945,7 +9071,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
8945
9071
|
if (direct !== null) {
|
|
8946
9072
|
return direct;
|
|
8947
9073
|
}
|
|
8948
|
-
if (!
|
|
9074
|
+
if (!import_ts_morph41.Node.isIdentifier(arg)) {
|
|
8949
9075
|
return null;
|
|
8950
9076
|
}
|
|
8951
9077
|
const symbol = arg.getSymbol();
|
|
@@ -8953,7 +9079,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
8953
9079
|
return null;
|
|
8954
9080
|
}
|
|
8955
9081
|
for (const decl of symbol.getDeclarations()) {
|
|
8956
|
-
if (
|
|
9082
|
+
if (import_ts_morph41.Node.isImportClause(decl) || import_ts_morph41.Node.isImportSpecifier(decl)) {
|
|
8957
9083
|
const fromGraphqlFile = resolveGraphqlFileImport(decl);
|
|
8958
9084
|
if (fromGraphqlFile !== null) {
|
|
8959
9085
|
return fromGraphqlFile;
|
|
@@ -8972,7 +9098,7 @@ function resolveGqlTemplateText(arg, assembly) {
|
|
|
8972
9098
|
return null;
|
|
8973
9099
|
}
|
|
8974
9100
|
function resolveTypedDocumentSource(arg) {
|
|
8975
|
-
if (!
|
|
9101
|
+
if (!import_ts_morph41.Node.isIdentifier(arg)) {
|
|
8976
9102
|
return null;
|
|
8977
9103
|
}
|
|
8978
9104
|
for (const init of importedVariableInitializers(arg)) {
|
|
@@ -8985,7 +9111,7 @@ function resolveTypedDocumentSource(arg) {
|
|
|
8985
9111
|
}
|
|
8986
9112
|
function typedDocumentSourceOf(node) {
|
|
8987
9113
|
const inner = stripDocumentNodeCasts(node);
|
|
8988
|
-
if (!
|
|
9114
|
+
if (!import_ts_morph41.Node.isObjectLiteralExpression(inner)) {
|
|
8989
9115
|
return null;
|
|
8990
9116
|
}
|
|
8991
9117
|
const evaluated = evaluateObjectLiteralAsJson(inner);
|
|
@@ -9003,7 +9129,7 @@ function typedDocumentSourceOf(node) {
|
|
|
9003
9129
|
}
|
|
9004
9130
|
}
|
|
9005
9131
|
function resolveTypedDocumentHeader(arg) {
|
|
9006
|
-
if (!
|
|
9132
|
+
if (!import_ts_morph41.Node.isIdentifier(arg)) {
|
|
9007
9133
|
return null;
|
|
9008
9134
|
}
|
|
9009
9135
|
const reference = arg.getText();
|
|
@@ -9013,7 +9139,7 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
9013
9139
|
}
|
|
9014
9140
|
const resolved = resolveAliasedSymbol(symbol) ?? symbol;
|
|
9015
9141
|
for (const decl of resolved.getDeclarations()) {
|
|
9016
|
-
if (!
|
|
9142
|
+
if (!import_ts_morph41.Node.isVariableDeclaration(decl)) {
|
|
9017
9143
|
continue;
|
|
9018
9144
|
}
|
|
9019
9145
|
const init = decl.getInitializer();
|
|
@@ -9046,10 +9172,10 @@ function resolveTypedDocumentHeader(arg) {
|
|
|
9046
9172
|
}
|
|
9047
9173
|
function documentNodeCastTypeArgs(node) {
|
|
9048
9174
|
let current2 = node;
|
|
9049
|
-
while (
|
|
9050
|
-
if (
|
|
9175
|
+
while (import_ts_morph41.Node.isAsExpression(current2) || import_ts_morph41.Node.isParenthesizedExpression(current2)) {
|
|
9176
|
+
if (import_ts_morph41.Node.isAsExpression(current2)) {
|
|
9051
9177
|
const typeNode = current2.getTypeNode();
|
|
9052
|
-
if (typeNode !== void 0 &&
|
|
9178
|
+
if (typeNode !== void 0 && import_ts_morph41.Node.isTypeReference(typeNode)) {
|
|
9053
9179
|
const name = typeNode.getTypeName().getText();
|
|
9054
9180
|
const simpleName = name.includes(".") ? name.split(".").pop() ?? name : name;
|
|
9055
9181
|
if (simpleName === "TypedDocumentNode" || simpleName === "DocumentNode") {
|
|
@@ -9062,7 +9188,7 @@ function documentNodeCastTypeArgs(node) {
|
|
|
9062
9188
|
return null;
|
|
9063
9189
|
}
|
|
9064
9190
|
function operationHeaderFromResultType(typeNode) {
|
|
9065
|
-
if (typeNode === void 0 || !
|
|
9191
|
+
if (typeNode === void 0 || !import_ts_morph41.Node.isTypeReference(typeNode)) {
|
|
9066
9192
|
return null;
|
|
9067
9193
|
}
|
|
9068
9194
|
const name = typeNode.getTypeName().getText();
|
|
@@ -9083,16 +9209,16 @@ function operationHeaderFromResultType(typeNode) {
|
|
|
9083
9209
|
}
|
|
9084
9210
|
function stripDocumentNodeCasts(node) {
|
|
9085
9211
|
let current2 = node;
|
|
9086
|
-
while (
|
|
9212
|
+
while (import_ts_morph41.Node.isAsExpression(current2) || import_ts_morph41.Node.isParenthesizedExpression(current2)) {
|
|
9087
9213
|
current2 = current2.getExpression();
|
|
9088
9214
|
}
|
|
9089
9215
|
return current2;
|
|
9090
9216
|
}
|
|
9091
9217
|
function evaluateObjectLiteralAsJson(node) {
|
|
9092
|
-
if (
|
|
9218
|
+
if (import_ts_morph41.Node.isStringLiteral(node) || import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
9093
9219
|
return node.getLiteralValue();
|
|
9094
9220
|
}
|
|
9095
|
-
if (
|
|
9221
|
+
if (import_ts_morph41.Node.isNumericLiteral(node)) {
|
|
9096
9222
|
return Number(node.getText());
|
|
9097
9223
|
}
|
|
9098
9224
|
const kind = node.getText();
|
|
@@ -9105,17 +9231,17 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
9105
9231
|
if (kind === "null") {
|
|
9106
9232
|
return null;
|
|
9107
9233
|
}
|
|
9108
|
-
if (
|
|
9234
|
+
if (import_ts_morph41.Node.isObjectLiteralExpression(node)) {
|
|
9109
9235
|
const out = {};
|
|
9110
9236
|
for (const prop of node.getProperties()) {
|
|
9111
|
-
if (!
|
|
9237
|
+
if (!import_ts_morph41.Node.isPropertyAssignment(prop)) {
|
|
9112
9238
|
return null;
|
|
9113
9239
|
}
|
|
9114
9240
|
const nameNode = prop.getNameNode();
|
|
9115
9241
|
let name;
|
|
9116
|
-
if (
|
|
9242
|
+
if (import_ts_morph41.Node.isIdentifier(nameNode)) {
|
|
9117
9243
|
name = nameNode.getText();
|
|
9118
|
-
} else if (
|
|
9244
|
+
} else if (import_ts_morph41.Node.isStringLiteral(nameNode) || import_ts_morph41.Node.isNoSubstitutionTemplateLiteral(nameNode)) {
|
|
9119
9245
|
name = nameNode.getLiteralValue();
|
|
9120
9246
|
} else {
|
|
9121
9247
|
return null;
|
|
@@ -9132,7 +9258,7 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
9132
9258
|
}
|
|
9133
9259
|
return out;
|
|
9134
9260
|
}
|
|
9135
|
-
if (
|
|
9261
|
+
if (import_ts_morph41.Node.isArrayLiteralExpression(node)) {
|
|
9136
9262
|
const out = [];
|
|
9137
9263
|
for (const el of node.getElements()) {
|
|
9138
9264
|
const value = evaluateObjectLiteralAsJson(el);
|
|
@@ -9146,8 +9272,8 @@ function evaluateObjectLiteralAsJson(node) {
|
|
|
9146
9272
|
return void 0;
|
|
9147
9273
|
}
|
|
9148
9274
|
function resolveGraphqlFileImport(decl) {
|
|
9149
|
-
const importDecl =
|
|
9150
|
-
if (importDecl === null || importDecl === void 0 || !
|
|
9275
|
+
const importDecl = import_ts_morph41.Node.isImportSpecifier(decl) ? decl.getImportDeclaration() : import_ts_morph41.Node.isImportClause(decl) ? decl.getParent() : null;
|
|
9276
|
+
if (importDecl === null || importDecl === void 0 || !import_ts_morph41.Node.isImportDeclaration(importDecl)) {
|
|
9151
9277
|
return null;
|
|
9152
9278
|
}
|
|
9153
9279
|
const specifier = importDecl.getModuleSpecifierValue();
|
|
@@ -9166,7 +9292,7 @@ function resolveGraphqlFileImport(decl) {
|
|
|
9166
9292
|
function enclosingFunctionRoot(node) {
|
|
9167
9293
|
let current2 = node.getParent();
|
|
9168
9294
|
while (current2 !== void 0) {
|
|
9169
|
-
if (
|
|
9295
|
+
if (import_ts_morph41.Node.isFunctionDeclaration(current2) || import_ts_morph41.Node.isFunctionExpression(current2) || import_ts_morph41.Node.isArrowFunction(current2) || import_ts_morph41.Node.isMethodDeclaration(current2)) {
|
|
9170
9296
|
return current2;
|
|
9171
9297
|
}
|
|
9172
9298
|
current2 = current2.getParent();
|
|
@@ -9174,11 +9300,11 @@ function enclosingFunctionRoot(node) {
|
|
|
9174
9300
|
return null;
|
|
9175
9301
|
}
|
|
9176
9302
|
function functionNameOrAnon(func) {
|
|
9177
|
-
if (
|
|
9303
|
+
if (import_ts_morph41.Node.isFunctionDeclaration(func) || import_ts_morph41.Node.isMethodDeclaration(func)) {
|
|
9178
9304
|
return func.getName() ?? "<anon>";
|
|
9179
9305
|
}
|
|
9180
9306
|
const parent = func.getParent();
|
|
9181
|
-
if (parent !== void 0 &&
|
|
9307
|
+
if (parent !== void 0 && import_ts_morph41.Node.isVariableDeclaration(parent)) {
|
|
9182
9308
|
return parent.getName();
|
|
9183
9309
|
}
|
|
9184
9310
|
return "<anon>";
|
|
@@ -9209,11 +9335,11 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
9209
9335
|
}
|
|
9210
9336
|
const results = [];
|
|
9211
9337
|
sourceFile.forEachDescendant((node) => {
|
|
9212
|
-
if (!
|
|
9338
|
+
if (!import_ts_morph42.Node.isCallExpression(node)) {
|
|
9213
9339
|
return;
|
|
9214
9340
|
}
|
|
9215
9341
|
const callee = node.getExpression();
|
|
9216
|
-
if (!
|
|
9342
|
+
if (!import_ts_morph42.Node.isIdentifier(callee)) {
|
|
9217
9343
|
return;
|
|
9218
9344
|
}
|
|
9219
9345
|
const spec = hookByLocal.get(callee.getText());
|
|
@@ -9249,7 +9375,7 @@ function discoverGraphqlHookCalls(sourceFile, match, kind, resolution) {
|
|
|
9249
9375
|
}
|
|
9250
9376
|
|
|
9251
9377
|
// src/discovery/graphqlImperativeCall.ts
|
|
9252
|
-
var
|
|
9378
|
+
var import_ts_morph43 = require("ts-morph");
|
|
9253
9379
|
function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
9254
9380
|
const isTheClient = clientReceiverCheckFor(sourceFile, match, resolution);
|
|
9255
9381
|
const methodSpec = /* @__PURE__ */ new Map();
|
|
@@ -9261,11 +9387,11 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
9261
9387
|
}
|
|
9262
9388
|
const results = [];
|
|
9263
9389
|
sourceFile.forEachDescendant((node) => {
|
|
9264
|
-
if (!
|
|
9390
|
+
if (!import_ts_morph43.Node.isCallExpression(node)) {
|
|
9265
9391
|
return;
|
|
9266
9392
|
}
|
|
9267
9393
|
const callee = node.getExpression();
|
|
9268
|
-
if (!
|
|
9394
|
+
if (!import_ts_morph43.Node.isPropertyAccessExpression(callee)) {
|
|
9269
9395
|
return;
|
|
9270
9396
|
}
|
|
9271
9397
|
const methodName = callee.getName();
|
|
@@ -9277,7 +9403,7 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
9277
9403
|
return;
|
|
9278
9404
|
}
|
|
9279
9405
|
const args = node.getArguments();
|
|
9280
|
-
if (args.length === 0 || !
|
|
9406
|
+
if (args.length === 0 || !import_ts_morph43.Node.isObjectLiteralExpression(args[0])) {
|
|
9281
9407
|
return;
|
|
9282
9408
|
}
|
|
9283
9409
|
const config = args[0];
|
|
@@ -9313,16 +9439,16 @@ function discoverGraphqlImperativeCalls(sourceFile, match, kind, resolution) {
|
|
|
9313
9439
|
return results;
|
|
9314
9440
|
}
|
|
9315
9441
|
function imperativeConfigValue(prop) {
|
|
9316
|
-
if (
|
|
9442
|
+
if (import_ts_morph43.Node.isPropertyAssignment(prop)) {
|
|
9317
9443
|
return prop.getInitializer() ?? null;
|
|
9318
9444
|
}
|
|
9319
|
-
if (
|
|
9445
|
+
if (import_ts_morph43.Node.isShorthandPropertyAssignment(prop)) {
|
|
9320
9446
|
const valueSymbol = prop.getValueSymbol();
|
|
9321
9447
|
if (valueSymbol === void 0) {
|
|
9322
9448
|
return null;
|
|
9323
9449
|
}
|
|
9324
9450
|
for (const decl of valueSymbol.getDeclarations()) {
|
|
9325
|
-
if (
|
|
9451
|
+
if (import_ts_morph43.Node.isVariableDeclaration(decl)) {
|
|
9326
9452
|
const init = decl.getInitializer();
|
|
9327
9453
|
if (init !== void 0) {
|
|
9328
9454
|
return init;
|
|
@@ -9335,7 +9461,7 @@ function imperativeConfigValue(prop) {
|
|
|
9335
9461
|
}
|
|
9336
9462
|
|
|
9337
9463
|
// src/discovery/jsxElementRoute.ts
|
|
9338
|
-
var
|
|
9464
|
+
var import_ts_morph44 = require("ts-morph");
|
|
9339
9465
|
var PATH_NOT_LITERAL = "The path this route declares is not written as a string literal, so no path is claimed and this route pairs with nothing";
|
|
9340
9466
|
var ENCLOSING_PATH_NOT_LITERAL = "A route this one is nested under declares its path as something other than a string literal, so the full path is not claimed and this route pairs with nothing";
|
|
9341
9467
|
var SPREAD_NOT_ENUMERATED = "A spread stands in for routes declared elsewhere in this array, and they are not read here, so no path is claimed for any of them";
|
|
@@ -9367,7 +9493,7 @@ function discoverJsxElementRoutes(sourceFile, match, kind, resolution) {
|
|
|
9367
9493
|
}
|
|
9368
9494
|
return;
|
|
9369
9495
|
}
|
|
9370
|
-
if (
|
|
9496
|
+
if (import_ts_morph44.Node.isCallExpression(node) && callsAFactory(node, factoryNames)) {
|
|
9371
9497
|
results.push(
|
|
9372
9498
|
...unitsForRouteArray(node, match, elementsNames, kind, resolution)
|
|
9373
9499
|
);
|
|
@@ -9394,7 +9520,7 @@ function localNamesFor2(sourceFile, match, exported) {
|
|
|
9394
9520
|
return local;
|
|
9395
9521
|
}
|
|
9396
9522
|
function asRouteJsx(node, routeNames) {
|
|
9397
|
-
if (!
|
|
9523
|
+
if (!import_ts_morph44.Node.isJsxSelfClosingElement(node) && !import_ts_morph44.Node.isJsxElement(node)) {
|
|
9398
9524
|
return null;
|
|
9399
9525
|
}
|
|
9400
9526
|
return isRouteJsx(node, routeNames) ? node : null;
|
|
@@ -9404,15 +9530,15 @@ function isRouteJsx(node, routeNames) {
|
|
|
9404
9530
|
return tag !== null && routeNames.has(tag.getText());
|
|
9405
9531
|
}
|
|
9406
9532
|
function tagNameOf(node) {
|
|
9407
|
-
const tag =
|
|
9408
|
-
return
|
|
9533
|
+
const tag = import_ts_morph44.Node.isJsxElement(node) ? node.getOpeningElement().getTagNameNode() : node.getTagNameNode();
|
|
9534
|
+
return import_ts_morph44.Node.isIdentifier(tag) ? tag : null;
|
|
9409
9535
|
}
|
|
9410
9536
|
function attributesOf(node) {
|
|
9411
|
-
return
|
|
9537
|
+
return import_ts_morph44.Node.isJsxElement(node) ? node.getOpeningElement().getAttributes() : node.getAttributes();
|
|
9412
9538
|
}
|
|
9413
9539
|
function attributeValueOf(node, name) {
|
|
9414
9540
|
for (const attribute of attributesOf(node)) {
|
|
9415
|
-
if (!
|
|
9541
|
+
if (!import_ts_morph44.Node.isJsxAttribute(attribute)) {
|
|
9416
9542
|
continue;
|
|
9417
9543
|
}
|
|
9418
9544
|
if (attribute.getNameNode().getText() !== name) {
|
|
@@ -9423,8 +9549,8 @@ function attributeValueOf(node, name) {
|
|
|
9423
9549
|
return null;
|
|
9424
9550
|
}
|
|
9425
9551
|
function literalStringOf2(value) {
|
|
9426
|
-
const unwrapped2 =
|
|
9427
|
-
if (
|
|
9552
|
+
const unwrapped2 = import_ts_morph44.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
9553
|
+
if (import_ts_morph44.Node.isStringLiteral(unwrapped2) || import_ts_morph44.Node.isNoSubstitutionTemplateLiteral(unwrapped2)) {
|
|
9428
9554
|
return unwrapped2.getLiteralValue();
|
|
9429
9555
|
}
|
|
9430
9556
|
return null;
|
|
@@ -9444,8 +9570,8 @@ function elementTargetOfValue(value) {
|
|
|
9444
9570
|
if (value === null) {
|
|
9445
9571
|
return { kind: "absent" };
|
|
9446
9572
|
}
|
|
9447
|
-
const unwrapped2 =
|
|
9448
|
-
if (!
|
|
9573
|
+
const unwrapped2 = import_ts_morph44.Node.isJsxExpression(value) ? value.getExpression() ?? value : value;
|
|
9574
|
+
if (!import_ts_morph44.Node.isJsxSelfClosingElement(unwrapped2) && !import_ts_morph44.Node.isJsxElement(unwrapped2)) {
|
|
9449
9575
|
return { kind: "unreadable" };
|
|
9450
9576
|
}
|
|
9451
9577
|
const tag = tagNameOf(unwrapped2);
|
|
@@ -9457,7 +9583,7 @@ function elementTargetOfValue(value) {
|
|
|
9457
9583
|
function composedPrefixOf(node, match, routeNames) {
|
|
9458
9584
|
const enclosing = [];
|
|
9459
9585
|
for (const ancestor of node.getAncestors()) {
|
|
9460
|
-
if (
|
|
9586
|
+
if (import_ts_morph44.Node.isJsxElement(ancestor) && isRouteJsx(ancestor, routeNames)) {
|
|
9461
9587
|
enclosing.push(ancestor);
|
|
9462
9588
|
}
|
|
9463
9589
|
}
|
|
@@ -9573,14 +9699,14 @@ function abstention(at, kind, sentence, label) {
|
|
|
9573
9699
|
}
|
|
9574
9700
|
function callsAFactory(call, factoryNames) {
|
|
9575
9701
|
const callee = call.getExpression();
|
|
9576
|
-
return
|
|
9702
|
+
return import_ts_morph44.Node.isIdentifier(callee) && factoryNames.has(callee.getText());
|
|
9577
9703
|
}
|
|
9578
9704
|
function unitsForRouteArray(call, match, elementsNames, kind, resolution) {
|
|
9579
9705
|
const first = call.getArguments()[0];
|
|
9580
9706
|
if (first === void 0) {
|
|
9581
9707
|
return [];
|
|
9582
9708
|
}
|
|
9583
|
-
if (
|
|
9709
|
+
if (import_ts_morph44.Node.isJsxElement(first) || import_ts_morph44.Node.isJsxSelfClosingElement(first) || import_ts_morph44.Node.isCallExpression(first) && callsAFactory(first, elementsNames)) {
|
|
9584
9710
|
return [];
|
|
9585
9711
|
}
|
|
9586
9712
|
const array = arrayLiteralOf(first, resolution);
|
|
@@ -9605,7 +9731,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
9605
9731
|
const nestedIn = new Set(ancestry).add(array);
|
|
9606
9732
|
const results = [];
|
|
9607
9733
|
for (const element of array.getElements()) {
|
|
9608
|
-
if (
|
|
9734
|
+
if (import_ts_morph44.Node.isSpreadElement(element)) {
|
|
9609
9735
|
results.push(
|
|
9610
9736
|
abstention(
|
|
9611
9737
|
element,
|
|
@@ -9616,7 +9742,7 @@ function unitsOfArrayElements(array, match, kind, resolution, prefix, ancestry)
|
|
|
9616
9742
|
);
|
|
9617
9743
|
continue;
|
|
9618
9744
|
}
|
|
9619
|
-
if (!
|
|
9745
|
+
if (!import_ts_morph44.Node.isObjectLiteralExpression(element)) {
|
|
9620
9746
|
results.push(
|
|
9621
9747
|
abstention(
|
|
9622
9748
|
element,
|
|
@@ -9705,7 +9831,7 @@ function ownPathOfObject(object, match) {
|
|
|
9705
9831
|
}
|
|
9706
9832
|
if (match.indexAttribute !== void 0) {
|
|
9707
9833
|
const indexValue = routePropertyOf(object, match.indexAttribute);
|
|
9708
|
-
if (indexValue !== null &&
|
|
9834
|
+
if (indexValue !== null && import_ts_morph44.Node.isTrueLiteral(indexValue)) {
|
|
9709
9835
|
return { kind: "inherited" };
|
|
9710
9836
|
}
|
|
9711
9837
|
}
|
|
@@ -9719,10 +9845,10 @@ function objectLabelOf(target) {
|
|
|
9719
9845
|
return target.kind === "named" ? target.identifier.getText() : "declaration";
|
|
9720
9846
|
}
|
|
9721
9847
|
function labelOfExpression(node) {
|
|
9722
|
-
if (
|
|
9848
|
+
if (import_ts_morph44.Node.isIdentifier(node)) {
|
|
9723
9849
|
return node.getText();
|
|
9724
9850
|
}
|
|
9725
|
-
if (
|
|
9851
|
+
if (import_ts_morph44.Node.isCallExpression(node)) {
|
|
9726
9852
|
return node.getExpression().getText();
|
|
9727
9853
|
}
|
|
9728
9854
|
return node.getKindName();
|
|
@@ -9730,7 +9856,7 @@ function labelOfExpression(node) {
|
|
|
9730
9856
|
|
|
9731
9857
|
// src/discovery/packageExports.ts
|
|
9732
9858
|
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
9733
|
-
var
|
|
9859
|
+
var import_ts_morph46 = require("ts-morph");
|
|
9734
9860
|
|
|
9735
9861
|
// src/packageExports.ts
|
|
9736
9862
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
@@ -9828,12 +9954,12 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
9828
9954
|
}
|
|
9829
9955
|
|
|
9830
9956
|
// src/discovery/factorySurface.ts
|
|
9831
|
-
var
|
|
9957
|
+
var import_ts_morph45 = require("ts-morph");
|
|
9832
9958
|
function surfaceMethods(decl) {
|
|
9833
|
-
if (
|
|
9959
|
+
if (import_ts_morph45.Node.isClassDeclaration(decl)) {
|
|
9834
9960
|
return surfaceClassMethods(decl);
|
|
9835
9961
|
}
|
|
9836
|
-
if (
|
|
9962
|
+
if (import_ts_morph45.Node.isFunctionDeclaration(decl) || import_ts_morph45.Node.isFunctionExpression(decl) || import_ts_morph45.Node.isArrowFunction(decl) || import_ts_morph45.Node.isMethodDeclaration(decl)) {
|
|
9837
9963
|
return surfaceFactoryReturnMethods(decl);
|
|
9838
9964
|
}
|
|
9839
9965
|
return [];
|
|
@@ -9842,7 +9968,7 @@ function surfaceClassMethods(cls) {
|
|
|
9842
9968
|
const out = [];
|
|
9843
9969
|
const seen = /* @__PURE__ */ new Set();
|
|
9844
9970
|
for (const method of cls.getInstanceMethods()) {
|
|
9845
|
-
if (method.hasModifier(
|
|
9971
|
+
if (method.hasModifier(import_ts_morph45.SyntaxKind.PrivateKeyword)) {
|
|
9846
9972
|
continue;
|
|
9847
9973
|
}
|
|
9848
9974
|
const name = method.getName();
|
|
@@ -9853,7 +9979,7 @@ function surfaceClassMethods(cls) {
|
|
|
9853
9979
|
out.push({ func: method, name });
|
|
9854
9980
|
}
|
|
9855
9981
|
for (const method of cls.getStaticMethods()) {
|
|
9856
|
-
if (method.hasModifier(
|
|
9982
|
+
if (method.hasModifier(import_ts_morph45.SyntaxKind.PrivateKeyword)) {
|
|
9857
9983
|
continue;
|
|
9858
9984
|
}
|
|
9859
9985
|
const name = method.getName();
|
|
@@ -9868,9 +9994,9 @@ function surfaceClassMethods(cls) {
|
|
|
9868
9994
|
function surfaceFactoryReturnMethods(fn) {
|
|
9869
9995
|
const out = [];
|
|
9870
9996
|
const seen = /* @__PURE__ */ new Set();
|
|
9871
|
-
if (
|
|
9997
|
+
if (import_ts_morph45.Node.isArrowFunction(fn)) {
|
|
9872
9998
|
const body2 = fn.getBody();
|
|
9873
|
-
if (
|
|
9999
|
+
if (import_ts_morph45.Node.isExpression(body2)) {
|
|
9874
10000
|
collectFromObjectLiteral(body2, out, seen);
|
|
9875
10001
|
return out;
|
|
9876
10002
|
}
|
|
@@ -9881,11 +10007,11 @@ function surfaceFactoryReturnMethods(fn) {
|
|
|
9881
10007
|
}
|
|
9882
10008
|
const returns = [];
|
|
9883
10009
|
body.forEachDescendant((node, traversal) => {
|
|
9884
|
-
if (
|
|
10010
|
+
if (import_ts_morph45.Node.isFunctionDeclaration(node) || import_ts_morph45.Node.isFunctionExpression(node) || import_ts_morph45.Node.isArrowFunction(node) || import_ts_morph45.Node.isMethodDeclaration(node) || import_ts_morph45.Node.isConstructorDeclaration(node) || import_ts_morph45.Node.isGetAccessorDeclaration(node) || import_ts_morph45.Node.isSetAccessorDeclaration(node)) {
|
|
9885
10011
|
traversal.skip();
|
|
9886
10012
|
return;
|
|
9887
10013
|
}
|
|
9888
|
-
if (
|
|
10014
|
+
if (import_ts_morph45.Node.isReturnStatement(node)) {
|
|
9889
10015
|
returns.push(node);
|
|
9890
10016
|
}
|
|
9891
10017
|
});
|
|
@@ -9900,14 +10026,14 @@ function surfaceFactoryReturnMethods(fn) {
|
|
|
9900
10026
|
}
|
|
9901
10027
|
function collectFromObjectLiteral(node, out, seen) {
|
|
9902
10028
|
let e = node;
|
|
9903
|
-
while (
|
|
10029
|
+
while (import_ts_morph45.Node.isParenthesizedExpression(e)) {
|
|
9904
10030
|
e = e.getExpression();
|
|
9905
10031
|
}
|
|
9906
|
-
if (!
|
|
10032
|
+
if (!import_ts_morph45.Node.isObjectLiteralExpression(e)) {
|
|
9907
10033
|
return;
|
|
9908
10034
|
}
|
|
9909
10035
|
for (const prop of e.getProperties()) {
|
|
9910
|
-
if (
|
|
10036
|
+
if (import_ts_morph45.Node.isMethodDeclaration(prop)) {
|
|
9911
10037
|
const name = prop.getName();
|
|
9912
10038
|
if (seen.has(name)) {
|
|
9913
10039
|
continue;
|
|
@@ -9916,16 +10042,16 @@ function collectFromObjectLiteral(node, out, seen) {
|
|
|
9916
10042
|
out.push({ func: prop, name });
|
|
9917
10043
|
continue;
|
|
9918
10044
|
}
|
|
9919
|
-
if (
|
|
10045
|
+
if (import_ts_morph45.Node.isPropertyAssignment(prop)) {
|
|
9920
10046
|
const init = prop.getInitializer();
|
|
9921
10047
|
if (init === void 0) {
|
|
9922
10048
|
continue;
|
|
9923
10049
|
}
|
|
9924
10050
|
let v3 = init;
|
|
9925
|
-
while (
|
|
10051
|
+
while (import_ts_morph45.Node.isParenthesizedExpression(v3)) {
|
|
9926
10052
|
v3 = v3.getExpression();
|
|
9927
10053
|
}
|
|
9928
|
-
if (
|
|
10054
|
+
if (import_ts_morph45.Node.isArrowFunction(v3) || import_ts_morph45.Node.isFunctionExpression(v3)) {
|
|
9929
10055
|
const name = prop.getName();
|
|
9930
10056
|
if (seen.has(name)) {
|
|
9931
10057
|
continue;
|
|
@@ -9991,9 +10117,9 @@ function discoverPackageExports(sourceFile, match, kind) {
|
|
|
9991
10117
|
continue;
|
|
9992
10118
|
}
|
|
9993
10119
|
for (const decl of decls) {
|
|
9994
|
-
if (
|
|
10120
|
+
if (import_ts_morph46.Node.isVariableDeclaration(decl)) {
|
|
9995
10121
|
const init = decl.getInitializer();
|
|
9996
|
-
if (init !== void 0 && (
|
|
10122
|
+
if (init !== void 0 && (import_ts_morph46.Node.isArrowFunction(init) || import_ts_morph46.Node.isFunctionExpression(init))) {
|
|
9997
10123
|
results.push(buildUnit(init, kind, exportName, entry));
|
|
9998
10124
|
for (const m of surfaceMethods(init)) {
|
|
9999
10125
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
@@ -10003,7 +10129,7 @@ function discoverPackageExports(sourceFile, match, kind) {
|
|
|
10003
10129
|
}
|
|
10004
10130
|
continue;
|
|
10005
10131
|
}
|
|
10006
|
-
if (
|
|
10132
|
+
if (import_ts_morph46.Node.isClassDeclaration(decl)) {
|
|
10007
10133
|
for (const m of surfaceMethods(decl)) {
|
|
10008
10134
|
results.push(buildSurfacedUnit(m, kind, exportName, entry));
|
|
10009
10135
|
}
|
|
@@ -10048,12 +10174,12 @@ function buildSurfacedUnit(m, kind, parentExportName, entry) {
|
|
|
10048
10174
|
}
|
|
10049
10175
|
|
|
10050
10176
|
// src/discovery/packageImport.ts
|
|
10051
|
-
var
|
|
10177
|
+
var import_ts_morph48 = require("ts-morph");
|
|
10052
10178
|
|
|
10053
10179
|
// src/discovery/factoryTracking.ts
|
|
10054
|
-
var
|
|
10180
|
+
var import_ts_morph47 = require("ts-morph");
|
|
10055
10181
|
function isScopeNode(node) {
|
|
10056
|
-
return
|
|
10182
|
+
return import_ts_morph47.Node.isFunctionDeclaration(node) || import_ts_morph47.Node.isFunctionExpression(node) || import_ts_morph47.Node.isArrowFunction(node) || import_ts_morph47.Node.isMethodDeclaration(node) || import_ts_morph47.Node.isConstructorDeclaration(node) || import_ts_morph47.Node.isGetAccessorDeclaration(node) || import_ts_morph47.Node.isSetAccessorDeclaration(node);
|
|
10057
10183
|
}
|
|
10058
10184
|
function trackFactoryBindings(sourceFile, recognize) {
|
|
10059
10185
|
const scopes = /* @__PURE__ */ new Map();
|
|
@@ -10076,19 +10202,19 @@ function trackFactoryBindings(sourceFile, recognize) {
|
|
|
10076
10202
|
map.set(name, provenance);
|
|
10077
10203
|
}
|
|
10078
10204
|
for (const varDecl of sourceFile.getDescendantsOfKind(
|
|
10079
|
-
|
|
10205
|
+
import_ts_morph47.SyntaxKind.VariableDeclaration
|
|
10080
10206
|
)) {
|
|
10081
10207
|
const init = varDecl.getInitializer();
|
|
10082
10208
|
if (init === void 0) {
|
|
10083
10209
|
continue;
|
|
10084
10210
|
}
|
|
10085
|
-
const peeled =
|
|
10211
|
+
const peeled = import_ts_morph47.Node.isAwaitExpression(init) ? init.getExpression() : init;
|
|
10086
10212
|
let callee;
|
|
10087
10213
|
let isNew;
|
|
10088
|
-
if (
|
|
10214
|
+
if (import_ts_morph47.Node.isCallExpression(peeled)) {
|
|
10089
10215
|
callee = peeled.getExpression();
|
|
10090
10216
|
isNew = false;
|
|
10091
|
-
} else if (
|
|
10217
|
+
} else if (import_ts_morph47.Node.isNewExpression(peeled)) {
|
|
10092
10218
|
const expr = peeled.getExpression();
|
|
10093
10219
|
if (expr === void 0) {
|
|
10094
10220
|
continue;
|
|
@@ -10104,11 +10230,11 @@ function trackFactoryBindings(sourceFile, recognize) {
|
|
|
10104
10230
|
}
|
|
10105
10231
|
const scope = scopeOf(varDecl);
|
|
10106
10232
|
const nameNode = varDecl.getNameNode();
|
|
10107
|
-
if (
|
|
10233
|
+
if (import_ts_morph47.Node.isIdentifier(nameNode)) {
|
|
10108
10234
|
record(scope, nameNode.getText(), provenance);
|
|
10109
10235
|
continue;
|
|
10110
10236
|
}
|
|
10111
|
-
if (
|
|
10237
|
+
if (import_ts_morph47.Node.isObjectBindingPattern(nameNode)) {
|
|
10112
10238
|
for (const elem of nameNode.getElements()) {
|
|
10113
10239
|
if (elem.getDotDotDotToken() !== void 0) {
|
|
10114
10240
|
continue;
|
|
@@ -10162,13 +10288,13 @@ function splitPackageSpec(spec) {
|
|
|
10162
10288
|
};
|
|
10163
10289
|
}
|
|
10164
10290
|
function enclosingFunctionName(func) {
|
|
10165
|
-
if (
|
|
10291
|
+
if (import_ts_morph48.Node.isFunctionDeclaration(func) || import_ts_morph48.Node.isMethodDeclaration(func)) {
|
|
10166
10292
|
const n = func.getName?.();
|
|
10167
10293
|
if (typeof n === "string" && n.length > 0) {
|
|
10168
10294
|
return n;
|
|
10169
10295
|
}
|
|
10170
10296
|
}
|
|
10171
|
-
if (
|
|
10297
|
+
if (import_ts_morph48.Node.isFunctionExpression(func)) {
|
|
10172
10298
|
const n = func.getName();
|
|
10173
10299
|
if (typeof n === "string" && n.length > 0) {
|
|
10174
10300
|
return n;
|
|
@@ -10176,10 +10302,10 @@ function enclosingFunctionName(func) {
|
|
|
10176
10302
|
}
|
|
10177
10303
|
const parent = func.getParent();
|
|
10178
10304
|
if (parent !== void 0) {
|
|
10179
|
-
if (
|
|
10305
|
+
if (import_ts_morph48.Node.isVariableDeclaration(parent)) {
|
|
10180
10306
|
return parent.getName();
|
|
10181
10307
|
}
|
|
10182
|
-
if (
|
|
10308
|
+
if (import_ts_morph48.Node.isPropertyAssignment(parent)) {
|
|
10183
10309
|
return parent.getName();
|
|
10184
10310
|
}
|
|
10185
10311
|
}
|
|
@@ -10214,37 +10340,37 @@ function discoverPackageImports(sourceFile, match, kind) {
|
|
|
10214
10340
|
return [];
|
|
10215
10341
|
}
|
|
10216
10342
|
const trackedBindings = trackFactoryBindings(sourceFile, (callee) => {
|
|
10217
|
-
if (!
|
|
10343
|
+
if (!import_ts_morph48.Node.isIdentifier(callee)) {
|
|
10218
10344
|
return null;
|
|
10219
10345
|
}
|
|
10220
10346
|
return localToExport.get(callee.getText()) ?? null;
|
|
10221
10347
|
});
|
|
10222
10348
|
function resolveReceiverProvenance(node, fromNode) {
|
|
10223
10349
|
let n = node;
|
|
10224
|
-
while (
|
|
10350
|
+
while (import_ts_morph48.Node.isParenthesizedExpression(n)) {
|
|
10225
10351
|
n = n.getExpression();
|
|
10226
10352
|
}
|
|
10227
|
-
if (
|
|
10353
|
+
if (import_ts_morph48.Node.isAwaitExpression(n)) {
|
|
10228
10354
|
const inner = n.getExpression();
|
|
10229
10355
|
if (inner === void 0) {
|
|
10230
10356
|
return null;
|
|
10231
10357
|
}
|
|
10232
10358
|
n = inner;
|
|
10233
10359
|
}
|
|
10234
|
-
if (
|
|
10360
|
+
if (import_ts_morph48.Node.isIdentifier(n)) {
|
|
10235
10361
|
const text = n.getText();
|
|
10236
10362
|
return trackedBindings.resolve(text, fromNode) ?? localToExport.get(text) ?? null;
|
|
10237
10363
|
}
|
|
10238
|
-
if (
|
|
10364
|
+
if (import_ts_morph48.Node.isCallExpression(n)) {
|
|
10239
10365
|
const callee = n.getExpression();
|
|
10240
|
-
if (
|
|
10366
|
+
if (import_ts_morph48.Node.isIdentifier(callee)) {
|
|
10241
10367
|
return localToExport.get(callee.getText()) ?? null;
|
|
10242
10368
|
}
|
|
10243
10369
|
return null;
|
|
10244
10370
|
}
|
|
10245
|
-
if (
|
|
10371
|
+
if (import_ts_morph48.Node.isNewExpression(n)) {
|
|
10246
10372
|
const expr = n.getExpression();
|
|
10247
|
-
if (expr !== void 0 &&
|
|
10373
|
+
if (expr !== void 0 && import_ts_morph48.Node.isIdentifier(expr)) {
|
|
10248
10374
|
return localToExport.get(expr.getText()) ?? null;
|
|
10249
10375
|
}
|
|
10250
10376
|
return null;
|
|
@@ -10252,11 +10378,11 @@ function discoverPackageImports(sourceFile, match, kind) {
|
|
|
10252
10378
|
return null;
|
|
10253
10379
|
}
|
|
10254
10380
|
function attributeCall(callee) {
|
|
10255
|
-
if (
|
|
10381
|
+
if (import_ts_morph48.Node.isIdentifier(callee)) {
|
|
10256
10382
|
const text = callee.getText();
|
|
10257
10383
|
return trackedBindings.resolve(text, callee) ?? localToExport.get(text) ?? null;
|
|
10258
10384
|
}
|
|
10259
|
-
if (
|
|
10385
|
+
if (import_ts_morph48.Node.isPropertyAccessExpression(callee)) {
|
|
10260
10386
|
const subject = callee.getExpression();
|
|
10261
10387
|
const subjectProvenance = resolveReceiverProvenance(subject, callee);
|
|
10262
10388
|
if (subjectProvenance === null) {
|
|
@@ -10284,7 +10410,7 @@ function discoverPackageImports(sourceFile, match, kind) {
|
|
|
10284
10410
|
const results = [];
|
|
10285
10411
|
const seen = /* @__PURE__ */ new Set();
|
|
10286
10412
|
sourceFile.forEachDescendant((node) => {
|
|
10287
|
-
if (!
|
|
10413
|
+
if (!import_ts_morph48.Node.isCallExpression(node)) {
|
|
10288
10414
|
return;
|
|
10289
10415
|
}
|
|
10290
10416
|
const callee = node.getExpression();
|
|
@@ -10315,10 +10441,10 @@ function discoverPackageImports(sourceFile, match, kind) {
|
|
|
10315
10441
|
}
|
|
10316
10442
|
|
|
10317
10443
|
// src/discovery/registrationCall.ts
|
|
10318
|
-
var
|
|
10444
|
+
var import_ts_morph50 = require("ts-morph");
|
|
10319
10445
|
|
|
10320
10446
|
// src/resolve/routePath.ts
|
|
10321
|
-
var
|
|
10447
|
+
var import_ts_morph49 = require("ts-morph");
|
|
10322
10448
|
var import_behavioral_ir5 = require("@suss/behavioral-ir");
|
|
10323
10449
|
var URL_SCHEME = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\//;
|
|
10324
10450
|
var URL_ORIGIN = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\/[^/]*/;
|
|
@@ -10412,26 +10538,26 @@ function pathFromTemplateUrl(arg, resolution) {
|
|
|
10412
10538
|
return path13 === "" ? void 0 : path13;
|
|
10413
10539
|
}
|
|
10414
10540
|
function pathFromUrlNode(node, resolution) {
|
|
10415
|
-
if (
|
|
10541
|
+
if (import_ts_morph49.Node.isStringLiteral(node)) {
|
|
10416
10542
|
return pathFromLiteralUrl(node.getLiteralValue());
|
|
10417
10543
|
}
|
|
10418
|
-
if (
|
|
10544
|
+
if (import_ts_morph49.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
10419
10545
|
return pathFromLiteralUrl(node.getLiteralValue());
|
|
10420
10546
|
}
|
|
10421
|
-
if (
|
|
10547
|
+
if (import_ts_morph49.Node.isTemplateExpression(node)) {
|
|
10422
10548
|
return pathFromTemplateUrl(node, resolution);
|
|
10423
10549
|
}
|
|
10424
|
-
if (
|
|
10550
|
+
if (import_ts_morph49.Node.isBinaryExpression(node)) {
|
|
10425
10551
|
const joined = joinedStringOf(node, resolution);
|
|
10426
10552
|
return joined === void 0 ? void 0 : pathFromLiteralUrl(joined);
|
|
10427
10553
|
}
|
|
10428
10554
|
return void 0;
|
|
10429
10555
|
}
|
|
10430
10556
|
function joinedStringOf(node, resolution) {
|
|
10431
|
-
if (
|
|
10557
|
+
if (import_ts_morph49.Node.isStringLiteral(node) || import_ts_morph49.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
10432
10558
|
return node.getLiteralValue();
|
|
10433
10559
|
}
|
|
10434
|
-
if (
|
|
10560
|
+
if (import_ts_morph49.Node.isBinaryExpression(node) && node.getOperatorToken().getText() === "+") {
|
|
10435
10561
|
const left = joinedStringOf(node.getLeft(), resolution);
|
|
10436
10562
|
const right = joinedStringOf(node.getRight(), resolution);
|
|
10437
10563
|
return left === void 0 || right === void 0 ? void 0 : left + right;
|
|
@@ -10440,10 +10566,10 @@ function joinedStringOf(node, resolution) {
|
|
|
10440
10566
|
return written === null || written === node ? void 0 : joinedStringOf(written, resolution);
|
|
10441
10567
|
}
|
|
10442
10568
|
function placeholderName(expr) {
|
|
10443
|
-
if (
|
|
10569
|
+
if (import_ts_morph49.Node.isIdentifier(expr)) {
|
|
10444
10570
|
return expr.getText();
|
|
10445
10571
|
}
|
|
10446
|
-
if (
|
|
10572
|
+
if (import_ts_morph49.Node.isPropertyAccessExpression(expr)) {
|
|
10447
10573
|
return expr.getName();
|
|
10448
10574
|
}
|
|
10449
10575
|
return "param";
|
|
@@ -10459,7 +10585,7 @@ function holeText(expr, resolution) {
|
|
|
10459
10585
|
return pathFromUrlNode(written, resolution) ?? (0, import_behavioral_ir5.patternHole)(placeholderName(expr));
|
|
10460
10586
|
}
|
|
10461
10587
|
function emptyStringLiteral(node) {
|
|
10462
|
-
return (
|
|
10588
|
+
return (import_ts_morph49.Node.isStringLiteral(node) || import_ts_morph49.Node.isNoSubstitutionTemplateLiteral(node)) && node.getLiteralValue() === "";
|
|
10463
10589
|
}
|
|
10464
10590
|
function pathFromArgument(arg, resolution) {
|
|
10465
10591
|
const written = pathFromUrlNode(arg, resolution);
|
|
@@ -10485,11 +10611,11 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
10485
10611
|
(c) => c.startsWith(".") ? c.slice(1) : c
|
|
10486
10612
|
);
|
|
10487
10613
|
sourceFile.forEachDescendant((node) => {
|
|
10488
|
-
if (!
|
|
10614
|
+
if (!import_ts_morph50.Node.isCallExpression(node)) {
|
|
10489
10615
|
return;
|
|
10490
10616
|
}
|
|
10491
10617
|
const callee = node.getExpression();
|
|
10492
|
-
if (!
|
|
10618
|
+
if (!import_ts_morph50.Node.isPropertyAccessExpression(callee)) {
|
|
10493
10619
|
return;
|
|
10494
10620
|
}
|
|
10495
10621
|
const methodName = callee.getName();
|
|
@@ -10497,7 +10623,7 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
10497
10623
|
return;
|
|
10498
10624
|
}
|
|
10499
10625
|
const subject = callee.getExpression();
|
|
10500
|
-
const subjectName =
|
|
10626
|
+
const subjectName = import_ts_morph50.Node.isIdentifier(subject) ? subject.getText() : null;
|
|
10501
10627
|
const subjectNode = subjectName === null ? void 0 : registrationSubjects.get(subjectName);
|
|
10502
10628
|
if (subjectNode === void 0) {
|
|
10503
10629
|
return;
|
|
@@ -10505,12 +10631,12 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
10505
10631
|
const args = node.getArguments();
|
|
10506
10632
|
let foundObjectArg = false;
|
|
10507
10633
|
for (const arg of args) {
|
|
10508
|
-
if (!
|
|
10634
|
+
if (!import_ts_morph50.Node.isObjectLiteralExpression(arg)) {
|
|
10509
10635
|
continue;
|
|
10510
10636
|
}
|
|
10511
10637
|
foundObjectArg = true;
|
|
10512
10638
|
for (const prop of arg.getProperties()) {
|
|
10513
|
-
if (
|
|
10639
|
+
if (import_ts_morph50.Node.isMethodDeclaration(prop)) {
|
|
10514
10640
|
results.push({
|
|
10515
10641
|
func: prop,
|
|
10516
10642
|
kind,
|
|
@@ -10518,7 +10644,7 @@ function discoverRegistrationCalls(sourceFile, match, kind, bindingExtraction, r
|
|
|
10518
10644
|
});
|
|
10519
10645
|
continue;
|
|
10520
10646
|
}
|
|
10521
|
-
if (!
|
|
10647
|
+
if (!import_ts_morph50.Node.isPropertyAssignment(prop)) {
|
|
10522
10648
|
continue;
|
|
10523
10649
|
}
|
|
10524
10650
|
const propInit = prop.getInitializer();
|
|
@@ -10616,9 +10742,9 @@ function registrationSubjectsOf(sourceFile, importModule, importName) {
|
|
|
10616
10742
|
continue;
|
|
10617
10743
|
}
|
|
10618
10744
|
let calleeText = null;
|
|
10619
|
-
if (
|
|
10745
|
+
if (import_ts_morph50.Node.isCallExpression(init)) {
|
|
10620
10746
|
calleeText = init.getExpression().getText();
|
|
10621
|
-
} else if (
|
|
10747
|
+
} else if (import_ts_morph50.Node.isNewExpression(init)) {
|
|
10622
10748
|
calleeText = init.getExpression().getText();
|
|
10623
10749
|
}
|
|
10624
10750
|
if (calleeText === importedLocalName) {
|
|
@@ -10626,7 +10752,7 @@ function registrationSubjectsOf(sourceFile, importModule, importName) {
|
|
|
10626
10752
|
}
|
|
10627
10753
|
}
|
|
10628
10754
|
sourceFile.forEachDescendant((node) => {
|
|
10629
|
-
if (!
|
|
10755
|
+
if (!import_ts_morph50.Node.isParameterDeclaration(node)) {
|
|
10630
10756
|
return;
|
|
10631
10757
|
}
|
|
10632
10758
|
const typeNode = node.getTypeNode();
|
|
@@ -10670,21 +10796,21 @@ function discoverMountEdges(sourceFile, match, mount, knownSubjectIds, resolutio
|
|
|
10670
10796
|
}
|
|
10671
10797
|
const edges = [];
|
|
10672
10798
|
sourceFile.forEachDescendant((node) => {
|
|
10673
|
-
if (!
|
|
10799
|
+
if (!import_ts_morph50.Node.isCallExpression(node)) {
|
|
10674
10800
|
return;
|
|
10675
10801
|
}
|
|
10676
10802
|
const callee = node.getExpression();
|
|
10677
|
-
if (!
|
|
10803
|
+
if (!import_ts_morph50.Node.isPropertyAccessExpression(callee) || callee.getName() !== mount.method) {
|
|
10678
10804
|
return;
|
|
10679
10805
|
}
|
|
10680
10806
|
const subject = callee.getExpression();
|
|
10681
|
-
const subjectNode =
|
|
10807
|
+
const subjectNode = import_ts_morph50.Node.isIdentifier(subject) ? subjects.get(subject.getText()) : void 0;
|
|
10682
10808
|
if (subjectNode === void 0) {
|
|
10683
10809
|
return;
|
|
10684
10810
|
}
|
|
10685
10811
|
const args = node.getArguments();
|
|
10686
10812
|
const prefixArg = args[mount.prefixPosition];
|
|
10687
|
-
if (prefixArg === void 0 || !(
|
|
10813
|
+
if (prefixArg === void 0 || !(import_ts_morph50.Node.isStringLiteral(prefixArg) || import_ts_morph50.Node.isNoSubstitutionTemplateLiteral(prefixArg))) {
|
|
10688
10814
|
return;
|
|
10689
10815
|
}
|
|
10690
10816
|
const targetNodes = mountTargetsAmong(
|
|
@@ -10718,15 +10844,15 @@ function mountTargetsAmong(args, targetPosition, knownSubjectIds, resolution) {
|
|
|
10718
10844
|
return targets;
|
|
10719
10845
|
}
|
|
10720
10846
|
function stringProperty(obj, name) {
|
|
10721
|
-
if (!
|
|
10847
|
+
if (!import_ts_morph50.Node.isObjectLiteralExpression(obj)) {
|
|
10722
10848
|
return null;
|
|
10723
10849
|
}
|
|
10724
10850
|
const property = obj.getProperty(name);
|
|
10725
|
-
if (property === void 0 || !
|
|
10851
|
+
if (property === void 0 || !import_ts_morph50.Node.isPropertyAssignment(property)) {
|
|
10726
10852
|
return null;
|
|
10727
10853
|
}
|
|
10728
10854
|
const value = property.getInitializer();
|
|
10729
|
-
if (value !== void 0 && (
|
|
10855
|
+
if (value !== void 0 && (import_ts_morph50.Node.isStringLiteral(value) || import_ts_morph50.Node.isNoSubstitutionTemplateLiteral(value))) {
|
|
10730
10856
|
return value.getLiteralValue();
|
|
10731
10857
|
}
|
|
10732
10858
|
return null;
|
|
@@ -10757,7 +10883,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
10757
10883
|
} else {
|
|
10758
10884
|
const args = call.getArguments();
|
|
10759
10885
|
const arg = args[binding.method.position];
|
|
10760
|
-
if (arg === void 0 || !(
|
|
10886
|
+
if (arg === void 0 || !(import_ts_morph50.Node.isStringLiteral(arg) || import_ts_morph50.Node.isNoSubstitutionTemplateLiteral(arg))) {
|
|
10761
10887
|
return null;
|
|
10762
10888
|
}
|
|
10763
10889
|
method = arg.getLiteralValue().toUpperCase();
|
|
@@ -10768,7 +10894,7 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
10768
10894
|
}
|
|
10769
10895
|
|
|
10770
10896
|
// src/discovery/registrationLoop.ts
|
|
10771
|
-
var
|
|
10897
|
+
var import_ts_morph51 = require("ts-morph");
|
|
10772
10898
|
function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
10773
10899
|
const results = [];
|
|
10774
10900
|
const routables = routableNames(sourceFile, match);
|
|
@@ -10776,7 +10902,7 @@ function discoverRegistrationLoops(sourceFile, match, kind, resolution) {
|
|
|
10776
10902
|
return results;
|
|
10777
10903
|
}
|
|
10778
10904
|
sourceFile.forEachDescendant((node) => {
|
|
10779
|
-
if (!
|
|
10905
|
+
if (!import_ts_morph51.Node.isForOfStatement(node)) {
|
|
10780
10906
|
return;
|
|
10781
10907
|
}
|
|
10782
10908
|
const expanded = tryExpandLoop(node, match, kind, resolution, routables);
|
|
@@ -10838,13 +10964,13 @@ function tryExpandLoop(loop, match, kind, resolution, routables) {
|
|
|
10838
10964
|
}
|
|
10839
10965
|
function loopVariableName(loop) {
|
|
10840
10966
|
const initializer = loop.getInitializer();
|
|
10841
|
-
if (
|
|
10967
|
+
if (import_ts_morph51.Node.isVariableDeclarationList(initializer)) {
|
|
10842
10968
|
const decls = initializer.getDeclarations();
|
|
10843
10969
|
if (decls.length !== 1) {
|
|
10844
10970
|
return null;
|
|
10845
10971
|
}
|
|
10846
10972
|
const nameNode = decls[0]?.getNameNode();
|
|
10847
|
-
if (nameNode !== void 0 &&
|
|
10973
|
+
if (nameNode !== void 0 && import_ts_morph51.Node.isIdentifier(nameNode)) {
|
|
10848
10974
|
return nameNode.getText();
|
|
10849
10975
|
}
|
|
10850
10976
|
}
|
|
@@ -10857,14 +10983,14 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
10857
10983
|
if (referenced) {
|
|
10858
10984
|
return;
|
|
10859
10985
|
}
|
|
10860
|
-
if (!
|
|
10986
|
+
if (!import_ts_morph51.Node.isCallExpression(node)) {
|
|
10861
10987
|
return;
|
|
10862
10988
|
}
|
|
10863
10989
|
node.forEachDescendant((inner) => {
|
|
10864
10990
|
if (referenced) {
|
|
10865
10991
|
return;
|
|
10866
10992
|
}
|
|
10867
|
-
if (
|
|
10993
|
+
if (import_ts_morph51.Node.isIdentifier(inner) && inner.getText() === name) {
|
|
10868
10994
|
referenced = true;
|
|
10869
10995
|
}
|
|
10870
10996
|
});
|
|
@@ -10874,12 +11000,12 @@ function bodyReferencesLoopVar(loop, name) {
|
|
|
10874
11000
|
function bodyCallsOn(loop, routables) {
|
|
10875
11001
|
let found = false;
|
|
10876
11002
|
loop.getStatement().forEachDescendant((node) => {
|
|
10877
|
-
if (found || !
|
|
11003
|
+
if (found || !import_ts_morph51.Node.isCallExpression(node)) {
|
|
10878
11004
|
return;
|
|
10879
11005
|
}
|
|
10880
11006
|
const callee = node.getExpression();
|
|
10881
|
-
const subject =
|
|
10882
|
-
if (subject !== null &&
|
|
11007
|
+
const subject = import_ts_morph51.Node.isPropertyAccessExpression(callee) || import_ts_morph51.Node.isElementAccessExpression(callee) ? callee.getExpression() : null;
|
|
11008
|
+
if (subject !== null && import_ts_morph51.Node.isIdentifier(subject) && routables.has(subject.getText())) {
|
|
10883
11009
|
found = true;
|
|
10884
11010
|
}
|
|
10885
11011
|
});
|
|
@@ -10890,11 +11016,11 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
10890
11016
|
let path13 = null;
|
|
10891
11017
|
let handler = null;
|
|
10892
11018
|
for (const prop of element.getProperties()) {
|
|
10893
|
-
if (
|
|
11019
|
+
if (import_ts_morph51.Node.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
10894
11020
|
handler = { func: prop, name: shape.handlerKey };
|
|
10895
11021
|
continue;
|
|
10896
11022
|
}
|
|
10897
|
-
if (!
|
|
11023
|
+
if (!import_ts_morph51.Node.isPropertyAssignment(prop)) {
|
|
10898
11024
|
continue;
|
|
10899
11025
|
}
|
|
10900
11026
|
const name = prop.getName();
|
|
@@ -10917,17 +11043,17 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
10917
11043
|
return { method, path: path13, handler: handler.func, handlerName: handler.name };
|
|
10918
11044
|
}
|
|
10919
11045
|
function readStringLiteralValue(node) {
|
|
10920
|
-
if (
|
|
11046
|
+
if (import_ts_morph51.Node.isStringLiteral(node) || import_ts_morph51.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
10921
11047
|
return node.getLiteralValue();
|
|
10922
11048
|
}
|
|
10923
11049
|
return null;
|
|
10924
11050
|
}
|
|
10925
11051
|
function handlerName(value) {
|
|
10926
|
-
return
|
|
11052
|
+
return import_ts_morph51.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
10927
11053
|
}
|
|
10928
11054
|
|
|
10929
11055
|
// src/discovery/registrationTemplate.ts
|
|
10930
|
-
var
|
|
11056
|
+
var import_ts_morph52 = require("ts-morph");
|
|
10931
11057
|
function discoverRegistrationTemplates(sourceFile, match, kind, resolution) {
|
|
10932
11058
|
const localName = resolveImportedLocalName2(sourceFile, match);
|
|
10933
11059
|
if (localName === null) {
|
|
@@ -10935,7 +11061,7 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution) {
|
|
|
10935
11061
|
}
|
|
10936
11062
|
const results = [];
|
|
10937
11063
|
sourceFile.forEachDescendant((node) => {
|
|
10938
|
-
if (!
|
|
11064
|
+
if (!import_ts_morph52.Node.isCallExpression(node)) {
|
|
10939
11065
|
return;
|
|
10940
11066
|
}
|
|
10941
11067
|
if (!isCallToHelper(node, localName)) {
|
|
@@ -10986,7 +11112,7 @@ function resolveImportedLocalName2(sourceFile, match) {
|
|
|
10986
11112
|
}
|
|
10987
11113
|
function isCallToHelper(call, localName) {
|
|
10988
11114
|
const callee = call.getExpression();
|
|
10989
|
-
return
|
|
11115
|
+
return import_ts_morph52.Node.isIdentifier(callee) && callee.getText() === localName;
|
|
10990
11116
|
}
|
|
10991
11117
|
function substitutePath(template, args) {
|
|
10992
11118
|
const re = /\{(\d+)\}/g;
|
|
@@ -11012,7 +11138,7 @@ function substitutePath(template, args) {
|
|
|
11012
11138
|
return result;
|
|
11013
11139
|
}
|
|
11014
11140
|
function readStringLiteral(node) {
|
|
11015
|
-
if (
|
|
11141
|
+
if (import_ts_morph52.Node.isStringLiteral(node) || import_ts_morph52.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
11016
11142
|
return node.getLiteralValue();
|
|
11017
11143
|
}
|
|
11018
11144
|
return null;
|
|
@@ -11035,7 +11161,7 @@ function resolveHandler(template, args, resolution) {
|
|
|
11035
11161
|
return readPropertyAsFunction(arg, prop, resolution);
|
|
11036
11162
|
}
|
|
11037
11163
|
function handlerName2(value) {
|
|
11038
|
-
return
|
|
11164
|
+
return import_ts_morph52.Node.isIdentifier(value) ? value.getText() : value.getKindName();
|
|
11039
11165
|
}
|
|
11040
11166
|
function readPropertyAsFunction(arg, prop, resolution) {
|
|
11041
11167
|
const obj = objectLiteralOf(arg, resolution);
|
|
@@ -11046,7 +11172,7 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
11046
11172
|
if (propertyName2(property) !== prop) {
|
|
11047
11173
|
continue;
|
|
11048
11174
|
}
|
|
11049
|
-
if (
|
|
11175
|
+
if (import_ts_morph52.Node.isMethodDeclaration(property)) {
|
|
11050
11176
|
return { func: property, name: prop };
|
|
11051
11177
|
}
|
|
11052
11178
|
const held = propertyValueOf(property);
|
|
@@ -11054,19 +11180,19 @@ function readPropertyAsFunction(arg, prop, resolution) {
|
|
|
11054
11180
|
return null;
|
|
11055
11181
|
}
|
|
11056
11182
|
const func = functionValueOf(held, resolution);
|
|
11057
|
-
return func === null ? null : { func, name:
|
|
11183
|
+
return func === null ? null : { func, name: import_ts_morph52.Node.isIdentifier(held) ? held.getText() : prop };
|
|
11058
11184
|
}
|
|
11059
11185
|
return null;
|
|
11060
11186
|
}
|
|
11061
11187
|
function propertyName2(property) {
|
|
11062
|
-
if (
|
|
11188
|
+
if (import_ts_morph52.Node.isPropertyAssignment(property) || import_ts_morph52.Node.isShorthandPropertyAssignment(property) || import_ts_morph52.Node.isMethodDeclaration(property)) {
|
|
11063
11189
|
return property.getName();
|
|
11064
11190
|
}
|
|
11065
11191
|
return null;
|
|
11066
11192
|
}
|
|
11067
11193
|
|
|
11068
11194
|
// src/discovery/resolverMap.ts
|
|
11069
|
-
var
|
|
11195
|
+
var import_ts_morph53 = require("ts-morph");
|
|
11070
11196
|
function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
11071
11197
|
const localName = resolveImportedLocalName(
|
|
11072
11198
|
sourceFile,
|
|
@@ -11080,15 +11206,15 @@ function discoverResolverMaps(sourceFile, match, kind, resolution) {
|
|
|
11080
11206
|
const excludeTypes = new Set(match.excludeTypes ?? []);
|
|
11081
11207
|
const results = [];
|
|
11082
11208
|
sourceFile.forEachDescendant((node) => {
|
|
11083
|
-
if (!
|
|
11209
|
+
if (!import_ts_morph53.Node.isCallExpression(node) && !import_ts_morph53.Node.isNewExpression(node)) {
|
|
11084
11210
|
return;
|
|
11085
11211
|
}
|
|
11086
11212
|
const callee = node.getExpression();
|
|
11087
|
-
if (!
|
|
11213
|
+
if (!import_ts_morph53.Node.isIdentifier(callee) || callee.getText() !== localName) {
|
|
11088
11214
|
return;
|
|
11089
11215
|
}
|
|
11090
11216
|
const args = node.getArguments();
|
|
11091
|
-
if (args.length === 0 || !
|
|
11217
|
+
if (args.length === 0 || !import_ts_morph53.Node.isObjectLiteralExpression(args[0])) {
|
|
11092
11218
|
return;
|
|
11093
11219
|
}
|
|
11094
11220
|
const config = args[0];
|
|
@@ -11142,7 +11268,7 @@ function resolverMapObject(prop, resolution) {
|
|
|
11142
11268
|
return held === null ? null : objectLiteralOf(held, resolution);
|
|
11143
11269
|
}
|
|
11144
11270
|
function extractTypeDefsSdl(config, resolution) {
|
|
11145
|
-
if (!
|
|
11271
|
+
if (!import_ts_morph53.Node.isObjectLiteralExpression(config)) {
|
|
11146
11272
|
return null;
|
|
11147
11273
|
}
|
|
11148
11274
|
const prop = config.getProperty("typeDefs");
|
|
@@ -11164,15 +11290,15 @@ function schemaSdlOf(expr, resolution) {
|
|
|
11164
11290
|
return resolved === null ? null : writtenSdl(resolved);
|
|
11165
11291
|
}
|
|
11166
11292
|
function writtenSdl(expr) {
|
|
11167
|
-
if (
|
|
11293
|
+
if (import_ts_morph53.Node.isStringLiteral(expr) || import_ts_morph53.Node.isNoSubstitutionTemplateLiteral(expr)) {
|
|
11168
11294
|
const value = expr.getLiteralValue();
|
|
11169
11295
|
return value === "" ? null : value;
|
|
11170
11296
|
}
|
|
11171
|
-
if (
|
|
11297
|
+
if (import_ts_morph53.Node.isTaggedTemplateExpression(expr)) {
|
|
11172
11298
|
const tag = expr.getTag();
|
|
11173
|
-
if (
|
|
11299
|
+
if (import_ts_morph53.Node.isIdentifier(tag) && tag.getText() === "gql") {
|
|
11174
11300
|
const template = expr.getTemplate();
|
|
11175
|
-
if (
|
|
11301
|
+
if (import_ts_morph53.Node.isNoSubstitutionTemplateLiteral(template)) {
|
|
11176
11302
|
return template.getLiteralValue();
|
|
11177
11303
|
}
|
|
11178
11304
|
}
|
|
@@ -11180,16 +11306,16 @@ function writtenSdl(expr) {
|
|
|
11180
11306
|
return null;
|
|
11181
11307
|
}
|
|
11182
11308
|
function resolverPropertyName(prop) {
|
|
11183
|
-
if (
|
|
11309
|
+
if (import_ts_morph53.Node.isPropertyAssignment(prop) || import_ts_morph53.Node.isMethodDeclaration(prop)) {
|
|
11184
11310
|
return prop.getName();
|
|
11185
11311
|
}
|
|
11186
|
-
if (
|
|
11312
|
+
if (import_ts_morph53.Node.isShorthandPropertyAssignment(prop)) {
|
|
11187
11313
|
return prop.getName();
|
|
11188
11314
|
}
|
|
11189
11315
|
return null;
|
|
11190
11316
|
}
|
|
11191
11317
|
function resolverPropertyFunction(prop, resolution) {
|
|
11192
|
-
if (
|
|
11318
|
+
if (import_ts_morph53.Node.isMethodDeclaration(prop)) {
|
|
11193
11319
|
return prop;
|
|
11194
11320
|
}
|
|
11195
11321
|
const held = propertyValueOf(prop);
|
|
@@ -11451,7 +11577,7 @@ function resolvePrefix(edgesByChild, memo, childId, visiting) {
|
|
|
11451
11577
|
}
|
|
11452
11578
|
|
|
11453
11579
|
// src/discoveryContext.ts
|
|
11454
|
-
var
|
|
11580
|
+
var import_ts_morph54 = require("ts-morph");
|
|
11455
11581
|
function createTsDiscoveryContext(resolution) {
|
|
11456
11582
|
return {
|
|
11457
11583
|
getFilePath,
|
|
@@ -11483,7 +11609,7 @@ function exportedFunctions(sourceFile, resolution) {
|
|
|
11483
11609
|
return out;
|
|
11484
11610
|
}
|
|
11485
11611
|
function exportedFunction(decl, resolution) {
|
|
11486
|
-
const writtenAgain =
|
|
11612
|
+
const writtenAgain = import_ts_morph54.Node.isVariableDeclaration(decl) && isWrittenAgain(decl);
|
|
11487
11613
|
if (!writtenAgain) {
|
|
11488
11614
|
const declared = resolveDeclarationToFunction(decl);
|
|
11489
11615
|
if (declared !== null) {
|
|
@@ -11504,7 +11630,7 @@ function valueToAskAbout(decl, writtenAgain) {
|
|
|
11504
11630
|
if (writtenAgain) {
|
|
11505
11631
|
return decl;
|
|
11506
11632
|
}
|
|
11507
|
-
const value =
|
|
11633
|
+
const value = import_ts_morph54.Node.isVariableDeclaration(decl) ? decl.getInitializer() ?? decl : decl;
|
|
11508
11634
|
return couldStillNameAFunction(value) ? value : null;
|
|
11509
11635
|
}
|
|
11510
11636
|
function exportedCallConfigString(sourceFile, exportName, spec, resolution) {
|
|
@@ -11514,11 +11640,11 @@ function exportedCallConfigString(sourceFile, exportName, spec, resolution) {
|
|
|
11514
11640
|
}
|
|
11515
11641
|
const found = /* @__PURE__ */ new Set();
|
|
11516
11642
|
for (const decl of declarations) {
|
|
11517
|
-
if (!
|
|
11643
|
+
if (!import_ts_morph54.Node.isVariableDeclaration(decl)) {
|
|
11518
11644
|
continue;
|
|
11519
11645
|
}
|
|
11520
11646
|
const init = peelExpression(decl.getInitializer());
|
|
11521
|
-
if (init === void 0 || !
|
|
11647
|
+
if (init === void 0 || !import_ts_morph54.Node.isCallExpression(init)) {
|
|
11522
11648
|
continue;
|
|
11523
11649
|
}
|
|
11524
11650
|
if (!calleeIsNamed(init.getExpression(), spec.callees)) {
|
|
@@ -11537,7 +11663,7 @@ function calleeIsNamed(callee, names) {
|
|
|
11537
11663
|
if (names === void 0 || names.length === 0) {
|
|
11538
11664
|
return true;
|
|
11539
11665
|
}
|
|
11540
|
-
return
|
|
11666
|
+
return import_ts_morph54.Node.isIdentifier(callee) && names.includes(callee.getText());
|
|
11541
11667
|
}
|
|
11542
11668
|
function configArguments(args, argIndex) {
|
|
11543
11669
|
if (argIndex === void 0) {
|
|
@@ -11552,18 +11678,18 @@ function configString(arg, property, resolution) {
|
|
|
11552
11678
|
return null;
|
|
11553
11679
|
}
|
|
11554
11680
|
const prop = config.getProperty(property);
|
|
11555
|
-
if (prop === void 0 || !
|
|
11681
|
+
if (prop === void 0 || !import_ts_morph54.Node.isPropertyAssignment(prop)) {
|
|
11556
11682
|
return null;
|
|
11557
11683
|
}
|
|
11558
11684
|
const value = peelExpression(prop.getInitializer());
|
|
11559
|
-
if (value !== void 0 &&
|
|
11685
|
+
if (value !== void 0 && import_ts_morph54.Node.isStringLiteral(value)) {
|
|
11560
11686
|
return value.getLiteralValue();
|
|
11561
11687
|
}
|
|
11562
11688
|
return null;
|
|
11563
11689
|
}
|
|
11564
11690
|
function peelExpression(node) {
|
|
11565
11691
|
let current2 = node;
|
|
11566
|
-
while (current2 !== void 0 && (
|
|
11692
|
+
while (current2 !== void 0 && (import_ts_morph54.Node.isAsExpression(current2) || import_ts_morph54.Node.isSatisfiesExpression(current2) || import_ts_morph54.Node.isParenthesizedExpression(current2) || import_ts_morph54.Node.isNonNullExpression(current2))) {
|
|
11567
11693
|
current2 = current2.getExpression();
|
|
11568
11694
|
}
|
|
11569
11695
|
return current2;
|
|
@@ -11573,14 +11699,14 @@ function toObjectLiteral(node, resolution) {
|
|
|
11573
11699
|
if (peeled === void 0) {
|
|
11574
11700
|
return null;
|
|
11575
11701
|
}
|
|
11576
|
-
if (
|
|
11702
|
+
if (import_ts_morph54.Node.isObjectLiteralExpression(peeled)) {
|
|
11577
11703
|
return peeled;
|
|
11578
11704
|
}
|
|
11579
11705
|
if (resolution === void 0) {
|
|
11580
11706
|
return null;
|
|
11581
11707
|
}
|
|
11582
11708
|
const resolved = resolution.resolveObject(peeled);
|
|
11583
|
-
if (resolved !== null &&
|
|
11709
|
+
if (resolved !== null && import_ts_morph54.Node.isObjectLiteralExpression(resolved)) {
|
|
11584
11710
|
return resolved;
|
|
11585
11711
|
}
|
|
11586
11712
|
return null;
|
|
@@ -11590,18 +11716,18 @@ function resolveDeclarationToFunction(decl) {
|
|
|
11590
11716
|
if (fn !== null) {
|
|
11591
11717
|
return fn;
|
|
11592
11718
|
}
|
|
11593
|
-
if (
|
|
11719
|
+
if (import_ts_morph54.Node.isVariableDeclaration(decl)) {
|
|
11594
11720
|
const init = decl.getInitializer();
|
|
11595
|
-
if (init !== void 0 && (
|
|
11721
|
+
if (init !== void 0 && (import_ts_morph54.Node.isArrowFunction(init) || import_ts_morph54.Node.isFunctionExpression(init))) {
|
|
11596
11722
|
return init;
|
|
11597
11723
|
}
|
|
11598
11724
|
}
|
|
11599
11725
|
return null;
|
|
11600
11726
|
}
|
|
11601
11727
|
function hasJsxReturn(func) {
|
|
11602
|
-
if (
|
|
11728
|
+
if (import_ts_morph54.Node.isArrowFunction(func)) {
|
|
11603
11729
|
const body2 = func.getBody();
|
|
11604
|
-
if (
|
|
11730
|
+
if (import_ts_morph54.Node.isExpression(body2) && isJsxOrFragment(body2)) {
|
|
11605
11731
|
return true;
|
|
11606
11732
|
}
|
|
11607
11733
|
}
|
|
@@ -11615,11 +11741,11 @@ function hasJsxReturn(func) {
|
|
|
11615
11741
|
traversal.stop();
|
|
11616
11742
|
return;
|
|
11617
11743
|
}
|
|
11618
|
-
if (node !== func && (
|
|
11744
|
+
if (node !== func && (import_ts_morph54.Node.isFunctionDeclaration(node) || import_ts_morph54.Node.isFunctionExpression(node) || import_ts_morph54.Node.isArrowFunction(node) || import_ts_morph54.Node.isMethodDeclaration(node))) {
|
|
11619
11745
|
traversal.skip();
|
|
11620
11746
|
return;
|
|
11621
11747
|
}
|
|
11622
|
-
if (
|
|
11748
|
+
if (import_ts_morph54.Node.isReturnStatement(node)) {
|
|
11623
11749
|
const expr = node.getExpression();
|
|
11624
11750
|
if (expr !== void 0 && isJsxOrFragment(expr)) {
|
|
11625
11751
|
found = true;
|
|
@@ -11630,14 +11756,14 @@ function hasJsxReturn(func) {
|
|
|
11630
11756
|
}
|
|
11631
11757
|
function isJsxOrFragment(node) {
|
|
11632
11758
|
let current2 = node;
|
|
11633
|
-
while (
|
|
11759
|
+
while (import_ts_morph54.Node.isParenthesizedExpression(current2)) {
|
|
11634
11760
|
current2 = current2.getExpression();
|
|
11635
11761
|
}
|
|
11636
|
-
return
|
|
11762
|
+
return import_ts_morph54.Node.isJsxElement(current2) || import_ts_morph54.Node.isJsxSelfClosingElement(current2) || import_ts_morph54.Node.isJsxFragment(current2);
|
|
11637
11763
|
}
|
|
11638
11764
|
|
|
11639
11765
|
// src/facts/store.ts
|
|
11640
|
-
var
|
|
11766
|
+
var import_ts_morph55 = require("ts-morph");
|
|
11641
11767
|
var import_datalog2 = require("@suss/datalog");
|
|
11642
11768
|
var import_resolution = require("@suss/resolution");
|
|
11643
11769
|
var JS_RULES = [
|
|
@@ -11882,7 +12008,7 @@ var ResolutionStore = class {
|
|
|
11882
12008
|
* can be rooted anywhere, so the queried value gets its own facts.
|
|
11883
12009
|
*/
|
|
11884
12010
|
seedValue(value) {
|
|
11885
|
-
if (!
|
|
12011
|
+
if (!import_ts_morph55.Node.isExpression(value)) {
|
|
11886
12012
|
return;
|
|
11887
12013
|
}
|
|
11888
12014
|
const id = nodeId(value);
|
|
@@ -11921,7 +12047,7 @@ var ResolutionStore = class {
|
|
|
11921
12047
|
const candidates = /* @__PURE__ */ new Set();
|
|
11922
12048
|
for (const target of this.answersFor("wantedIsWrittenAs", nodeId(value))) {
|
|
11923
12049
|
const node = this.table.byId.get(target);
|
|
11924
|
-
if (node === void 0 || node === value || !
|
|
12050
|
+
if (node === void 0 || node === value || !import_ts_morph55.Node.isExpression(node)) {
|
|
11925
12051
|
continue;
|
|
11926
12052
|
}
|
|
11927
12053
|
candidates.add(node);
|
|
@@ -12012,7 +12138,7 @@ function namesPackage2(moduleKey, packages) {
|
|
|
12012
12138
|
);
|
|
12013
12139
|
}
|
|
12014
12140
|
function declarationOf2(value) {
|
|
12015
|
-
const nameNode =
|
|
12141
|
+
const nameNode = import_ts_morph55.Node.isPropertyAccessExpression(value) ? value.getNameNode() : value;
|
|
12016
12142
|
return nameNode.getSymbol()?.getDeclarations()[0] ?? value;
|
|
12017
12143
|
}
|
|
12018
12144
|
|
|
@@ -12144,6 +12270,68 @@ function moduleInitSummary(sourceFile, effects, options) {
|
|
|
12144
12270
|
return (0, import_extractor3.assembleSummary)(raw, options);
|
|
12145
12271
|
}
|
|
12146
12272
|
|
|
12273
|
+
// src/parameterReads.ts
|
|
12274
|
+
var import_ts_morph56 = require("ts-morph");
|
|
12275
|
+
function pathAbove(reference) {
|
|
12276
|
+
const path13 = [];
|
|
12277
|
+
let current2 = reference;
|
|
12278
|
+
for (; ; ) {
|
|
12279
|
+
const parent = current2.getParent();
|
|
12280
|
+
if (parent !== void 0 && import_ts_morph56.Node.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
12281
|
+
path13.push(parent.getName());
|
|
12282
|
+
current2 = parent;
|
|
12283
|
+
continue;
|
|
12284
|
+
}
|
|
12285
|
+
if (parent !== void 0 && import_ts_morph56.Node.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
12286
|
+
const argument = parent.getArgumentExpression();
|
|
12287
|
+
if (argument !== void 0 && import_ts_morph56.Node.isStringLiteral(argument)) {
|
|
12288
|
+
path13.push(argument.getLiteralValue());
|
|
12289
|
+
current2 = parent;
|
|
12290
|
+
continue;
|
|
12291
|
+
}
|
|
12292
|
+
}
|
|
12293
|
+
return path13;
|
|
12294
|
+
}
|
|
12295
|
+
}
|
|
12296
|
+
function declaresParameterOf(node, func) {
|
|
12297
|
+
if (import_ts_morph56.Node.isParameterDeclaration(node)) {
|
|
12298
|
+
return node.getParent() === func;
|
|
12299
|
+
}
|
|
12300
|
+
if (import_ts_morph56.Node.isBindingElement(node)) {
|
|
12301
|
+
const parameter = node.getFirstAncestor(import_ts_morph56.Node.isParameterDeclaration);
|
|
12302
|
+
return parameter !== void 0 && parameter.getParent() === func;
|
|
12303
|
+
}
|
|
12304
|
+
return false;
|
|
12305
|
+
}
|
|
12306
|
+
function parameterReads(func, parameterNames) {
|
|
12307
|
+
const wanted = new Set(parameterNames);
|
|
12308
|
+
if (wanted.size === 0) {
|
|
12309
|
+
return [];
|
|
12310
|
+
}
|
|
12311
|
+
const found = /* @__PURE__ */ new Map();
|
|
12312
|
+
func.forEachDescendant((node) => {
|
|
12313
|
+
if (!import_ts_morph56.Node.isIdentifier(node) || !wanted.has(node.getText())) {
|
|
12314
|
+
return;
|
|
12315
|
+
}
|
|
12316
|
+
const declarations = node.getSymbol()?.getDeclarations() ?? [];
|
|
12317
|
+
if (!declarations.some((decl) => declaresParameterOf(decl, func))) {
|
|
12318
|
+
return;
|
|
12319
|
+
}
|
|
12320
|
+
const inDeclaration = declarations.some(
|
|
12321
|
+
(decl) => decl.getStart() <= node.getStart() && node.getEnd() <= decl.getEnd()
|
|
12322
|
+
);
|
|
12323
|
+
if (inDeclaration) {
|
|
12324
|
+
return;
|
|
12325
|
+
}
|
|
12326
|
+
const read2 = { input: node.getText(), path: pathAbove(node) };
|
|
12327
|
+
const key = `${read2.input}\0${read2.path.join(".")}`;
|
|
12328
|
+
if (!found.has(key)) {
|
|
12329
|
+
found.set(key, read2);
|
|
12330
|
+
}
|
|
12331
|
+
});
|
|
12332
|
+
return [...found.values()];
|
|
12333
|
+
}
|
|
12334
|
+
|
|
12147
12335
|
// src/referencedFiles.ts
|
|
12148
12336
|
function createReferenceIndex(sourceFiles) {
|
|
12149
12337
|
const direct = /* @__PURE__ */ new Map();
|
|
@@ -12285,108 +12473,10 @@ function deriveBoundaryEffects(summaries, facts) {
|
|
|
12285
12473
|
}
|
|
12286
12474
|
|
|
12287
12475
|
// src/resolve/reachableClosure.ts
|
|
12288
|
-
var
|
|
12476
|
+
var import_ts_morph57 = require("ts-morph");
|
|
12289
12477
|
var import_behavioral_ir6 = require("@suss/behavioral-ir");
|
|
12290
12478
|
var import_datalog4 = require("@suss/datalog");
|
|
12291
12479
|
var import_extractor4 = require("@suss/extractor");
|
|
12292
|
-
|
|
12293
|
-
// src/resolve/unfollowedCall.ts
|
|
12294
|
-
var import_ts_morph55 = require("ts-morph");
|
|
12295
|
-
function isInExternalCode(sourceFile) {
|
|
12296
|
-
if (sourceFile.isDeclarationFile()) {
|
|
12297
|
-
return true;
|
|
12298
|
-
}
|
|
12299
|
-
return sourceFile.getFilePath().includes("/node_modules/");
|
|
12300
|
-
}
|
|
12301
|
-
function hasBody(fn) {
|
|
12302
|
-
if (import_ts_morph55.Node.isFunctionDeclaration(fn) || import_ts_morph55.Node.isMethodDeclaration(fn) || import_ts_morph55.Node.isFunctionExpression(fn)) {
|
|
12303
|
-
return fn.getBody?.() !== void 0;
|
|
12304
|
-
}
|
|
12305
|
-
return true;
|
|
12306
|
-
}
|
|
12307
|
-
function isDeclaredShape(declaration) {
|
|
12308
|
-
return (import_ts_morph55.Node.isMethodSignature(declaration) || import_ts_morph55.Node.isPropertySignature(declaration)) && !isInExternalCode(declaration.getSourceFile());
|
|
12309
|
-
}
|
|
12310
|
-
function isExternalDeclaration(declaration) {
|
|
12311
|
-
if (isInExternalCode(declaration.getSourceFile())) {
|
|
12312
|
-
return true;
|
|
12313
|
-
}
|
|
12314
|
-
if (import_ts_morph55.Node.isImportSpecifier(declaration) || import_ts_morph55.Node.isImportClause(declaration) || import_ts_morph55.Node.isNamespaceImport(declaration)) {
|
|
12315
|
-
const target = declaration.getFirstAncestorByKind(import_ts_morph55.SyntaxKind.ImportDeclaration)?.getModuleSpecifierSourceFile();
|
|
12316
|
-
return target === void 0 || isInExternalCode(target);
|
|
12317
|
-
}
|
|
12318
|
-
return declaresAnotherModule(declaration);
|
|
12319
|
-
}
|
|
12320
|
-
function declaresAnotherModule(declaration) {
|
|
12321
|
-
const module2 = declaration.getFirstAncestorByKind(
|
|
12322
|
-
import_ts_morph55.SyntaxKind.ModuleDeclaration
|
|
12323
|
-
);
|
|
12324
|
-
return module2 !== void 0 && import_ts_morph55.Node.isStringLiteral(module2.getNameNode());
|
|
12325
|
-
}
|
|
12326
|
-
function statesShapeOnly(declaration) {
|
|
12327
|
-
if (isExternalDeclaration(declaration)) {
|
|
12328
|
-
return false;
|
|
12329
|
-
}
|
|
12330
|
-
if (import_ts_morph55.Node.isMethodSignature(declaration) || import_ts_morph55.Node.isPropertySignature(declaration)) {
|
|
12331
|
-
return true;
|
|
12332
|
-
}
|
|
12333
|
-
if (import_ts_morph55.Node.isFunctionDeclaration(declaration) || import_ts_morph55.Node.isMethodDeclaration(declaration)) {
|
|
12334
|
-
return declaration.getBody() === void 0;
|
|
12335
|
-
}
|
|
12336
|
-
return false;
|
|
12337
|
-
}
|
|
12338
|
-
function declarationsBehind(symbol) {
|
|
12339
|
-
if (symbol === void 0) {
|
|
12340
|
-
return [];
|
|
12341
|
-
}
|
|
12342
|
-
const behind = symbol.getAliasedSymbol()?.getDeclarations() ?? [];
|
|
12343
|
-
return behind.length > 0 ? behind : symbol.getDeclarations();
|
|
12344
|
-
}
|
|
12345
|
-
function classifyStop(declarations) {
|
|
12346
|
-
if (declarations.length === 0) {
|
|
12347
|
-
return "noDeclaration";
|
|
12348
|
-
}
|
|
12349
|
-
for (const declaration of declarations) {
|
|
12350
|
-
if (!isInExternalCode(declaration.getSourceFile())) {
|
|
12351
|
-
recordFileDependency(declaration.getSourceFile().getFilePath());
|
|
12352
|
-
}
|
|
12353
|
-
}
|
|
12354
|
-
if (declarations.every(isExternalDeclaration)) {
|
|
12355
|
-
return "outsideRun";
|
|
12356
|
-
}
|
|
12357
|
-
if (declarations.some(statesShapeOnly)) {
|
|
12358
|
-
return "noBody";
|
|
12359
|
-
}
|
|
12360
|
-
return "unsettledValue";
|
|
12361
|
-
}
|
|
12362
|
-
var RECORDED = {
|
|
12363
|
-
noBody: true,
|
|
12364
|
-
unsettledValue: true,
|
|
12365
|
-
multipleSources: true,
|
|
12366
|
-
outsideRun: false,
|
|
12367
|
-
noDeclaration: false
|
|
12368
|
-
};
|
|
12369
|
-
function worthRecording(reason) {
|
|
12370
|
-
return RECORDED[reason];
|
|
12371
|
-
}
|
|
12372
|
-
var STOP_SENTENCE = {
|
|
12373
|
-
noBody: (callee) => `The call to ${callee} lands on a declaration with no body, so whatever runs there is missing from this summary`,
|
|
12374
|
-
unsettledValue: (callee) => `The call to ${callee} goes through a value this run could not settle, so whatever runs there is missing from this summary`,
|
|
12375
|
-
multipleSources: (callee) => `The call to ${callee} reaches a value with more than one possible source, so whatever runs there is missing from this summary`,
|
|
12376
|
-
outsideRun: (callee) => `The call to ${callee} lands in a package whose source is not in this run, so whatever runs there is missing from this summary`,
|
|
12377
|
-
noDeclaration: (callee) => `The call to ${callee} has no declaration this run could find, so whatever runs there is missing from this summary`
|
|
12378
|
-
};
|
|
12379
|
-
function unfollowedCallGap(stop) {
|
|
12380
|
-
return {
|
|
12381
|
-
type: "unfollowedCall",
|
|
12382
|
-
conditions: [],
|
|
12383
|
-
consequence: "unknown",
|
|
12384
|
-
description: STOP_SENTENCE[stop.reason](stop.callee),
|
|
12385
|
-
callee: stop.callee
|
|
12386
|
-
};
|
|
12387
|
-
}
|
|
12388
|
-
|
|
12389
|
-
// src/resolve/reachableClosure.ts
|
|
12390
12480
|
var reachablePack = {
|
|
12391
12481
|
name: "reachable",
|
|
12392
12482
|
languages: ["typescript"],
|
|
@@ -12420,9 +12510,9 @@ function resolveDecl(decl, calleeName) {
|
|
|
12420
12510
|
}
|
|
12421
12511
|
return { func: fn, name: declName(decl) ?? calleeName };
|
|
12422
12512
|
}
|
|
12423
|
-
if (
|
|
12513
|
+
if (import_ts_morph57.Node.isVariableDeclaration(decl)) {
|
|
12424
12514
|
const init = decl.getInitializer();
|
|
12425
|
-
if (init !== void 0 && (
|
|
12515
|
+
if (init !== void 0 && (import_ts_morph57.Node.isArrowFunction(init) || import_ts_morph57.Node.isFunctionExpression(init))) {
|
|
12426
12516
|
return { func: init, name: decl.getName() };
|
|
12427
12517
|
}
|
|
12428
12518
|
return null;
|
|
@@ -12430,26 +12520,26 @@ function resolveDecl(decl, calleeName) {
|
|
|
12430
12520
|
return null;
|
|
12431
12521
|
}
|
|
12432
12522
|
function declName(decl) {
|
|
12433
|
-
if (
|
|
12523
|
+
if (import_ts_morph57.Node.isFunctionDeclaration(decl) || import_ts_morph57.Node.isMethodDeclaration(decl)) {
|
|
12434
12524
|
const n = decl.getName?.();
|
|
12435
12525
|
if (typeof n === "string" && n.length > 0) {
|
|
12436
12526
|
return n;
|
|
12437
12527
|
}
|
|
12438
12528
|
}
|
|
12439
|
-
if (
|
|
12529
|
+
if (import_ts_morph57.Node.isFunctionExpression(decl)) {
|
|
12440
12530
|
const n = decl.getName();
|
|
12441
12531
|
if (typeof n === "string" && n.length > 0) {
|
|
12442
12532
|
return n;
|
|
12443
12533
|
}
|
|
12444
12534
|
}
|
|
12445
12535
|
const parent = decl.getParent();
|
|
12446
|
-
if (parent !== void 0 &&
|
|
12536
|
+
if (parent !== void 0 && import_ts_morph57.Node.isVariableDeclaration(parent)) {
|
|
12447
12537
|
return parent.getName();
|
|
12448
12538
|
}
|
|
12449
12539
|
return null;
|
|
12450
12540
|
}
|
|
12451
12541
|
function resolveCallee(call, calleeName, scan) {
|
|
12452
|
-
if (!
|
|
12542
|
+
if (!import_ts_morph57.Node.isCallExpression(call)) {
|
|
12453
12543
|
return null;
|
|
12454
12544
|
}
|
|
12455
12545
|
const callee = call.getExpression();
|
|
@@ -12462,7 +12552,7 @@ function resolveCallee(call, calleeName, scan) {
|
|
|
12462
12552
|
}
|
|
12463
12553
|
}
|
|
12464
12554
|
const resolveSources = scan.resolveCallableSources;
|
|
12465
|
-
if (resolveSources !== void 0 &&
|
|
12555
|
+
if (resolveSources !== void 0 && import_ts_morph57.Node.isPropertyAccessExpression(callee) && declarations.some(isDeclaredShape)) {
|
|
12466
12556
|
const sources = resolveSources(callee, scan.reachedFrom);
|
|
12467
12557
|
const only = sources.length === 1 ? sources[0] : void 0;
|
|
12468
12558
|
const resolved = only === void 0 ? null : resolveDecl(only, calleeName);
|
|
@@ -12484,19 +12574,35 @@ function resolveCallee(call, calleeName, scan) {
|
|
|
12484
12574
|
}
|
|
12485
12575
|
};
|
|
12486
12576
|
}
|
|
12577
|
+
function resolveJsxReference(node) {
|
|
12578
|
+
if (!import_ts_morph57.Node.isJsxOpeningElement(node) && !import_ts_morph57.Node.isJsxSelfClosingElement(node)) {
|
|
12579
|
+
return null;
|
|
12580
|
+
}
|
|
12581
|
+
const tag = node.getTagNameNode();
|
|
12582
|
+
if (!import_ts_morph57.Node.isIdentifier(tag) || !/^[A-Z]/.test(tag.getText())) {
|
|
12583
|
+
return null;
|
|
12584
|
+
}
|
|
12585
|
+
const name = tag.getText();
|
|
12586
|
+
const declarations = declarationsBehind(tag.getSymbol());
|
|
12587
|
+
for (const decl of declarations) {
|
|
12588
|
+
const resolved = resolveDecl(decl, name);
|
|
12589
|
+
if (resolved !== null) {
|
|
12590
|
+
return { tag: name, outcome: { kind: "followed", candidate: resolved } };
|
|
12591
|
+
}
|
|
12592
|
+
}
|
|
12593
|
+
return {
|
|
12594
|
+
tag: name,
|
|
12595
|
+
outcome: {
|
|
12596
|
+
kind: "stopped",
|
|
12597
|
+
stop: { callee: name, reason: classifyStop(declarations) }
|
|
12598
|
+
}
|
|
12599
|
+
};
|
|
12600
|
+
}
|
|
12487
12601
|
function collectReachable(func, scan) {
|
|
12488
12602
|
const candidates = [];
|
|
12489
12603
|
const stops = [];
|
|
12490
12604
|
const seen = /* @__PURE__ */ new Set();
|
|
12491
|
-
|
|
12492
|
-
if (!import_ts_morph56.Node.isCallExpression(node)) {
|
|
12493
|
-
return;
|
|
12494
|
-
}
|
|
12495
|
-
const calleeText = normalizeCallee(node.getExpression().getText());
|
|
12496
|
-
const outcome = resolveCallee(node, calleeText, scan);
|
|
12497
|
-
if (outcome === null) {
|
|
12498
|
-
return;
|
|
12499
|
-
}
|
|
12605
|
+
const record = (outcome) => {
|
|
12500
12606
|
if (outcome.kind === "stopped") {
|
|
12501
12607
|
const stopKey = `${outcome.stop.reason}:${outcome.stop.callee}`;
|
|
12502
12608
|
if (!seen.has(stopKey) && worthRecording(outcome.stop.reason)) {
|
|
@@ -12511,6 +12617,22 @@ function collectReachable(func, scan) {
|
|
|
12511
12617
|
}
|
|
12512
12618
|
seen.add(key);
|
|
12513
12619
|
candidates.push(outcome.candidate);
|
|
12620
|
+
};
|
|
12621
|
+
func.forEachDescendant((node) => {
|
|
12622
|
+
const jsx = resolveJsxReference(node);
|
|
12623
|
+
if (jsx !== null) {
|
|
12624
|
+
record(jsx.outcome);
|
|
12625
|
+
return;
|
|
12626
|
+
}
|
|
12627
|
+
if (!import_ts_morph57.Node.isCallExpression(node)) {
|
|
12628
|
+
return;
|
|
12629
|
+
}
|
|
12630
|
+
const calleeText = normalizeCallee(node.getExpression().getText());
|
|
12631
|
+
const outcome = resolveCallee(node, calleeText, scan);
|
|
12632
|
+
if (outcome === null) {
|
|
12633
|
+
return;
|
|
12634
|
+
}
|
|
12635
|
+
record(outcome);
|
|
12514
12636
|
});
|
|
12515
12637
|
return { candidates, stops };
|
|
12516
12638
|
}
|
|
@@ -12572,7 +12694,7 @@ function recognizerOnlyRoots(packsByFile) {
|
|
|
12572
12694
|
}
|
|
12573
12695
|
for (const declaration of variableStatement.getDeclarations()) {
|
|
12574
12696
|
const init = declaration.getInitializer();
|
|
12575
|
-
if (init !== void 0 && (
|
|
12697
|
+
if (init !== void 0 && (import_ts_morph57.Node.isArrowFunction(init) || import_ts_morph57.Node.isFunctionExpression(init)) && hasBody(init)) {
|
|
12576
12698
|
roots.push({ func: init, name: declaration.getName() });
|
|
12577
12699
|
}
|
|
12578
12700
|
}
|
|
@@ -12713,7 +12835,7 @@ function recordStops(stopsByKey, summariesByKey, options) {
|
|
|
12713
12835
|
}
|
|
12714
12836
|
|
|
12715
12837
|
// src/resolve/rethrowEnrichment.ts
|
|
12716
|
-
var
|
|
12838
|
+
var import_ts_morph58 = require("ts-morph");
|
|
12717
12839
|
var import_datalog5 = require("@suss/datalog");
|
|
12718
12840
|
var RETHROW_RULES = [
|
|
12719
12841
|
(0, import_datalog5.rule)(
|
|
@@ -12853,7 +12975,7 @@ function findBareRethrow(func, location) {
|
|
|
12853
12975
|
traversal.stop();
|
|
12854
12976
|
return;
|
|
12855
12977
|
}
|
|
12856
|
-
if (!
|
|
12978
|
+
if (!import_ts_morph58.Node.isThrowStatement(node)) {
|
|
12857
12979
|
return;
|
|
12858
12980
|
}
|
|
12859
12981
|
if (startLineOf(node) !== location.start) {
|
|
@@ -12863,7 +12985,7 @@ function findBareRethrow(func, location) {
|
|
|
12863
12985
|
return;
|
|
12864
12986
|
}
|
|
12865
12987
|
const thrown = node.getExpression();
|
|
12866
|
-
if (thrown !== void 0 &&
|
|
12988
|
+
if (thrown !== void 0 && import_ts_morph58.Node.isIdentifier(thrown)) {
|
|
12867
12989
|
found = node;
|
|
12868
12990
|
}
|
|
12869
12991
|
});
|
|
@@ -12873,13 +12995,13 @@ function enclosingTry(throwStmt) {
|
|
|
12873
12995
|
let current2 = throwStmt.getParent();
|
|
12874
12996
|
let sawCatchClause = false;
|
|
12875
12997
|
while (current2 !== void 0) {
|
|
12876
|
-
if (
|
|
12998
|
+
if (import_ts_morph58.Node.isCatchClause(current2)) {
|
|
12877
12999
|
sawCatchClause = true;
|
|
12878
13000
|
}
|
|
12879
|
-
if (
|
|
13001
|
+
if (import_ts_morph58.Node.isTryStatement(current2)) {
|
|
12880
13002
|
return sawCatchClause ? current2 : null;
|
|
12881
13003
|
}
|
|
12882
|
-
if (
|
|
13004
|
+
if (import_ts_morph58.Node.isFunctionDeclaration(current2) || import_ts_morph58.Node.isFunctionExpression(current2) || import_ts_morph58.Node.isArrowFunction(current2) || import_ts_morph58.Node.isMethodDeclaration(current2)) {
|
|
12883
13005
|
return null;
|
|
12884
13006
|
}
|
|
12885
13007
|
current2 = current2.getParent();
|
|
@@ -12887,14 +13009,14 @@ function enclosingTry(throwStmt) {
|
|
|
12887
13009
|
return null;
|
|
12888
13010
|
}
|
|
12889
13011
|
function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
12890
|
-
if (!
|
|
13012
|
+
if (!import_ts_morph58.Node.isTryStatement(tryStmt)) {
|
|
12891
13013
|
return [];
|
|
12892
13014
|
}
|
|
12893
13015
|
const tryBlock = tryStmt.getTryBlock();
|
|
12894
13016
|
const callees = [];
|
|
12895
13017
|
const seen = /* @__PURE__ */ new Set();
|
|
12896
13018
|
tryBlock.forEachDescendant((node) => {
|
|
12897
|
-
if (!
|
|
13019
|
+
if (!import_ts_morph58.Node.isCallExpression(node)) {
|
|
12898
13020
|
return;
|
|
12899
13021
|
}
|
|
12900
13022
|
const calleeSummary = resolveCalleeSummary(node, index);
|
|
@@ -12911,7 +13033,7 @@ function collectTryBodyCallees(tryStmt, index, keyFor) {
|
|
|
12911
13033
|
return callees;
|
|
12912
13034
|
}
|
|
12913
13035
|
function resolveCalleeSummary(call, index) {
|
|
12914
|
-
if (!
|
|
13036
|
+
if (!import_ts_morph58.Node.isCallExpression(call)) {
|
|
12915
13037
|
return null;
|
|
12916
13038
|
}
|
|
12917
13039
|
const callee = call.getExpression();
|
|
@@ -12937,12 +13059,12 @@ function resolveCalleeSummary(call, index) {
|
|
|
12937
13059
|
return null;
|
|
12938
13060
|
}
|
|
12939
13061
|
function functionFromDecl(decl) {
|
|
12940
|
-
if (
|
|
13062
|
+
if (import_ts_morph58.Node.isFunctionDeclaration(decl) || import_ts_morph58.Node.isFunctionExpression(decl) || import_ts_morph58.Node.isArrowFunction(decl) || import_ts_morph58.Node.isMethodDeclaration(decl)) {
|
|
12941
13063
|
return decl;
|
|
12942
13064
|
}
|
|
12943
|
-
if (
|
|
13065
|
+
if (import_ts_morph58.Node.isVariableDeclaration(decl)) {
|
|
12944
13066
|
const init = decl.getInitializer();
|
|
12945
|
-
if (init !== void 0 && (
|
|
13067
|
+
if (init !== void 0 && (import_ts_morph58.Node.isArrowFunction(init) || import_ts_morph58.Node.isFunctionExpression(init))) {
|
|
12946
13068
|
return init;
|
|
12947
13069
|
}
|
|
12948
13070
|
}
|
|
@@ -12950,22 +13072,22 @@ function functionFromDecl(decl) {
|
|
|
12950
13072
|
}
|
|
12951
13073
|
|
|
12952
13074
|
// src/shapes/fieldAccesses.ts
|
|
12953
|
-
var
|
|
13075
|
+
var import_ts_morph59 = require("ts-morph");
|
|
12954
13076
|
function findResponseAccessor(callExpr) {
|
|
12955
13077
|
let current2 = callExpr;
|
|
12956
13078
|
const parent1 = current2.getParent();
|
|
12957
|
-
if (parent1 !== void 0 &&
|
|
13079
|
+
if (parent1 !== void 0 && import_ts_morph59.Node.isAwaitExpression(parent1)) {
|
|
12958
13080
|
current2 = parent1;
|
|
12959
13081
|
}
|
|
12960
13082
|
const parent2 = current2.getParent();
|
|
12961
|
-
if (parent2 === void 0 || !
|
|
13083
|
+
if (parent2 === void 0 || !import_ts_morph59.Node.isVariableDeclaration(parent2)) {
|
|
12962
13084
|
return null;
|
|
12963
13085
|
}
|
|
12964
13086
|
const nameNode = parent2.getNameNode();
|
|
12965
|
-
if (
|
|
13087
|
+
if (import_ts_morph59.Node.isIdentifier(nameNode)) {
|
|
12966
13088
|
return { kind: "identifier", name: nameNode.getText() };
|
|
12967
13089
|
}
|
|
12968
|
-
if (
|
|
13090
|
+
if (import_ts_morph59.Node.isObjectBindingPattern(nameNode)) {
|
|
12969
13091
|
const bindings = /* @__PURE__ */ new Map();
|
|
12970
13092
|
for (const element of nameNode.getElements()) {
|
|
12971
13093
|
if (element.getDotDotDotToken() !== void 0) {
|
|
@@ -12986,11 +13108,11 @@ function findResponseAccessor(callExpr) {
|
|
|
12986
13108
|
function buildThenChainAccessor(callExpr, func) {
|
|
12987
13109
|
const bindings = /* @__PURE__ */ new Map();
|
|
12988
13110
|
func.forEachDescendant((node) => {
|
|
12989
|
-
if (!
|
|
13111
|
+
if (!import_ts_morph59.Node.isParameterDeclaration(node)) {
|
|
12990
13112
|
return;
|
|
12991
13113
|
}
|
|
12992
13114
|
const nameNode = node.getNameNode();
|
|
12993
|
-
if (!
|
|
13115
|
+
if (!import_ts_morph59.Node.isIdentifier(nameNode)) {
|
|
12994
13116
|
return;
|
|
12995
13117
|
}
|
|
12996
13118
|
const prefix = prefixOfThenParam(node, callExpr, 0);
|
|
@@ -13022,7 +13144,7 @@ function prefixOfExpr(expr, responseCall, depth) {
|
|
|
13022
13144
|
if (node === responseCall) {
|
|
13023
13145
|
return [];
|
|
13024
13146
|
}
|
|
13025
|
-
if (
|
|
13147
|
+
if (import_ts_morph59.Node.isCallExpression(node)) {
|
|
13026
13148
|
const hop = thenLikeCall(node);
|
|
13027
13149
|
if (hop !== null) {
|
|
13028
13150
|
if (hop.method === "catch") {
|
|
@@ -13054,14 +13176,14 @@ function prefixOfMemberExpr(expr, responseCall, depth) {
|
|
|
13054
13176
|
return null;
|
|
13055
13177
|
}
|
|
13056
13178
|
const decl = chain.root.getSymbol()?.getDeclarations()?.[0];
|
|
13057
|
-
if (decl === void 0 || !
|
|
13179
|
+
if (decl === void 0 || !import_ts_morph59.Node.isParameterDeclaration(decl)) {
|
|
13058
13180
|
return null;
|
|
13059
13181
|
}
|
|
13060
13182
|
const base = prefixOfThenParam(decl, responseCall, depth + 1);
|
|
13061
13183
|
return base === null ? null : [...base, ...chain.segments];
|
|
13062
13184
|
}
|
|
13063
13185
|
function firstCallbackParamName(callback) {
|
|
13064
|
-
if (callback === void 0 || !(
|
|
13186
|
+
if (callback === void 0 || !(import_ts_morph59.Node.isArrowFunction(callback) || import_ts_morph59.Node.isFunctionExpression(callback))) {
|
|
13065
13187
|
return null;
|
|
13066
13188
|
}
|
|
13067
13189
|
const param = callback.getParameters()[0];
|
|
@@ -13069,11 +13191,11 @@ function firstCallbackParamName(callback) {
|
|
|
13069
13191
|
return null;
|
|
13070
13192
|
}
|
|
13071
13193
|
const nameNode = param.getNameNode();
|
|
13072
|
-
return
|
|
13194
|
+
return import_ts_morph59.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
13073
13195
|
}
|
|
13074
13196
|
function unwrap2(expr) {
|
|
13075
13197
|
let node = expr;
|
|
13076
|
-
while (
|
|
13198
|
+
while (import_ts_morph59.Node.isAwaitExpression(node) || import_ts_morph59.Node.isParenthesizedExpression(node) || import_ts_morph59.Node.isAsExpression(node)) {
|
|
13077
13199
|
node = node.getExpression();
|
|
13078
13200
|
}
|
|
13079
13201
|
return node;
|
|
@@ -13083,15 +13205,15 @@ function chainRootedAt(expr, rootName) {
|
|
|
13083
13205
|
if (chain === null) {
|
|
13084
13206
|
return null;
|
|
13085
13207
|
}
|
|
13086
|
-
return
|
|
13208
|
+
return import_ts_morph59.Node.isIdentifier(chain.root) && chain.root.getText() === rootName ? chain.segments : null;
|
|
13087
13209
|
}
|
|
13088
13210
|
function memberChain(expr) {
|
|
13089
|
-
let node =
|
|
13090
|
-
if (
|
|
13211
|
+
let node = import_ts_morph59.Node.isExpression(expr) ? unwrap2(expr) : expr;
|
|
13212
|
+
if (import_ts_morph59.Node.isCallExpression(node)) {
|
|
13091
13213
|
node = node.getExpression();
|
|
13092
13214
|
}
|
|
13093
13215
|
const segments = [];
|
|
13094
|
-
while (
|
|
13216
|
+
while (import_ts_morph59.Node.isPropertyAccessExpression(node)) {
|
|
13095
13217
|
segments.unshift(node.getName());
|
|
13096
13218
|
node = node.getExpression();
|
|
13097
13219
|
}
|
|
@@ -13110,16 +13232,16 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
13110
13232
|
if (accessor.kind === "identifier") {
|
|
13111
13233
|
const varName = accessor.name;
|
|
13112
13234
|
subtree.forEachDescendant((node) => {
|
|
13113
|
-
if (!
|
|
13235
|
+
if (!import_ts_morph59.Node.isPropertyAccessExpression(node)) {
|
|
13114
13236
|
return;
|
|
13115
13237
|
}
|
|
13116
13238
|
const chain = [];
|
|
13117
13239
|
let current2 = node;
|
|
13118
|
-
while (
|
|
13240
|
+
while (import_ts_morph59.Node.isPropertyAccessExpression(current2)) {
|
|
13119
13241
|
chain.unshift(current2.getName());
|
|
13120
13242
|
current2 = current2.getExpression();
|
|
13121
13243
|
}
|
|
13122
|
-
if (
|
|
13244
|
+
if (import_ts_morph59.Node.isIdentifier(current2) && current2.getText() === varName) {
|
|
13123
13245
|
pushChain(chain);
|
|
13124
13246
|
}
|
|
13125
13247
|
});
|
|
@@ -13130,7 +13252,7 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
13130
13252
|
return source === void 0 ? void 0 : [source];
|
|
13131
13253
|
} : (name) => accessor.bindings.get(name);
|
|
13132
13254
|
subtree.forEachDescendant((node) => {
|
|
13133
|
-
if (!
|
|
13255
|
+
if (!import_ts_morph59.Node.isIdentifier(node)) {
|
|
13134
13256
|
return;
|
|
13135
13257
|
}
|
|
13136
13258
|
const prefix = prefixOf(node.getText());
|
|
@@ -13142,13 +13264,13 @@ function collectPropertyAccesses(subtree, accessor) {
|
|
|
13142
13264
|
}
|
|
13143
13265
|
let chainTop = node;
|
|
13144
13266
|
let parent = chainTop.getParent();
|
|
13145
|
-
while (parent !== void 0 &&
|
|
13267
|
+
while (parent !== void 0 && import_ts_morph59.Node.isPropertyAccessExpression(parent) && parent.getExpression() === chainTop) {
|
|
13146
13268
|
chainTop = parent;
|
|
13147
13269
|
parent = chainTop.getParent();
|
|
13148
13270
|
}
|
|
13149
13271
|
const segments = [];
|
|
13150
13272
|
let current2 = chainTop;
|
|
13151
|
-
while (
|
|
13273
|
+
while (import_ts_morph59.Node.isPropertyAccessExpression(current2)) {
|
|
13152
13274
|
segments.push(current2.getName());
|
|
13153
13275
|
current2 = current2.getExpression();
|
|
13154
13276
|
}
|
|
@@ -13162,15 +13284,15 @@ function isBindingDeclarationSite(node) {
|
|
|
13162
13284
|
return true;
|
|
13163
13285
|
}
|
|
13164
13286
|
const parent = node.getParent();
|
|
13165
|
-
return parent !== void 0 &&
|
|
13287
|
+
return parent !== void 0 && import_ts_morph59.Node.isParameterDeclaration(parent) && parent.getNameNode() === node;
|
|
13166
13288
|
}
|
|
13167
13289
|
function isInsideObjectBindingPattern(node) {
|
|
13168
13290
|
let current2 = node.getParent();
|
|
13169
13291
|
while (current2 !== void 0) {
|
|
13170
|
-
if (
|
|
13292
|
+
if (import_ts_morph59.Node.isObjectBindingPattern(current2)) {
|
|
13171
13293
|
return true;
|
|
13172
13294
|
}
|
|
13173
|
-
if (
|
|
13295
|
+
if (import_ts_morph59.Node.isFunctionLikeDeclaration(current2) || import_ts_morph59.Node.isVariableStatement(current2)) {
|
|
13174
13296
|
break;
|
|
13175
13297
|
}
|
|
13176
13298
|
current2 = current2.getParent();
|
|
@@ -13233,7 +13355,7 @@ function findBranchSubtree(func, byLineRange, terminalStartLine, terminalEndLine
|
|
|
13233
13355
|
if (parent === void 0) {
|
|
13234
13356
|
break;
|
|
13235
13357
|
}
|
|
13236
|
-
if (
|
|
13358
|
+
if (import_ts_morph59.Node.isIfStatement(parent)) {
|
|
13237
13359
|
const ifStmt = parent;
|
|
13238
13360
|
const thenBlock = ifStmt.getThenStatement();
|
|
13239
13361
|
const elseBlock = ifStmt.getElseStatement();
|
|
@@ -13295,7 +13417,7 @@ function buildNonBodyPropertySet(semantics) {
|
|
|
13295
13417
|
}
|
|
13296
13418
|
|
|
13297
13419
|
// src/subUnitContext.ts
|
|
13298
|
-
var
|
|
13420
|
+
var import_ts_morph60 = require("ts-morph");
|
|
13299
13421
|
function createTsSubUnitContext() {
|
|
13300
13422
|
return {
|
|
13301
13423
|
findJsxAttributes,
|
|
@@ -13308,7 +13430,7 @@ function createTsSubUnitContext() {
|
|
|
13308
13430
|
}
|
|
13309
13431
|
function skipNestedFunctions(parent) {
|
|
13310
13432
|
return (node, traversal) => {
|
|
13311
|
-
if (node !== parent && (
|
|
13433
|
+
if (node !== parent && (import_ts_morph60.Node.isFunctionDeclaration(node) || import_ts_morph60.Node.isFunctionExpression(node) || import_ts_morph60.Node.isArrowFunction(node) || import_ts_morph60.Node.isMethodDeclaration(node))) {
|
|
13312
13434
|
traversal.skip();
|
|
13313
13435
|
return true;
|
|
13314
13436
|
}
|
|
@@ -13322,18 +13444,18 @@ function findJsxAttributes(parent) {
|
|
|
13322
13444
|
if (skip(node, traversal)) {
|
|
13323
13445
|
return;
|
|
13324
13446
|
}
|
|
13325
|
-
if (!
|
|
13447
|
+
if (!import_ts_morph60.Node.isJsxOpeningElement(node) && !import_ts_morph60.Node.isJsxSelfClosingElement(node)) {
|
|
13326
13448
|
return;
|
|
13327
13449
|
}
|
|
13328
13450
|
const tag = node.getTagNameNode().getText();
|
|
13329
13451
|
for (const attr of node.getAttributes()) {
|
|
13330
|
-
if (!
|
|
13452
|
+
if (!import_ts_morph60.Node.isJsxAttribute(attr)) {
|
|
13331
13453
|
continue;
|
|
13332
13454
|
}
|
|
13333
13455
|
const initializer = attr.getInitializer();
|
|
13334
13456
|
let valueExpression = null;
|
|
13335
13457
|
if (initializer !== void 0) {
|
|
13336
|
-
if (
|
|
13458
|
+
if (import_ts_morph60.Node.isJsxExpression(initializer)) {
|
|
13337
13459
|
const inner = initializer.getExpression();
|
|
13338
13460
|
valueExpression = inner ?? null;
|
|
13339
13461
|
} else {
|
|
@@ -13356,11 +13478,11 @@ function findCallExpressionsByName(parent, name) {
|
|
|
13356
13478
|
if (skip(node, traversal)) {
|
|
13357
13479
|
return;
|
|
13358
13480
|
}
|
|
13359
|
-
if (!
|
|
13481
|
+
if (!import_ts_morph60.Node.isCallExpression(node)) {
|
|
13360
13482
|
return;
|
|
13361
13483
|
}
|
|
13362
13484
|
const callee = node.getExpression();
|
|
13363
|
-
if (
|
|
13485
|
+
if (import_ts_morph60.Node.isIdentifier(callee) && callee.getText() === name) {
|
|
13364
13486
|
out.push(node);
|
|
13365
13487
|
}
|
|
13366
13488
|
});
|
|
@@ -13371,10 +13493,10 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
13371
13493
|
if (expr === null) {
|
|
13372
13494
|
return null;
|
|
13373
13495
|
}
|
|
13374
|
-
if (
|
|
13496
|
+
if (import_ts_morph60.Node.isArrowFunction(expr) || import_ts_morph60.Node.isFunctionExpression(expr)) {
|
|
13375
13497
|
return { func: expr, localName: null };
|
|
13376
13498
|
}
|
|
13377
|
-
if (
|
|
13499
|
+
if (import_ts_morph60.Node.isIdentifier(expr)) {
|
|
13378
13500
|
const symbol = expr.getSymbol();
|
|
13379
13501
|
if (symbol === void 0) {
|
|
13380
13502
|
return null;
|
|
@@ -13393,15 +13515,15 @@ function resolveAttributeValueFunction(attr, parent) {
|
|
|
13393
13515
|
return null;
|
|
13394
13516
|
}
|
|
13395
13517
|
function tryExtractFunction(decl) {
|
|
13396
|
-
if (
|
|
13518
|
+
if (import_ts_morph60.Node.isFunctionDeclaration(decl)) {
|
|
13397
13519
|
return decl;
|
|
13398
13520
|
}
|
|
13399
|
-
if (
|
|
13521
|
+
if (import_ts_morph60.Node.isVariableDeclaration(decl)) {
|
|
13400
13522
|
const init = decl.getInitializer();
|
|
13401
13523
|
if (init === void 0) {
|
|
13402
13524
|
return null;
|
|
13403
13525
|
}
|
|
13404
|
-
if (
|
|
13526
|
+
if (import_ts_morph60.Node.isArrowFunction(init) || import_ts_morph60.Node.isFunctionExpression(init)) {
|
|
13405
13527
|
return init;
|
|
13406
13528
|
}
|
|
13407
13529
|
}
|
|
@@ -13422,7 +13544,7 @@ function getCallArgumentFunction(call, position) {
|
|
|
13422
13544
|
if (arg === void 0) {
|
|
13423
13545
|
return null;
|
|
13424
13546
|
}
|
|
13425
|
-
if (
|
|
13547
|
+
if (import_ts_morph60.Node.isArrowFunction(arg) || import_ts_morph60.Node.isFunctionExpression(arg)) {
|
|
13426
13548
|
return arg;
|
|
13427
13549
|
}
|
|
13428
13550
|
return null;
|
|
@@ -13434,7 +13556,7 @@ function readArrayLiteralText(node) {
|
|
|
13434
13556
|
if (node === null) {
|
|
13435
13557
|
return null;
|
|
13436
13558
|
}
|
|
13437
|
-
if (
|
|
13559
|
+
if (import_ts_morph60.Node.isArrayLiteralExpression(node)) {
|
|
13438
13560
|
return node.getElements().map((e) => e.getText());
|
|
13439
13561
|
}
|
|
13440
13562
|
return [node.getText()];
|
|
@@ -13852,13 +13974,13 @@ var raise = (msg) => {
|
|
|
13852
13974
|
throw new Error(msg);
|
|
13853
13975
|
};
|
|
13854
13976
|
function bindingPatternNames(nameNode) {
|
|
13855
|
-
if (
|
|
13977
|
+
if (import_ts_morph61.Node.isObjectBindingPattern(nameNode)) {
|
|
13856
13978
|
return nameNode.getElements().map((e) => e.getName());
|
|
13857
13979
|
}
|
|
13858
|
-
if (
|
|
13980
|
+
if (import_ts_morph61.Node.isArrayBindingPattern(nameNode)) {
|
|
13859
13981
|
const names = [];
|
|
13860
13982
|
for (const element of nameNode.getElements()) {
|
|
13861
|
-
if (
|
|
13983
|
+
if (import_ts_morph61.Node.isOmittedExpression(element)) {
|
|
13862
13984
|
continue;
|
|
13863
13985
|
}
|
|
13864
13986
|
names.push(element.getName());
|
|
@@ -13888,7 +14010,7 @@ function objectParamInputs(param, position, mapping) {
|
|
|
13888
14010
|
}
|
|
13889
14011
|
function componentPropsParameters(param, mapping) {
|
|
13890
14012
|
const nameNode = param.getNameNode();
|
|
13891
|
-
if (!
|
|
14013
|
+
if (!import_ts_morph61.Node.isObjectBindingPattern(nameNode)) {
|
|
13892
14014
|
const type = param.getType();
|
|
13893
14015
|
return [
|
|
13894
14016
|
{
|
|
@@ -13937,7 +14059,17 @@ function extractParameters(func, inputMapping) {
|
|
|
13937
14059
|
const param = params[i];
|
|
13938
14060
|
const nameNode = param.getNameNode();
|
|
13939
14061
|
const boundNames = bindingPatternNames(nameNode);
|
|
13940
|
-
if (
|
|
14062
|
+
if (import_ts_morph61.Node.isObjectBindingPattern(nameNode)) {
|
|
14063
|
+
for (const element of nameNode.getElements()) {
|
|
14064
|
+
const rest = element.getDotDotDotToken() !== void 0;
|
|
14065
|
+
result.push({
|
|
14066
|
+
name: element.getName(),
|
|
14067
|
+
position: i,
|
|
14068
|
+
role: rest ? "rest" : inputMapping.defaultRole ?? element.getName(),
|
|
14069
|
+
typeText: null
|
|
14070
|
+
});
|
|
14071
|
+
}
|
|
14072
|
+
} else if (boundNames !== null) {
|
|
13941
14073
|
for (const name of boundNames) {
|
|
13942
14074
|
result.push({
|
|
13943
14075
|
name,
|
|
@@ -13991,11 +14123,11 @@ function extractParameters(func, inputMapping) {
|
|
|
13991
14123
|
function extractDependencyCalls(func) {
|
|
13992
14124
|
const results = [];
|
|
13993
14125
|
func.forEachDescendant((node, traversal) => {
|
|
13994
|
-
if (node !== func && (
|
|
14126
|
+
if (node !== func && (import_ts_morph61.Node.isFunctionDeclaration(node) || import_ts_morph61.Node.isFunctionExpression(node) || import_ts_morph61.Node.isArrowFunction(node) || import_ts_morph61.Node.isMethodDeclaration(node))) {
|
|
13995
14127
|
traversal.skip();
|
|
13996
14128
|
return;
|
|
13997
14129
|
}
|
|
13998
|
-
if (!
|
|
14130
|
+
if (!import_ts_morph61.Node.isVariableDeclaration(node)) {
|
|
13999
14131
|
return;
|
|
14000
14132
|
}
|
|
14001
14133
|
const init = node.getInitializer();
|
|
@@ -14004,19 +14136,19 @@ function extractDependencyCalls(func) {
|
|
|
14004
14136
|
}
|
|
14005
14137
|
let isAsync = false;
|
|
14006
14138
|
let callExpr = init;
|
|
14007
|
-
if (
|
|
14139
|
+
if (import_ts_morph61.Node.isAwaitExpression(init)) {
|
|
14008
14140
|
isAsync = true;
|
|
14009
14141
|
callExpr = init.getExpression();
|
|
14010
14142
|
}
|
|
14011
|
-
if (!
|
|
14143
|
+
if (!import_ts_morph61.Node.isCallExpression(callExpr)) {
|
|
14012
14144
|
return;
|
|
14013
14145
|
}
|
|
14014
14146
|
const calleeName = callExpr.getExpression().getText();
|
|
14015
14147
|
const nameNode = node.getNameNode();
|
|
14016
|
-
const assignedTo =
|
|
14148
|
+
const assignedTo = import_ts_morph61.Node.isIdentifier(nameNode) ? nameNode.getText() : null;
|
|
14017
14149
|
const declList = node.getParent();
|
|
14018
14150
|
const varStmt = declList?.getParent();
|
|
14019
|
-
const locationNode = varStmt !== void 0 &&
|
|
14151
|
+
const locationNode = varStmt !== void 0 && import_ts_morph61.Node.isVariableStatement(varStmt) ? varStmt : node;
|
|
14020
14152
|
results.push({
|
|
14021
14153
|
name: calleeName,
|
|
14022
14154
|
assignedTo,
|
|
@@ -14196,6 +14328,10 @@ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers,
|
|
|
14196
14328
|
barriers
|
|
14197
14329
|
);
|
|
14198
14330
|
const depCalls = extractDependencyCalls(func);
|
|
14331
|
+
const paramReads = parameterReads(
|
|
14332
|
+
func,
|
|
14333
|
+
params.map((one) => one.name)
|
|
14334
|
+
);
|
|
14199
14335
|
if (unit.callSite !== void 0) {
|
|
14200
14336
|
const calleeText = unit.callSite.callExpression.getExpression().getText();
|
|
14201
14337
|
if (pack.responseSemantics !== void 0) {
|
|
@@ -14243,6 +14379,7 @@ function readCodeStructure(unit, pack, invocationRecognizers, accessRecognizers,
|
|
|
14243
14379
|
bodyContent: bodyContentOf(func),
|
|
14244
14380
|
dependencyCalls: depCalls,
|
|
14245
14381
|
declaredContract: null,
|
|
14382
|
+
...paramReads.length > 0 ? { extraInputReads: paramReads } : {},
|
|
14246
14383
|
...accessors,
|
|
14247
14384
|
...unit.callSite !== void 0 && pack.failureDelivery !== void 0 ? { failureDelivery: pack.failureDelivery } : {}
|
|
14248
14385
|
};
|
|
@@ -14301,9 +14438,9 @@ function extractBindingMethod(binding, callSite, pack, resolution) {
|
|
|
14301
14438
|
if (m.type === "fromArgumentProperty") {
|
|
14302
14439
|
const args = callSite.callExpression.getArguments();
|
|
14303
14440
|
const arg = args[m.position];
|
|
14304
|
-
if (arg !== void 0 &&
|
|
14441
|
+
if (arg !== void 0 && import_ts_morph61.Node.isObjectLiteralExpression(arg)) {
|
|
14305
14442
|
const prop = arg.getProperty(m.property);
|
|
14306
|
-
if (prop !== void 0 &&
|
|
14443
|
+
if (prop !== void 0 && import_ts_morph61.Node.isPropertyAssignment(prop)) {
|
|
14307
14444
|
const init = prop.getInitializer();
|
|
14308
14445
|
if (init !== void 0) {
|
|
14309
14446
|
const value = stringValueOf(init, resolution);
|
|
@@ -14386,8 +14523,8 @@ function collectAccessRecognizers(frameworks, tallies) {
|
|
|
14386
14523
|
}
|
|
14387
14524
|
return out;
|
|
14388
14525
|
}
|
|
14389
|
-
function computeSubUnitBarriers(unit,
|
|
14390
|
-
if (
|
|
14526
|
+
function computeSubUnitBarriers(unit, packs, ctx, tallies, file) {
|
|
14527
|
+
if (unit.func === null) {
|
|
14391
14528
|
return NO_BARRIERS;
|
|
14392
14529
|
}
|
|
14393
14530
|
const parentHandle = {
|
|
@@ -14395,27 +14532,27 @@ function computeSubUnitBarriers(unit, pack, ctx, tally, file) {
|
|
|
14395
14532
|
name: unit.name,
|
|
14396
14533
|
kind: unit.kind
|
|
14397
14534
|
};
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
if (subUnits
|
|
14401
|
-
|
|
14535
|
+
const barriers = /* @__PURE__ */ new Set();
|
|
14536
|
+
for (const pack of packs) {
|
|
14537
|
+
if (pack.subUnits === void 0) {
|
|
14538
|
+
continue;
|
|
14402
14539
|
}
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14540
|
+
try {
|
|
14541
|
+
for (const su of pack.subUnits(parentHandle, ctx)) {
|
|
14542
|
+
barriers.add(su.func);
|
|
14543
|
+
}
|
|
14544
|
+
} catch (err) {
|
|
14545
|
+
process.stderr.write(
|
|
14546
|
+
recordPackFailure(tallies?.get(pack.name), {
|
|
14547
|
+
pack: pack.name,
|
|
14548
|
+
hook: "subUnits",
|
|
14549
|
+
file,
|
|
14550
|
+
error: err
|
|
14551
|
+
})
|
|
14552
|
+
);
|
|
14406
14553
|
}
|
|
14407
|
-
return barriers;
|
|
14408
|
-
} catch (err) {
|
|
14409
|
-
process.stderr.write(
|
|
14410
|
-
recordPackFailure(tally, {
|
|
14411
|
-
pack: pack.name,
|
|
14412
|
-
hook: "subUnits",
|
|
14413
|
-
file,
|
|
14414
|
-
error: err
|
|
14415
|
-
})
|
|
14416
|
-
);
|
|
14417
|
-
return NO_BARRIERS;
|
|
14418
14554
|
}
|
|
14555
|
+
return barriers.size === 0 ? NO_BARRIERS : barriers;
|
|
14419
14556
|
}
|
|
14420
14557
|
function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, tallies, resolution, mountPrefixes) {
|
|
14421
14558
|
const summaries = [];
|
|
@@ -14497,9 +14634,9 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
14497
14634
|
}
|
|
14498
14635
|
const barriers = computeSubUnitBarriers(
|
|
14499
14636
|
unit,
|
|
14500
|
-
|
|
14637
|
+
frameworks,
|
|
14501
14638
|
subUnitCtx,
|
|
14502
|
-
|
|
14639
|
+
tallies,
|
|
14503
14640
|
sourceFile.getFilePath()
|
|
14504
14641
|
);
|
|
14505
14642
|
const raw = extractCodeStructure(
|
|
@@ -14840,9 +14977,9 @@ function findWrapperPathParam(summary, lookup) {
|
|
|
14840
14977
|
if (names.length === 0) {
|
|
14841
14978
|
return null;
|
|
14842
14979
|
}
|
|
14843
|
-
for (const call of func.getDescendantsOfKind(
|
|
14980
|
+
for (const call of func.getDescendantsOfKind(import_ts_morph61.SyntaxKind.CallExpression)) {
|
|
14844
14981
|
const first = call.getArguments()[0];
|
|
14845
|
-
if (first === void 0 || !
|
|
14982
|
+
if (first === void 0 || !import_ts_morph61.Node.isIdentifier(first)) {
|
|
14846
14983
|
continue;
|
|
14847
14984
|
}
|
|
14848
14985
|
const at = names.indexOf(first.getText());
|
|
@@ -14891,16 +15028,16 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
14891
15028
|
return out;
|
|
14892
15029
|
}
|
|
14893
15030
|
function wrapperNameNode(func) {
|
|
14894
|
-
if (
|
|
15031
|
+
if (import_ts_morph61.Node.isFunctionDeclaration(func) || import_ts_morph61.Node.isMethodDeclaration(func)) {
|
|
14895
15032
|
const name = func.getNameNode();
|
|
14896
|
-
if (name !== void 0 &&
|
|
15033
|
+
if (name !== void 0 && import_ts_morph61.Node.isIdentifier(name)) {
|
|
14897
15034
|
return name;
|
|
14898
15035
|
}
|
|
14899
15036
|
}
|
|
14900
15037
|
const parent = func.getParent();
|
|
14901
|
-
if (parent !== void 0 &&
|
|
15038
|
+
if (parent !== void 0 && import_ts_morph61.Node.isVariableDeclaration(parent)) {
|
|
14902
15039
|
const nameNode = parent.getNameNode();
|
|
14903
|
-
if (
|
|
15040
|
+
if (import_ts_morph61.Node.isIdentifier(nameNode)) {
|
|
14904
15041
|
return nameNode;
|
|
14905
15042
|
}
|
|
14906
15043
|
}
|
|
@@ -14909,10 +15046,10 @@ function wrapperNameNode(func) {
|
|
|
14909
15046
|
function enclosingCall(node) {
|
|
14910
15047
|
let current2 = node.getParent();
|
|
14911
15048
|
while (current2 !== void 0) {
|
|
14912
|
-
if (
|
|
15049
|
+
if (import_ts_morph61.Node.isCallExpression(current2)) {
|
|
14913
15050
|
return current2;
|
|
14914
15051
|
}
|
|
14915
|
-
if (
|
|
15052
|
+
if (import_ts_morph61.Node.isPropertyAccessExpression(current2)) {
|
|
14916
15053
|
current2 = current2.getParent();
|
|
14917
15054
|
continue;
|
|
14918
15055
|
}
|
|
@@ -14923,7 +15060,7 @@ function enclosingCall(node) {
|
|
|
14923
15060
|
function enclosingFunction(node) {
|
|
14924
15061
|
let current2 = node.getParent();
|
|
14925
15062
|
while (current2 !== void 0) {
|
|
14926
|
-
if (
|
|
15063
|
+
if (import_ts_morph61.Node.isFunctionDeclaration(current2) || import_ts_morph61.Node.isFunctionExpression(current2) || import_ts_morph61.Node.isArrowFunction(current2) || import_ts_morph61.Node.isMethodDeclaration(current2)) {
|
|
14927
15064
|
return current2;
|
|
14928
15065
|
}
|
|
14929
15066
|
current2 = current2.getParent();
|
|
@@ -14931,13 +15068,13 @@ function enclosingFunction(node) {
|
|
|
14931
15068
|
return null;
|
|
14932
15069
|
}
|
|
14933
15070
|
function callerName(func) {
|
|
14934
|
-
if (
|
|
15071
|
+
if (import_ts_morph61.Node.isFunctionDeclaration(func) || import_ts_morph61.Node.isMethodDeclaration(func)) {
|
|
14935
15072
|
return func.getName() ?? "anonymous";
|
|
14936
15073
|
}
|
|
14937
15074
|
const parent = func.getParent();
|
|
14938
|
-
if (parent !== void 0 &&
|
|
15075
|
+
if (parent !== void 0 && import_ts_morph61.Node.isVariableDeclaration(parent)) {
|
|
14939
15076
|
const nameNode = parent.getNameNode();
|
|
14940
|
-
if (
|
|
15077
|
+
if (import_ts_morph61.Node.isIdentifier(nameNode)) {
|
|
14941
15078
|
return nameNode.getText();
|
|
14942
15079
|
}
|
|
14943
15080
|
}
|
|
@@ -15049,7 +15186,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
15049
15186
|
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? import_node_path10.default.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
15050
15187
|
)
|
|
15051
15188
|
};
|
|
15052
|
-
const project = config.project ?? new
|
|
15189
|
+
const project = config.project ?? new import_ts_morph61.Project(
|
|
15053
15190
|
config.tsConfigFilePath !== void 0 ? {
|
|
15054
15191
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
15055
15192
|
skipAddingFilesFromTsConfig: true
|
|
@@ -15268,6 +15405,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
15268
15405
|
pipeline,
|
|
15269
15406
|
project,
|
|
15270
15407
|
config.frameworks,
|
|
15408
|
+
packsByFile,
|
|
15271
15409
|
config.extractorOptions,
|
|
15272
15410
|
tallies,
|
|
15273
15411
|
(created, parent) => {
|
|
@@ -15608,11 +15746,15 @@ function buildCacheAttribution(args) {
|
|
|
15608
15746
|
];
|
|
15609
15747
|
return { roots, owners };
|
|
15610
15748
|
}
|
|
15611
|
-
function synthesizeSubUnits(summaries, project, frameworks, options, tallies, onCreated) {
|
|
15749
|
+
function synthesizeSubUnits(summaries, project, frameworks, packsByFile, options, tallies, onCreated) {
|
|
15612
15750
|
const packByRecognition = /* @__PURE__ */ new Map();
|
|
15613
15751
|
for (const pack of frameworks) {
|
|
15614
15752
|
packByRecognition.set(pack.name, pack);
|
|
15615
15753
|
}
|
|
15754
|
+
const packsByPath = /* @__PURE__ */ new Map();
|
|
15755
|
+
for (const [sf, packs] of packsByFile) {
|
|
15756
|
+
packsByPath.set(sf.getFilePath(), packs);
|
|
15757
|
+
}
|
|
15616
15758
|
const allInvocationRecognizers = collectInvocationRecognizers(
|
|
15617
15759
|
frameworks,
|
|
15618
15760
|
tallies
|
|
@@ -15626,8 +15768,15 @@ function synthesizeSubUnits(summaries, project, frameworks, options, tallies, on
|
|
|
15626
15768
|
if (binding === null) {
|
|
15627
15769
|
continue;
|
|
15628
15770
|
}
|
|
15629
|
-
const
|
|
15630
|
-
|
|
15771
|
+
const discovering = packByRecognition.get(binding.recognition);
|
|
15772
|
+
const applicable = packsByPath.get(parent.location.file) ?? (discovering !== void 0 ? [discovering] : []);
|
|
15773
|
+
const hooked = [
|
|
15774
|
+
...discovering?.subUnits !== void 0 ? [discovering] : [],
|
|
15775
|
+
...applicable.filter(
|
|
15776
|
+
(one) => one.subUnits !== void 0 && one !== discovering
|
|
15777
|
+
)
|
|
15778
|
+
];
|
|
15779
|
+
if (hooked.length === 0) {
|
|
15631
15780
|
continue;
|
|
15632
15781
|
}
|
|
15633
15782
|
lookup ??= createSourceFileLookup(project);
|
|
@@ -15640,7 +15789,17 @@ function synthesizeSubUnits(summaries, project, frameworks, options, tallies, on
|
|
|
15640
15789
|
name: parent.identity.name,
|
|
15641
15790
|
kind: parent.kind
|
|
15642
15791
|
};
|
|
15643
|
-
const
|
|
15792
|
+
const claimedFuncs = /* @__PURE__ */ new Set();
|
|
15793
|
+
const subUnits = [];
|
|
15794
|
+
for (const pack of hooked) {
|
|
15795
|
+
for (const subUnit of pack.subUnits?.(parentHandle, subUnitCtx) ?? []) {
|
|
15796
|
+
if (claimedFuncs.has(subUnit.func)) {
|
|
15797
|
+
continue;
|
|
15798
|
+
}
|
|
15799
|
+
claimedFuncs.add(subUnit.func);
|
|
15800
|
+
subUnits.push(subUnit);
|
|
15801
|
+
}
|
|
15802
|
+
}
|
|
15644
15803
|
for (const subUnit of subUnits) {
|
|
15645
15804
|
const summary = buildSubUnitSummary(
|
|
15646
15805
|
subUnit,
|
|
@@ -15706,7 +15865,7 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
15706
15865
|
// src/bootstrap/noTsconfigProject.ts
|
|
15707
15866
|
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
15708
15867
|
var import_node_path11 = __toESM(require("path"), 1);
|
|
15709
|
-
var
|
|
15868
|
+
var import_ts_morph62 = require("ts-morph");
|
|
15710
15869
|
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
15711
15870
|
".ts",
|
|
15712
15871
|
".tsx",
|
|
@@ -15754,12 +15913,12 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
15754
15913
|
return found;
|
|
15755
15914
|
}
|
|
15756
15915
|
function createProjectWithoutTsconfig(rootDir) {
|
|
15757
|
-
const project = new
|
|
15916
|
+
const project = new import_ts_morph62.Project({
|
|
15758
15917
|
skipAddingFilesFromTsConfig: true,
|
|
15759
15918
|
compilerOptions: {
|
|
15760
|
-
target:
|
|
15761
|
-
module:
|
|
15762
|
-
moduleResolution:
|
|
15919
|
+
target: import_ts_morph62.ScriptTarget.ES2022,
|
|
15920
|
+
module: import_ts_morph62.ModuleKind.ESNext,
|
|
15921
|
+
moduleResolution: import_ts_morph62.ModuleResolutionKind.Bundler,
|
|
15763
15922
|
allowJs: true,
|
|
15764
15923
|
checkJs: false,
|
|
15765
15924
|
noEmit: true,
|
|
@@ -15800,7 +15959,7 @@ function findNearestTsconfig(startDir) {
|
|
|
15800
15959
|
|
|
15801
15960
|
// src/facts/why.ts
|
|
15802
15961
|
var import_node_path12 = __toESM(require("path"), 1);
|
|
15803
|
-
var
|
|
15962
|
+
var import_ts_morph63 = require("ts-morph");
|
|
15804
15963
|
var import_resolution2 = require("@suss/resolution");
|
|
15805
15964
|
var JS_PHRASES = {
|
|
15806
15965
|
bind: ({ tuple, describe }) => ({
|
|
@@ -15814,7 +15973,7 @@ var WhySession = class {
|
|
|
15814
15973
|
constructor(options) {
|
|
15815
15974
|
this.root = import_node_path12.default.resolve(options.dir);
|
|
15816
15975
|
const tsconfig = findNearestTsconfig(this.root);
|
|
15817
|
-
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new
|
|
15976
|
+
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new import_ts_morph63.Project({ tsConfigFilePath: tsconfig });
|
|
15818
15977
|
this.store = new ResolutionStore();
|
|
15819
15978
|
}
|
|
15820
15979
|
/**
|
|
@@ -15829,7 +15988,7 @@ var WhySession = class {
|
|
|
15829
15988
|
}
|
|
15830
15989
|
let found = null;
|
|
15831
15990
|
sourceFile.forEachDescendant((node) => {
|
|
15832
|
-
if (
|
|
15991
|
+
if (import_ts_morph63.Node.isExpression(node) && node.getStartLineNumber() === line && node.getText() === text && (found === null || node.getWidth() <= found.getWidth())) {
|
|
15833
15992
|
found = node;
|
|
15834
15993
|
}
|
|
15835
15994
|
});
|
|
@@ -15847,7 +16006,7 @@ var WhySession = class {
|
|
|
15847
16006
|
return null;
|
|
15848
16007
|
}
|
|
15849
16008
|
for (const call of sourceFile.getDescendantsOfKind(
|
|
15850
|
-
|
|
16009
|
+
import_ts_morph63.SyntaxKind.CallExpression
|
|
15851
16010
|
)) {
|
|
15852
16011
|
const line = call.getStartLineNumber();
|
|
15853
16012
|
if (line < startLine || line > endLine) {
|
|
@@ -15921,21 +16080,21 @@ var WhySession = class {
|
|
|
15921
16080
|
}
|
|
15922
16081
|
};
|
|
15923
16082
|
function displayNameOf(node) {
|
|
15924
|
-
if (
|
|
16083
|
+
if (import_ts_morph63.Node.isIdentifier(node) || import_ts_morph63.Node.isPropertyAccessExpression(node)) {
|
|
15925
16084
|
return node.getText();
|
|
15926
16085
|
}
|
|
15927
|
-
if (
|
|
16086
|
+
if (import_ts_morph63.Node.isCallExpression(node) || import_ts_morph63.Node.isNewExpression(node)) {
|
|
15928
16087
|
return `${node.getExpression()?.getText() ?? "call"}(...)`;
|
|
15929
16088
|
}
|
|
15930
|
-
if (
|
|
16089
|
+
if (import_ts_morph63.Node.isFunctionDeclaration(node) || import_ts_morph63.Node.isClassDeclaration(node) || import_ts_morph63.Node.isMethodDeclaration(node) || import_ts_morph63.Node.isVariableDeclaration(node)) {
|
|
15931
16090
|
const name = node.getName();
|
|
15932
16091
|
if (name !== void 0) {
|
|
15933
16092
|
return name;
|
|
15934
16093
|
}
|
|
15935
16094
|
}
|
|
15936
|
-
if (
|
|
16095
|
+
if (import_ts_morph63.Node.isArrowFunction(node) || import_ts_morph63.Node.isFunctionExpression(node)) {
|
|
15937
16096
|
const parent = node.getParent();
|
|
15938
|
-
if (parent !== void 0 &&
|
|
16097
|
+
if (parent !== void 0 && import_ts_morph63.Node.isVariableDeclaration(parent)) {
|
|
15939
16098
|
return parent.getName();
|
|
15940
16099
|
}
|
|
15941
16100
|
}
|