@systemfsoftware/stryker-js 13.0.0 → 13.1.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/CHANGELOG.md +12 -0
- package/dist/{Run.schema-BlvpjFjJ.d.mts → Run.schema-BwLLAYqu.d.mts} +1 -1
- package/dist/{Run.schema-Bj7b_FMA.mjs → Run.schema-Cv2_Kup0.mjs} +6 -3
- package/dist/{RunEnvironment.service-BJAsZsdn.d.mts → RunEnvironment.service-rkMZ8nm1.d.mts} +8 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{dist-BscHZmXN.mjs → dist-CQ7r4AaH.mjs} +315 -262
- package/dist/events.d.mts +1 -1
- package/dist/events.mjs +1 -1
- package/dist/{index-C09A80iv.d.mts → index-Ptvmn934.d.mts} +15 -5
- package/dist/index.d.mts +10 -6
- package/dist/index.mjs +3 -3
- package/dist/main.mjs +259 -51
- package/dist/{merge-config-X_AxYxMY.d.mts → merge-config-BVdwN_LJ.d.mts} +1 -1
- package/dist/{merge-config-DA_v1hGx.mjs → merge-config-DZHwEkGY.mjs} +1 -1
- package/dist/promises.d.mts +2 -2
- package/dist/promises.mjs +1 -1
- package/dist/{run-stages.cell-BN__EOCk.mjs → run-stages.cell-rdoY0cVH.mjs} +323 -255
- package/package.json +14 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Handle, Sandwich, Workflow } from "@systemfsoftware/effect-cell-types";
|
|
2
2
|
import * as Boolean$1$1 from "effect/Boolean";
|
|
3
|
-
import * as Match from "effect/Match";
|
|
3
|
+
import * as Match$1 from "effect/Match";
|
|
4
4
|
import * as Option$1 from "effect/Option";
|
|
5
5
|
import * as Predicate$1 from "effect/Predicate";
|
|
6
6
|
import * as Result from "effect/Result";
|
|
@@ -2439,7 +2439,7 @@ const nonEmptyText = Option$1.liftPredicate(S.is(S.NonEmptyString));
|
|
|
2439
2439
|
const errorTextOf$2 = (cause) => Option$1.flatMap(nonEmptyText(errorTextValueOf(cause)), (text) => ErrorText.makeOption({ text }));
|
|
2440
2440
|
const causeTextOf = (cause) => Option$1.flatMap(nonEmptyText(causeChainTextOf(cause)), (text) => CauseText.makeOption({ text }));
|
|
2441
2441
|
function errorTextValueOf(error) {
|
|
2442
|
-
return Match.value(error).pipe(Match.when(isEmptyError, () => ""), Match.when(Match.instanceOf(Error), errorText), Match.orElse(() => stringifyNonError(error)));
|
|
2442
|
+
return Match$1.value(error).pipe(Match$1.when(isEmptyError, () => ""), Match$1.when(Match$1.instanceOf(Error), errorText), Match$1.orElse(() => stringifyNonError(error)));
|
|
2443
2443
|
}
|
|
2444
2444
|
function causeChainTextOf(cause) {
|
|
2445
2445
|
return causeText(cause, 1) ?? "";
|
|
@@ -2450,30 +2450,30 @@ function readFieldOf(record, key) {
|
|
|
2450
2450
|
return record[key];
|
|
2451
2451
|
}
|
|
2452
2452
|
const fieldOf = (value, key) => Option$1.getOrUndefined(Option$1.filter(Option$1.some(value), (candidate) => Predicate$1.hasProperty(key)(candidate)).pipe(Option$1.map((record) => readFieldOf(record, key))));
|
|
2453
|
-
const hasStringCode = (error) => Match.value(fieldOf(error, "code")).pipe(Match.when(Match.string, () => true), Match.orElse(() => false));
|
|
2454
|
-
const isErrnoException = (error) => Match.value(error).pipe(Match.when(Match.instanceOf(Error), hasStringCode), Match.orElse(() => false));
|
|
2455
|
-
const isEmptyNumber = (value) => Match.value(value).pipe(Match.when(0, () => true), Match.orElse(Number.isNaN));
|
|
2456
|
-
const isEmptyError = (error) => Match.value(error).pipe(Match.when(Match.undefined, () => true), Match.when(Match.null, () => true), Match.when(Match.string, (text) => text.length === 0), Match.when(Match.number, isEmptyNumber), Match.when(Match.boolean, (value) => !value), Match.orElse(() => false));
|
|
2457
|
-
const formatErrnoException = (error) => Match.value(error.stack).pipe(Match.when(hasText, (stack) => `${error.name}: ${error.code} (${error.syscall}) ${stack}`), Match.orElse(() => `${error.name}: ${error.code} (${error.syscall})`));
|
|
2458
|
-
const formatError = (error) => Match.value(error.stack).pipe(Match.when(hasText, (stack) => `${error.name}: ${error.message}\n${stack}`), Match.orElse(() => `${error.name}: ${error.message}`));
|
|
2459
|
-
const isJsonPrimitive = (value) => Match.value(value).pipe(Match.when(Match.number, () => true), Match.when(Match.boolean, () => true), Match.when(Match.bigint, () => true), Match.orElse(() => false));
|
|
2453
|
+
const hasStringCode = (error) => Match$1.value(fieldOf(error, "code")).pipe(Match$1.when(Match$1.string, () => true), Match$1.orElse(() => false));
|
|
2454
|
+
const isErrnoException = (error) => Match$1.value(error).pipe(Match$1.when(Match$1.instanceOf(Error), hasStringCode), Match$1.orElse(() => false));
|
|
2455
|
+
const isEmptyNumber = (value) => Match$1.value(value).pipe(Match$1.when(0, () => true), Match$1.orElse(Number.isNaN));
|
|
2456
|
+
const isEmptyError = (error) => Match$1.value(error).pipe(Match$1.when(Match$1.undefined, () => true), Match$1.when(Match$1.null, () => true), Match$1.when(Match$1.string, (text) => text.length === 0), Match$1.when(Match$1.number, isEmptyNumber), Match$1.when(Match$1.boolean, (value) => !value), Match$1.orElse(() => false));
|
|
2457
|
+
const formatErrnoException = (error) => Match$1.value(error.stack).pipe(Match$1.when(hasText, (stack) => `${error.name}: ${error.code} (${error.syscall}) ${stack}`), Match$1.orElse(() => `${error.name}: ${error.code} (${error.syscall})`));
|
|
2458
|
+
const formatError = (error) => Match$1.value(error.stack).pipe(Match$1.when(hasText, (stack) => `${error.name}: ${error.message}\n${stack}`), Match$1.orElse(() => `${error.name}: ${error.message}`));
|
|
2459
|
+
const isJsonPrimitive = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.number, () => true), Match$1.when(Match$1.boolean, () => true), Match$1.when(Match$1.bigint, () => true), Match$1.orElse(() => false));
|
|
2460
2460
|
const jsonText = (error) => Result.getOrElse(Result.try({
|
|
2461
2461
|
try: () => textIfNonEmpty(JSON.stringify(error)),
|
|
2462
2462
|
catch: () => void 0
|
|
2463
2463
|
}), () => void 0);
|
|
2464
|
-
const isNonPlaceholderText = (text) => Match.value({
|
|
2464
|
+
const isNonPlaceholderText = (text) => Match$1.value({
|
|
2465
2465
|
hasLength: text.length > 0,
|
|
2466
2466
|
isPlaceholder: text === "[object Object]"
|
|
2467
|
-
}).pipe(Match.when({
|
|
2467
|
+
}).pipe(Match$1.when({
|
|
2468
2468
|
hasLength: true,
|
|
2469
2469
|
isPlaceholder: false
|
|
2470
|
-
}, () => true), Match.orElse(() => false));
|
|
2471
|
-
const isUsableText = (value) => Match.value(value).pipe(Match.when(Match.string, isNonPlaceholderText), Match.orElse(() => false));
|
|
2470
|
+
}, () => true), Match$1.orElse(() => false));
|
|
2471
|
+
const isUsableText = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.string, isNonPlaceholderText), Match$1.orElse(() => false));
|
|
2472
2472
|
const usableText = (value) => isUsableText(value) ? value : "";
|
|
2473
|
-
const objectToStringText = (value) => Match.value(fieldOf(value, "toString")).pipe(Match.when(Match.instanceOf(Function), (callable) => Result.getOrElse(Result.try({
|
|
2473
|
+
const objectToStringText = (value) => Match$1.value(fieldOf(value, "toString")).pipe(Match$1.when(Match$1.instanceOf(Function), (callable) => Result.getOrElse(Result.try({
|
|
2474
2474
|
try: () => usableText(Reflect.apply(callable, value, [])),
|
|
2475
2475
|
catch: () => ""
|
|
2476
|
-
}), () => "")), Match.orElse(() => ""));
|
|
2476
|
+
}), () => "")), Match$1.orElse(() => ""));
|
|
2477
2477
|
const toStringText = (error) => Predicate$1.isObjectOrArray(error) ? objectToStringText(error) : "";
|
|
2478
2478
|
const stringifyRest = (error) => Option$1.match(Option$1.filter(Option$1.fromUndefinedOr(jsonText(error)), hasText), {
|
|
2479
2479
|
onNone: () => toStringText(error),
|
|
@@ -2486,15 +2486,15 @@ const stringifyNonError = (error) => typeof error === "string" ? error : nonStri
|
|
|
2486
2486
|
function nonStringTextOf(error) {
|
|
2487
2487
|
return primitiveJsonOf(error) ?? stringifyRest(error);
|
|
2488
2488
|
}
|
|
2489
|
-
const errorText = (error) => Match.value(error).pipe(Match.when(isErrnoException, formatErrnoException), Match.orElse(() => formatError(error)));
|
|
2490
|
-
const errorNameOf = (value) => Match.value(value).pipe(Match.when(Match.instanceOf(Error), (error) => textIfNonEmpty(error.name)), Match.orElse(() => void 0));
|
|
2491
|
-
const tagOf = (value) => Match.value(textIfNonEmpty(fieldOf(value, "_tag"))).pipe(Match.when(hasText, (tag) => tag), Match.orElse(() => errorNameOf(value)));
|
|
2492
|
-
const textWithNested = (own, nested) => Match.value(own).pipe(Match.when(hasText, (text) => appendNested(text, nested)), Match.orElse(() => nested));
|
|
2493
|
-
const appendNested = (own, nested) => Match.value(nested).pipe(Match.when(hasText, (text) => `${own}: ${text}`), Match.orElse(() => own));
|
|
2494
|
-
const errorMessage = (error) => Match.value(error.message.length > 0).pipe(Match.when(true, () => error.message), Match.orElse(() => tagOf(error)));
|
|
2495
|
-
const errorMessageOrTag = (value) => Match.value(value).pipe(Match.when(Match.instanceOf(Error), errorMessage), Match.orElse(() => tagOf(value)));
|
|
2496
|
-
const messageText = (value) => Match.value(textIfNonEmpty(fieldOf(value, "message"))).pipe(Match.when(hasText, (message) => message), Match.orElse(() => errorMessageOrTag(value)));
|
|
2497
|
-
const ownCauseText = (value) => Match.value(textIfNonEmpty(fieldOf(value, "reason"))).pipe(Match.when(hasText, (reason) => reason), Match.orElse(() => messageText(value)));
|
|
2489
|
+
const errorText = (error) => Match$1.value(error).pipe(Match$1.when(isErrnoException, formatErrnoException), Match$1.orElse(() => formatError(error)));
|
|
2490
|
+
const errorNameOf = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.instanceOf(Error), (error) => textIfNonEmpty(error.name)), Match$1.orElse(() => void 0));
|
|
2491
|
+
const tagOf = (value) => Match$1.value(textIfNonEmpty(fieldOf(value, "_tag"))).pipe(Match$1.when(hasText, (tag) => tag), Match$1.orElse(() => errorNameOf(value)));
|
|
2492
|
+
const textWithNested = (own, nested) => Match$1.value(own).pipe(Match$1.when(hasText, (text) => appendNested(text, nested)), Match$1.orElse(() => nested));
|
|
2493
|
+
const appendNested = (own, nested) => Match$1.value(nested).pipe(Match$1.when(hasText, (text) => `${own}: ${text}`), Match$1.orElse(() => own));
|
|
2494
|
+
const errorMessage = (error) => Match$1.value(error.message.length > 0).pipe(Match$1.when(true, () => error.message), Match$1.orElse(() => tagOf(error)));
|
|
2495
|
+
const errorMessageOrTag = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.instanceOf(Error), errorMessage), Match$1.orElse(() => tagOf(value)));
|
|
2496
|
+
const messageText = (value) => Match$1.value(textIfNonEmpty(fieldOf(value, "message"))).pipe(Match$1.when(hasText, (message) => message), Match$1.orElse(() => errorMessageOrTag(value)));
|
|
2497
|
+
const ownCauseText = (value) => Match$1.value(textIfNonEmpty(fieldOf(value, "reason"))).pipe(Match$1.when(hasText, (reason) => reason), Match$1.orElse(() => messageText(value)));
|
|
2498
2498
|
const isPastDepth = (depth) => depth > 4;
|
|
2499
2499
|
const isMissingCause = (cause) => cause === void 0 || cause === null;
|
|
2500
2500
|
function causeText(cause, depth) {
|
|
@@ -2510,7 +2510,7 @@ function missingCauseTextOf(cause, depth) {
|
|
|
2510
2510
|
});
|
|
2511
2511
|
}
|
|
2512
2512
|
function causeNodeTextOf(cause, depth) {
|
|
2513
|
-
return Match.value(cause).pipe(Match.when(Match.string, (text) => textIfNonEmpty(text)), Match.orElse((value) => objectCauseTextOf(value, depth)));
|
|
2513
|
+
return Match$1.value(cause).pipe(Match$1.when(Match$1.string, (text) => textIfNonEmpty(text)), Match$1.orElse((value) => objectCauseTextOf(value, depth)));
|
|
2514
2514
|
}
|
|
2515
2515
|
function objectCauseTextOf(cause, depth) {
|
|
2516
2516
|
return Option$1.getOrUndefined(Option$1.map(Option$1.filter(Option$1.some(cause), Predicate$1.isObjectOrArray), (object) => textWithNested(ownCauseText(object), causeText(fieldOf(object, "cause"), depth + 1))));
|
|
@@ -2739,16 +2739,32 @@ var MutantsUnapplied = class extends S.TaggedError()("MutantsUnapplied", {
|
|
|
2739
2739
|
placer: PlacerNameSchema,
|
|
2740
2740
|
mutatorNames: S.Array(MutatorNameSchema),
|
|
2741
2741
|
cause: S.Defect()
|
|
2742
|
-
}) {
|
|
2742
|
+
}) {
|
|
2743
|
+
get message() {
|
|
2744
|
+
return `Failed to apply ${this.mutatorNames.join(", ")} in ${this.fileName}`;
|
|
2745
|
+
}
|
|
2746
|
+
};
|
|
2743
2747
|
var MutantNotApplied = class extends S.TaggedError()("MutantNotApplied", {
|
|
2744
2748
|
fileName: S.String,
|
|
2745
2749
|
mutatorName: MutatorNameSchema
|
|
2746
|
-
}) {
|
|
2747
|
-
|
|
2750
|
+
}) {
|
|
2751
|
+
get message() {
|
|
2752
|
+
return `Could not apply the ${this.mutatorName} mutant in ${this.fileName}`;
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
var NodeWithoutSpan = class extends S.TaggedError()("NodeWithoutSpan", { fileName: S.String }) {
|
|
2756
|
+
get message() {
|
|
2757
|
+
return `Node without a span in ${this.fileName}`;
|
|
2758
|
+
}
|
|
2759
|
+
};
|
|
2748
2760
|
var MutantsUnplaced = class extends S.TaggedError()("MutantsUnplaced", {
|
|
2749
2761
|
fileName: S.String,
|
|
2750
2762
|
detail: S.String
|
|
2751
|
-
}) {
|
|
2763
|
+
}) {
|
|
2764
|
+
get message() {
|
|
2765
|
+
return `Mutants cannot be placed. This shouldn't happen! Unplaced mutants: ${this.detail}`;
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2752
2768
|
var PlacementRefused = class extends S.TaggedError()("PlacementRefused", { message: S.String }) {};
|
|
2753
2769
|
const LINE_TERMINATOR = /\r\n|[\n\r\u2028\u2029]/g;
|
|
2754
2770
|
const lineStartsOf = (text) => [0, ...[...text.matchAll(LINE_TERMINATOR)].map((match) => match.index + match[0].length)];
|
|
@@ -3213,7 +3229,7 @@ const writeAtKey = (parent, key, index, replacement) => Option$1.match(Option$1.
|
|
|
3213
3229
|
onNone: () => void 0,
|
|
3214
3230
|
onSome: (name) => writeAtSlot(parent, name, index, replacement)
|
|
3215
3231
|
});
|
|
3216
|
-
const writeAtSlot = (parent, key, index, replacement) => Match.value(index).pipe(Match.when(Match.null, () => overwrite(parent, key, replacement)), Match.orElse((position) => writeElement(parent[key], position, replacement)));
|
|
3232
|
+
const writeAtSlot = (parent, key, index, replacement) => Match$1.value(index).pipe(Match$1.when(Match$1.null, () => overwrite(parent, key, replacement)), Match$1.orElse((position) => writeElement(parent[key], position, replacement)));
|
|
3217
3233
|
const overwrite = (parent, key, replacement) => {
|
|
3218
3234
|
parent[key] = replacement;
|
|
3219
3235
|
};
|
|
@@ -3325,26 +3341,26 @@ const EMPTY_IMPORT_TABLE = Object.freeze({
|
|
|
3325
3341
|
const buildImportTable = (program) => Arr.reduce(Arr.flatMap(Arr.filter(program.body, isImportDeclaration$1), importContributions), EMPTY_IMPORT_TABLE, applyContribution);
|
|
3326
3342
|
const withEntry = (entries, key, value) => new Map([...entries, [key, value]]);
|
|
3327
3343
|
const withMember = (members, value) => /* @__PURE__ */ new Set([...members, value]);
|
|
3328
|
-
const applyContribution = (table, contribution) => Match.value(contribution).pipe(Match.when((candidate) => candidate.kind === "module", (moduleBinding) => ({
|
|
3344
|
+
const applyContribution = (table, contribution) => Match$1.value(contribution).pipe(Match$1.when((candidate) => candidate.kind === "module", (moduleBinding) => ({
|
|
3329
3345
|
...table,
|
|
3330
3346
|
moduleBindings: withEntry(table.moduleBindings, moduleBinding.local, moduleBinding.module)
|
|
3331
|
-
})), Match.when((candidate) => candidate.kind === "namespace", (namespaceBinding) => ({
|
|
3347
|
+
})), Match$1.when((candidate) => candidate.kind === "namespace", (namespaceBinding) => ({
|
|
3332
3348
|
...table,
|
|
3333
3349
|
namespaces: withEntry(table.namespaces, namespaceBinding.local, namespaceBinding.binding)
|
|
3334
|
-
})), Match.when((candidate) => candidate.kind === "bareFunction", (bareFunction) => ({
|
|
3350
|
+
})), Match$1.when((candidate) => candidate.kind === "bareFunction", (bareFunction) => ({
|
|
3335
3351
|
...table,
|
|
3336
3352
|
bareFunctions: withEntry(table.bareFunctions, bareFunction.local, {
|
|
3337
3353
|
module: bareFunction.module,
|
|
3338
3354
|
exportName: bareFunction.exportName
|
|
3339
3355
|
})
|
|
3340
|
-
})), Match.orElse((pipeBinding) => ({
|
|
3356
|
+
})), Match$1.orElse((pipeBinding) => ({
|
|
3341
3357
|
...table,
|
|
3342
3358
|
pipeBindings: withMember(table.pipeBindings, pipeBinding.local)
|
|
3343
3359
|
})));
|
|
3344
3360
|
const importContributions = (declaration) => Option$1.toArray(onlyWhen(declaration.importKind !== "type", declaration)).flatMap((imported) => Arr.flatMap(imported.specifiers, (specifier) => Option$1.toArray(specifierContribution(imported.source.value, specifier))));
|
|
3345
|
-
const specifierContribution = (source, specifier) => Match.value(specifier).pipe(Match.when(isNamedImportSpecifier, (named) => namedSpecifierContribution(source, named)), Match.when(isNamespaceImportSpecifier, (namespace) => namespaceSpecifierContribution(source, namespace)), Match.orElse(() => Option$1.none()));
|
|
3361
|
+
const specifierContribution = (source, specifier) => Match$1.value(specifier).pipe(Match$1.when(isNamedImportSpecifier, (named) => namedSpecifierContribution(source, named)), Match$1.when(isNamespaceImportSpecifier, (namespace) => namespaceSpecifierContribution(source, namespace)), Match$1.orElse(() => Option$1.none()));
|
|
3346
3362
|
const namedSpecifierContribution = (source, specifier) => onlyWhen(specifier.importKind !== "type", specifier).pipe(Option$1.flatMap((imported) => namedContribution(source, moduleExportName(imported.imported), imported.local.name)));
|
|
3347
|
-
const namedContribution = (source, importedName, localName) => Match.value(source).pipe(Match.when((candidate) => candidate === EFFECT_SOURCE, () => effectRootContribution(importedName, localName)), Match.when((candidate) => candidate === FUNCTION_SOURCE, () => pipeContribution(importedName, localName)), Match.orElse(() => Option$1.map(moduleNameFromSource(source), (module) => bareFunctionContribution(localName, module, importedName))));
|
|
3363
|
+
const namedContribution = (source, importedName, localName) => Match$1.value(source).pipe(Match$1.when((candidate) => candidate === EFFECT_SOURCE, () => effectRootContribution(importedName, localName)), Match$1.when((candidate) => candidate === FUNCTION_SOURCE, () => pipeContribution(importedName, localName)), Match$1.orElse(() => Option$1.map(moduleNameFromSource(source), (module) => bareFunctionContribution(localName, module, importedName))));
|
|
3348
3364
|
const effectRootContribution = (importedName, localName) => Option$1.orElse(Option$1.map(moduleNameFromName(importedName), (module) => moduleContribution(localName, module)), () => pipeContribution(importedName, localName));
|
|
3349
3365
|
const pipeContribution = (importedName, localName) => onlyWhen(importedName === "pipe", pipeContributionOf(localName));
|
|
3350
3366
|
const namespaceSpecifierContribution = (source, specifier) => Option$1.map(namespaceBindingFor(source), (binding) => ({
|
|
@@ -3367,7 +3383,7 @@ const pipeContributionOf = (local) => ({
|
|
|
3367
3383
|
kind: "pipe",
|
|
3368
3384
|
local
|
|
3369
3385
|
});
|
|
3370
|
-
const namespaceBindingFor = (source) => Match.value(source).pipe(Match.when((candidate) => candidate === EFFECT_SOURCE, () => Option$1.some({ kind: "root" })), Match.when((candidate) => candidate === FUNCTION_SOURCE, () => Option$1.some({ kind: "functionModule" })), Match.orElse(() => Option$1.map(moduleNameFromSource(source), (module) => ({
|
|
3386
|
+
const namespaceBindingFor = (source) => Match$1.value(source).pipe(Match$1.when((candidate) => candidate === EFFECT_SOURCE, () => Option$1.some({ kind: "root" })), Match$1.when((candidate) => candidate === FUNCTION_SOURCE, () => Option$1.some({ kind: "functionModule" })), Match$1.orElse(() => Option$1.map(moduleNameFromSource(source), (module) => ({
|
|
3371
3387
|
kind: "module",
|
|
3372
3388
|
module
|
|
3373
3389
|
}))));
|
|
@@ -3376,7 +3392,7 @@ const moduleNameFromSource = (source) => Arr.findFirst(MODULE_NAMES, (module) =>
|
|
|
3376
3392
|
const resolveEffectCallDataFirst = (node, context) => Option$1.flatMap(programOf(context), (program) => resolveIn(node, context, buildImportTable(program)));
|
|
3377
3393
|
const resolveEffectCall = dual((args) => args.length >= 2, resolveEffectCallDataFirst);
|
|
3378
3394
|
const programOf = (context) => Arr.findLast(context.ancestors, isProgram);
|
|
3379
|
-
const resolveIn = (node, context, table) => Match.value(node).pipe(Match.when(isCallExpression$1, (call) => resolveCall(call, context, table)), Match.when(isMemberExpression, (member) => resolveReference(member, context, table)), Match.when(isIdentifier$1, (reference) => resolveReference(reference, context, table)), Match.orElse(() => Option$1.none()));
|
|
3395
|
+
const resolveIn = (node, context, table) => Match$1.value(node).pipe(Match$1.when(isCallExpression$1, (call) => resolveCall(call, context, table)), Match$1.when(isMemberExpression, (member) => resolveReference(member, context, table)), Match$1.when(isIdentifier$1, (reference) => resolveReference(reference, context, table)), Match$1.orElse(() => Option$1.none()));
|
|
3380
3396
|
const resolveCall = (call, context, table) => Option$1.flatMap(resolveCallee(call.callee, context, table), (callee) => Option$1.flatMap(spreadFreeArguments$1(call.arguments), (args) => Option$1.flatMap(callForm(callee, args, call, context, table), (form) => Option$1.some({
|
|
3381
3397
|
module: callee.module,
|
|
3382
3398
|
exportName: callee.exportName,
|
|
@@ -3392,8 +3408,8 @@ const resolveReference = (reference, context, table) => Option$1.flatMap(resolve
|
|
|
3392
3408
|
moduleAccess: moduleAccessFunction(callee, context, table)
|
|
3393
3409
|
})));
|
|
3394
3410
|
const referenceForm = (reference, context, table) => Option$1.flatMap(parentCall(context), (parent) => Option$1.map(pipePosition(parent, reference, context, table), () => PIPED_REFERENCE));
|
|
3395
|
-
const spreadFreeArguments$1 = (args) => Match.value(args.some(isSpreadElement)).pipe(Match.when(true, () => Option$1.none()), Match.orElse(() => Option$1.some(args.filter(isSpreadFree))));
|
|
3396
|
-
const resolveCallee = (callee, context, table) => Match.value(callee).pipe(Match.when(isIdentifier$1, (reference) => resolveBareCallee(reference, context, table)), Match.when(isMemberExpression, (member) => resolveMemberCallee(member, context, table)), Match.orElse(() => Option$1.none()));
|
|
3411
|
+
const spreadFreeArguments$1 = (args) => Match$1.value(args.some(isSpreadElement)).pipe(Match$1.when(true, () => Option$1.none()), Match$1.orElse(() => Option$1.some(args.filter(isSpreadFree))));
|
|
3412
|
+
const resolveCallee = (callee, context, table) => Match$1.value(callee).pipe(Match$1.when(isIdentifier$1, (reference) => resolveBareCallee(reference, context, table)), Match$1.when(isMemberExpression, (member) => resolveMemberCallee(member, context, table)), Match$1.orElse(() => Option$1.none()));
|
|
3397
3413
|
const resolveBareCallee = (reference, context, table) => Option$1.flatMap(Option$1.fromNullishOr(table.bareFunctions.get(reference.name)), (binding) => Option$1.map(unshadowedName(reference.name, context), () => ({
|
|
3398
3414
|
module: binding.module,
|
|
3399
3415
|
exportName: binding.exportName,
|
|
@@ -3404,7 +3420,7 @@ const resolveMemberCallee = (member, context, table) => Option$1.flatMap(staticM
|
|
|
3404
3420
|
exportName,
|
|
3405
3421
|
owner: Option$1.some(owner)
|
|
3406
3422
|
})));
|
|
3407
|
-
const resolveModuleObject = (expression, context, table) => Match.value(expression).pipe(Match.when(isIdentifier$1, (reference) => identifierModuleObject(reference, context, table)), Match.when(isMemberExpression, (member) => namespacedModuleObject(member, context, table)), Match.orElse(() => Option$1.none()));
|
|
3423
|
+
const resolveModuleObject = (expression, context, table) => Match$1.value(expression).pipe(Match$1.when(isIdentifier$1, (reference) => identifierModuleObject(reference, context, table)), Match$1.when(isMemberExpression, (member) => namespacedModuleObject(member, context, table)), Match$1.orElse(() => Option$1.none()));
|
|
3408
3424
|
const identifierModuleObject = (reference, context, table) => Option$1.orElse(Option$1.flatMap(Option$1.fromNullishOr(table.moduleBindings.get(reference.name)), (module) => Option$1.map(unshadowedName(reference.name, context), () => ({
|
|
3409
3425
|
module,
|
|
3410
3426
|
access: reference
|
|
@@ -3412,20 +3428,20 @@ const identifierModuleObject = (reference, context, table) => Option$1.orElse(Op
|
|
|
3412
3428
|
module,
|
|
3413
3429
|
access: reference
|
|
3414
3430
|
}))));
|
|
3415
|
-
const namespacedModuleObject = (member, context, table) => Option$1.flatMap(staticMemberName(member), (moduleName) => Option$1.flatMap(namespaceOf(member.object, context, table), (binding) => Match.value(binding).pipe(Match.when(isRootNamespace, () => Option$1.map(moduleNameFromName(moduleName), (module) => ({
|
|
3431
|
+
const namespacedModuleObject = (member, context, table) => Option$1.flatMap(staticMemberName(member), (moduleName) => Option$1.flatMap(namespaceOf(member.object, context, table), (binding) => Match$1.value(binding).pipe(Match$1.when(isRootNamespace, () => Option$1.map(moduleNameFromName(moduleName), (module) => ({
|
|
3416
3432
|
module,
|
|
3417
3433
|
access: member
|
|
3418
|
-
}))), Match.when(isModuleNamespace, (moduleNamespace) => Option$1.map(onlyWhen(moduleNamespace.module === moduleName, member), (access) => ({
|
|
3434
|
+
}))), Match$1.when(isModuleNamespace, (moduleNamespace) => Option$1.map(onlyWhen(moduleNamespace.module === moduleName, member), (access) => ({
|
|
3419
3435
|
module: moduleNamespace.module,
|
|
3420
3436
|
access
|
|
3421
|
-
}))), Match.orElse(() => Option$1.none()))));
|
|
3437
|
+
}))), Match$1.orElse(() => Option$1.none()))));
|
|
3422
3438
|
const isRootNamespace = (binding) => binding.kind === "root";
|
|
3423
|
-
const moduleOf = (binding) => Match.value(binding).pipe(Match.when(isModuleNamespace, (moduleNamespace) => Option$1.some(moduleNamespace.module)), Match.orElse(() => Option$1.none()));
|
|
3439
|
+
const moduleOf = (binding) => Match$1.value(binding).pipe(Match$1.when(isModuleNamespace, (moduleNamespace) => Option$1.some(moduleNamespace.module)), Match$1.orElse(() => Option$1.none()));
|
|
3424
3440
|
const isModuleNamespace = (binding) => binding.kind === "module";
|
|
3425
|
-
const namespaceOf = (expression, context, table) => Match.value(expression).pipe(Match.when(isIdentifier$1, (reference) => Option$1.flatMap(Option$1.fromNullishOr(table.namespaces.get(reference.name)), (binding) => Option$1.map(unshadowedName(reference.name, context), () => binding))), Match.orElse(() => Option$1.none()));
|
|
3426
|
-
const callForm = (callee, args, call, context, table) => Option$1.flatMap(arityOf(callee), (arity) => Match.value(args.length).pipe(Match.when((count) => arity.dataFirst.includes(count), () => Option$1.some(DATA_FIRST)), Match.when((count) => arity.dataLast === count, () => dataLastForm(call, context, table)), Match.orElse(() => Option$1.none())));
|
|
3441
|
+
const namespaceOf = (expression, context, table) => Match$1.value(expression).pipe(Match$1.when(isIdentifier$1, (reference) => Option$1.flatMap(Option$1.fromNullishOr(table.namespaces.get(reference.name)), (binding) => Option$1.map(unshadowedName(reference.name, context), () => binding))), Match$1.orElse(() => Option$1.none()));
|
|
3442
|
+
const callForm = (callee, args, call, context, table) => Option$1.flatMap(arityOf(callee), (arity) => Match$1.value(args.length).pipe(Match$1.when((count) => arity.dataFirst.includes(count), () => Option$1.some(DATA_FIRST)), Match$1.when((count) => arity.dataLast === count, () => dataLastForm(call, context, table)), Match$1.orElse(() => Option$1.none())));
|
|
3427
3443
|
const arityOf = (callee) => Option$1.fromNullishOr(ARITIES[`${callee.module}.${callee.exportName}`]);
|
|
3428
|
-
const dataLastForm = (call, context, table) => Option$1.flatMap(parentCall(context), (parent) => Match.value(parent.callee === call).pipe(Match.when(true, () => Option$1.some(DATA_LAST_IMMEDIATE)), Match.orElse(() => Option$1.flatMap(pipePosition(parent, call, context, table), formForPosition))));
|
|
3444
|
+
const dataLastForm = (call, context, table) => Option$1.flatMap(parentCall(context), (parent) => Match$1.value(parent.callee === call).pipe(Match$1.when(true, () => Option$1.some(DATA_LAST_IMMEDIATE)), Match$1.orElse(() => Option$1.flatMap(pipePosition(parent, call, context, table), formForPosition))));
|
|
3429
3445
|
const pipePosition = (parent, argument, context, table) => Option$1.flatMap(argumentIndex(parent.arguments, argument), (index) => Option$1.orElse(onlyWhen(isPipeMethodCall(parent), {
|
|
3430
3446
|
index,
|
|
3431
3447
|
callee: "method"
|
|
@@ -3433,16 +3449,16 @@ const pipePosition = (parent, argument, context, table) => Option$1.flatMap(argu
|
|
|
3433
3449
|
index,
|
|
3434
3450
|
callee: "effect"
|
|
3435
3451
|
})));
|
|
3436
|
-
const formForPosition = (position) => Match.value(position.callee).pipe(Match.when((callee) => callee === "method", () => Option$1.some(DATA_LAST_PIPE_METHOD)), Match.orElse(() => onlyWhen(position.index >= 1, DATA_LAST_PIPE_ARG)));
|
|
3452
|
+
const formForPosition = (position) => Match$1.value(position.callee).pipe(Match$1.when((callee) => callee === "method", () => Option$1.some(DATA_LAST_PIPE_METHOD)), Match$1.orElse(() => onlyWhen(position.index >= 1, DATA_LAST_PIPE_ARG)));
|
|
3437
3453
|
const argumentIndex = (args, node) => Option$1.flatMap(Option$1.fromNullishOr(args.findIndex((argument) => sameNode(argument, node))), (index) => onlyWhen(index >= 0, index));
|
|
3438
|
-
const parentCall = (context) => Option$1.flatMap(Option$1.fromNullishOr(context.parent), (parent) => Match.value(parent).pipe(Match.when(isCallExpression$1, (call) => Option$1.some(call)), Match.orElse(() => Option$1.none())));
|
|
3439
|
-
const isPipeMethodCall = (parent) => Match.value(parent.callee).pipe(Match.when(isMemberExpression, (member) => Option$1.exists(staticMemberName(member), (name) => name === "pipe")), Match.orElse(() => false));
|
|
3440
|
-
const isEffectPipeCall = (parent, context, table) => Match.value(parent.callee).pipe(Match.when(isIdentifier$1, (reference) => Boolean$1$1.and(isVisible(reference.name, context), table.pipeBindings.has(reference.name))), Match.when(isMemberExpression, (member) => Option$1.exists(staticMemberName(member), (name) => Boolean$1$1.and(name === "pipe", isPipeNamespace(member.object, context, table)))), Match.orElse(() => false));
|
|
3441
|
-
const isPipeNamespace = (expression, context, table) => Match.value(expression).pipe(Match.when(isIdentifier$1, (reference) => Option$1.match(namespaceOf(expression, context, table), {
|
|
3454
|
+
const parentCall = (context) => Option$1.flatMap(Option$1.fromNullishOr(context.parent), (parent) => Match$1.value(parent).pipe(Match$1.when(isCallExpression$1, (call) => Option$1.some(call)), Match$1.orElse(() => Option$1.none())));
|
|
3455
|
+
const isPipeMethodCall = (parent) => Match$1.value(parent.callee).pipe(Match$1.when(isMemberExpression, (member) => Option$1.exists(staticMemberName(member), (name) => name === "pipe")), Match$1.orElse(() => false));
|
|
3456
|
+
const isEffectPipeCall = (parent, context, table) => Match$1.value(parent.callee).pipe(Match$1.when(isIdentifier$1, (reference) => Boolean$1$1.and(isVisible(reference.name, context), table.pipeBindings.has(reference.name))), Match$1.when(isMemberExpression, (member) => Option$1.exists(staticMemberName(member), (name) => Boolean$1$1.and(name === "pipe", isPipeNamespace(member.object, context, table)))), Match$1.orElse(() => false));
|
|
3457
|
+
const isPipeNamespace = (expression, context, table) => Match$1.value(expression).pipe(Match$1.when(isIdentifier$1, (reference) => Option$1.match(namespaceOf(expression, context, table), {
|
|
3442
3458
|
onNone: () => false,
|
|
3443
3459
|
onSome: (binding) => Boolean$1$1.and(isPipeNamespaceBinding(binding), isVisible(reference.name, context))
|
|
3444
|
-
})), Match.orElse(() => false));
|
|
3445
|
-
const isPipeNamespaceBinding = (binding) => Match.value(binding.kind).pipe(Match.when((kind) => kind === "root", () => true), Match.when((kind) => kind === "functionModule", () => true), Match.orElse(() => false));
|
|
3460
|
+
})), Match$1.orElse(() => false));
|
|
3461
|
+
const isPipeNamespaceBinding = (binding) => Match$1.value(binding.kind).pipe(Match$1.when((kind) => kind === "root", () => true), Match$1.when((kind) => kind === "functionModule", () => true), Match$1.orElse(() => false));
|
|
3446
3462
|
const moduleAccessFunction = (callee, context, table) => (module) => Arr.findFirst([
|
|
3447
3463
|
ownerAccessFor(callee, module),
|
|
3448
3464
|
namedModuleAccess(module, context, table),
|
|
@@ -3458,17 +3474,17 @@ const YIELD_OR_AWAIT_KINDS = {
|
|
|
3458
3474
|
AwaitExpression: true,
|
|
3459
3475
|
YieldExpression: true
|
|
3460
3476
|
};
|
|
3461
|
-
const isDroppableArgument = (node) => Match.value(node).pipe(Match.when(isIdentifier$1, () => true), Match.when(isLiteral, () => true), Match.when(isThisExpression, () => true), Match.when(isFunctionLike, () => true), Match.when(isMemberExpression, (member) => isCallFreeMemberChain(member)), Match.orElse(() => false));
|
|
3462
|
-
const isCallFreeMemberChain = (member) => Match.value(member.computed).pipe(Match.when(true, () => false), Match.orElse(() => Match.value(member.object).pipe(Match.when(isIdentifier$1, () => true), Match.when(isThisExpression, () => true), Match.when(isMemberExpression, (inner) => isCallFreeMemberChain(inner)), Match.orElse(() => false))));
|
|
3477
|
+
const isDroppableArgument = (node) => Match$1.value(node).pipe(Match$1.when(isIdentifier$1, () => true), Match$1.when(isLiteral, () => true), Match$1.when(isThisExpression, () => true), Match$1.when(isFunctionLike, () => true), Match$1.when(isMemberExpression, (member) => isCallFreeMemberChain(member)), Match$1.orElse(() => false));
|
|
3478
|
+
const isCallFreeMemberChain = (member) => Match$1.value(member.computed).pipe(Match$1.when(true, () => false), Match$1.orElse(() => Match$1.value(member.object).pipe(Match$1.when(isIdentifier$1, () => true), Match$1.when(isThisExpression, () => true), Match$1.when(isMemberExpression, (inner) => isCallFreeMemberChain(inner)), Match$1.orElse(() => false))));
|
|
3463
3479
|
const identifiersIn = (node) => allNodesUnder(node).flatMap((candidate) => Option$1.toArray(identifierText(candidate)));
|
|
3464
3480
|
const freshIdentifierDataFirst = (base, taken) => freeIdentifier(base, taken, 0);
|
|
3465
3481
|
const freshIdentifier = dual((args) => args.length >= 2, freshIdentifierDataFirst);
|
|
3466
|
-
const freeIdentifier = (base, taken, suffix) => Match.value(taken.has(suffixedName(base, suffix))).pipe(Match.when(false, () => suffixedName(base, suffix)), Match.orElse(() => freeIdentifier(base, taken, suffix + 1)));
|
|
3467
|
-
const suffixedName = (base, suffix) => Match.value(suffix).pipe(Match.when(0, () => base), Match.orElse((count) => `${base}${count}`));
|
|
3482
|
+
const freeIdentifier = (base, taken, suffix) => Match$1.value(taken.has(suffixedName(base, suffix))).pipe(Match$1.when(false, () => suffixedName(base, suffix)), Match$1.orElse(() => freeIdentifier(base, taken, suffix + 1)));
|
|
3483
|
+
const suffixedName = (base, suffix) => Match$1.value(suffix).pipe(Match$1.when(0, () => base), Match$1.orElse((count) => `${base}${count}`));
|
|
3468
3484
|
const isShadowed = (name, context) => context.ancestors.some((ancestor) => scopeDeclares(ancestor, name));
|
|
3469
3485
|
const isVisible = (name, context) => isShadowed(name, context) === false;
|
|
3470
3486
|
const unshadowedName = (name, context) => onlyWhen(isVisible(name, context), name);
|
|
3471
|
-
const scopeDeclares = (ancestor, name) => Match.value(ancestor).pipe(Match.when(isProgram, (program) => statementsDeclare(program.body, name)), Match.when(isBlockStatement, (block) => statementsDeclare(block.body, name)), Match.when(isStaticBlock, (block) => statementsDeclare(block.body, name)), Match.when(isTSModuleBlock, (block) => statementsDeclare(block.body, name)), Match.when(isSwitchStatement, (statement) => statement.cases.some((caseClause) => statementsDeclare(caseClause.consequent, name))), Match.when(isFunctionLike, (fn) => functionDeclares(fn, name)), Match.when(isCatchClause, (clause) => patternDeclaresOr(clause.param, name)), Match.when(isForStatement, (statement) => variableDeclarationDeclaresOr(statement.init, name)), Match.when(isForInStatement, (statement) => variableDeclarationDeclaresOr(statement.left, name)), Match.when(isForOfStatement, (statement) => variableDeclarationDeclaresOr(statement.left, name)), Match.when(isClassLike, (cls) => declaresIdentifier(cls.id, name)), Match.orElse(() => false));
|
|
3487
|
+
const scopeDeclares = (ancestor, name) => Match$1.value(ancestor).pipe(Match$1.when(isProgram, (program) => statementsDeclare(program.body, name)), Match$1.when(isBlockStatement, (block) => statementsDeclare(block.body, name)), Match$1.when(isStaticBlock, (block) => statementsDeclare(block.body, name)), Match$1.when(isTSModuleBlock, (block) => statementsDeclare(block.body, name)), Match$1.when(isSwitchStatement, (statement) => statement.cases.some((caseClause) => statementsDeclare(caseClause.consequent, name))), Match$1.when(isFunctionLike, (fn) => functionDeclares(fn, name)), Match$1.when(isCatchClause, (clause) => patternDeclaresOr(clause.param, name)), Match$1.when(isForStatement, (statement) => variableDeclarationDeclaresOr(statement.init, name)), Match$1.when(isForInStatement, (statement) => variableDeclarationDeclaresOr(statement.left, name)), Match$1.when(isForOfStatement, (statement) => variableDeclarationDeclaresOr(statement.left, name)), Match$1.when(isClassLike, (cls) => declaresIdentifier(cls.id, name)), Match$1.orElse(() => false));
|
|
3472
3488
|
const functionDeclares = (fn, name) => holdsAny([
|
|
3473
3489
|
fn.params.some((param) => patternDeclaresOr(param, name)),
|
|
3474
3490
|
declaresIdentifier(fn.id, name),
|
|
@@ -3476,25 +3492,25 @@ const functionDeclares = (fn, name) => holdsAny([
|
|
|
3476
3492
|
]);
|
|
3477
3493
|
const blockBodyDeclaresHoistedVar = (body, name) => Option$1.match(Option$1.fromNullishOr(body), {
|
|
3478
3494
|
onNone: () => false,
|
|
3479
|
-
onSome: (present) => Match.value(present).pipe(Match.when(isBlockStatement, (block) => hoistedVarsDeclare(block, name)), Match.orElse(() => false))
|
|
3495
|
+
onSome: (present) => Match$1.value(present).pipe(Match$1.when(isBlockStatement, (block) => hoistedVarsDeclare(block, name)), Match$1.orElse(() => false))
|
|
3480
3496
|
});
|
|
3481
3497
|
const hoistedVarsDeclare = (block, name) => nodesOutsideFunctions(block).some((candidate) => hoistedCandidateDeclares(candidate, name));
|
|
3482
|
-
const hoistedCandidateDeclares = (candidate, name) => Match.value(candidate).pipe(Match.when(isVariableDeclaration, (declaration) => Boolean$1$1.and(declaration.kind === "var", statementBindingsDeclare(declaration, name))), Match.orElse(() => false));
|
|
3498
|
+
const hoistedCandidateDeclares = (candidate, name) => Match$1.value(candidate).pipe(Match$1.when(isVariableDeclaration, (declaration) => Boolean$1$1.and(declaration.kind === "var", statementBindingsDeclare(declaration, name))), Match$1.orElse(() => false));
|
|
3483
3499
|
const statementsDeclare = (statements, name) => statements.some((statement) => statementDeclares(statement, name));
|
|
3484
|
-
const statementDeclares = (statement, name) => Match.value(statement).pipe(Match.when(isVariableDeclaration, (declaration) => statementBindingsDeclare(declaration, name)), Match.when(isFunctionDeclaration, (declaration) => declaresIdentifier(declaration.id, name)), Match.when(isClassLike, (declaration) => declaresIdentifier(declaration.id, name)), Match.when(isTSEnumDeclaration, (declaration) => declaration.id.name === name), Match.when(isTSModuleDeclaration, (declaration) => moduleDeclarationDeclares(declaration, name)), Match.when(isTSImportEqualsDeclaration, (declaration) => importEqualsDeclares(declaration, name)), Match.when(isExportNamedDeclaration, (declaration) => Option$1.exists(Option$1.fromNullishOr(declaration.declaration), (inner) => statementDeclares(inner, name))), Match.orElse(() => false));
|
|
3500
|
+
const statementDeclares = (statement, name) => Match$1.value(statement).pipe(Match$1.when(isVariableDeclaration, (declaration) => statementBindingsDeclare(declaration, name)), Match$1.when(isFunctionDeclaration, (declaration) => declaresIdentifier(declaration.id, name)), Match$1.when(isClassLike, (declaration) => declaresIdentifier(declaration.id, name)), Match$1.when(isTSEnumDeclaration, (declaration) => declaration.id.name === name), Match$1.when(isTSModuleDeclaration, (declaration) => moduleDeclarationDeclares(declaration, name)), Match$1.when(isTSImportEqualsDeclaration, (declaration) => importEqualsDeclares(declaration, name)), Match$1.when(isExportNamedDeclaration, (declaration) => Option$1.exists(Option$1.fromNullishOr(declaration.declaration), (inner) => statementDeclares(inner, name))), Match$1.orElse(() => false));
|
|
3485
3501
|
const statementBindingsDeclare = (declaration, name) => declaration.declarations.some((declarator) => patternDeclaresOr(declarator.id, name));
|
|
3486
3502
|
const variableDeclarationDeclaresOr = (node, name) => Option$1.match(Option$1.fromNullishOr(node), {
|
|
3487
3503
|
onNone: () => false,
|
|
3488
|
-
onSome: (present) => Match.value(present).pipe(Match.when(isVariableDeclaration, (declaration) => statementBindingsDeclare(declaration, name)), Match.orElse(() => false))
|
|
3504
|
+
onSome: (present) => Match$1.value(present).pipe(Match$1.when(isVariableDeclaration, (declaration) => statementBindingsDeclare(declaration, name)), Match$1.orElse(() => false))
|
|
3489
3505
|
});
|
|
3490
3506
|
const moduleDeclarationDeclares = (declaration, name) => Boolean$1$1.and(declaration.body !== null, Option$1.exists(identifierText(declaration.id), (text) => text === name));
|
|
3491
3507
|
const importEqualsDeclares = (declaration, name) => Boolean$1$1.and(declaration.importKind !== "type", declaration.id.name === name);
|
|
3492
3508
|
const declaresIdentifier = (id, name) => Option$1.exists(identifierText(id), (text) => text === name);
|
|
3493
3509
|
const patternDeclaresOr = (pattern, name) => Option$1.match(Option$1.fromNullishOr(pattern), {
|
|
3494
3510
|
onNone: () => false,
|
|
3495
|
-
onSome: (present) => Match.value(present).pipe(Match.when(isBindingIdentifierPattern, (binding) => binding.name === name), Match.when(isObjectBindingPattern, (object) => object.properties.some((property) => propertyDeclares(property, name))), Match.when(isArrayBindingPattern, (array) => array.elements.some((element) => patternDeclaresOr(element, name))), Match.when(isAssignmentBindingPattern, (assignment) => patternDeclaresOr(assignment.left, name)), Match.when(isBindingRestElement, (rest) => patternDeclaresOr(rest.argument, name)), Match.orElse(() => false))
|
|
3511
|
+
onSome: (present) => Match$1.value(present).pipe(Match$1.when(isBindingIdentifierPattern, (binding) => binding.name === name), Match$1.when(isObjectBindingPattern, (object) => object.properties.some((property) => propertyDeclares(property, name))), Match$1.when(isArrayBindingPattern, (array) => array.elements.some((element) => patternDeclaresOr(element, name))), Match$1.when(isAssignmentBindingPattern, (assignment) => patternDeclaresOr(assignment.left, name)), Match$1.when(isBindingRestElement, (rest) => patternDeclaresOr(rest.argument, name)), Match$1.orElse(() => false))
|
|
3496
3512
|
});
|
|
3497
|
-
const propertyDeclares = (property, name) => Match.value(property).pipe(Match.when(isBindingProperty, (binding) => patternDeclaresOr(binding.value, name)), Match.when(isBindingRestElement, (rest) => patternDeclaresOr(rest.argument, name)), Match.orElse(() => false));
|
|
3513
|
+
const propertyDeclares = (property, name) => Match$1.value(property).pipe(Match$1.when(isBindingProperty, (binding) => patternDeclaresOr(binding.value, name)), Match$1.when(isBindingRestElement, (rest) => patternDeclaresOr(rest.argument, name)), Match$1.orElse(() => false));
|
|
3498
3514
|
const isBindingIdentifierPattern = (candidate) => nodeType(candidate) === "Identifier";
|
|
3499
3515
|
const isObjectBindingPattern = (candidate) => nodeType(candidate) === "ObjectPattern";
|
|
3500
3516
|
const isArrayBindingPattern = (candidate) => nodeType(candidate) === "ArrayPattern";
|
|
@@ -3503,11 +3519,11 @@ const isBindingRestElement = (candidate) => nodeType(candidate) === "RestElement
|
|
|
3503
3519
|
const isBindingProperty = (candidate) => nodeType(candidate) === "Property";
|
|
3504
3520
|
const identifierText = (node) => Option$1.match(Option$1.fromNullishOr(node), {
|
|
3505
3521
|
onNone: () => Option$1.none(),
|
|
3506
|
-
onSome: (present) => Match.value(present).pipe(Match.when(isNamedIdentifier, (name) => Option$1.some(name.name)), Match.when(isStringLiteral$1, (literal) => literalValueText(literal.value)), Match.orElse(() => Option$1.none()))
|
|
3522
|
+
onSome: (present) => Match$1.value(present).pipe(Match$1.when(isNamedIdentifier, (name) => Option$1.some(name.name)), Match$1.when(isStringLiteral$1, (literal) => literalValueText(literal.value)), Match$1.orElse(() => Option$1.none()))
|
|
3507
3523
|
});
|
|
3508
|
-
const literalValueText = (value) => Match.value(value).pipe(Match.when(Predicate$1.isString, (text) => Option$1.some(text)), Match.orElse(() => Option$1.none()));
|
|
3524
|
+
const literalValueText = (value) => Match$1.value(value).pipe(Match$1.when(Predicate$1.isString, (text) => Option$1.some(text)), Match$1.orElse(() => Option$1.none()));
|
|
3509
3525
|
const moduleExportName = (name) => Option$1.getOrElse(identifierText(name), () => "");
|
|
3510
|
-
const staticMemberName = (member) => Match.value(member.computed).pipe(Match.when(false, () => identifierText(member.property)), Match.orElse(() => Option$1.none()));
|
|
3526
|
+
const staticMemberName = (member) => Match$1.value(member.computed).pipe(Match$1.when(false, () => identifierText(member.property)), Match$1.orElse(() => Option$1.none()));
|
|
3511
3527
|
const nodesOutsideFunctions = (root) => {
|
|
3512
3528
|
const collected = [];
|
|
3513
3529
|
traverse(make(root), { enter(path) {
|
|
@@ -3529,7 +3545,7 @@ const pruneAtFunction = (path) => Option$1.match(onlyWhen(isFunctionLike(path.no
|
|
|
3529
3545
|
});
|
|
3530
3546
|
const moduleCallDataFirst = (module, property, args) => callExpression(memberExpression(module, identifier(property), false), args);
|
|
3531
3547
|
const moduleCall = dual((args) => args.length >= 3, moduleCallDataFirst);
|
|
3532
|
-
const onlyWhenDataFirst = (holds, value) => Match.value(holds).pipe(Match.when(true, () => Option$1.some(value)), Match.orElse(() => Option$1.none()));
|
|
3548
|
+
const onlyWhenDataFirst = (holds, value) => Match$1.value(holds).pipe(Match$1.when(true, () => Option$1.some(value)), Match$1.orElse(() => Option$1.none()));
|
|
3533
3549
|
const onlyWhen = dual((args) => args.length >= 2, onlyWhenDataFirst);
|
|
3534
3550
|
const holdsAny = (conditions) => conditions.some((condition) => condition);
|
|
3535
3551
|
const sameNode = (first, second) => first === second;
|
|
@@ -3587,7 +3603,7 @@ const atomicUpdateSplitMutatorDataFirst = (node, context) => Option$1.match(reso
|
|
|
3587
3603
|
});
|
|
3588
3604
|
const atomicUpdateSplitMutator = dual((args) => args.length >= 2, atomicUpdateSplitMutatorDataFirst);
|
|
3589
3605
|
const atomicUpdateSplitReplacement = (call) => Option$1.flatMap(splitOperation(call), (operation) => Option$1.some(replacementExpression$1(operation)));
|
|
3590
|
-
const splitOperation = (call) => Match.value(call).pipe(Match.when(isAtomicUpdateSplitOperation, (covered) => splitOperationOf(covered)), Match.orElse(() => Option$1.none()));
|
|
3606
|
+
const splitOperation = (call) => Match$1.value(call).pipe(Match$1.when(isAtomicUpdateSplitOperation, (covered) => splitOperationOf(covered)), Match$1.orElse(() => Option$1.none()));
|
|
3591
3607
|
const isAtomicUpdateSplitOperation = (call) => Boolean$1$1.and(included(ATOMIC_UPDATE_SPLIT_MODULES, call.module), included(ATOMIC_UPDATE_SPLIT_OPERATIONS, call.exportName));
|
|
3592
3608
|
const splitOperationOf = (call) => Option$1.flatMap(moduleBindings(call), (bindings) => Option$1.flatMap(splitArguments$1(call), (args) => Option$1.some({
|
|
3593
3609
|
effectModule: bindings.effectModule,
|
|
@@ -3597,7 +3613,7 @@ const splitOperationOf = (call) => Option$1.flatMap(moduleBindings(call), (bindi
|
|
|
3597
3613
|
f: args.f,
|
|
3598
3614
|
binders: freshBinders$1(takenNames$2(call, bindings, args.f))
|
|
3599
3615
|
})));
|
|
3600
|
-
const splitArguments$1 = (call) => Match.value(call.form).pipe(Match.when((form) => form === "data-first", () => dataFirstArguments$1(call)), Match.when((form) => form === "piped-reference", () => Option$1.none()), Match.orElse(() => dataLastArguments(call)));
|
|
3616
|
+
const splitArguments$1 = (call) => Match$1.value(call.form).pipe(Match$1.when((form) => form === "data-first", () => dataFirstArguments$1(call)), Match$1.when((form) => form === "piped-reference", () => Option$1.none()), Match$1.orElse(() => dataLastArguments(call)));
|
|
3601
3617
|
const dataFirstArguments$1 = (call) => Option$1.flatMap(Arr.get(call.args, 0), (ref) => Option$1.flatMap(Arr.get(call.args, 1), (f) => onlyWhen(Boolean$1$1.and(isMovableArgument(ref), isMovableArgument(f)), {
|
|
3602
3618
|
ref: Option$1.some(cloneNode(ref)),
|
|
3603
3619
|
f: cloneNode(f)
|
|
@@ -3650,8 +3666,8 @@ const replacementExpression = (call, effect, form, split, shape) => {
|
|
|
3650
3666
|
};
|
|
3651
3667
|
return placedBody(form, bodyExpression(plan), binders);
|
|
3652
3668
|
};
|
|
3653
|
-
const coveredForm = (call) => Match.value(call.form).pipe(Match.when("data-first", () => Option$1.some("data-first")), Match.when("data-last-pipe-arg", () => Option$1.some("data-last")), Match.when("data-last-pipe-method", () => Option$1.some("data-last")), Match.when("data-last-immediate", () => Option$1.some("data-last")), Match.orElse(() => Option$1.none()));
|
|
3654
|
-
const splitArguments = (call, form) => Match.value(form).pipe(Match.when("data-first", () => dataFirstArguments(call)), Match.orElse(() => Option$1.some({
|
|
3669
|
+
const coveredForm = (call) => Match$1.value(call.form).pipe(Match$1.when("data-first", () => Option$1.some("data-first")), Match$1.when("data-last-pipe-arg", () => Option$1.some("data-last")), Match$1.when("data-last-pipe-method", () => Option$1.some("data-last")), Match$1.when("data-last-immediate", () => Option$1.some("data-last")), Match$1.orElse(() => Option$1.none()));
|
|
3670
|
+
const splitArguments = (call, form) => Match$1.value(form).pipe(Match$1.when("data-first", () => dataFirstArguments(call)), Match$1.orElse(() => Option$1.some({
|
|
3655
3671
|
self: Option$1.none(),
|
|
3656
3672
|
rest: [...call.args]
|
|
3657
3673
|
})));
|
|
@@ -3660,7 +3676,7 @@ const dataFirstArguments = (call) => Option$1.map(Arr.get(call.args, 0), (self)
|
|
|
3660
3676
|
rest: call.args.slice(1)
|
|
3661
3677
|
}));
|
|
3662
3678
|
const selfExpression = (split, binders) => Option$1.getOrElse(split.self, () => identifier(binders.self));
|
|
3663
|
-
const shapeOf = (exportName, rest) => Match.value(exportName).pipe(Match.when("ensuring", () => finalizerShape(rest)), Match.when("onExit", () => exitShape(rest)), Match.when("onError", () => handlerShape(rest)), Match.when("onInterrupt", () => droppedHandlerShape(rest)), Match.when("acquireRelease", () => releaseShape(rest)), Match.when("acquireUseRelease", () => useReleaseShape(rest)), Match.orElse(() => Option$1.none()));
|
|
3679
|
+
const shapeOf = (exportName, rest) => Match$1.value(exportName).pipe(Match$1.when("ensuring", () => finalizerShape(rest)), Match$1.when("onExit", () => exitShape(rest)), Match$1.when("onError", () => handlerShape(rest)), Match$1.when("onInterrupt", () => droppedHandlerShape(rest)), Match$1.when("acquireRelease", () => releaseShape(rest)), Match$1.when("acquireUseRelease", () => useReleaseShape(rest)), Match$1.orElse(() => Option$1.none()));
|
|
3664
3680
|
const finalizerShape = (rest) => Option$1.flatMap(Arr.get(rest, 0), (fin) => onlyWhen(isMovableArgument(fin), {
|
|
3665
3681
|
kind: "ensuring",
|
|
3666
3682
|
fin
|
|
@@ -3691,19 +3707,19 @@ const droppableOptionAt = (rest, index) => Option$1.match(Arr.get(rest, index),
|
|
|
3691
3707
|
onNone: () => Option$1.some(true),
|
|
3692
3708
|
onSome: (argument) => onlyWhen(isDroppableArgument(argument), true)
|
|
3693
3709
|
});
|
|
3694
|
-
const bodyExpression = (plan) => Match.value(plan.shape).pipe(Match.when({ kind: "ensuring" }, (shape) => moduleCall(plan.effect, "onExitIf", [
|
|
3710
|
+
const bodyExpression = (plan) => Match$1.value(plan.shape).pipe(Match$1.when({ kind: "ensuring" }, (shape) => moduleCall(plan.effect, "onExitIf", [
|
|
3695
3711
|
plan.self,
|
|
3696
3712
|
notInterruptedPredicate(plan.binders),
|
|
3697
3713
|
arrowFunctionExpression([], shape.fin)
|
|
3698
|
-
])), Match.when({ kind: "onExit" }, (shape) => moduleCall(plan.effect, "onExitIf", [
|
|
3714
|
+
])), Match$1.when({ kind: "onExit" }, (shape) => moduleCall(plan.effect, "onExitIf", [
|
|
3699
3715
|
plan.self,
|
|
3700
3716
|
notInterruptedPredicate(plan.binders),
|
|
3701
3717
|
shape.f
|
|
3702
|
-
])), Match.when({ kind: "onError" }, (shape) => moduleCall(plan.effect, "onErrorIf", [
|
|
3718
|
+
])), Match$1.when({ kind: "onError" }, (shape) => moduleCall(plan.effect, "onErrorIf", [
|
|
3703
3719
|
plan.self,
|
|
3704
3720
|
noInterruptPredicate(plan.binders),
|
|
3705
3721
|
shape.h
|
|
3706
|
-
])), Match.when({ kind: "onInterrupt" }, () => plan.self), Match.when({ kind: "acquireRelease" }, (shape) => releaseBody(plan, shape)), Match.when({ kind: "acquireUseRelease" }, (shape) => useReleaseBody(plan, shape)), Match.exhaustive);
|
|
3722
|
+
])), Match$1.when({ kind: "onInterrupt" }, () => plan.self), Match$1.when({ kind: "acquireRelease" }, (shape) => releaseBody(plan, shape)), Match$1.when({ kind: "acquireUseRelease" }, (shape) => useReleaseBody(plan, shape)), Match$1.exhaustive);
|
|
3707
3723
|
const releaseBody = (plan, shape) => moduleCall(plan.effect, "flatMap", [moduleCall(plan.effect, "interruptible", [plan.self]), arrowFunctionExpression([identifier(plan.binders.a)], moduleCall(plan.effect, "acquireRelease", [moduleCall(plan.effect, "succeed", [identifier(plan.binders.a)]), shape.rel]))]);
|
|
3708
3724
|
const useReleaseBody = (plan, shape) => moduleCall(plan.effect, "acquireUseRelease", [
|
|
3709
3725
|
plan.self,
|
|
@@ -3711,11 +3727,11 @@ const useReleaseBody = (plan, shape) => moduleCall(plan.effect, "acquireUseRelea
|
|
|
3711
3727
|
arrowFunctionExpression([identifier(plan.binders.a), identifier(plan.binders.exit)], conditionalExpression(notInterruptedTest(plan.binders), appliedRelease(shape.rel, plan.binders, shape.releaseArity), memberExpression(plan.effect, identifier("void"), false)))
|
|
3712
3728
|
]);
|
|
3713
3729
|
const appliedRelease = (rel, binders, releaseArity) => callExpression(rel, Arr.take([identifier(binders.a), identifier(binders.exit)], releaseArity));
|
|
3714
|
-
const releaseArityOf = (rel) => Match.value(rel).pipe(Match.when(isInlineFunction, plainParameterArity), Match.orElse(() => Option$1.none()));
|
|
3730
|
+
const releaseArityOf = (rel) => Match$1.value(rel).pipe(Match$1.when(isInlineFunction, plainParameterArity), Match$1.orElse(() => Option$1.none()));
|
|
3715
3731
|
const isInlineFunction = (candidate) => nodeType(candidate) === "ArrowFunctionExpression" || nodeType(candidate) === "FunctionExpression";
|
|
3716
3732
|
const plainParameterArity = (fn) => onlyWhen(Boolean$1$1.and(fn.params.every(isPlainParameter), fn.params.length <= 2), fn.params.length);
|
|
3717
3733
|
const isPlainParameter = (param) => nodeType(param) === "Identifier";
|
|
3718
|
-
const placedBody = (form, body, binders) => Match.value(form).pipe(Match.when("data-first", () => body), Match.orElse(() => arrowFunctionExpression([identifier(binders.self)], body)));
|
|
3734
|
+
const placedBody = (form, body, binders) => Match$1.value(form).pipe(Match$1.when("data-first", () => body), Match$1.orElse(() => arrowFunctionExpression([identifier(binders.self)], body)));
|
|
3719
3735
|
const notInterruptedPredicate = (binders) => arrowFunctionExpression([identifier(binders.exit)], notInterruptedTest(binders));
|
|
3720
3736
|
const notInterruptedTest = (binders) => logicalExpression("||", tagCheck(binders.exit, SUCCESS_TAG), unaryExpression("!", interruptionSome(failureReasons(binders.exit), binders.reason)));
|
|
3721
3737
|
const noInterruptPredicate = (binders) => arrowFunctionExpression([identifier(binders.cause)], unaryExpression("!", interruptionSome(causeReasons(binders.cause), binders.reason)));
|
|
@@ -3737,16 +3753,16 @@ const synchronizationRemovalMutatorDataFirst = (node, context) => Option$1.match
|
|
|
3737
3753
|
onSome: (call) => Option$1.toArray(synchronizationRemovalReplacement(call))
|
|
3738
3754
|
});
|
|
3739
3755
|
const synchronizationRemovalMutator = dual((args) => args.length >= 2, synchronizationRemovalMutatorDataFirst);
|
|
3740
|
-
const synchronizationRemovalReplacement = (call) => Match.value(call).pipe(Match.when(isWithPermits, withPermitsReplacement), Match.when(isWithPermit, withPermitReplacement), Match.when(isUninterruptible, uninterruptibleReplacement), Match.when(isUninterruptibleMask, uninterruptibleMaskReplacement), Match.orElse(() => Option$1.none()));
|
|
3756
|
+
const synchronizationRemovalReplacement = (call) => Match$1.value(call).pipe(Match$1.when(isWithPermits, withPermitsReplacement), Match$1.when(isWithPermit, withPermitReplacement), Match$1.when(isUninterruptible, uninterruptibleReplacement), Match$1.when(isUninterruptibleMask, uninterruptibleMaskReplacement), Match$1.orElse(() => Option$1.none()));
|
|
3741
3757
|
const isWithPermits = (call) => Boolean$1$1.and(call.module === "Semaphore", call.exportName === "withPermits");
|
|
3742
3758
|
const isWithPermit = (call) => Boolean$1$1.and(call.module === "Semaphore", call.exportName === "withPermit");
|
|
3743
3759
|
const isUninterruptible = (call) => Boolean$1$1.and(call.module === "Effect", call.exportName === "uninterruptible");
|
|
3744
3760
|
const isUninterruptibleMask = (call) => Boolean$1$1.and(call.module === "Effect", call.exportName === "uninterruptibleMask");
|
|
3745
3761
|
const isDataFirst = (form) => form === "data-first";
|
|
3746
3762
|
const isPipedReference = (form) => form === "piped-reference";
|
|
3747
|
-
const withPermitsReplacement = (call) => Match.value(call.form).pipe(Match.when(isDataFirst, () => whenDroppable(call, [0, 1], (guarded) => argumentReplacement(guarded, 2))), Match.orElse(() => whenDroppable(call, [0, 1], identityFunctionOf)));
|
|
3748
|
-
const withPermitReplacement = (call) => Match.value(call.form).pipe(Match.when(isDataFirst, () => whenDroppable(call, [0], (guarded) => argumentReplacement(guarded, 1))), Match.orElse(() => whenDroppable(call, [0], identityFunctionOf)));
|
|
3749
|
-
const uninterruptibleReplacement = (call) => Match.value(call.form).pipe(Match.when(isPipedReference, () => Option$1.some(identityFunction(call))), Match.orElse(() => argumentReplacement(call, 0)));
|
|
3763
|
+
const withPermitsReplacement = (call) => Match$1.value(call.form).pipe(Match$1.when(isDataFirst, () => whenDroppable(call, [0, 1], (guarded) => argumentReplacement(guarded, 2))), Match$1.orElse(() => whenDroppable(call, [0, 1], identityFunctionOf)));
|
|
3764
|
+
const withPermitReplacement = (call) => Match$1.value(call.form).pipe(Match$1.when(isDataFirst, () => whenDroppable(call, [0], (guarded) => argumentReplacement(guarded, 1))), Match$1.orElse(() => whenDroppable(call, [0], identityFunctionOf)));
|
|
3765
|
+
const uninterruptibleReplacement = (call) => Match$1.value(call.form).pipe(Match$1.when(isPipedReference, () => Option$1.some(identityFunction(call))), Match$1.orElse(() => argumentReplacement(call, 0)));
|
|
3750
3766
|
const uninterruptibleMaskReplacement = (call) => whenMovable(call, [0], (masked) => Option$1.flatMap(masked.moduleAccess("Effect"), (effectModule) => Option$1.map(Arr.get(masked.args, 0), (f) => maskedReplacement(effectModule, f))));
|
|
3751
3767
|
const maskedReplacement = (effectModule, f) => moduleCall(effectModule, "suspend", [arrowFunctionExpression([], callExpression(cloneNode(f), [memberExpression(effectModule, identifier("interruptible"), false)]))]);
|
|
3752
3768
|
const argumentReplacement = (call, index) => Option$1.map(Arr.get(call.args, index), (argument) => cloneNode(argument));
|
|
@@ -3808,16 +3824,16 @@ function toApiMutant(mutant) {
|
|
|
3808
3824
|
});
|
|
3809
3825
|
}
|
|
3810
3826
|
function applyMutantDataFirst(mutant, originalTree) {
|
|
3811
|
-
return Match.value(originalTree === mutant.original).pipe(Match.when(true, () => Result.succeed(mutant.replacement)), Match.when(false, () => cloneWithReplacement(mutant, originalTree)), Match.exhaustive);
|
|
3827
|
+
return Match$1.value(originalTree === mutant.original).pipe(Match$1.when(true, () => Result.succeed(mutant.replacement)), Match$1.when(false, () => cloneWithReplacement(mutant, originalTree)), Match$1.exhaustive);
|
|
3812
3828
|
}
|
|
3813
3829
|
const applyMutant = dual((args) => args.length >= 2, applyMutantDataFirst);
|
|
3814
3830
|
function cloneWithReplacement(mutant, originalTree) {
|
|
3815
3831
|
const mutatedAst = cloneNode(originalTree);
|
|
3816
3832
|
const { original, replacement } = mutant;
|
|
3817
|
-
return Match.value(hasReplaced(mutatedAst, original, replacement)).pipe(Match.when(true, () => Result.succeed(mutatedAst)), Match.when(false, () => Result.fail(MutantNotApplied.make({
|
|
3833
|
+
return Match$1.value(hasReplaced(mutatedAst, original, replacement)).pipe(Match$1.when(true, () => Result.succeed(mutatedAst)), Match$1.when(false, () => Result.fail(MutantNotApplied.make({
|
|
3818
3834
|
fileName: mutant.fileName,
|
|
3819
3835
|
mutatorName: mutant.mutatorName
|
|
3820
|
-
}))), Match.exhaustive);
|
|
3836
|
+
}))), Match$1.exhaustive);
|
|
3821
3837
|
}
|
|
3822
3838
|
function hasReplaced(root, original, replacement) {
|
|
3823
3839
|
let applied = false;
|
|
@@ -3827,7 +3843,7 @@ function hasReplaced(root, original, replacement) {
|
|
|
3827
3843
|
return applied;
|
|
3828
3844
|
}
|
|
3829
3845
|
function replaceFirstMatch(path, original, replacement) {
|
|
3830
|
-
return Match.value(eqNode(path.node, original)).pipe(Match.when(false, () => false), Match.orElse(() => {
|
|
3846
|
+
return Match$1.value(eqNode(path.node, original)).pipe(Match$1.when(false, () => false), Match$1.orElse(() => {
|
|
3831
3847
|
path.replaceWith(replacement);
|
|
3832
3848
|
return true;
|
|
3833
3849
|
}));
|
|
@@ -3900,7 +3916,7 @@ function collectSplices(pattern, flags) {
|
|
|
3900
3916
|
return groups;
|
|
3901
3917
|
}
|
|
3902
3918
|
function collectAssertion(assertion, pattern, groups) {
|
|
3903
|
-
Match.value(assertion).pipe(Match.when(isEdgeAssertion, (edge) => pushAnchor(edge, pattern, groups)), Match.when(isLookaround, (lookaround) => groups.rest.push(lookaroundNegation(lookaround))), Match.orElse(() => void 0));
|
|
3919
|
+
Match$1.value(assertion).pipe(Match$1.when(isEdgeAssertion, (edge) => pushAnchor(edge, pattern, groups)), Match$1.when(isLookaround, (lookaround) => groups.rest.push(lookaroundNegation(lookaround))), Match$1.orElse(() => void 0));
|
|
3904
3920
|
}
|
|
3905
3921
|
function isEdgeAssertion(assertion) {
|
|
3906
3922
|
return assertion.kind === "start" || assertion.kind === "end";
|
|
@@ -3912,10 +3928,10 @@ function pushAnchor(edge, pattern, groups) {
|
|
|
3912
3928
|
pushWhen(anchorGroup(edge, groups), anchorRemoval(edge, pattern));
|
|
3913
3929
|
}
|
|
3914
3930
|
function anchorGroup(edge, groups) {
|
|
3915
|
-
return Match.value(edge.kind).pipe(Match.when("start", () => groups.bol), Match.orElse(() => groups.eol));
|
|
3931
|
+
return Match$1.value(edge.kind).pipe(Match$1.when("start", () => groups.bol), Match$1.orElse(() => groups.eol));
|
|
3916
3932
|
}
|
|
3917
3933
|
function lookaroundNegation(lookaround) {
|
|
3918
|
-
return Match.value(lookaround.kind).pipe(Match.when("lookahead", () => lookaroundSplice(lookaround, 2)), Match.orElse(() => lookaroundSplice(lookaround, 3)));
|
|
3934
|
+
return Match$1.value(lookaround.kind).pipe(Match$1.when("lookahead", () => lookaroundSplice(lookaround, 2)), Match$1.orElse(() => lookaroundSplice(lookaround, 3)));
|
|
3919
3935
|
}
|
|
3920
3936
|
function lookaroundSplice(lookaround, markerWidth) {
|
|
3921
3937
|
return {
|
|
@@ -3926,16 +3942,16 @@ function lookaroundSplice(lookaround, markerWidth) {
|
|
|
3926
3942
|
};
|
|
3927
3943
|
}
|
|
3928
3944
|
function negationMarker(negate) {
|
|
3929
|
-
return Match.value(negate).pipe(Match.when(true, () => "="), Match.orElse(() => "!"));
|
|
3945
|
+
return Match$1.value(negate).pipe(Match$1.when(true, () => "="), Match$1.orElse(() => "!"));
|
|
3930
3946
|
}
|
|
3931
3947
|
function collectCharacterClass(characterClass, groups) {
|
|
3932
3948
|
const pos = characterClass.start + 1;
|
|
3933
|
-
groups.rest.push(Match.value(characterClass.negate).pipe(Match.when(true, () => ({
|
|
3949
|
+
groups.rest.push(Match$1.value(characterClass.negate).pipe(Match$1.when(true, () => ({
|
|
3934
3950
|
start: pos,
|
|
3935
3951
|
end: pos + 1,
|
|
3936
3952
|
text: "",
|
|
3937
3953
|
priority: 1
|
|
3938
|
-
})), Match.orElse(() => ({
|
|
3954
|
+
})), Match$1.orElse(() => ({
|
|
3939
3955
|
start: pos,
|
|
3940
3956
|
end: pos,
|
|
3941
3957
|
text: "^",
|
|
@@ -3946,7 +3962,7 @@ function collectCharacterSet(characterSet, groups) {
|
|
|
3946
3962
|
pushWhen(groups.rest, characterSetSplice(characterSet));
|
|
3947
3963
|
}
|
|
3948
3964
|
function characterSetSplice(characterSet) {
|
|
3949
|
-
return Match.value(characterSet.kind).pipe(Match.when((kind) => NEGATABLE_CHARACTER_SETS[kind] === true, () => classSplice(characterSet)), Match.orElse(() => void 0));
|
|
3965
|
+
return Match$1.value(characterSet.kind).pipe(Match$1.when((kind) => NEGATABLE_CHARACTER_SETS[kind] === true, () => classSplice(characterSet)), Match$1.orElse(() => void 0));
|
|
3950
3966
|
}
|
|
3951
3967
|
const NEGATABLE_CHARACTER_SETS = {
|
|
3952
3968
|
digit: true,
|
|
@@ -4011,7 +4027,7 @@ function withOperator(node, operator) {
|
|
|
4011
4027
|
}
|
|
4012
4028
|
/** The mutants a condition selects, built only when it holds. */
|
|
4013
4029
|
function mutantsWhen(holds, build) {
|
|
4014
|
-
return Match.value(holds).pipe(Match.when(true, build), Match.orElse(() => NO_MUTANTS));
|
|
4030
|
+
return Match$1.value(holds).pipe(Match$1.when(true, build), Match$1.orElse(() => NO_MUTANTS));
|
|
4015
4031
|
}
|
|
4016
4032
|
const hasPropertyIn = (node, key) => key in node;
|
|
4017
4033
|
const readPropertyOf = (node, key) => hasPropertyIn(node, key) ? node[key] : void 0;
|
|
@@ -4032,7 +4048,7 @@ const arithmeticOperatorReplacements = Object.freeze({
|
|
|
4032
4048
|
"%": "*"
|
|
4033
4049
|
});
|
|
4034
4050
|
const ARITHMETIC_OPERATOR_KEYS = Object.keys(arithmeticOperatorReplacements);
|
|
4035
|
-
const arithmeticOperatorMutator = (node) => Match.value(node).pipe(Match.when(isArithmeticBinary, (binary) => [withOperator(binary, arithmeticOperatorReplacements[binary.operator])]), Match.orElse(() => NO_MUTANTS));
|
|
4051
|
+
const arithmeticOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isArithmeticBinary, (binary) => [withOperator(binary, arithmeticOperatorReplacements[binary.operator])]), Match$1.orElse(() => NO_MUTANTS));
|
|
4036
4052
|
function isArithmeticBinary(node) {
|
|
4037
4053
|
return isBinaryExpression(node) && isSupportedArithmeticOperator(node.operator, node);
|
|
4038
4054
|
}
|
|
@@ -4053,7 +4069,7 @@ function isStringConcatenation(node) {
|
|
|
4053
4069
|
function outerLeftOperand(node) {
|
|
4054
4070
|
return node.left.type === "BinaryExpression" ? node.left.right : node.left;
|
|
4055
4071
|
}
|
|
4056
|
-
const arrayDeclarationMutator = (node) => Match.value(node).pipe(Match.when(isArrayExpression, (array) => [arrayDeclarationReplacement(array)]), Match.when(isArrayConstructorCall, (construct) => [arrayConstructorReplacement(construct)]), Match.orElse(() => NO_MUTANTS));
|
|
4072
|
+
const arrayDeclarationMutator = (node) => Match$1.value(node).pipe(Match$1.when(isArrayExpression, (array) => [arrayDeclarationReplacement(array)]), Match$1.when(isArrayConstructorCall, (construct) => [arrayConstructorReplacement(construct)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4057
4073
|
function isArrayExpression(node) {
|
|
4058
4074
|
return node.type === "ArrayExpression";
|
|
4059
4075
|
}
|
|
@@ -4077,7 +4093,7 @@ function arrayConstructorReplacement(construct) {
|
|
|
4077
4093
|
function constructorArguments(args) {
|
|
4078
4094
|
return args.length > 0 ? [] : [arrayExpression([])];
|
|
4079
4095
|
}
|
|
4080
|
-
const arrowFunctionMutator = (node) => Match.value(node).pipe(Match.when(isExpressionBodiedArrow, () => [arrowFunctionExpression([], identifier("undefined"))]), Match.orElse(() => NO_MUTANTS));
|
|
4096
|
+
const arrowFunctionMutator = (node) => Match$1.value(node).pipe(Match$1.when(isExpressionBodiedArrow, () => [arrowFunctionExpression([], identifier("undefined"))]), Match$1.orElse(() => NO_MUTANTS));
|
|
4081
4097
|
function isExpressionBodiedArrow(node) {
|
|
4082
4098
|
return node.type === "ArrowFunctionExpression" && hasMutableArrowBody(node.body);
|
|
4083
4099
|
}
|
|
@@ -4119,7 +4135,7 @@ const stringAssignmentTypes = Object.freeze([
|
|
|
4119
4135
|
"??="
|
|
4120
4136
|
]);
|
|
4121
4137
|
const ASSIGNMENT_OPERATOR_KEYS = Object.keys(assignmentOperatorReplacements);
|
|
4122
|
-
const assignmentOperatorMutator = (node) => Match.value(node).pipe(Match.when(isMutatableAssignment, (assignment) => [withOperator(assignment, assignmentOperatorReplacements[assignment.operator])]), Match.orElse(() => NO_MUTANTS));
|
|
4138
|
+
const assignmentOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isMutatableAssignment, (assignment) => [withOperator(assignment, assignmentOperatorReplacements[assignment.operator])]), Match$1.orElse(() => NO_MUTANTS));
|
|
4123
4139
|
function isMutatableAssignment(node) {
|
|
4124
4140
|
return node.type === "AssignmentExpression" && isSupportedAssignment(node);
|
|
4125
4141
|
}
|
|
@@ -4196,7 +4212,7 @@ function hasSuperInChildren(node) {
|
|
|
4196
4212
|
function containsSuperInValue(value) {
|
|
4197
4213
|
return Array.isArray(value) ? value.some(containsSuperCall) : containsSuperCall(value);
|
|
4198
4214
|
}
|
|
4199
|
-
const booleanLiteralMutator = (node) => Match.value(node).pipe(Match.when(isBooleanLiteral, (literal) => [booleanLiteral(!literal.value)]), Match.when(isNegatedPrefix, (unary) => [cloneNode(unary.argument)]), Match.orElse(() => NO_MUTANTS));
|
|
4215
|
+
const booleanLiteralMutator = (node) => Match$1.value(node).pipe(Match$1.when(isBooleanLiteral, (literal) => [booleanLiteral(!literal.value)]), Match$1.when(isNegatedPrefix, (unary) => [cloneNode(unary.argument)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4200
4216
|
function isBooleanLiteral(node) {
|
|
4201
4217
|
return node.type === "Literal" && typeof node.value === "boolean";
|
|
4202
4218
|
}
|
|
@@ -4221,15 +4237,15 @@ const booleanOperators = Object.freeze([
|
|
|
4221
4237
|
">=",
|
|
4222
4238
|
"||"
|
|
4223
4239
|
]);
|
|
4224
|
-
const conditionalExpressionMutator = (node, context) => Match.value(isTestOfLoop(node, context)).pipe(Match.when(true, () => [booleanLiteral(false)]), Match.orElse(() => conditionTestMutants(node, context)));
|
|
4240
|
+
const conditionalExpressionMutator = (node, context) => Match$1.value(isTestOfLoop(node, context)).pipe(Match$1.when(true, () => [booleanLiteral(false)]), Match$1.orElse(() => conditionTestMutants(node, context)));
|
|
4225
4241
|
function conditionTestMutants(node, context) {
|
|
4226
|
-
return Match.value(isTestOfCondition(node, context)).pipe(Match.when(true, () => [booleanLiteral(true), booleanLiteral(false)]), Match.orElse(() => booleanExpressionMutants(node, context)));
|
|
4242
|
+
return Match$1.value(isTestOfCondition(node, context)).pipe(Match$1.when(true, () => [booleanLiteral(true), booleanLiteral(false)]), Match$1.orElse(() => booleanExpressionMutants(node, context)));
|
|
4227
4243
|
}
|
|
4228
4244
|
function booleanExpressionMutants(node, context) {
|
|
4229
|
-
return Match.value(isBooleanExpression(node)).pipe(Match.when(true, () => booleanExpressionReplacements(context)), Match.orElse(() => statementMutants(node)));
|
|
4245
|
+
return Match$1.value(isBooleanExpression(node)).pipe(Match$1.when(true, () => booleanExpressionReplacements(context)), Match$1.orElse(() => statementMutants(node)));
|
|
4230
4246
|
}
|
|
4231
4247
|
function statementMutants(node) {
|
|
4232
|
-
return Match.value(node).pipe(Match.when(isEmptyTestForStatement, (loop) => [withEmptyTest(loop)]), Match.when(isNonEmptySwitchCase, (switchCase) => [withEmptyConsequent(switchCase)]), Match.orElse(() => NO_MUTANTS));
|
|
4248
|
+
return Match$1.value(node).pipe(Match$1.when(isEmptyTestForStatement, (loop) => [withEmptyTest(loop)]), Match$1.when(isNonEmptySwitchCase, (switchCase) => [withEmptyConsequent(switchCase)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4233
4249
|
}
|
|
4234
4250
|
function withEmptyTest(loop) {
|
|
4235
4251
|
const replacement = cloneNode(loop);
|
|
@@ -4249,10 +4265,10 @@ function isNonEmptySwitchCase(node) {
|
|
|
4249
4265
|
}
|
|
4250
4266
|
/** A `true` test only matters in `a && b` and a `false` one in `a || b`; any other parent takes both. */
|
|
4251
4267
|
function booleanExpressionReplacements(context) {
|
|
4252
|
-
return Match.value(logicalParentOperator(context.parent)).pipe(Match.when("&&", () => [booleanLiteral(true)]), Match.when("||", () => [booleanLiteral(false)]), Match.orElse(() => [booleanLiteral(true), booleanLiteral(false)]));
|
|
4268
|
+
return Match$1.value(logicalParentOperator(context.parent)).pipe(Match$1.when("&&", () => [booleanLiteral(true)]), Match$1.when("||", () => [booleanLiteral(false)]), Match$1.orElse(() => [booleanLiteral(true), booleanLiteral(false)]));
|
|
4253
4269
|
}
|
|
4254
4270
|
function logicalParentOperator(parent) {
|
|
4255
|
-
return Match.value(parent).pipe(Match.when(isLogicalExpression, (logical) => logical.operator), Match.orElse(() => void 0));
|
|
4271
|
+
return Match$1.value(parent).pipe(Match$1.when(isLogicalExpression, (logical) => logical.operator), Match$1.orElse(() => void 0));
|
|
4256
4272
|
}
|
|
4257
4273
|
function isLogicalExpression(node) {
|
|
4258
4274
|
return node?.type === "LogicalExpression";
|
|
@@ -4284,7 +4300,7 @@ function isTestBearingStatement(node) {
|
|
|
4284
4300
|
return node !== void 0 && TEST_BEARING_KINDS[node.type] === true;
|
|
4285
4301
|
}
|
|
4286
4302
|
function testOfStatement(node) {
|
|
4287
|
-
return Match.value(node).pipe(Match.when(isTestBearingStatement, (statement) => statement.test ?? void 0), Match.orElse(() => void 0));
|
|
4303
|
+
return Match$1.value(node).pipe(Match$1.when(isTestBearingStatement, (statement) => statement.test ?? void 0), Match$1.orElse(() => void 0));
|
|
4288
4304
|
}
|
|
4289
4305
|
function isBooleanExpression(node) {
|
|
4290
4306
|
return isOperatorExpression(node) && booleanOperators.includes(node.operator);
|
|
@@ -4303,7 +4319,7 @@ const operators = {
|
|
|
4303
4319
|
"!==": ["==="]
|
|
4304
4320
|
};
|
|
4305
4321
|
const EQUALITY_OPERATOR_KEYS = Object.keys(operators);
|
|
4306
|
-
const equalityOperatorMutator = (node) => Match.value(node).pipe(Match.when(isEqualityBinary, (binary) => mutatedEqualityOperators(binary)), Match.orElse(() => NO_MUTANTS));
|
|
4322
|
+
const equalityOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isEqualityBinary, (binary) => mutatedEqualityOperators(binary)), Match$1.orElse(() => NO_MUTANTS));
|
|
4307
4323
|
function isEqualityBinary(node) {
|
|
4308
4324
|
return node.type === "BinaryExpression" && EQUALITY_OPERATOR_KEYS.includes(node.operator);
|
|
4309
4325
|
}
|
|
@@ -4316,7 +4332,7 @@ const logicalOperatorReplacements = Object.freeze({
|
|
|
4316
4332
|
"??": "&&"
|
|
4317
4333
|
});
|
|
4318
4334
|
const LOGICAL_OPERATOR_KEYS = Object.keys(logicalOperatorReplacements);
|
|
4319
|
-
const logicalOperatorMutator = (node) => Match.value(node).pipe(Match.when(isSupportedLogicalOperator, (binary) => [withOperator(binary, logicalOperatorReplacements[binary.operator])]), Match.orElse(() => NO_MUTANTS));
|
|
4335
|
+
const logicalOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isSupportedLogicalOperator, (binary) => [withOperator(binary, logicalOperatorReplacements[binary.operator])]), Match$1.orElse(() => NO_MUTANTS));
|
|
4320
4336
|
function isSupportedLogicalOperator(node) {
|
|
4321
4337
|
return node.type === "LogicalExpression" && LOGICAL_OPERATOR_KEYS.includes(node.operator);
|
|
4322
4338
|
}
|
|
@@ -4351,9 +4367,9 @@ const replacements = {
|
|
|
4351
4367
|
...baseReplacements,
|
|
4352
4368
|
...reverseReplacements
|
|
4353
4369
|
};
|
|
4354
|
-
const methodExpressionMutator = (node) => Match.value(node).pipe(Match.when(isCallExpression, (call) => methodCallMutants(call)), Match.orElse(() => NO_MUTANTS));
|
|
4370
|
+
const methodExpressionMutator = (node) => Match$1.value(node).pipe(Match$1.when(isCallExpression, (call) => methodCallMutants(call)), Match$1.orElse(() => NO_MUTANTS));
|
|
4355
4371
|
function methodCallMutants(call) {
|
|
4356
|
-
return Match.value(methodMutation(call)).pipe(Match.when(isMethodMutation, (mutation) => [methodExpressionReplacement(mutation)]), Match.orElse(() => NO_MUTANTS));
|
|
4372
|
+
return Match$1.value(methodMutation(call)).pipe(Match$1.when(isMethodMutation, (mutation) => [methodExpressionReplacement(mutation)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4357
4373
|
}
|
|
4358
4374
|
function isMethodMutation(mutation) {
|
|
4359
4375
|
return mutation !== void 0;
|
|
@@ -4361,19 +4377,19 @@ function isMethodMutation(mutation) {
|
|
|
4361
4377
|
/** The method this call replaces, or `undefined` when the call is not one this operator knows. */
|
|
4362
4378
|
function methodMutation(call) {
|
|
4363
4379
|
const callee = namedMethodCallee(call);
|
|
4364
|
-
return Match.value(callee).pipe(Match.when(void 0, () => void 0), Match.orElse((member) => mutationFor(call, member)));
|
|
4380
|
+
return Match$1.value(callee).pipe(Match$1.when(void 0, () => void 0), Match$1.orElse((member) => mutationFor(call, member)));
|
|
4365
4381
|
}
|
|
4366
4382
|
function mutationFor(call, callee) {
|
|
4367
4383
|
const methodName = callee.property.name;
|
|
4368
4384
|
const replacement = Object.hasOwn(replacements, methodName) ? replacements[methodName] : void 0;
|
|
4369
|
-
return Match.value(replacement).pipe(Match.when(void 0, () => void 0), Match.orElse((newName) => ({
|
|
4385
|
+
return Match$1.value(replacement).pipe(Match$1.when(void 0, () => void 0), Match$1.orElse((newName) => ({
|
|
4370
4386
|
call,
|
|
4371
4387
|
callee,
|
|
4372
4388
|
newName
|
|
4373
4389
|
})));
|
|
4374
4390
|
}
|
|
4375
4391
|
function namedMethodCallee(call) {
|
|
4376
|
-
return Match.value(call.callee).pipe(Match.when(isNamedMember, (member) => member), Match.orElse(() => void 0));
|
|
4392
|
+
return Match$1.value(call.callee).pipe(Match$1.when(isNamedMember, (member) => member), Match$1.orElse(() => void 0));
|
|
4377
4393
|
}
|
|
4378
4394
|
function isNamedMember(node) {
|
|
4379
4395
|
return isMemberProperty(node) && isNotSuperMember(node);
|
|
@@ -4385,7 +4401,7 @@ function isNotSuperMember(member) {
|
|
|
4385
4401
|
return !isSuperType(member.object);
|
|
4386
4402
|
}
|
|
4387
4403
|
function methodExpressionReplacement(mutation) {
|
|
4388
|
-
return Match.value(mutation.newName).pipe(Match.when(null, () => callExpression(cloneNode(mutation.callee.object), [], mutation.callee.optional === true)), Match.orElse((newName) => renamedMethodCall(mutation, newName)));
|
|
4404
|
+
return Match$1.value(mutation.newName).pipe(Match$1.when(null, () => callExpression(cloneNode(mutation.callee.object), [], mutation.callee.optional === true)), Match$1.orElse((newName) => renamedMethodCall(mutation, newName)));
|
|
4389
4405
|
}
|
|
4390
4406
|
function renamedMethodCall(mutation, newName) {
|
|
4391
4407
|
const mutatedCallee = memberExpression(cloneNode(mutation.callee.object), identifier(newName), mutation.callee.optional === true);
|
|
@@ -4397,14 +4413,14 @@ function spreadFreeArguments(args) {
|
|
|
4397
4413
|
function isNotSpreadElement(node) {
|
|
4398
4414
|
return node.type !== "SpreadElement";
|
|
4399
4415
|
}
|
|
4400
|
-
const objectLiteralMutator = (node) => Match.value(node).pipe(Match.when(isNonEmptyObjectLiteral, () => [{
|
|
4416
|
+
const objectLiteralMutator = (node) => Match$1.value(node).pipe(Match$1.when(isNonEmptyObjectLiteral, () => [{
|
|
4401
4417
|
type: "ObjectExpression",
|
|
4402
4418
|
properties: []
|
|
4403
|
-
}]), Match.orElse(() => NO_MUTANTS));
|
|
4419
|
+
}]), Match$1.orElse(() => NO_MUTANTS));
|
|
4404
4420
|
function isNonEmptyObjectLiteral(node) {
|
|
4405
4421
|
return node.type === "ObjectExpression" && node.properties.length > 0;
|
|
4406
4422
|
}
|
|
4407
|
-
const optionalChainingMutator = (node) => Match.value(node).pipe(Match.when(isOptionalMember, (member) => [withoutOptional(member)]), Match.when(isOptionalCall, (call) => [withoutOptional(call)]), Match.orElse(() => NO_MUTANTS));
|
|
4423
|
+
const optionalChainingMutator = (node) => Match$1.value(node).pipe(Match$1.when(isOptionalMember, (member) => [withoutOptional(member)]), Match$1.when(isOptionalCall, (call) => [withoutOptional(call)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4408
4424
|
function isOptionalMember(node) {
|
|
4409
4425
|
return node.type === "MemberExpression" && node.optional === true;
|
|
4410
4426
|
}
|
|
@@ -4416,7 +4432,7 @@ function withoutOptional(node) {
|
|
|
4416
4432
|
replacement.optional = false;
|
|
4417
4433
|
return replacement;
|
|
4418
4434
|
}
|
|
4419
|
-
const regexMutator = (node, context) => Match.value(node).pipe(Match.when(isRegexLiteral, (literal) => regexLiteralMutants(literal)), Match.when(isStringLiteral, (literal) => mutantsWhen(isObviousRegexString(literal, context), () => regexConstructorMutants(literal, context))), Match.orElse(() => NO_MUTANTS));
|
|
4435
|
+
const regexMutator = (node, context) => Match$1.value(node).pipe(Match$1.when(isRegexLiteral, (literal) => regexLiteralMutants(literal)), Match$1.when(isStringLiteral, (literal) => mutantsWhen(isObviousRegexString(literal, context), () => regexConstructorMutants(literal, context))), Match$1.orElse(() => NO_MUTANTS));
|
|
4420
4436
|
function isRegexLiteral(node) {
|
|
4421
4437
|
return nodeType(node) === "Literal" && Predicate$1.isNotNullish(propertyOf(node, "regex"));
|
|
4422
4438
|
}
|
|
@@ -4440,13 +4456,13 @@ function isRegExpIdentifier(node) {
|
|
|
4440
4456
|
return node.type === "Identifier" && node.name === RegExp.name;
|
|
4441
4457
|
}
|
|
4442
4458
|
function newExpressionArgument(parent, index) {
|
|
4443
|
-
return Match.value(parent).pipe(Match.when(isNewExpression, (call) => call.arguments[index]), Match.orElse(() => void 0));
|
|
4459
|
+
return Match$1.value(parent).pipe(Match$1.when(isNewExpression, (call) => call.arguments[index]), Match$1.orElse(() => void 0));
|
|
4444
4460
|
}
|
|
4445
4461
|
function regexFlags(parent) {
|
|
4446
|
-
return Match.value(newExpressionArgument(parent, 1)).pipe(Match.when(isStringLiteral, (literal) => literal.value), Match.orElse(() => void 0));
|
|
4462
|
+
return Match$1.value(newExpressionArgument(parent, 1)).pipe(Match$1.when(isStringLiteral, (literal) => literal.value), Match$1.orElse(() => void 0));
|
|
4447
4463
|
}
|
|
4448
4464
|
const PLACEHOLDER = "Stryker was here!";
|
|
4449
|
-
const stringLiteralMutator = (node, context) => Match.value(node).pipe(Match.when(isTemplateLiteral, (template) => templateMutants(template)), Match.when(isStringLiteral, (literal) => mutantsWhen(isValidParent(literal, context), () => [stringLiteral(replacementText(literal.value.length === 0))])), Match.orElse(() => NO_MUTANTS));
|
|
4465
|
+
const stringLiteralMutator = (node, context) => Match$1.value(node).pipe(Match$1.when(isTemplateLiteral, (template) => templateMutants(template)), Match$1.when(isStringLiteral, (literal) => mutantsWhen(isValidParent(literal, context), () => [stringLiteral(replacementText(literal.value.length === 0))])), Match$1.orElse(() => NO_MUTANTS));
|
|
4450
4466
|
function templateMutants(template) {
|
|
4451
4467
|
const first = template.quasis[0];
|
|
4452
4468
|
return Option$1.match(Option$1.fromNullishOr(first), {
|
|
@@ -4512,7 +4528,7 @@ function isDisallowedCallExpression(parent) {
|
|
|
4512
4528
|
return isCallExpression(parent) && DISALLOWED_CALLEES[calleeName(parent)] === true;
|
|
4513
4529
|
}
|
|
4514
4530
|
function calleeName(parent) {
|
|
4515
|
-
return Match.value(parent.callee).pipe(Match.when(isIdentifier, (identifier) => identifier.name), Match.when(isImportCallee, () => "import"), Match.orElse(() => ""));
|
|
4531
|
+
return Match$1.value(parent.callee).pipe(Match$1.when(isIdentifier, (identifier) => identifier.name), Match$1.when(isImportCallee, () => "import"), Match$1.orElse(() => ""));
|
|
4516
4532
|
}
|
|
4517
4533
|
function isImportCallee(callee) {
|
|
4518
4534
|
return nodeType(callee) === "Import";
|
|
@@ -4523,7 +4539,7 @@ const UnaryOperator = {
|
|
|
4523
4539
|
"~": ""
|
|
4524
4540
|
};
|
|
4525
4541
|
const UNARY_OPERATOR_KEYS = Object.keys(UnaryOperator);
|
|
4526
|
-
const unaryOperatorMutator = (node) => Match.value(node).pipe(Match.when(isSupportedUnaryExpression, (unary) => [unaryOperatorReplacement(unary)]), Match.orElse(() => NO_MUTANTS));
|
|
4542
|
+
const unaryOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isSupportedUnaryExpression, (unary) => [unaryOperatorReplacement(unary)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4527
4543
|
function isSupportedUnaryExpression(node) {
|
|
4528
4544
|
return isPrefixUnaryExpression(node) && isSupportedUnaryOperator(node.operator);
|
|
4529
4545
|
}
|
|
@@ -4533,7 +4549,7 @@ function isPrefixUnaryExpression(node) {
|
|
|
4533
4549
|
/** The sign-flipping unary becomes a flipped unary; `~x` loses its operator entirely. */
|
|
4534
4550
|
function unaryOperatorReplacement(unary) {
|
|
4535
4551
|
const mutatedOperator = UnaryOperator[unary.operator];
|
|
4536
|
-
return Match.value(mutatedOperator).pipe(Match.when(isPlusOrMinus, (operator) => unaryExpression(operator, cloneNode(unary.argument))), Match.orElse(() => cloneNode(unary.argument)));
|
|
4552
|
+
return Match$1.value(mutatedOperator).pipe(Match$1.when(isPlusOrMinus, (operator) => unaryExpression(operator, cloneNode(unary.argument))), Match$1.orElse(() => cloneNode(unary.argument)));
|
|
4537
4553
|
}
|
|
4538
4554
|
function isSupportedUnaryOperator(operator) {
|
|
4539
4555
|
return UNARY_OPERATOR_KEYS.includes(operator);
|
|
@@ -4545,7 +4561,7 @@ const UpdateOperators = {
|
|
|
4545
4561
|
"++": "--",
|
|
4546
4562
|
"--": "++"
|
|
4547
4563
|
};
|
|
4548
|
-
const updateOperatorMutator = (node) => Match.value(node).pipe(Match.when(isUpdateExpression, (update) => [updateExpression(UpdateOperators[update.operator], cloneNode(update.argument), update.prefix)]), Match.orElse(() => NO_MUTANTS));
|
|
4564
|
+
const updateOperatorMutator = (node) => Match$1.value(node).pipe(Match$1.when(isUpdateExpression, (update) => [updateExpression(UpdateOperators[update.operator], cloneNode(update.argument), update.prefix)]), Match$1.orElse(() => NO_MUTANTS));
|
|
4549
4565
|
function isUpdateExpression(node) {
|
|
4550
4566
|
return node.type === "UpdateExpression";
|
|
4551
4567
|
}
|
|
@@ -4647,7 +4663,7 @@ const oxcParseFailure = (errors, fileName, lineStarts) => Option$1.match(Option$
|
|
|
4647
4663
|
})
|
|
4648
4664
|
});
|
|
4649
4665
|
const oxcErrorLabelStart = (error) => Option$1.getOrElse(Option$1.map(Option$1.fromNullishOr(error.labels.at(0)), (label) => label.start), () => 0);
|
|
4650
|
-
const createParser = () => ({ parse: (code, fileName, scriptFormat) => Match.value(scriptFormat).pipe(Match.when("js", () => parseJS(code, fileName)), Match.when("ts", () => parseTS(code, fileName)), Match.when("tsx", () => parseTsx(code, fileName)), Match.exhaustive) });
|
|
4666
|
+
const createParser = () => ({ parse: (code, fileName, scriptFormat) => Match$1.value(scriptFormat).pipe(Match$1.when("js", () => parseJS(code, fileName)), Match$1.when("ts", () => parseTS(code, fileName)), Match$1.when("tsx", () => parseTsx(code, fileName)), Match$1.exhaustive) });
|
|
4651
4667
|
const parseJSDataFirst = Effect$1.fn("stryker.instrument.parser.parseJS")(function* (text, fileName) {
|
|
4652
4668
|
const parsed = yield* parseWithOxc(text, fileName, "js");
|
|
4653
4669
|
return {
|
|
@@ -4775,7 +4791,7 @@ const jumpStatementText = (keyword, label) => Option$1.match(Option$1.fromNullis
|
|
|
4775
4791
|
onSome: (value) => `${keyword} ${value.name};`,
|
|
4776
4792
|
onNone: () => `${keyword};`
|
|
4777
4793
|
});
|
|
4778
|
-
const emitComment = (comment) => Match.value(comment.type).pipe(Match.when("Line", () => `//${comment.value}\n`), Match.orElse(() => `/*${comment.value}*/\n`));
|
|
4794
|
+
const emitComment = (comment) => Match$1.value(comment.type).pipe(Match$1.when("Line", () => `//${comment.value}\n`), Match$1.orElse(() => `/*${comment.value}*/\n`));
|
|
4779
4795
|
const hashbangPrefix = (hashbang) => Option$1.match(Option$1.fromNullishOr(hashbang), {
|
|
4780
4796
|
onNone: () => "",
|
|
4781
4797
|
onSome: (value) => `#!${value.value}\n`
|
|
@@ -4808,7 +4824,7 @@ const printNodePrec = (ctx, node, prec) => Option$1.match(Option$1.fromNullishOr
|
|
|
4808
4824
|
onSome: (value) => dispatchNode(ctx, value, prec)
|
|
4809
4825
|
});
|
|
4810
4826
|
const unknownNodeText = (type) => `/* unknown:${type} */`;
|
|
4811
|
-
const nodeText = Match.type().pipe(Match.withReturnType(), Match.discriminatorsExhaustive("type")({
|
|
4827
|
+
const nodeText = Match$1.type().pipe(Match$1.withReturnType(), Match$1.discriminatorsExhaustive("type")({
|
|
4812
4828
|
Literal: (n) => () => literalText(n),
|
|
4813
4829
|
Identifier: (n) => () => n.name,
|
|
4814
4830
|
PrivateIdentifier: (n) => () => `#${n.name}`,
|
|
@@ -4977,7 +4993,7 @@ const nodeText = Match.type().pipe(Match.withReturnType(), Match.discriminatorsE
|
|
|
4977
4993
|
TSQualifiedName: (n) => () => unknownNodeText(n.type)
|
|
4978
4994
|
}));
|
|
4979
4995
|
const dispatchNode = (ctx, node, prec) => nodeText(node)(ctx, prec);
|
|
4980
|
-
const tsTypeText = Match.type().pipe(Match.withReturnType(), Match.discriminatorsExhaustive("type")({
|
|
4996
|
+
const tsTypeText = Match$1.type().pipe(Match$1.withReturnType(), Match$1.discriminatorsExhaustive("type")({
|
|
4981
4997
|
TSAnyKeyword: () => () => "any",
|
|
4982
4998
|
TSStringKeyword: () => () => "string",
|
|
4983
4999
|
TSBooleanKeyword: () => () => "boolean",
|
|
@@ -5021,7 +5037,7 @@ const typeTextOf = (ctx, node) => Option$1.match(Option$1.filter(Option$1.some(n
|
|
|
5021
5037
|
onSome: (typed) => printTSTypeToString(ctx, typed),
|
|
5022
5038
|
onNone: () => unknownNodeText(node.type)
|
|
5023
5039
|
});
|
|
5024
|
-
const statementKindText = (ctx, node) => Match.value(node).pipe(Match.withReturnType(), Match.when(isFunctionNode, (n) => functionText(ctx, n)), Match.when(isClassNode, (n) => classText(ctx, n)), Match.discriminatorsExhaustive("type")({
|
|
5040
|
+
const statementKindText = (ctx, node) => Match$1.value(node).pipe(Match$1.withReturnType(), Match$1.when(isFunctionNode, (n) => functionText(ctx, n)), Match$1.when(isClassNode, (n) => classText(ctx, n)), Match$1.discriminatorsExhaustive("type")({
|
|
5025
5041
|
BlockStatement: (n) => blockStatementText(ctx, n),
|
|
5026
5042
|
VariableDeclaration: (n) => `${variableDeclarationText(ctx, n)};`,
|
|
5027
5043
|
ExpressionStatement: (n) => expressionStatementText(ctx, n),
|
|
@@ -5062,10 +5078,10 @@ const literalWithoutRegex = (node) => Option$1.match(Option$1.fromNullishOr(node
|
|
|
5062
5078
|
onSome: (bigint) => bigint,
|
|
5063
5079
|
onNone: () => valueLiteralText(node.value)
|
|
5064
5080
|
});
|
|
5065
|
-
const valueLiteralText = (value) => Match.value(value).pipe(Match.when(Match.string, (v) => JSON.stringify(v)), Match.orElse(nonStringLiteralText));
|
|
5066
|
-
const nonStringLiteralText = (value) => Match.value(value).pipe(Match.when(Match.number, (v) => String(v)), Match.orElse(booleanOrBigintText));
|
|
5067
|
-
const booleanOrBigintText = (value) => Match.value(value).pipe(Match.when(Match.boolean, (v) => String(v)), Match.orElse(bigintText));
|
|
5068
|
-
const bigintText = (value) => Match.value(value).pipe(Match.when((candidate) => typeof candidate === "bigint", (v) => `${String(v)}n`), Match.orElse(() => "null"));
|
|
5081
|
+
const valueLiteralText = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.string, (v) => JSON.stringify(v)), Match$1.orElse(nonStringLiteralText));
|
|
5082
|
+
const nonStringLiteralText = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.number, (v) => String(v)), Match$1.orElse(booleanOrBigintText));
|
|
5083
|
+
const booleanOrBigintText = (value) => Match$1.value(value).pipe(Match$1.when(Match$1.boolean, (v) => String(v)), Match$1.orElse(bigintText));
|
|
5084
|
+
const bigintText = (value) => Match$1.value(value).pipe(Match$1.when((candidate) => typeof candidate === "bigint", (v) => `${String(v)}n`), Match$1.orElse(() => "null"));
|
|
5069
5085
|
const flagText = (present, text) => Boolean$1$1.match(Predicate$1.isTruthy(present), {
|
|
5070
5086
|
onTrue: () => text,
|
|
5071
5087
|
onFalse: () => ""
|
|
@@ -5079,18 +5095,18 @@ const objectExpressionText = (ctx, node) => Boolean$1$1.match(node.properties.le
|
|
|
5079
5095
|
onTrue: () => "{}",
|
|
5080
5096
|
onFalse: () => `{ ${nodeListText(ctx, node.properties, PREC.Sequence)} }`
|
|
5081
5097
|
});
|
|
5082
|
-
const propertyText = (ctx, node) => Match.value(propertyFormOf(node)).pipe(Match.when("accessor", () => `${node.kind} ${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}${functionValueTailText(ctx, node.value)}`), Match.when("method", () => `${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}${functionValueTailText(ctx, node.value)}`), Match.when("shorthand", () => identifierNameText(node.key)), Match.when("shorthandDefault", () => shorthandDefaultPropertyText(ctx, node)), Match.orElse(() => `${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}: ${printNodePrec(ctx, node.value, PREC.Assignment)}`));
|
|
5083
|
-
const functionValueTailText = (ctx, value) => Match.value(value).pipe(Match.when(isFunctionNode, (fn) => functionTailText(ctx, fn)), Match.orElse(() => ""));
|
|
5084
|
-
const shorthandDefaultPropertyText = (ctx, node) => Match.value(node.value).pipe(Match.when(isAssignmentPattern, (value) => `${identifierNameText(node.key)} = ${printNodePrec(ctx, value.right, PREC.Assignment)}`), Match.orElse(() => ""));
|
|
5098
|
+
const propertyText = (ctx, node) => Match$1.value(propertyFormOf(node)).pipe(Match$1.when("accessor", () => `${node.kind} ${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}${functionValueTailText(ctx, node.value)}`), Match$1.when("method", () => `${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}${functionValueTailText(ctx, node.value)}`), Match$1.when("shorthand", () => identifierNameText(node.key)), Match$1.when("shorthandDefault", () => shorthandDefaultPropertyText(ctx, node)), Match$1.orElse(() => `${propertyKeyText(ctx, node.key, node.computed === true, PREC.Assignment)}: ${printNodePrec(ctx, node.value, PREC.Assignment)}`));
|
|
5099
|
+
const functionValueTailText = (ctx, value) => Match$1.value(value).pipe(Match$1.when(isFunctionNode, (fn) => functionTailText(ctx, fn)), Match$1.orElse(() => ""));
|
|
5100
|
+
const shorthandDefaultPropertyText = (ctx, node) => Match$1.value(node.value).pipe(Match$1.when(isAssignmentPattern, (value) => `${identifierNameText(node.key)} = ${printNodePrec(ctx, value.right, PREC.Assignment)}`), Match$1.orElse(() => ""));
|
|
5085
5101
|
const propertyKeyText = (ctx, key, computed, computedPrec) => Boolean$1$1.match(computed, {
|
|
5086
5102
|
onTrue: () => `[${dispatchNode(ctx, key, computedPrec)}]`,
|
|
5087
5103
|
onFalse: () => plainPropertyKeyText(ctx, key)
|
|
5088
5104
|
});
|
|
5089
|
-
const plainPropertyKeyText = (ctx, key) => Match.value(key).pipe(Match.discriminators("type")({
|
|
5105
|
+
const plainPropertyKeyText = (ctx, key) => Match$1.value(key).pipe(Match$1.discriminators("type")({
|
|
5090
5106
|
Identifier: (n) => identifierNameText(n),
|
|
5091
5107
|
PrivateIdentifier: (n) => privateIdentifierText(n),
|
|
5092
5108
|
Literal: (n) => literalText(n)
|
|
5093
|
-
}), Match.orElse((n) => dispatchNode(ctx, n, PREC.Assignment)));
|
|
5109
|
+
}), Match$1.orElse((n) => dispatchNode(ctx, n, PREC.Assignment)));
|
|
5094
5110
|
const functionTailText = (ctx, fn) => `${typeParametersText(ctx, fn.typeParameters)}(${paramsText(ctx, fn.params)})${typeAnnotationText(ctx, fn.returnType)}${functionBodyText(ctx, fn)}`;
|
|
5095
5111
|
const functionBodyText = (ctx, fn) => Option$1.match(Option$1.fromNullishOr(fn.body), {
|
|
5096
5112
|
onSome: (body) => ` ${blockStatementText(ctx, body)}`,
|
|
@@ -5120,10 +5136,10 @@ const memberSelectorText = (ctx, access) => Boolean$1$1.match(access.computed, {
|
|
|
5120
5136
|
onTrue: () => `[${sequenceNodeText(ctx, access.property)}]`,
|
|
5121
5137
|
onFalse: () => `${flagText(!access.optional, ".")}${memberPropertyText(ctx, access.property)}`
|
|
5122
5138
|
});
|
|
5123
|
-
const memberPropertyText = (ctx, property) => Match.value(property).pipe(Match.discriminators("type")({
|
|
5139
|
+
const memberPropertyText = (ctx, property) => Match$1.value(property).pipe(Match$1.discriminators("type")({
|
|
5124
5140
|
Identifier: (n) => identifierNameText(n),
|
|
5125
5141
|
PrivateIdentifier: (n) => privateIdentifierText(n)
|
|
5126
|
-
}), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5142
|
+
}), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5127
5143
|
const callExpressionText = (ctx, node) => `${wrappedExpressionText(ctx, node.callee, PREC.Member, CALLEE_WRAPPED_KINDS)}${flagText(node.optional, "?.")}${typeArgumentsText(ctx, node.typeArguments)}(${nodeListText(ctx, node.arguments, PREC.Assignment)})`;
|
|
5128
5144
|
const newExpressionText = (ctx, node) => `new ${dispatchNode(ctx, node.callee, PREC.Member)}${typeArgumentsText(ctx, node.typeArguments)}(${nodeListText(ctx, node.arguments, PREC.Assignment)})`;
|
|
5129
5145
|
const metaPropertyText = (node) => `${node.meta.name}.${node.property.name}`;
|
|
@@ -5181,7 +5197,7 @@ const arrowParamsText = (ctx, node) => {
|
|
|
5181
5197
|
onFalse: () => bareParam
|
|
5182
5198
|
});
|
|
5183
5199
|
};
|
|
5184
|
-
const arrowBodyText = (ctx, node) => Match.value(node.body).pipe(Match.discriminators("type")({ BlockStatement: (body) => blockStatementText(ctx, body) }), Match.orElse((body) => assignmentNodeText(ctx, body)));
|
|
5200
|
+
const arrowBodyText = (ctx, node) => Match$1.value(node.body).pipe(Match$1.discriminators("type")({ BlockStatement: (body) => blockStatementText(ctx, body) }), Match$1.orElse((body) => assignmentNodeText(ctx, body)));
|
|
5185
5201
|
const functionText = (ctx, node) => `${functionHeaderText(node)}${functionTailText(ctx, node)}`;
|
|
5186
5202
|
const classText = (ctx, node) => `${decoratorsText(ctx, node.decorators)}${flagText(node.declare, "declare ")}${flagText(node.abstract, "abstract ")}class${namedDeclarationText(node)}${typeParametersText(ctx, node.typeParameters)}${classHeritageText(ctx, node)}${classImplementsText(ctx, node)} ${classBodyText(ctx, node.body)}`;
|
|
5187
5203
|
const classHeritageText = (ctx, node) => Option$1.match(Option$1.fromNullishOr(node.superClass), {
|
|
@@ -5208,30 +5224,30 @@ const jsxOpeningElementText = (ctx, node) => `<${jsxElementNameText(ctx, node.na
|
|
|
5208
5224
|
onTrue: () => " />",
|
|
5209
5225
|
onFalse: () => ">"
|
|
5210
5226
|
})}`;
|
|
5211
|
-
const jsxElementNameText = (ctx, name) => Match.value(name).pipe(Match.discriminators("type")({
|
|
5227
|
+
const jsxElementNameText = (ctx, name) => Match$1.value(name).pipe(Match$1.discriminators("type")({
|
|
5212
5228
|
JSXIdentifier: (n) => n.name,
|
|
5213
5229
|
JSXNamespacedName: (n) => `${n.namespace.name}:${n.name.name}`,
|
|
5214
5230
|
JSXMemberExpression: (n) => jsxMemberExpressionText(n)
|
|
5215
|
-
}), Match.orElse(() => ""));
|
|
5216
|
-
const jsxMemberExpressionText = (node) => Match.value(node.object).pipe(Match.discriminators("type")({ JSXIdentifier: (obj) => `${obj.name}.${node.property.name}` }), Match.orElse((obj) => `${jsxMemberExpressionText(obj)}.${node.property.name}`));
|
|
5231
|
+
}), Match$1.orElse(() => ""));
|
|
5232
|
+
const jsxMemberExpressionText = (node) => Match$1.value(node.object).pipe(Match$1.discriminators("type")({ JSXIdentifier: (obj) => `${obj.name}.${node.property.name}` }), Match$1.orElse((obj) => `${jsxMemberExpressionText(obj)}.${node.property.name}`));
|
|
5217
5233
|
const jsxAttributeText = (ctx, node) => `${jsxAttributeNameText(node.name)}${jsxAttributeValueClauseText(ctx, node.value)}`;
|
|
5218
5234
|
const jsxAttributeValueClauseText = (ctx, value) => Option$1.match(Option$1.fromNullishOr(value), {
|
|
5219
5235
|
onSome: (nonNull) => `=${jsxAttributeValueText(ctx, nonNull)}`,
|
|
5220
5236
|
onNone: () => ""
|
|
5221
5237
|
});
|
|
5222
|
-
const jsxAttributeValueText = (ctx, value) => Match.value(value).pipe(Match.discriminators("type")({
|
|
5238
|
+
const jsxAttributeValueText = (ctx, value) => Match$1.value(value).pipe(Match$1.discriminators("type")({
|
|
5223
5239
|
Literal: (n) => literalText(n),
|
|
5224
5240
|
JSXExpressionContainer: (n) => `{${sequenceNodeText(ctx, n.expression)}}`,
|
|
5225
5241
|
JSXElement: (n) => sequenceNodeText(ctx, n),
|
|
5226
5242
|
JSXFragment: (n) => sequenceNodeText(ctx, n)
|
|
5227
|
-
}), Match.orElse(() => ""));
|
|
5228
|
-
const jsxChildText = (ctx, child) => Match.value(child).pipe(Match.discriminators("type")({
|
|
5243
|
+
}), Match$1.orElse(() => ""));
|
|
5244
|
+
const jsxChildText = (ctx, child) => Match$1.value(child).pipe(Match$1.discriminators("type")({
|
|
5229
5245
|
JSXText: (n) => n.value,
|
|
5230
5246
|
JSXElement: (n) => jsxElementText(ctx, n),
|
|
5231
5247
|
JSXFragment: (n) => jsxFragmentText(ctx, n),
|
|
5232
5248
|
JSXExpressionContainer: (n) => `{${printNodePrec(ctx, n.expression, PREC.Sequence)}}`,
|
|
5233
5249
|
JSXSpreadChild: (n) => `{...${printNodePrec(ctx, n.expression, PREC.Assignment)}}`
|
|
5234
|
-
}), Match.orElse(() => ""));
|
|
5250
|
+
}), Match$1.orElse(() => ""));
|
|
5235
5251
|
const tsAsExpressionText = (ctx, node, prec) => {
|
|
5236
5252
|
const myPrec = PREC.Relational;
|
|
5237
5253
|
return parenthesizedIf(myPrec < prec, `${dispatchNode(ctx, node.expression, myPrec)} as ${printTSTypeToString(ctx, node.typeAnnotation)}`);
|
|
@@ -5255,16 +5271,16 @@ const ifStatementText = (ctx, node) => `if (${printNodePrec(ctx, node.test, PREC
|
|
|
5255
5271
|
onSome: (alternate) => ` else ${statementOrBlockText(ctx, alternate)}`,
|
|
5256
5272
|
onNone: () => ""
|
|
5257
5273
|
})}`;
|
|
5258
|
-
const statementOrBlockText = (ctx, node) => Match.value(node).pipe(Match.discriminators("type")({ BlockStatement: (n) => blockStatementText(ctx, n) }), Match.orElse((n) => statementText(ctx, n)));
|
|
5274
|
+
const statementOrBlockText = (ctx, node) => Match$1.value(node).pipe(Match$1.discriminators("type")({ BlockStatement: (n) => blockStatementText(ctx, n) }), Match$1.orElse((n) => statementText(ctx, n)));
|
|
5259
5275
|
const whileStatementText = (ctx, node) => `while (${printNodePrec(ctx, node.test, PREC.Sequence)}) ${statementOrBlockText(ctx, node.body)}`;
|
|
5260
5276
|
const doWhileStatementText = (ctx, node) => `do ${statementOrBlockText(ctx, node.body)} while (${printNodePrec(ctx, node.test, PREC.Sequence)});`;
|
|
5261
5277
|
const forStatementText = (ctx, node) => `for (${declarationOrExpressionText(ctx, node.init)}; ${optionalSequenceText(ctx, node.test)}; ${optionalSequenceText(ctx, node.update)}) ${statementOrBlockText(ctx, node.body)}`;
|
|
5262
5278
|
const declarationOrExpressionText = (ctx, node) => Option$1.match(Option$1.fromNullishOr(node), {
|
|
5263
5279
|
onNone: () => "",
|
|
5264
|
-
onSome: (value) => Match.value(value).pipe(Match.discriminators("type")({ VariableDeclaration: (n) => variableDeclarationText(ctx, n) }), Match.orElse((n) => printNodePrec(ctx, n, PREC.Sequence)))
|
|
5280
|
+
onSome: (value) => Match$1.value(value).pipe(Match$1.discriminators("type")({ VariableDeclaration: (n) => variableDeclarationText(ctx, n) }), Match$1.orElse((n) => printNodePrec(ctx, n, PREC.Sequence)))
|
|
5265
5281
|
});
|
|
5266
5282
|
const optionalSequenceText = (ctx, node) => sequenceNodeText(ctx, node);
|
|
5267
|
-
const forInStatementText = (ctx, node) => `for (${Match.value(node.left).pipe(Match.discriminators("type")({ VariableDeclaration: (n) => variableDeclarationText(ctx, n) }), Match.orElse((n) => printNodePrec(ctx, n, PREC.Sequence)))} in ${printNodePrec(ctx, node.right, PREC.Sequence)}) ${statementOrBlockText(ctx, node.body)}`;
|
|
5283
|
+
const forInStatementText = (ctx, node) => `for (${Match$1.value(node.left).pipe(Match$1.discriminators("type")({ VariableDeclaration: (n) => variableDeclarationText(ctx, n) }), Match$1.orElse((n) => printNodePrec(ctx, n, PREC.Sequence)))} in ${printNodePrec(ctx, node.right, PREC.Sequence)}) ${statementOrBlockText(ctx, node.body)}`;
|
|
5268
5284
|
const forOfStatementText = (ctx, node) => `${Boolean$1$1.match(node.await, {
|
|
5269
5285
|
onTrue: () => "for await (",
|
|
5270
5286
|
onFalse: () => "for ("
|
|
@@ -5293,28 +5309,28 @@ const catchParamText = (ctx, param) => Option$1.match(Option$1.fromNullishOr(par
|
|
|
5293
5309
|
onSome: (value) => ` (${catchParamBodyText(ctx, value)})`,
|
|
5294
5310
|
onNone: () => ""
|
|
5295
5311
|
});
|
|
5296
|
-
const catchParamBodyText = (ctx, param) => Match.value(param).pipe(Match.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5312
|
+
const catchParamBodyText = (ctx, param) => Match$1.value(param).pipe(Match$1.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5297
5313
|
const finallyClauseText = (ctx, finalizer) => Option$1.match(Option$1.fromNullishOr(finalizer), {
|
|
5298
5314
|
onSome: (value) => ` finally ${blockStatementText(ctx, value)}`,
|
|
5299
5315
|
onNone: () => ""
|
|
5300
5316
|
});
|
|
5301
5317
|
const variableDeclarationText = (ctx, node) => `${flagText(node.declare, "declare ")}${node.kind} ${node.declarations.map((declaration) => variableDeclaratorText(ctx, declaration)).join(", ")}`;
|
|
5302
5318
|
const variableDeclaratorText = (ctx, node) => `${bindingTargetText(ctx, node.id)}${flagText(node.definite, "!")}${typeAnnotationText(ctx, bindingTypeAnnotation(node.id))}${initializerText(ctx, node.init)}`;
|
|
5303
|
-
const bindingTargetText = (ctx, id) => Match.value(id).pipe(Match.discriminators("type")({ Identifier: (n) => `${bindingNameText(n)}${flagText(n.optional, "?")}` }), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5319
|
+
const bindingTargetText = (ctx, id) => Match$1.value(id).pipe(Match$1.discriminators("type")({ Identifier: (n) => `${bindingNameText(n)}${flagText(n.optional, "?")}` }), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5304
5320
|
const identifierWithOptionalText = (ctx, node) => `${bindingNameText(node)}${flagText(node.optional, "?")}${typeAnnotationText(ctx, node.typeAnnotation)}`;
|
|
5305
|
-
const paramText = (ctx, param) => Match.value(param).pipe(Match.discriminators("type")({
|
|
5321
|
+
const paramText = (ctx, param) => Match$1.value(param).pipe(Match$1.discriminators("type")({
|
|
5306
5322
|
RestElement: (n) => restParamText(ctx, n),
|
|
5307
5323
|
TSParameterProperty: (n) => parameterPropertyText(ctx, n),
|
|
5308
5324
|
Identifier: (n) => formalParameterText(ctx, n),
|
|
5309
5325
|
ObjectPattern: (n) => formalParameterText(ctx, n),
|
|
5310
5326
|
ArrayPattern: (n) => formalParameterText(ctx, n),
|
|
5311
5327
|
AssignmentPattern: (n) => formalParameterText(ctx, n)
|
|
5312
|
-
}), Match.orElse(() => ""));
|
|
5328
|
+
}), Match$1.orElse(() => ""));
|
|
5313
5329
|
const restParamText = (ctx, param) => `...${assignmentNodeText(ctx, param.argument)}${typeAnnotationText(ctx, param.typeAnnotation)}`;
|
|
5314
5330
|
const parameterPropertyText = (ctx, param) => `${decoratorsText(ctx, param.decorators)}${parameterPropertyModifiers(param)}${parameterPropertyTargetText(ctx, param.parameter)}`;
|
|
5315
|
-
const parameterPropertyTargetText = (ctx, parameter) => Match.value(parameter).pipe(Match.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5331
|
+
const parameterPropertyTargetText = (ctx, parameter) => Match$1.value(parameter).pipe(Match$1.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5316
5332
|
const formalParameterText = (ctx, param) => `${decoratorsText(ctx, param.decorators)}${formalParameterBodyText(ctx, param)}`;
|
|
5317
|
-
const formalParameterBodyText = (ctx, param) => Match.value(param).pipe(Match.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match.orElse((n) => `${assignmentNodeText(ctx, n)}${typeAnnotationText(ctx, bindingTypeAnnotation(n))}`));
|
|
5333
|
+
const formalParameterBodyText = (ctx, param) => Match$1.value(param).pipe(Match$1.discriminators("type")({ Identifier: (n) => identifierWithOptionalText(ctx, n) }), Match$1.orElse((n) => `${assignmentNodeText(ctx, n)}${typeAnnotationText(ctx, bindingTypeAnnotation(n))}`));
|
|
5318
5334
|
const classBodyText = (ctx, node) => Boolean$1$1.match(node.body.length === 0, {
|
|
5319
5335
|
onTrue: () => "{}",
|
|
5320
5336
|
onFalse: () => `{\n${indentedBodyText(ctx, node.body, (inner, element) => printNodePrec(inner, element, PREC.Sequence))}${indent(ctx)}}`
|
|
@@ -5348,7 +5364,7 @@ const exportSourceClauseText = (node) => Option$1.match(Option$1.fromNullishOr(n
|
|
|
5348
5364
|
onSome: (source) => ` from ${JSON.stringify(source.value)}${importAttributesText(node.attributes)}`,
|
|
5349
5365
|
onNone: () => ""
|
|
5350
5366
|
});
|
|
5351
|
-
const exportDefaultDeclarationText = (ctx, node) => `export default ${Match.value(node.declaration).pipe(Match.when(isBareDefaultExport, (declaration) => statementText(ctx, declaration)), Match.orElse((declaration) => `${printNodePrec(ctx, declaration, PREC.Assignment)};`))}`;
|
|
5367
|
+
const exportDefaultDeclarationText = (ctx, node) => `export default ${Match$1.value(node.declaration).pipe(Match$1.when(isBareDefaultExport, (declaration) => statementText(ctx, declaration)), Match$1.orElse((declaration) => `${printNodePrec(ctx, declaration, PREC.Assignment)};`))}`;
|
|
5352
5368
|
const exportAllDeclarationText = (ctx, node) => `export ${flagText(node.exportKind === "type", "type ")}*${exportedNameClauseText(node.exported)} from ${JSON.stringify(node.source.value)}${importAttributesText(node.attributes)};`;
|
|
5353
5369
|
const tsTypeAliasDeclarationText = (ctx, node) => `${flagText(node.declare, "declare ")}type ${node.id.name}${typeParametersText(ctx, node.typeParameters)} = ${printTSTypeToString(ctx, node.typeAnnotation)};`;
|
|
5354
5370
|
const tsInterfaceDeclarationText = (ctx, node) => `${flagText(node.declare, "declare ")}interface ${node.id.name}${typeParametersText(ctx, node.typeParameters)}${interfaceExtendsText(ctx, node.extends)} ${tsInterfaceBodyText(ctx, node.body)}`;
|
|
@@ -5360,13 +5376,13 @@ const tsInterfaceBodyText = (ctx, node) => Boolean$1$1.match(node.body.length ==
|
|
|
5360
5376
|
onTrue: () => "{}",
|
|
5361
5377
|
onFalse: () => `{\n${indentedBodyText(ctx, node.body, printTSSignatureText)}${indent(ctx)}}`
|
|
5362
5378
|
});
|
|
5363
|
-
const printTSSignatureText = (ctx, sig) => Match.value(sig).pipe(Match.discriminators("type")({
|
|
5379
|
+
const printTSSignatureText = (ctx, sig) => Match$1.value(sig).pipe(Match$1.discriminators("type")({
|
|
5364
5380
|
TSPropertySignature: (n) => printTSPropertySignatureText(ctx, n),
|
|
5365
5381
|
TSIndexSignature: (n) => printTSIndexSignatureText(ctx, n),
|
|
5366
5382
|
TSCallSignatureDeclaration: (n) => printTSCallSignatureText(ctx, n),
|
|
5367
5383
|
TSConstructSignatureDeclaration: (n) => printTSConstructSignatureText(ctx, n),
|
|
5368
5384
|
TSMethodSignature: (n) => printTSMethodSignatureText(ctx, n)
|
|
5369
|
-
}), Match.orElse(() => ""));
|
|
5385
|
+
}), Match$1.orElse(() => ""));
|
|
5370
5386
|
const printTSPropertySignatureText = (ctx, node) => `${flagText(node.readonly, "readonly ")}${propertyKeyText(ctx, node.key, node.computed === true, PREC.Sequence)}${flagText(node.optional, "?")}${typeAnnotationText(ctx, node.typeAnnotation)};`;
|
|
5371
5387
|
const printTSIndexSignatureText = (ctx, node) => {
|
|
5372
5388
|
const parameters = node.parameters.map((parameter) => indexParameterText(ctx, parameter)).join(", ");
|
|
@@ -5378,10 +5394,10 @@ const printTSConstructSignatureText = (ctx, node) => `new ${typeParametersText(c
|
|
|
5378
5394
|
const printTSMethodSignatureText = (ctx, node) => `${methodKindText(node.kind)}${propertyKeyText(ctx, node.key, node.computed === true, PREC.Sequence)}${flagText(node.optional, "?")}${typeParametersText(ctx, node.typeParameters)}(${paramsText(ctx, node.params)})${typeAnnotationText(ctx, node.returnType)};`;
|
|
5379
5395
|
const tsEnumDeclarationText = (ctx, node) => `${flagText(node.declare, "declare ")}${flagText(node.const, "const ")}enum ${node.id.name} {\n${indentedBodyText(ctx, node.body.members, printEnumMemberText)}${indent(ctx)}}`;
|
|
5380
5396
|
const printEnumMemberText = (ctx, member) => `${identifierOrLiteralNameText(ctx, member.id)}${initializerText(ctx, member.initializer)},`;
|
|
5381
|
-
const identifierOrLiteralNameText = (ctx, id) => Match.value(id).pipe(Match.discriminators("type")({
|
|
5397
|
+
const identifierOrLiteralNameText = (ctx, id) => Match$1.value(id).pipe(Match$1.discriminators("type")({
|
|
5382
5398
|
Identifier: (n) => identifierNameText(n),
|
|
5383
5399
|
Literal: (n) => literalText(n)
|
|
5384
|
-
}), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5400
|
+
}), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5385
5401
|
const tsModuleDeclarationText = (ctx, node) => `${flagText(node.declare, "declare ")}${moduleHeaderText(ctx, node)}${moduleBodyText(ctx, node)}`;
|
|
5386
5402
|
const moduleHeaderText = (ctx, node) => Boolean$1$1.match(node.global === true, {
|
|
5387
5403
|
onTrue: () => "global ",
|
|
@@ -5393,7 +5409,7 @@ const moduleBodyText = (ctx, node) => Option$1.match(Option$1.fromNullishOr(node
|
|
|
5393
5409
|
});
|
|
5394
5410
|
const tsModuleBlockText = (ctx, node) => `{\n${indentedBodyText(ctx, node.body, statementText)}${indent(ctx)}}`;
|
|
5395
5411
|
const tsImportEqualsDeclarationText = (ctx, node) => `import ${flagText(node.importKind === "type", "type ")}${node.id.name} = ${moduleReferenceText(ctx, node.moduleReference)};`;
|
|
5396
|
-
const moduleReferenceText = (ctx, reference) => Match.value(reference).pipe(Match.discriminators("type")({ TSExternalModuleReference: (n) => `require(${externalModuleArgumentText(n.expression.value)})` }), Match.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5412
|
+
const moduleReferenceText = (ctx, reference) => Match$1.value(reference).pipe(Match$1.discriminators("type")({ TSExternalModuleReference: (n) => `require(${externalModuleArgumentText(n.expression.value)})` }), Match$1.orElse((n) => sequenceNodeText(ctx, n)));
|
|
5397
5413
|
const tsTypeListText = (ctx, types, separator) => types.map((type) => printTSTypeToString(ctx, type)).join(separator);
|
|
5398
5414
|
const arrayElementTypeText = (ctx, type) => parenthesizedIf(ARRAY_ELEMENT_WRAPPED_KINDS[type.type] === true, printTSTypeToString(ctx, type));
|
|
5399
5415
|
const printTSTypeLiteral = (ctx, members) => Boolean$1$1.match(members.length === 0, {
|
|
@@ -5408,18 +5424,18 @@ const signatureText = (ctx, member) => {
|
|
|
5408
5424
|
});
|
|
5409
5425
|
};
|
|
5410
5426
|
const printTupleType = (ctx, elements) => `[${elements.map((element) => printTupleElement(ctx, element)).join(", ")}]`;
|
|
5411
|
-
const printTupleElement = (ctx, element) => Match.value(element).pipe(Match.discriminators("type")({
|
|
5427
|
+
const printTupleElement = (ctx, element) => Match$1.value(element).pipe(Match$1.discriminators("type")({
|
|
5412
5428
|
TSRestType: (n) => `...${printTSTypeToString(ctx, n.typeAnnotation)}`,
|
|
5413
5429
|
TSOptionalType: (n) => `${printTSTypeToString(ctx, n.typeAnnotation)}?`,
|
|
5414
5430
|
TSNamedTupleMember: (n) => printNamedTupleMember(ctx, n)
|
|
5415
|
-
}), Match.when(isTSType, (n) => printTSTypeToString(ctx, n)), Match.orElse(() => ""));
|
|
5431
|
+
}), Match$1.when(isTSType, (n) => printTSTypeToString(ctx, n)), Match$1.orElse(() => ""));
|
|
5416
5432
|
const printNamedTupleMember = (ctx, member) => `${member.label.name}${flagText(member.optional, "?")}: ${printTupleElement(ctx, member.elementType)}`;
|
|
5417
5433
|
const printTypeClause = (ctx, keyword, type) => Option$1.match(Option$1.fromNullishOr(type), {
|
|
5418
5434
|
onSome: (value) => `${keyword}${printTSTypeToString(ctx, value)}`,
|
|
5419
5435
|
onNone: () => ""
|
|
5420
5436
|
});
|
|
5421
|
-
const printTypeQueryName = (ctx, node) => Match.value(node.exprName).pipe(Match.discriminators("type")({ TSImportType: (n) => printTSTypeToString(ctx, n) }), Match.orElse((n) => printTSTypeName(n)));
|
|
5422
|
-
const printTSTypeName = (name) => Match.value(name).pipe(Match.withReturnType(), Match.discriminatorsExhaustive("type")({
|
|
5437
|
+
const printTypeQueryName = (ctx, node) => Match$1.value(node.exprName).pipe(Match$1.discriminators("type")({ TSImportType: (n) => printTSTypeToString(ctx, n) }), Match$1.orElse((n) => printTSTypeName(n)));
|
|
5438
|
+
const printTSTypeName = (name) => Match$1.value(name).pipe(Match$1.withReturnType(), Match$1.discriminatorsExhaustive("type")({
|
|
5423
5439
|
TSQualifiedName: (n) => `${printTSTypeName(n.left)}.${n.right.name}`,
|
|
5424
5440
|
Identifier: (n) => n.name,
|
|
5425
5441
|
ThisExpression: () => "this"
|
|
@@ -5428,13 +5444,13 @@ const printTSImportTypeQualifier = (ctx, qualifier) => Option$1.match(Option$1.f
|
|
|
5428
5444
|
onSome: (value) => printTSImportTypeQualifierNode(ctx, value),
|
|
5429
5445
|
onNone: () => ""
|
|
5430
5446
|
});
|
|
5431
|
-
const printTSImportTypeQualifierNode = (ctx, qualifier) => Match.value(qualifier).pipe(Match.discriminators("type")({ Identifier: (n) => n.name }), Match.orElse((n) => `${printTSImportTypeQualifier(ctx, n.left)}.${n.right.name}`));
|
|
5447
|
+
const printTSImportTypeQualifierNode = (ctx, qualifier) => Match$1.value(qualifier).pipe(Match$1.discriminators("type")({ Identifier: (n) => n.name }), Match$1.orElse((n) => `${printTSImportTypeQualifier(ctx, n.left)}.${n.right.name}`));
|
|
5432
5448
|
const printTSImportType = (ctx, node) => `import(${JSON.stringify(node.source.value)}${flagText(node.options, `, ${assignmentNodeText(ctx, node.options)}`)})${Option$1.match(Option$1.fromNullishOr(node.qualifier), {
|
|
5433
5449
|
onSome: (qualifier) => `.${printTSImportTypeQualifierNode(ctx, qualifier)}`,
|
|
5434
5450
|
onNone: () => ""
|
|
5435
5451
|
})}${typeArgumentsText(ctx, node.typeArguments)}`;
|
|
5436
5452
|
const printMappedType = (ctx, node) => `{ ${printMappedTypeModifier(node.readonly, "readonly ")}[${node.key.name} in ${printTSTypeToString(ctx, node.constraint)}${printTypeClause(ctx, " as ", node.nameType)}]${printMappedTypeModifier(node.optional, "?")}${printTypeClause(ctx, ": ", node.typeAnnotation)} }`;
|
|
5437
|
-
const printMappedTypeModifier = (modifier, rendered) => Match.value(modifier).pipe(Match.when(true, () => rendered), Match.when("+", () => `+${rendered}`), Match.when("-", () => `-${rendered}`), Match.orElse(() => ""));
|
|
5453
|
+
const printMappedTypeModifier = (modifier, rendered) => Match$1.value(modifier).pipe(Match$1.when(true, () => rendered), Match$1.when("+", () => `+${rendered}`), Match$1.when("-", () => `-${rendered}`), Match$1.orElse(() => ""));
|
|
5438
5454
|
const printTSTemplateLiteral = (ctx, node) => {
|
|
5439
5455
|
const tail = Arr.last(node.quasis);
|
|
5440
5456
|
const segments = Arr.zipWith(Arr.dropRight(node.quasis, 1), node.types, (quasi, type) => `${quasi.value.raw}\${${printTSTypeToString(ctx, type)}}`);
|
|
@@ -5448,11 +5464,11 @@ const printPredicateAnnotation = (ctx, node) => Option$1.match(Option$1.fromNull
|
|
|
5448
5464
|
onSome: (annotation) => printTypeClause(ctx, " is ", annotation.typeAnnotation),
|
|
5449
5465
|
onNone: () => ""
|
|
5450
5466
|
});
|
|
5451
|
-
const printTSLiteralType = (ctx, literal) => Match.value(literal).pipe(Match.discriminators("type")({
|
|
5467
|
+
const printTSLiteralType = (ctx, literal) => Match$1.value(literal).pipe(Match$1.discriminators("type")({
|
|
5452
5468
|
Literal: (n) => literalText(n),
|
|
5453
5469
|
TemplateLiteral: (n) => templateLiteralText(ctx, n),
|
|
5454
|
-
UnaryExpression: (n) => `${n.operator}${Match.value(n.argument).pipe(Match.discriminators("type")({ Literal: (argument) => literalText(argument) }), Match.orElse(() => ""))}`
|
|
5455
|
-
}), Match.orElse(() => ""));
|
|
5470
|
+
UnaryExpression: (n) => `${n.operator}${Match$1.value(n.argument).pipe(Match$1.discriminators("type")({ Literal: (argument) => literalText(argument) }), Match$1.orElse(() => ""))}`
|
|
5471
|
+
}), Match$1.orElse(() => ""));
|
|
5456
5472
|
const printJSDocPostfixModifier = (ctx, node, marker) => Boolean$1$1.match(node.postfix, {
|
|
5457
5473
|
onTrue: () => `${printTSTypeToString(ctx, node.typeAnnotation)}${marker}`,
|
|
5458
5474
|
onFalse: () => `${marker}${printTSTypeToString(ctx, node.typeAnnotation)}`
|
|
@@ -5519,9 +5535,9 @@ const identifierName = (node) => Option$1.getOrUndefined(Option$1.map(Option$1.f
|
|
|
5519
5535
|
const identifierNameText = (node) => identifierName(node) ?? "";
|
|
5520
5536
|
const privateIdentifierText = (node) => Option$1.match(Option$1.fromNullishOr(node), {
|
|
5521
5537
|
onNone: () => "",
|
|
5522
|
-
onSome: (value) => Match.value(value).pipe(Match.discriminators("type")({ PrivateIdentifier: (n) => `#${n.name}` }), Match.orElse(() => ""))
|
|
5538
|
+
onSome: (value) => Match$1.value(value).pipe(Match$1.discriminators("type")({ PrivateIdentifier: (n) => `#${n.name}` }), Match$1.orElse(() => ""))
|
|
5523
5539
|
});
|
|
5524
|
-
const precOf = Match.type().pipe(Match.discriminators("type")({
|
|
5540
|
+
const precOf = Match$1.type().pipe(Match$1.discriminators("type")({
|
|
5525
5541
|
SequenceExpression: () => PREC.Sequence,
|
|
5526
5542
|
AssignmentExpression: () => PREC.Assignment,
|
|
5527
5543
|
ConditionalExpression: () => PREC.Conditional,
|
|
@@ -5537,7 +5553,7 @@ const precOf = Match.type().pipe(Match.discriminators("type")({
|
|
|
5537
5553
|
ImportExpression: () => PREC.Call,
|
|
5538
5554
|
MemberExpression: () => PREC.Member,
|
|
5539
5555
|
ChainExpression: () => PREC.Member
|
|
5540
|
-
}), Match.orElse(() => PREC.Primary));
|
|
5556
|
+
}), Match$1.orElse(() => PREC.Primary));
|
|
5541
5557
|
const MEMBER_OBJECT_WRAPPED_KINDS = {
|
|
5542
5558
|
SequenceExpression: true,
|
|
5543
5559
|
AssignmentExpression: true,
|
|
@@ -5568,8 +5584,8 @@ const ARRAY_ELEMENT_WRAPPED_KINDS = {
|
|
|
5568
5584
|
TSUnionType: true,
|
|
5569
5585
|
TSIntersectionType: true
|
|
5570
5586
|
};
|
|
5571
|
-
const jsxAttributeNameText = (name) => Match.value(name).pipe(Match.discriminators("type")({ JSXIdentifier: (n) => n.name }), Match.orElse((n) => `${n.namespace.name}:${n.name.name}`));
|
|
5572
|
-
const propertyFormOf = (fields) => Match.value(fields).pipe(Match.withReturnType(), Match.when(isAccessorKind, () => "accessor"), Match.when(isMethodKind, () => "method"), Match.when(isShorthandMatch, () => "shorthand"), Match.when(isShorthandDefaultMatch, () => "shorthandDefault"), Match.orElse(() => "verbose"));
|
|
5587
|
+
const jsxAttributeNameText = (name) => Match$1.value(name).pipe(Match$1.discriminators("type")({ JSXIdentifier: (n) => n.name }), Match$1.orElse((n) => `${n.namespace.name}:${n.name.name}`));
|
|
5588
|
+
const propertyFormOf = (fields) => Match$1.value(fields).pipe(Match$1.withReturnType(), Match$1.when(isAccessorKind, () => "accessor"), Match$1.when(isMethodKind, () => "method"), Match$1.when(isShorthandMatch, () => "shorthand"), Match$1.when(isShorthandDefaultMatch, () => "shorthandDefault"), Match$1.orElse(() => "verbose"));
|
|
5573
5589
|
const isAccessorKind = (fields) => fields.kind === "get" || fields.kind === "set";
|
|
5574
5590
|
const isMethodKind = (fields) => fields.method === true;
|
|
5575
5591
|
const isShorthandMatch = (fields) => fields.shorthand === true && namesMatch(identifierName(fields.key), identifierName(fields.value));
|
|
@@ -5616,7 +5632,7 @@ const importedNameText = (imported) => Option$1.match(Option$1.fromUndefinedOr(i
|
|
|
5616
5632
|
onSome: (value) => importedNameOf(value),
|
|
5617
5633
|
onNone: () => ""
|
|
5618
5634
|
});
|
|
5619
|
-
const importedNameOf = (imported) => Match.value(imported.type).pipe(Match.when("Identifier", () => imported.name ?? ""), Match.orElse(() => imported.value ?? ""));
|
|
5635
|
+
const importedNameOf = (imported) => Match$1.value(imported.type).pipe(Match$1.when("Identifier", () => imported.name ?? ""), Match$1.orElse(() => imported.value ?? ""));
|
|
5620
5636
|
const exportAliasText = (localName, exportedName) => Boolean$1$1.match(localName === exportedName, {
|
|
5621
5637
|
onTrue: () => localName,
|
|
5622
5638
|
onFalse: () => `${localName} as ${exportedName}`
|
|
@@ -5631,12 +5647,12 @@ const importAttributesText = (attrs) => {
|
|
|
5631
5647
|
return flagText(rendered, ` with { ${rendered} }`);
|
|
5632
5648
|
};
|
|
5633
5649
|
const importAttributeText = (attribute) => `${importAttrKeyText(attribute.key)}: ${JSON.stringify(attribute.value.value)}`;
|
|
5634
|
-
const importAttrKeyText = (key) => Match.value(key).pipe(Match.discriminators("type")({ Identifier: (n) => n.name }), Match.orElse((n) => JSON.stringify(n.value)));
|
|
5650
|
+
const importAttrKeyText = (key) => Match$1.value(key).pipe(Match$1.discriminators("type")({ Identifier: (n) => n.name }), Match$1.orElse((n) => JSON.stringify(n.value)));
|
|
5635
5651
|
const bareArrowParamName = (node) => {
|
|
5636
5652
|
const name = singleParamName(node);
|
|
5637
5653
|
return flagText(name.length > 0 && node.returnType == null, name);
|
|
5638
5654
|
};
|
|
5639
|
-
const singleParamName = (node) => Match.value(node.params.length).pipe(Match.when(1, () => bareParameterName(Arr.head(node.params))), Match.orElse(() => ""));
|
|
5655
|
+
const singleParamName = (node) => Match$1.value(node.params.length).pipe(Match$1.when(1, () => bareParameterName(Arr.head(node.params))), Match$1.orElse(() => ""));
|
|
5640
5656
|
const bareParameterName = (param) => Option$1.match(param, {
|
|
5641
5657
|
onSome: (value) => bareParameterNameOf(value),
|
|
5642
5658
|
onNone: () => ""
|
|
@@ -5649,9 +5665,9 @@ const namedDeclarationText = (node) => Option$1.match(Option$1.fromNullishOr(nod
|
|
|
5649
5665
|
onNone: () => ""
|
|
5650
5666
|
});
|
|
5651
5667
|
const parameterPropertyModifiers = (param) => `${flagText(param.accessibility, `${param.accessibility} `)}${flagText(param.readonly, "readonly ")}${flagText(param.override, "override ")}${flagText(param.static, "static ")}`;
|
|
5652
|
-
const commentText = (comment) => Match.value(comment.type).pipe(Match.when("Block", () => `/*${comment.value}*/`), Match.orElse(() => `//${comment.value}`));
|
|
5668
|
+
const commentText = (comment) => Match$1.value(comment.type).pipe(Match$1.when("Block", () => `/*${comment.value}*/`), Match$1.orElse(() => `//${comment.value}`));
|
|
5653
5669
|
const methodDefinitionPrefix = (node, fn) => `${flagText(node.accessibility, `${node.accessibility} `)}${flagText(node.static, "static ")}${flagText(node.override, "override ")}${flagText(fn.async, "async ")}${flagText(fn.generator, "*")}${methodKindText(node.kind)}`;
|
|
5654
|
-
const methodKindText = (kind) => Match.value(kind).pipe(Match.when("get", () => "get "), Match.when("set", () => "set "), Match.orElse(() => ""));
|
|
5670
|
+
const methodKindText = (kind) => Match$1.value(kind).pipe(Match$1.when("get", () => "get "), Match$1.when("set", () => "set "), Match$1.orElse(() => ""));
|
|
5655
5671
|
const propertyDefinitionModifiers = (node) => `${flagText(node.declare, "declare ")}${flagText(node.accessibility, `${node.accessibility} `)}${flagText(node.static, "static ")}${flagText(node.readonly, "readonly ")}${flagText(node.override, "override ")}`;
|
|
5656
5672
|
const BARE_DEFAULT_EXPORT_KINDS = {
|
|
5657
5673
|
FunctionDeclaration: true,
|
|
@@ -5660,7 +5676,7 @@ const BARE_DEFAULT_EXPORT_KINDS = {
|
|
|
5660
5676
|
};
|
|
5661
5677
|
const isBareDefaultExport = (node) => BARE_DEFAULT_EXPORT_KINDS[node.type] === true;
|
|
5662
5678
|
const typeParameterModifiersText = (node) => `${flagText(node.in, "in ")}${flagText(node.out, "out ")}${flagText(node.const, "const ")}`;
|
|
5663
|
-
const typePredicateParameterText = (parameterName) => Match.value(parameterName).pipe(Match.discriminators("type")({ TSThisType: () => "this" }), Match.orElse((n) => identifierNameText(n)));
|
|
5679
|
+
const typePredicateParameterText = (parameterName) => Match$1.value(parameterName).pipe(Match$1.discriminators("type")({ TSThisType: () => "this" }), Match$1.orElse((n) => identifierNameText(n)));
|
|
5664
5680
|
const externalModuleArgumentText = (value) => Boolean$1$1.match(Predicate$1.isTruthy(value), {
|
|
5665
5681
|
onTrue: () => JSON.stringify(value),
|
|
5666
5682
|
onFalse: () => "\"\""
|
|
@@ -5720,9 +5736,13 @@ var FormatOverrideUnclaimed = class extends S.TaggedError()("FormatOverrideUncla
|
|
|
5720
5736
|
fileName: S.String,
|
|
5721
5737
|
formatId: S.String,
|
|
5722
5738
|
reason: S.String
|
|
5723
|
-
}) {
|
|
5739
|
+
}) {
|
|
5740
|
+
get message() {
|
|
5741
|
+
return `Cannot instrument ${this.fileName}: ${this.reason}`;
|
|
5742
|
+
}
|
|
5743
|
+
};
|
|
5724
5744
|
const pinOf = (command) => Option$1.fromUndefinedOr(command.formatId);
|
|
5725
|
-
const matchesCommand = (claim, command) => Match.value(pinOf(command)).pipe(Match.when(Option$1.isSome, (pin) => claim.formatId === pin.value), Match.orElse(() => claim.extensions.includes(command.extension)));
|
|
5745
|
+
const matchesCommand = (claim, command) => Match$1.value(pinOf(command)).pipe(Match$1.when(Option$1.isSome, (pin) => claim.formatId === pin.value), Match$1.orElse(() => claim.extensions.includes(command.extension)));
|
|
5726
5746
|
const claimFor = (command) => command.claims.find((claim) => matchesCommand(claim, command));
|
|
5727
5747
|
const assignedFrom = (claim, command) => FormatAssigned.make({
|
|
5728
5748
|
fileName: command.fileName,
|
|
@@ -5759,7 +5779,7 @@ const resolveFormat = Workflow.make({
|
|
|
5759
5779
|
command: FormatResolutionCommand,
|
|
5760
5780
|
decision: S.Union([FormatAssigned, FormatSkipped]),
|
|
5761
5781
|
error: FormatOverrideUnclaimed,
|
|
5762
|
-
decide: (command) => Match.value(selectionFor(command)).pipe(Match.tag("ClaimSelected", ({ claim }) => Result.succeed(assignedFrom(claim, command))), Match.tag("PinUnclaimed", ({ formatId }) => Result.fail(overrideUnclaimedFrom(command, formatId))), Match.tag("ExtensionUnclaimed", () => Result.succeed(skippedFrom(command))), Match.exhaustive)
|
|
5782
|
+
decide: (command) => Match$1.value(selectionFor(command)).pipe(Match$1.tag("ClaimSelected", ({ claim }) => Result.succeed(assignedFrom(claim, command))), Match$1.tag("PinUnclaimed", ({ formatId }) => Result.fail(overrideUnclaimedFrom(command, formatId))), Match$1.tag("ExtensionUnclaimed", () => Result.succeed(skippedFrom(command))), Match$1.exhaustive)
|
|
5763
5783
|
});
|
|
5764
5784
|
const DIRECTIVE_PATTERN = /^\s?Stryker (disable|restore)(?: (next-line))? ([a-zA-Z, ]+)(?::(.+)?)?/;
|
|
5765
5785
|
const DEFAULT_REASON = "Ignored using a comment";
|
|
@@ -5774,7 +5794,7 @@ var DirectiveDecoded = class extends S.TaggedClass()("DirectiveDecoded", { direc
|
|
|
5774
5794
|
var DirectiveMalformed = class extends S.TaggedClass()("DirectiveMalformed", { commentText: S.String }) {
|
|
5775
5795
|
[DirectiveDecisionTypeId] = DirectiveDecisionTypeId;
|
|
5776
5796
|
};
|
|
5777
|
-
const actionOf = (action) => Match.value(action).pipe(Match.when("restore", () => "restore"), Match.orElse(() => "disable"));
|
|
5797
|
+
const actionOf = (action) => Match$1.value(action).pipe(Match$1.when("restore", () => "restore"), Match$1.orElse(() => "disable"));
|
|
5778
5798
|
const scopeOf = (nextLine) => Option$1.match(nextLine, {
|
|
5779
5799
|
onNone: () => "block",
|
|
5780
5800
|
onSome: () => NEXT_LINE$1
|
|
@@ -5791,7 +5811,7 @@ const decodeDirective = Workflow.make({
|
|
|
5791
5811
|
command: DecodeDirectiveCommand,
|
|
5792
5812
|
decision: S.Union([DirectiveDecoded, DirectiveMalformed]),
|
|
5793
5813
|
error: S.Never,
|
|
5794
|
-
decide: (command) => Match.value(Option$1.flatMap(Option$1.fromNullishOr(DIRECTIVE_PATTERN.exec(command.commentText)), decodedDirective)).pipe(Match.when(Option$1.isSome, (decoded) => Result.succeed(DirectiveDecoded.make({ directive: decoded.value }))), Match.when(Option$1.isNone, () => Result.succeed(DirectiveMalformed.make({ commentText: command.commentText }))), Match.exhaustive)
|
|
5814
|
+
decide: (command) => Match$1.value(Option$1.flatMap(Option$1.fromNullishOr(DIRECTIVE_PATTERN.exec(command.commentText)), decodedDirective)).pipe(Match$1.when(Option$1.isSome, (decoded) => Result.succeed(DirectiveDecoded.make({ directive: decoded.value }))), Match$1.when(Option$1.isNone, () => Result.succeed(DirectiveMalformed.make({ commentText: command.commentText }))), Match$1.exhaustive)
|
|
5795
5815
|
});
|
|
5796
5816
|
var FoldRuleCommand = class extends S.TaggedClass()("FoldRuleCommand", {
|
|
5797
5817
|
rule: S.Array(LocatedDirectiveSchema),
|
|
@@ -5810,7 +5830,7 @@ const foldRule = Workflow.make({
|
|
|
5810
5830
|
command: FoldRuleCommand,
|
|
5811
5831
|
decision: S.Union([DisableFolded, RestoreFolded]),
|
|
5812
5832
|
error: S.Never,
|
|
5813
|
-
decide: (command) => Match.value(command.directive.directive.action).pipe(Match.when("restore", () => Result.succeed(RestoreFolded.make({ rule: [...command.rule, command.directive] }))), Match.when("disable", () => Result.succeed(DisableFolded.make({ rule: [...command.rule, command.directive] }))), Match.exhaustive)
|
|
5833
|
+
decide: (command) => Match$1.value(command.directive.directive.action).pipe(Match$1.when("restore", () => Result.succeed(RestoreFolded.make({ rule: [...command.rule, command.directive] }))), Match$1.when("disable", () => Result.succeed(DisableFolded.make({ rule: [...command.rule, command.directive] }))), Match$1.exhaustive)
|
|
5814
5834
|
});
|
|
5815
5835
|
const hasLeadingComments$1 = (value) => Predicate$1.hasProperty(value, "leadingComments") && Array.isArray(value.leadingComments);
|
|
5816
5836
|
const STRYKER_NAMESPACE_HELPER = "stryNS_9fa48";
|
|
@@ -5949,15 +5969,23 @@ var MutantKindMismatch = class extends S.TaggedError()("MutantKindMismatch", {
|
|
|
5949
5969
|
mutantId: MutantId,
|
|
5950
5970
|
mutatorName: MutatorNameSchema,
|
|
5951
5971
|
expected: ExpectedKindSchema
|
|
5952
|
-
}) {
|
|
5953
|
-
|
|
5954
|
-
|
|
5972
|
+
}) {
|
|
5973
|
+
get message() {
|
|
5974
|
+
return `Expected ${this.expected} for mutant ${this.mutantId} (${this.mutatorName}) in ${this.fileName}`;
|
|
5975
|
+
}
|
|
5976
|
+
};
|
|
5977
|
+
var NoPlacerClaimsNode = class extends S.TaggedError()("NoPlacerClaimsNode", { fileName: S.String }) {
|
|
5978
|
+
get message() {
|
|
5979
|
+
return `No placer claims the node in ${this.fileName}`;
|
|
5980
|
+
}
|
|
5981
|
+
};
|
|
5982
|
+
const claimingPlacer = (facts) => Match$1.value(facts).pipe(Match$1.when({
|
|
5955
5983
|
isExpression: true,
|
|
5956
5984
|
expressionIsValid: true
|
|
5957
|
-
}, () => Option$1.some("expression")), Match.when({ isStatement: true }, () => Option$1.some("statement")), Match.when({ isSwitchCase: true }, () => Option$1.some("switch-case")), Match.orElse(() => Option$1.none()));
|
|
5958
|
-
const placerOf = (command) => Match.value(claimingPlacer(command.facts)).pipe(Match.when(Option$1.isSome, (chosen) => Result.succeed(chosen.value)), Match.when(Option$1.isNone, () => Result.fail(NoPlacerClaimsNode.make({ fileName: command.fileName }))), Match.exhaustive);
|
|
5959
|
-
const expectedKindOf = (placer) => Match.value(placer).pipe(Match.when("expression", () => "an expression"), Match.when("statement", () => "a statement"), Match.when("switch-case", () => "a switch case"), Match.exhaustive);
|
|
5960
|
-
const matchesPlacer = (placer, replacement) => Match.value(placer).pipe(Match.when("expression", () => replacement.isExpression), Match.when("statement", () => replacement.isStatement), Match.when("switch-case", () => replacement.isSwitchCase), Match.exhaustive);
|
|
5985
|
+
}, () => Option$1.some("expression")), Match$1.when({ isStatement: true }, () => Option$1.some("statement")), Match$1.when({ isSwitchCase: true }, () => Option$1.some("switch-case")), Match$1.orElse(() => Option$1.none()));
|
|
5986
|
+
const placerOf = (command) => Match$1.value(claimingPlacer(command.facts)).pipe(Match$1.when(Option$1.isSome, (chosen) => Result.succeed(chosen.value)), Match$1.when(Option$1.isNone, () => Result.fail(NoPlacerClaimsNode.make({ fileName: command.fileName }))), Match$1.exhaustive);
|
|
5987
|
+
const expectedKindOf = (placer) => Match$1.value(placer).pipe(Match$1.when("expression", () => "an expression"), Match$1.when("statement", () => "a statement"), Match$1.when("switch-case", () => "a switch case"), Match$1.exhaustive);
|
|
5988
|
+
const matchesPlacer = (placer, replacement) => Match$1.value(placer).pipe(Match$1.when("expression", () => replacement.isExpression), Match$1.when("statement", () => replacement.isStatement), Match$1.when("switch-case", () => replacement.isSwitchCase), Match$1.exhaustive);
|
|
5961
5989
|
const firstMismatch = (command, placer) => Option$1.map(Option$1.fromNullishOr(command.mutants.find((mutant) => !matchesPlacer(placer, mutant.replacement))), (mutant) => MutantKindMismatch.make({
|
|
5962
5990
|
fileName: command.fileName,
|
|
5963
5991
|
placer,
|
|
@@ -5965,19 +5993,19 @@ const firstMismatch = (command, placer) => Option$1.map(Option$1.fromNullishOr(c
|
|
|
5965
5993
|
mutatorName: mutant.mutatorName,
|
|
5966
5994
|
expected: expectedKindOf(placer)
|
|
5967
5995
|
}));
|
|
5968
|
-
const placementRefusal = (command, placer) => Match.value(firstMismatch(command, placer)).pipe(Match.when(Option$1.isSome, (mismatch) => Result.fail(mismatch.value)), Match.when(Option$1.isNone, () => Result.succeed(void 0)), Match.exhaustive);
|
|
5996
|
+
const placementRefusal = (command, placer) => Match$1.value(firstMismatch(command, placer)).pipe(Match$1.when(Option$1.isSome, (mismatch) => Result.fail(mismatch.value)), Match$1.when(Option$1.isNone, () => Result.succeed(void 0)), Match$1.exhaustive);
|
|
5969
5997
|
const siteOf = (command, placer) => {
|
|
5970
5998
|
const mutantIds = command.mutants.map((mutant) => mutant.id);
|
|
5971
|
-
return Match.value(placer).pipe(Match.when("expression", () => ExpressionSite.make({
|
|
5999
|
+
return Match$1.value(placer).pipe(Match$1.when("expression", () => ExpressionSite.make({
|
|
5972
6000
|
fileName: command.fileName,
|
|
5973
6001
|
mutantIds
|
|
5974
|
-
})), Match.when("statement", () => StatementSite.make({
|
|
6002
|
+
})), Match$1.when("statement", () => StatementSite.make({
|
|
5975
6003
|
fileName: command.fileName,
|
|
5976
6004
|
mutantIds
|
|
5977
|
-
})), Match.when("switch-case", () => SwitchCaseSite.make({
|
|
6005
|
+
})), Match$1.when("switch-case", () => SwitchCaseSite.make({
|
|
5978
6006
|
fileName: command.fileName,
|
|
5979
6007
|
mutantIds
|
|
5980
|
-
})), Match.exhaustive);
|
|
6008
|
+
})), Match$1.exhaustive);
|
|
5981
6009
|
};
|
|
5982
6010
|
const placeMutants = Workflow.make({
|
|
5983
6011
|
command: PlaceMutantsCommand,
|
|
@@ -6050,12 +6078,16 @@ var MutantsFullyIgnored = class extends S.TaggedClass()("MutantsFullyIgnored", {
|
|
|
6050
6078
|
var MutantWithoutLocation = class extends S.TaggedError()("MutantWithoutLocation", {
|
|
6051
6079
|
fileName: S.String,
|
|
6052
6080
|
mutatorName: MutatorNameSchema
|
|
6053
|
-
}) {
|
|
6054
|
-
|
|
6081
|
+
}) {
|
|
6082
|
+
get message() {
|
|
6083
|
+
return `Mutant without a source location: ${this.mutatorName} in ${this.fileName}`;
|
|
6084
|
+
}
|
|
6085
|
+
};
|
|
6086
|
+
const reachedLine = (located, line) => Match$1.value(located.directive.scope).pipe(Match$1.when(NEXT_LINE, () => located.governedLine === line), Match$1.when("block", () => true), Match$1.exhaustive);
|
|
6055
6087
|
const namesMutator = (located, lowerMutatorName) => located.directive.mutatorNames.some((name) => [name === WILDCARD, name.toLowerCase() === lowerMutatorName].some(Boolean));
|
|
6056
6088
|
const lastReachingDirective = (rule, lowerMutatorName, line) => Option$1.fromNullishOr(rule.findLast((located) => [reachedLine(located, line), namesMutator(located, lowerMutatorName)].every(Boolean)));
|
|
6057
|
-
const directiveReason = (rule, mutatorName, line) => Option$1.flatMap(lastReachingDirective(rule, mutatorName.toLowerCase(), line), (located) => Match.value(located.directive.action).pipe(Match.when("disable", () => Option$1.some(located.directive.reason)), Match.when("restore", () => Option$1.none()), Match.exhaustive));
|
|
6058
|
-
const exclusionReason = (excludedMutations, mutatorName) => Match.value(excludedMutations.includes(mutatorName)).pipe(Match.when(true, () => Option$1.some(`Ignored because of excluded mutation "${mutatorName}"`)), Match.when(false, () => Option$1.none()), Match.exhaustive);
|
|
6089
|
+
const directiveReason = (rule, mutatorName, line) => Option$1.flatMap(lastReachingDirective(rule, mutatorName.toLowerCase(), line), (located) => Match$1.value(located.directive.action).pipe(Match$1.when("disable", () => Option$1.some(located.directive.reason)), Match$1.when("restore", () => Option$1.none()), Match$1.exhaustive));
|
|
6090
|
+
const exclusionReason = (excludedMutations, mutatorName) => Match$1.value(excludedMutations.includes(mutatorName)).pipe(Match$1.when(true, () => Option$1.some(`Ignored because of excluded mutation "${mutatorName}"`)), Match$1.when(false, () => Option$1.none()), Match$1.exhaustive);
|
|
6059
6091
|
const ignoreReasonOf = (command, candidate) => Option$1.getOrUndefined(Option$1.orElse(Option$1.orElse(directiveReason(command.rule, candidate.mutatorName, command.line), () => exclusionReason(command.excludedMutations, candidate.mutatorName)), () => Option$1.fromNullishOr(candidate.ignorerReason)));
|
|
6060
6092
|
const unusedDirectives = (directives, mutatorNames) => directives.flatMap((located) => located.directive.mutatorNames.filter((mutatorName) => mutatorName !== WILDCARD).filter((mutatorName) => !mutatorNames.includes(mutatorName.toLowerCase())).map((mutatorName) => ({
|
|
6061
6093
|
directive: located.directive,
|
|
@@ -6063,7 +6095,7 @@ const unusedDirectives = (directives, mutatorNames) => directives.flatMap((locat
|
|
|
6063
6095
|
mutatorName
|
|
6064
6096
|
})));
|
|
6065
6097
|
const unusedDirectiveWarning = (unused, fileName) => {
|
|
6066
|
-
return `Unused 'Stryker ${Match.value(unused.directive.scope).pipe(Match.when(NEXT_LINE, () => `${unused.directive.action} ${NEXT_LINE}`), Match.when("block", () => unused.directive.action), Match.exhaustive)}' directive. Mutator with name '${unused.mutatorName}' not found. Directive found at: ${fileName}:${unused.at.line}:${unused.at.column}.`;
|
|
6098
|
+
return `Unused 'Stryker ${Match$1.value(unused.directive.scope).pipe(Match$1.when(NEXT_LINE, () => `${unused.directive.action} ${NEXT_LINE}`), Match$1.when("block", () => unused.directive.action), Match$1.exhaustive)}' directive. Mutator with name '${unused.mutatorName}' not found. Directive found at: ${fileName}:${unused.at.line}:${unused.at.column}.`;
|
|
6067
6099
|
};
|
|
6068
6100
|
const warningsOf = (command) => unusedDirectives(command.directives, command.mutatorNames).map((unused) => unusedDirectiveWarning(unused, command.fileName));
|
|
6069
6101
|
/**
|
|
@@ -6073,7 +6105,7 @@ const warningsOf = (command) => unusedDirectives(command.directives, command.mut
|
|
|
6073
6105
|
* column 1, so the shift adds `offset.line - 1` lines and — only when the node
|
|
6074
6106
|
* sits on the region's first line — `offset.columnShift`.
|
|
6075
6107
|
*/
|
|
6076
|
-
const columnOffsetOf = (source, offset) => Match.value(source.line === 1).pipe(Match.when(true, () => offset.columnShift), Match.when(false, () => 0), Match.exhaustive);
|
|
6108
|
+
const columnOffsetOf = (source, offset) => Match$1.value(source.line === 1).pipe(Match$1.when(true, () => offset.columnShift), Match$1.when(false, () => 0), Match$1.exhaustive);
|
|
6077
6109
|
const shiftedPosition = (source, offset) => ({
|
|
6078
6110
|
column: source.column + columnOffsetOf(source, offset),
|
|
6079
6111
|
line: source.line + offset.line - 1
|
|
@@ -6097,16 +6129,16 @@ const plannedMutant = (command, candidate, index) => Option$1.match(Option$1.fro
|
|
|
6097
6129
|
});
|
|
6098
6130
|
const plannedMutants = (command) => command.candidates.reduce((accumulated, candidate, index) => Result.flatMap(accumulated, (mutants) => Result.map(plannedMutant(command, candidate, index), (mutant) => [...mutants, mutant])), Result.succeed([]));
|
|
6099
6131
|
const withoutReason = (mutant) => mutant.ignoreReason === void 0;
|
|
6100
|
-
const planOf = (command, mutants) => Match.value(mutants.some(withoutReason)).pipe(Match.when(true, () => MutantsPlanned.make({
|
|
6132
|
+
const planOf = (command, mutants) => Match$1.value(mutants.some(withoutReason)).pipe(Match$1.when(true, () => MutantsPlanned.make({
|
|
6101
6133
|
mutants: [...mutants],
|
|
6102
6134
|
placeable: mutants.filter(withoutReason),
|
|
6103
6135
|
warnings: warningsOf(command),
|
|
6104
6136
|
nextIndex: command.firstIndex + mutants.length
|
|
6105
|
-
})), Match.when(false, () => MutantsFullyIgnored.make({
|
|
6137
|
+
})), Match$1.when(false, () => MutantsFullyIgnored.make({
|
|
6106
6138
|
mutants: [...mutants],
|
|
6107
6139
|
warnings: warningsOf(command),
|
|
6108
6140
|
nextIndex: command.firstIndex + mutants.length
|
|
6109
|
-
})), Match.exhaustive);
|
|
6141
|
+
})), Match$1.exhaustive);
|
|
6110
6142
|
const planMutants = Workflow.make({
|
|
6111
6143
|
command: PlanMutantsCommand,
|
|
6112
6144
|
decision: S.Union([MutantsPlanned, MutantsFullyIgnored]),
|
|
@@ -6143,17 +6175,17 @@ const createMutantCollector = () => {
|
|
|
6143
6175
|
map: (transform) => mutants.map(transform)
|
|
6144
6176
|
};
|
|
6145
6177
|
};
|
|
6146
|
-
const decidedDirective = (commentText) => Match.value(decodeDirective(DecodeDirectiveCommand.make({ commentText }))).pipe(Match.when(Result.isSuccess, (decoded) => Match.value(decoded.success).pipe(Match.tag("DirectiveDecoded", (decision) => Option$1.some(decision.directive)), Match.orElse(() => Option$1.none()))), Match.orElse(() => Option$1.none()));
|
|
6178
|
+
const decidedDirective = (commentText) => Match$1.value(decodeDirective(DecodeDirectiveCommand.make({ commentText }))).pipe(Match$1.when(Result.isSuccess, (decoded) => Match$1.value(decoded.success).pipe(Match$1.tag("DirectiveDecoded", (decision) => Option$1.some(decision.directive)), Match$1.orElse(() => Option$1.none()))), Match$1.orElse(() => Option$1.none()));
|
|
6147
6179
|
const locatedDirective = (comment, governedLine) => Option$1.flatMap(Option$1.fromNullishOr(comment.loc), (loc) => Option$1.map(decidedDirective(comment.value), (directive) => ({
|
|
6148
6180
|
directive,
|
|
6149
6181
|
at: loc.start,
|
|
6150
6182
|
governedLine
|
|
6151
6183
|
})));
|
|
6152
6184
|
const directivesOf = (node, governedLine) => attachedComments(node).flatMap((comment) => Option$1.toArray(locatedDirective(comment, governedLine)));
|
|
6153
|
-
const foldInto = (rule, directive) => Match.value(foldRule(FoldRuleCommand.make({
|
|
6185
|
+
const foldInto = (rule, directive) => Match$1.value(foldRule(FoldRuleCommand.make({
|
|
6154
6186
|
rule,
|
|
6155
6187
|
directive
|
|
6156
|
-
}))).pipe(Match.when(Result.isSuccess, (folded) => folded.success.rule), Match.orElse(() => rule));
|
|
6188
|
+
}))).pipe(Match$1.when(Result.isSuccess, (folded) => folded.success.rule), Match$1.orElse(() => rule));
|
|
6157
6189
|
const NO_COMMENTS = [];
|
|
6158
6190
|
const attachedComments = (node) => hasLeadingComments(node) ? node.leadingComments : NO_COMMENTS;
|
|
6159
6191
|
const hasLeadingComments = (value) => Predicate$1.hasProperty(value, "leadingComments") && Array.isArray(value.leadingComments);
|
|
@@ -6209,8 +6241,8 @@ function mutationCoverageSequenceExpression(mutants, targetExpression) {
|
|
|
6209
6241
|
const sequence = [callExpression(identifier(COVER_MUTANT_HELPER), mutantIds)];
|
|
6210
6242
|
return sequenceExpression(targetExpression === void 0 ? sequence : [...sequence, targetExpression]);
|
|
6211
6243
|
}
|
|
6212
|
-
const refusalPlacer = (refusal) => Match.value(refusal).pipe(Match.tag("MutantKindMismatch", (mismatch) => mismatch.placer), Match.tag("MutantsUnapplied", (unapplied) => unapplied.placer), Match.tag("NoPlacerClaimsNode", () => "no placer"), Match.tag("MutantNotApplied", () => "no placer"), Match.exhaustive);
|
|
6213
|
-
const refusalDetail = (refusal) => Match.value(refusal).pipe(Match.tag("MutantKindMismatch", (mismatch) => `Expected ${mismatch.expected} for mutant ${mismatch.mutantId}`), Match.tag("MutantsUnapplied", (unapplied) => `Failed to apply ${unapplied.mutatorNames.join(", ")}`), Match.tag("NoPlacerClaimsNode", () => "No placer claims the node"), Match.tag("MutantNotApplied", (unapplied) => `Could not apply the ${unapplied.mutatorName} mutant`), Match.exhaustive);
|
|
6244
|
+
const refusalPlacer = (refusal) => Match$1.value(refusal).pipe(Match$1.tag("MutantKindMismatch", (mismatch) => mismatch.placer), Match$1.tag("MutantsUnapplied", (unapplied) => unapplied.placer), Match$1.tag("NoPlacerClaimsNode", () => "no placer"), Match$1.tag("MutantNotApplied", () => "no placer"), Match$1.exhaustive);
|
|
6245
|
+
const refusalDetail = (refusal) => Match$1.value(refusal).pipe(Match$1.tag("MutantKindMismatch", (mismatch) => `Expected ${mismatch.expected} for mutant ${mismatch.mutantId}`), Match$1.tag("MutantsUnapplied", (unapplied) => `Failed to apply ${unapplied.mutatorNames.join(", ")}`), Match$1.tag("NoPlacerClaimsNode", () => "No placer claims the node"), Match$1.tag("MutantNotApplied", (unapplied) => `Could not apply the ${unapplied.mutatorName} mutant`), Match$1.exhaustive);
|
|
6214
6246
|
const placementFailureMessage = (refusal, node, mutants, fileName, lineStarts, basePath) => {
|
|
6215
6247
|
const message = `${refusalPlacer(refusal)} could not place mutants with type(s): "${placementListFormat.format(mutants.map((mutant) => mutant.mutatorName))}"`;
|
|
6216
6248
|
return `${placementLocation(node, fileName, lineStarts, basePath)} ${message}. Either remove this file from the list of files to be mutated, or exclude the mutator (using \`mutator.excludedMutations\`). Original error: ${refusalDetail(refusal)}`;
|
|
@@ -6254,14 +6286,14 @@ function classOrFunctionExpressionNamedIfNeeded(path) {
|
|
|
6254
6286
|
return Option$1.flatMap(Option$1.filter(Option$1.some(path.node), isAnonymousFunctionOrClass), (node) => nameFromParent(path, node));
|
|
6255
6287
|
}
|
|
6256
6288
|
function nameFromParent(path, node) {
|
|
6257
|
-
return Match.value(path.parentPath?.node).pipe(Match.when(isVariableDeclarator, (declarator) => adoptDeclaredName(node, declarator)), Match.when({
|
|
6289
|
+
return Match$1.value(path.parentPath?.node).pipe(Match$1.when(isVariableDeclarator, (declarator) => adoptDeclaredName(node, declarator)), Match$1.when({
|
|
6258
6290
|
type: "Property",
|
|
6259
6291
|
key: { type: "Identifier" }
|
|
6260
|
-
}, () => namedPropertyValue(path, node)), Match.orElse(() => Option$1.none()));
|
|
6292
|
+
}, () => namedPropertyValue(path, node)), Match$1.orElse(() => Option$1.none()));
|
|
6261
6293
|
}
|
|
6262
6294
|
/** A property value only survives by name when the declaration above it carries one. */
|
|
6263
6295
|
function namedPropertyValue(path, node) {
|
|
6264
|
-
return Match.value(path.getStatementParent()?.node.type).pipe(Match.when("VariableDeclaration", () => Option$1.some(node)), Match.orElse(() => Option$1.none()));
|
|
6296
|
+
return Match$1.value(path.getStatementParent()?.node.type).pipe(Match$1.when("VariableDeclaration", () => Option$1.some(node)), Match$1.orElse(() => Option$1.none()));
|
|
6265
6297
|
}
|
|
6266
6298
|
function adoptIdentifier(node, identifier) {
|
|
6267
6299
|
node.id = identifier;
|
|
@@ -6274,7 +6306,7 @@ function isFunctionOrClassExpression(node) {
|
|
|
6274
6306
|
return node.type === "FunctionExpression" || node.type === "ClassExpression";
|
|
6275
6307
|
}
|
|
6276
6308
|
function arrowFunctionExpressionNamedIfNeeded(path) {
|
|
6277
|
-
return Match.value(path.node).pipe(Match.when({ type: "ArrowFunctionExpression" }, (node) => arrowNamedByDeclarator(node, path.parentPath)), Match.orElse(() => Option$1.none()));
|
|
6309
|
+
return Match$1.value(path.node).pipe(Match$1.when({ type: "ArrowFunctionExpression" }, (node) => arrowNamedByDeclarator(node, path.parentPath)), Match$1.orElse(() => Option$1.none()));
|
|
6278
6310
|
}
|
|
6279
6311
|
/** An arrow bound to a named declaration is re-emitted as a named function. */
|
|
6280
6312
|
function arrowNamedByDeclarator(node, parentPath) {
|
|
@@ -6285,7 +6317,7 @@ function namedArrowExpression(node, identifier) {
|
|
|
6285
6317
|
return callExpression(arrowFunctionExpression([], blockStatement([declaration, returnStatement(identifier)])), []);
|
|
6286
6318
|
}
|
|
6287
6319
|
function declaratorIdentifier(parentPath) {
|
|
6288
|
-
return Option$1.flatMap(Option$1.fromNullishOr(parentPath), (parent) => Match.value(parent.node).pipe(Match.when(isVariableDeclarator, (declarator) => declaredName(declarator)), Match.orElse(() => Option$1.none())));
|
|
6320
|
+
return Option$1.flatMap(Option$1.fromNullishOr(parentPath), (parent) => Match$1.value(parent.node).pipe(Match$1.when(isVariableDeclarator, (declarator) => declaredName(declarator)), Match$1.orElse(() => Option$1.none())));
|
|
6289
6321
|
}
|
|
6290
6322
|
function isVariableDeclarator(node) {
|
|
6291
6323
|
return nodeType(node) === "VariableDeclarator";
|
|
@@ -6294,7 +6326,7 @@ function adoptDeclaredName(node, declarator) {
|
|
|
6294
6326
|
return Option$1.map(declaredName(declarator), (identifier) => adoptIdentifier(node, identifier));
|
|
6295
6327
|
}
|
|
6296
6328
|
function declaredName(declarator) {
|
|
6297
|
-
return Match.value(declarator.id).pipe(Match.when(isIdentifierReference, (identifier) => Option$1.some(identifier)), Match.orElse(() => Option$1.none()));
|
|
6329
|
+
return Match$1.value(declarator.id).pipe(Match$1.when(isIdentifierReference, (identifier) => Option$1.some(identifier)), Match$1.orElse(() => Option$1.none()));
|
|
6298
6330
|
}
|
|
6299
6331
|
function isIdentifierReference(node) {
|
|
6300
6332
|
return nodeType(node) === "Identifier";
|
|
@@ -6403,7 +6435,7 @@ function guardedStatement(statement, entry) {
|
|
|
6403
6435
|
return Result.map(nodeOfKind(entry[0], entry[1], isStatementKind, "a statement"), (narrowed) => ifStatement(mutantTestExpression(entry[0].id), blockStatement([narrowed]), statement));
|
|
6404
6436
|
}
|
|
6405
6437
|
function wrappedStatement(path, statement) {
|
|
6406
|
-
return Match.value(nodeType(path.node)).pipe(Match.when("BlockStatement", () => blockStatement([statement])), Match.orElse(() => statement));
|
|
6438
|
+
return Match$1.value(nodeType(path.node)).pipe(Match$1.when("BlockStatement", () => blockStatement([statement])), Match$1.orElse(() => statement));
|
|
6407
6439
|
}
|
|
6408
6440
|
const placerBuilders = Object.freeze({
|
|
6409
6441
|
expression: expressionMutantPlacer,
|
|
@@ -6425,7 +6457,7 @@ const transformDataFirst = (ast, mutantCollector, transformerContext) => {
|
|
|
6425
6457
|
transform
|
|
6426
6458
|
};
|
|
6427
6459
|
const formatKey = formatKeyOf(ast);
|
|
6428
|
-
return Match.value(transformerContext.registry.entryForFormat(formatKey)).pipe(Match.when(Option$1.isSome, (entry) => entry.value.transform(ast, mutantCollector, context)), Match.orElse(() => Effect$1.fail(InstrumentError.make({
|
|
6460
|
+
return Match$1.value(transformerContext.registry.entryForFormat(formatKey)).pipe(Match$1.when(Option$1.isSome, (entry) => entry.value.transform(ast, mutantCollector, context)), Match$1.orElse(() => Effect$1.fail(InstrumentError.make({
|
|
6429
6461
|
message: `No registered format transforms the "${formatKey}" AST`,
|
|
6430
6462
|
cause: /* @__PURE__ */ new Error(`Missing format entry for "${formatKey}"`)
|
|
6431
6463
|
}))));
|
|
@@ -6463,7 +6495,7 @@ const placementFactsOf = (frame) => ({
|
|
|
6463
6495
|
isSwitchCase: nodeType(frame.node) === "SwitchCase",
|
|
6464
6496
|
expressionIsValid: isValidExpression(frame.node, parentNodeOf(frame))
|
|
6465
6497
|
});
|
|
6466
|
-
const placerNameOf = (site) => Match.value(site).pipe(Match.tag("ExpressionSite", () => "expression"), Match.tag("StatementSite", () => "statement"), Match.tag("SwitchCaseSite", () => "switch-case"), Match.exhaustive);
|
|
6498
|
+
const placerNameOf = (site) => Match$1.value(site).pipe(Match$1.tag("ExpressionSite", () => "expression"), Match$1.tag("StatementSite", () => "statement"), Match$1.tag("SwitchCaseSite", () => "switch-case"), Match$1.exhaustive);
|
|
6467
6499
|
const replacementRecord = (mutant, applied) => {
|
|
6468
6500
|
const replacement = unwrapParenthesizedExpression(applied);
|
|
6469
6501
|
return {
|
|
@@ -6529,13 +6561,13 @@ const applyToClaim = (mutants, target, state, context) => {
|
|
|
6529
6561
|
} : claim)
|
|
6530
6562
|
}));
|
|
6531
6563
|
};
|
|
6532
|
-
const attachPlaceable = (mutants, frame, state, context) => Match.value(mutants.length > 0).pipe(Match.when(false, () => Result.succeed(state)), Match.when(true, () => Option$1.match(Option$1.fromNullishOr(framesUpward(frame).find((candidate) => state.claims.some((claim) => claim.node === candidate.node))), {
|
|
6564
|
+
const attachPlaceable = (mutants, frame, state, context) => Match$1.value(mutants.length > 0).pipe(Match$1.when(false, () => Result.succeed(state)), Match$1.when(true, () => Option$1.match(Option$1.fromNullishOr(framesUpward(frame).find((candidate) => state.claims.some((claim) => claim.node === candidate.node))), {
|
|
6533
6565
|
onNone: () => Result.fail(MutantsUnplaced.make({
|
|
6534
6566
|
fileName: context.fileName,
|
|
6535
6567
|
detail: JSON.stringify(mutants, null, 2)
|
|
6536
6568
|
})),
|
|
6537
6569
|
onSome: (target) => applyToClaim(mutants, target, state, context)
|
|
6538
|
-
})), Match.exhaustive);
|
|
6570
|
+
})), Match$1.exhaustive);
|
|
6539
6571
|
const collectPlan = (frame, candidates, plan, state, context) => {
|
|
6540
6572
|
const collected = plannedWithNodes(candidates, plan.mutants, context.fileName);
|
|
6541
6573
|
const nextState = {
|
|
@@ -6544,10 +6576,10 @@ const collectPlan = (frame, candidates, plan, state, context) => {
|
|
|
6544
6576
|
warnings: [...state.warnings, ...plan.warnings],
|
|
6545
6577
|
nextIndex: plan.nextIndex
|
|
6546
6578
|
};
|
|
6547
|
-
return Match.value(plan).pipe(Match.tag("MutantsPlanned", (planned) => attachPlaceable(plannedWithNodes(candidates, planned.placeable, context.fileName), frame, {
|
|
6579
|
+
return Match$1.value(plan).pipe(Match$1.tag("MutantsPlanned", (planned) => attachPlaceable(plannedWithNodes(candidates, planned.placeable, context.fileName), frame, {
|
|
6548
6580
|
...nextState,
|
|
6549
6581
|
hasLiveMutants: true
|
|
6550
|
-
}, context)), Match.orElse(() => Result.succeed(nextState)));
|
|
6582
|
+
}, context)), Match$1.orElse(() => Result.succeed(nextState)));
|
|
6551
6583
|
};
|
|
6552
6584
|
const planMutantsAt = (frame, candidates, directives, location, state, context) => {
|
|
6553
6585
|
const plan = planMutants(PlanMutantsCommand.make({
|
|
@@ -6561,13 +6593,13 @@ const planMutantsAt = (frame, candidates, directives, location, state, context)
|
|
|
6561
6593
|
directives: [...directives],
|
|
6562
6594
|
candidates: candidates.map((candidate) => candidate.data)
|
|
6563
6595
|
}));
|
|
6564
|
-
return Match.value(plan).pipe(Match.when(Result.isFailure, (failed) => Result.fail(failed.failure)), Match.orElse((succeeded) => collectPlan(frame, candidates, succeeded.success, state, context)));
|
|
6596
|
+
return Match$1.value(plan).pipe(Match$1.when(Result.isFailure, (failed) => Result.fail(failed.failure)), Match$1.orElse((succeeded) => collectPlan(frame, candidates, succeeded.success, state, context)));
|
|
6565
6597
|
};
|
|
6566
|
-
const candidatesFor = (frame, location, context) => Match.value(shouldMutateAt(location, context.mutateDescription)).pipe(Match.when(true, () => mutablesFor(frame, location, context)), Match.orElse(() => []));
|
|
6598
|
+
const candidatesFor = (frame, location, context) => Match$1.value(shouldMutateAt(location, context.mutateDescription)).pipe(Match$1.when(true, () => mutablesFor(frame, location, context)), Match$1.orElse(() => []));
|
|
6567
6599
|
const needsPlan = (candidates, directives) => [candidates.length > 0, directives.length > 0].some(Boolean);
|
|
6568
6600
|
const planAtNode = (frame, directives, location, state, context) => {
|
|
6569
6601
|
const candidates = candidatesFor(frame, location, context);
|
|
6570
|
-
return Match.value(needsPlan(candidates, directives)).pipe(Match.when(false, () => Result.succeed(state)), Match.when(true, () => planMutantsAt(frame, candidates, directives, location, state, context)), Match.exhaustive);
|
|
6602
|
+
return Match$1.value(needsPlan(candidates, directives)).pipe(Match$1.when(false, () => Result.succeed(state)), Match$1.when(true, () => planMutantsAt(frame, candidates, directives, location, state, context)), Match$1.exhaustive);
|
|
6571
6603
|
};
|
|
6572
6604
|
const claimSelf = (frame, facts, claims, context) => {
|
|
6573
6605
|
const claimed = placeMutants(PlaceMutantsCommand.make({
|
|
@@ -6575,11 +6607,11 @@ const claimSelf = (frame, facts, claims, context) => {
|
|
|
6575
6607
|
facts,
|
|
6576
6608
|
mutants: []
|
|
6577
6609
|
}));
|
|
6578
|
-
return Match.value(claimed.pipe(Result.isSuccess)).pipe(Match.when(true, () => [...claims, {
|
|
6610
|
+
return Match$1.value(claimed.pipe(Result.isSuccess)).pipe(Match$1.when(true, () => [...claims, {
|
|
6579
6611
|
node: frame.node,
|
|
6580
6612
|
facts,
|
|
6581
6613
|
applied: []
|
|
6582
|
-
}]), Match.orElse(() => claims));
|
|
6614
|
+
}]), Match$1.orElse(() => claims));
|
|
6583
6615
|
};
|
|
6584
6616
|
const siteOfClaim = (claim, context) => {
|
|
6585
6617
|
const mutants = claim.applied.map(([mutant]) => mutant);
|
|
@@ -6588,16 +6620,16 @@ const siteOfClaim = (claim, context) => {
|
|
|
6588
6620
|
facts: claim.facts,
|
|
6589
6621
|
mutants: claim.applied.map(([mutant, applied]) => replacementRecord(mutant, applied))
|
|
6590
6622
|
}));
|
|
6591
|
-
return Match.value(decision).pipe(Match.when(Result.isFailure, (refused) => Result.fail(refusedPlacement(refused.failure, claim.node, mutants, context))), Match.orElse((decided) => Result.succeed(decided.success)));
|
|
6623
|
+
return Match$1.value(decision).pipe(Match$1.when(Result.isFailure, (refused) => Result.fail(refusedPlacement(refused.failure, claim.node, mutants, context))), Match$1.orElse((decided) => Result.succeed(decided.success)));
|
|
6592
6624
|
};
|
|
6593
|
-
const emitClaim = (claim, state, context) => Match.value(claim.applied.length > 0).pipe(Match.when(false, () => Result.succeed(state)), Match.when(true, () => Result.map(siteOfClaim(claim, context), (site) => ({
|
|
6625
|
+
const emitClaim = (claim, state, context) => Match$1.value(claim.applied.length > 0).pipe(Match$1.when(false, () => Result.succeed(state)), Match$1.when(true, () => Result.map(siteOfClaim(claim, context), (site) => ({
|
|
6594
6626
|
...state,
|
|
6595
6627
|
placements: [...state.placements, {
|
|
6596
6628
|
node: claim.node,
|
|
6597
6629
|
placer: placerNameOf(site),
|
|
6598
6630
|
applied: claim.applied
|
|
6599
6631
|
}]
|
|
6600
|
-
}))), Match.exhaustive);
|
|
6632
|
+
}))), Match$1.exhaustive);
|
|
6601
6633
|
const emitPlacement = (frame, state, context) => Option$1.match(Option$1.fromNullishOr(state.claims.find((claim) => claim.node === frame.node)), {
|
|
6602
6634
|
onNone: () => Result.succeed(state),
|
|
6603
6635
|
onSome: (claim) => emitClaim(claim, state, context)
|
|
@@ -6620,7 +6652,7 @@ const foldPlacements = (frame, state, context) => Result.flatMap(locationOfNode(
|
|
|
6620
6652
|
...state,
|
|
6621
6653
|
directiveRule: directives.reduce(foldInto, state.directiveRule)
|
|
6622
6654
|
};
|
|
6623
|
-
return Match.value(shouldSkipNode(frame, location, context.mutateDescription)).pipe(Match.when(true, () => Result.succeed(ruled)), Match.when(false, () => visitFrame(frame, directives, location, ruled, context)), Match.exhaustive);
|
|
6655
|
+
return Match$1.value(shouldSkipNode(frame, location, context.mutateDescription)).pipe(Match$1.when(true, () => Result.succeed(ruled)), Match$1.when(false, () => visitFrame(frame, directives, location, ruled, context)), Match$1.exhaustive);
|
|
6624
6656
|
});
|
|
6625
6657
|
const planInstrumentation = (root, firstIndex, context) => Result.map(foldPlacements({
|
|
6626
6658
|
node: root,
|
|
@@ -6665,19 +6697,19 @@ const applyPlan = (root, plan, context) => {
|
|
|
6665
6697
|
}))
|
|
6666
6698
|
});
|
|
6667
6699
|
};
|
|
6668
|
-
const refusalError = (refusal) => Match.value(refusal).pipe(Match.tag("NodeWithoutSpan", () => InstrumentError.make({
|
|
6700
|
+
const refusalError = (refusal) => Match$1.value(refusal).pipe(Match$1.tag("NodeWithoutSpan", () => InstrumentError.make({
|
|
6669
6701
|
message: "Node without a span",
|
|
6670
6702
|
cause: void 0
|
|
6671
|
-
})), Match.tag("MutantsUnplaced", (unplaced) => InstrumentError.make({
|
|
6703
|
+
})), Match$1.tag("MutantsUnplaced", (unplaced) => InstrumentError.make({
|
|
6672
6704
|
message: `Mutants cannot be placed. This shouldn't happen! Unplaced mutants: ${unplaced.detail}`,
|
|
6673
6705
|
cause: void 0
|
|
6674
|
-
})), Match.tag("PlacementRefused", (refused) => InstrumentError.make({
|
|
6706
|
+
})), Match$1.tag("PlacementRefused", (refused) => InstrumentError.make({
|
|
6675
6707
|
message: refused.message,
|
|
6676
6708
|
cause: new Error(refused.message)
|
|
6677
|
-
})), Match.tag("MutantWithoutLocation", (failed) => InstrumentError.make({
|
|
6709
|
+
})), Match$1.tag("MutantWithoutLocation", (failed) => InstrumentError.make({
|
|
6678
6710
|
message: `Mutant without a source location: ${failed.mutatorName} in ${failed.fileName}`,
|
|
6679
6711
|
cause: void 0
|
|
6680
|
-
})), Match.exhaustive);
|
|
6712
|
+
})), Match$1.exhaustive);
|
|
6681
6713
|
const transformScriptDataFirst = Effect$1.fn("stryker.instrument.transform.script")(function* ({ root, originFileName, rawContent, offset, comments }, mutantCollector, { options, mutateDescription, basePath }) {
|
|
6682
6714
|
const lineStarts = lineStartsOf(rawContent);
|
|
6683
6715
|
attachComments(make(root), comments, lineStarts);
|
|
@@ -6697,10 +6729,10 @@ const transformScriptDataFirst = Effect$1.fn("stryker.instrument.transform.scrip
|
|
|
6697
6729
|
try: () => planInstrumentation(root, mutantCollector.nextIndex, context),
|
|
6698
6730
|
catch: traversalFailure
|
|
6699
6731
|
});
|
|
6700
|
-
const plan = yield* Match.value(planned).pipe(Match.when(Result.isFailure, (refused) => {
|
|
6732
|
+
const plan = yield* Match$1.value(planned).pipe(Match$1.when(Result.isFailure, (refused) => {
|
|
6701
6733
|
const error = refusalError(refused.failure);
|
|
6702
6734
|
return Effect$1.fail(error);
|
|
6703
|
-
}), Match.orElse((succeeded) => Effect$1.succeed(succeeded.success)));
|
|
6735
|
+
}), Match$1.orElse((succeeded) => Effect$1.succeed(succeeded.success)));
|
|
6704
6736
|
mutantCollector.append(plan.mutants);
|
|
6705
6737
|
yield* applyPlan(root, plan, context);
|
|
6706
6738
|
yield* placeHeaderIfNeeded(plan.hasLiveMutants, options, root);
|
|
@@ -6769,7 +6801,7 @@ const scriptAstError = (ast) => InstrumentError.make({
|
|
|
6769
6801
|
message: `Expected a script AST, received the "${ast.format}" format`,
|
|
6770
6802
|
cause: void 0
|
|
6771
6803
|
});
|
|
6772
|
-
const scriptAstOf = (ast) => Match.value(ast).pipe(Match.when({ format: "embedded" }, () => Option$1.none()), Match.orElse((script) => Option$1.some(script)));
|
|
6804
|
+
const scriptAstOf = (ast) => Match$1.value(ast).pipe(Match$1.when({ format: "embedded" }, () => Option$1.none()), Match$1.orElse((script) => Option$1.some(script)));
|
|
6773
6805
|
const extensionOf = (fileName) => {
|
|
6774
6806
|
const dot = fileName.lastIndexOf(".");
|
|
6775
6807
|
return dot > Math.max(fileName.lastIndexOf("/"), fileName.lastIndexOf("\\")) ? fileName.slice(dot).toLowerCase() : "";
|
|
@@ -6811,8 +6843,8 @@ const scriptHooks = (scriptFormat) => ({
|
|
|
6811
6843
|
onSome: (script) => Effect$1.succeed(disableTypeCheckingInScript(script))
|
|
6812
6844
|
})
|
|
6813
6845
|
});
|
|
6814
|
-
const parseScriptFormat = (scriptFormat, text, fileName) => Match.value(scriptFormat).pipe(Match.when("js", () => parseJS(text, fileName)), Match.when("ts", () => parseTS(text, fileName)), Match.when("tsx", () => parseTsx(text, fileName)), Match.exhaustive);
|
|
6815
|
-
const printScriptAst = (ast, context) => Match.value(ast).pipe(Match.when({ format: "js" }, (js) => jsPrint(js, context)), Match.when({ format: "ts" }, (ts) => tsPrint(ts, context)), Match.when({ format: "tsx" }, (tsx) => tsPrint(tsx, context)), Match.orElse(printNothingForEmbeddedAst));
|
|
6846
|
+
const parseScriptFormat = (scriptFormat, text, fileName) => Match$1.value(scriptFormat).pipe(Match$1.when("js", () => parseJS(text, fileName)), Match$1.when("ts", () => parseTS(text, fileName)), Match$1.when("tsx", () => parseTsx(text, fileName)), Match$1.exhaustive);
|
|
6847
|
+
const printScriptAst = (ast, context) => Match$1.value(ast).pipe(Match$1.when({ format: "js" }, (js) => jsPrint(js, context)), Match$1.when({ format: "ts" }, (ts) => tsPrint(ts, context)), Match$1.when({ format: "tsx" }, (tsx) => tsPrint(tsx, context)), Match$1.orElse(printNothingForEmbeddedAst));
|
|
6816
6848
|
const printNothingForEmbeddedAst = () => "";
|
|
6817
6849
|
const coreFormatRegistry = formatRegistry([
|
|
6818
6850
|
{
|
|
@@ -6898,8 +6930,8 @@ const unclaimedOverrideError = (file) => InstrumentError.make({
|
|
|
6898
6930
|
message: `No installed format owns ${file.name}`,
|
|
6899
6931
|
cause: /* @__PURE__ */ new Error(`Unresolvable format pin for ${file.name}`)
|
|
6900
6932
|
});
|
|
6901
|
-
const outcomeFor = (registry, file, decision) => Match.value(decision).pipe(Match.when(S.is(FormatAssigned), (assigned) => parsedOutcomeFor(registry, file, assigned)), Match.when(S.is(FormatSkipped), (skipped) => Effect$1.succeed(skippedOutcomeFor(file, skipped))), Match.exhaustive);
|
|
6902
|
-
const fileOutcome = (request) => Match.value(resolveFile(request.registry, request.file.name)).pipe(Match.when(Result.isSuccess, (resolved) => outcomeFor(request.registry, request.file, resolved.success)), Match.orElse(() => Effect$1.fail(unclaimedOverrideError(request.file))));
|
|
6933
|
+
const outcomeFor = (registry, file, decision) => Match$1.value(decision).pipe(Match$1.when(S.is(FormatAssigned), (assigned) => parsedOutcomeFor(registry, file, assigned)), Match$1.when(S.is(FormatSkipped), (skipped) => Effect$1.succeed(skippedOutcomeFor(file, skipped))), Match$1.exhaustive);
|
|
6934
|
+
const fileOutcome = (request) => Match$1.value(resolveFile(request.registry, request.file.name)).pipe(Match$1.when(Result.isSuccess, (resolved) => outcomeFor(request.registry, request.file, resolved.success)), Match$1.orElse(() => Effect$1.fail(unclaimedOverrideError(request.file))));
|
|
6903
6935
|
const isParsedOutcome = (outcome) => outcome.kind === "parsed";
|
|
6904
6936
|
const skipsOf = (outcome) => outcome.kind === "skipped" ? [outcome.record] : [];
|
|
6905
6937
|
const transformInto = (request) => transform(request.ast, request.collector, {
|
|
@@ -6917,7 +6949,7 @@ const collectMutants = (collector) => Effect$1.flatMap(Effect$1.sync(() => Resul
|
|
|
6917
6949
|
const isScriptEntry = (entry) => entry.claim.kind === "script";
|
|
6918
6950
|
const lacksTsDirective = (file) => !tsDirectiveLikeRegEx.test(file.content);
|
|
6919
6951
|
const prefixesScriptWithoutParsing = (file, entry) => entry.scriptFormat !== "tsx" && lacksTsDirective(file);
|
|
6920
|
-
const prefixesWithoutParsing = (file, entry) => Match.value(entry).pipe(Match.when(isScriptEntry, (scriptEntry) => prefixesScriptWithoutParsing(file, scriptEntry)), Match.orElse(() => false));
|
|
6952
|
+
const prefixesWithoutParsing = (file, entry) => Match$1.value(entry).pipe(Match$1.when(isScriptEntry, (scriptEntry) => prefixesScriptWithoutParsing(file, scriptEntry)), Match$1.orElse(() => false));
|
|
6921
6953
|
const disabledFile = (file, entry, ast) => Effect$1.map(entry.disableTypeChecks(ast), (content) => ({
|
|
6922
6954
|
...file,
|
|
6923
6955
|
content
|
|
@@ -6979,7 +7011,7 @@ const embeddedAstError = (ast) => InstrumentError.make({
|
|
|
6979
7011
|
message: `Expected an embedded document AST, received the "${ast.format}" format`,
|
|
6980
7012
|
cause: void 0
|
|
6981
7013
|
});
|
|
6982
|
-
const embeddedOf = (ast) => Match.value(ast).pipe(Match.when({ format: "embedded" }, (embedded) => Option$1.some(embedded)), Match.orElse(() => Option$1.none()));
|
|
7014
|
+
const embeddedOf = (ast) => Match$1.value(ast).pipe(Match$1.when({ format: "embedded" }, (embedded) => Option$1.some(embedded)), Match$1.orElse(() => Option$1.none()));
|
|
6983
7015
|
const printNothingForNonEmbeddedAst = () => "";
|
|
6984
7016
|
const frameworkFailure = (moduleName, fileName, detail) => InstrumentError.make({
|
|
6985
7017
|
message: `The framework "${moduleName}" could not parse ${fileName}: ${detail}`,
|
|
@@ -7084,10 +7116,10 @@ const admitInstrumentFiles = Workflow.make({
|
|
|
7084
7116
|
command: InstrumentFilesCommand,
|
|
7085
7117
|
decision: S.Union([InstrumentFilesAdmitted, InstrumentFilesSkippedOnly]),
|
|
7086
7118
|
error: S.Never,
|
|
7087
|
-
decide: (command) => Match.value(isZero(command.claimedCount)).pipe(Match.when(true, () => Result.succeed(InstrumentFilesSkippedOnly.make({ skipped: command.skipped }))), Match.when(false, () => Result.succeed(InstrumentFilesAdmitted.make({
|
|
7119
|
+
decide: (command) => Match$1.value(isZero(command.claimedCount)).pipe(Match$1.when(true, () => Result.succeed(InstrumentFilesSkippedOnly.make({ skipped: command.skipped }))), Match$1.when(false, () => Result.succeed(InstrumentFilesAdmitted.make({
|
|
7088
7120
|
fileCount: command.fileCount,
|
|
7089
7121
|
skipped: command.skipped
|
|
7090
|
-
}))), Match.exhaustive)
|
|
7122
|
+
}))), Match$1.exhaustive)
|
|
7091
7123
|
});
|
|
7092
7124
|
const printedFile = (raw, { file, ast }) => Result.map(print(ast, raw.registry.entryForFormat), (content) => ({
|
|
7093
7125
|
name: file.name,
|
|
@@ -7241,7 +7273,12 @@ var CheckerFailed = class extends S.TaggedError()("CheckerFailed", {
|
|
|
7241
7273
|
cause: S.String,
|
|
7242
7274
|
checkerName: S.String,
|
|
7243
7275
|
mutantIds: S.Array(Mutant_exports.MutantId)
|
|
7244
|
-
}) {
|
|
7276
|
+
}) {
|
|
7277
|
+
get message() {
|
|
7278
|
+
const mutants = this.mutantIds.length === 0 ? "" : ` for mutants ${this.mutantIds.join(", ")}`;
|
|
7279
|
+
return `Checker "${this.checkerName}" failed${mutants}: ${this.cause}`;
|
|
7280
|
+
}
|
|
7281
|
+
};
|
|
7245
7282
|
var Checker = class extends Context.Service()("@systemfsoftware/stryker-js-plugin-interface/Checker.service/Checker") {};
|
|
7246
7283
|
var Checker_exports = /* @__PURE__ */ __exportAll({
|
|
7247
7284
|
CheckResultSchema: () => CheckResultSchema,
|
|
@@ -7420,7 +7457,11 @@ var TestRunnerFailed = class extends S.TaggedError()("TestRunnerFailed", {
|
|
|
7420
7457
|
"mutantRun"
|
|
7421
7458
|
]),
|
|
7422
7459
|
runnerName: S.String
|
|
7423
|
-
}) {
|
|
7460
|
+
}) {
|
|
7461
|
+
get message() {
|
|
7462
|
+
return `Test runner "${this.runnerName}" failed during ${this.phase}: ${this.cause}`;
|
|
7463
|
+
}
|
|
7464
|
+
};
|
|
7424
7465
|
const MutantResultSchema = S.Struct({
|
|
7425
7466
|
id: Mutant_exports.MutantId,
|
|
7426
7467
|
mutatorName: S.String,
|
|
@@ -7794,7 +7835,11 @@ var ReporterFailed = class extends S.TaggedError()("ReporterFailed", {
|
|
|
7794
7835
|
cause: S.String,
|
|
7795
7836
|
event: ReporterEventKind,
|
|
7796
7837
|
reporterName: S.String
|
|
7797
|
-
}) {
|
|
7838
|
+
}) {
|
|
7839
|
+
get message() {
|
|
7840
|
+
return `Reporter "${this.reporterName}" failed while handling ${this.event}: ${this.cause}`;
|
|
7841
|
+
}
|
|
7842
|
+
};
|
|
7798
7843
|
const TraceparentHeader = S.Literal("traceparent");
|
|
7799
7844
|
const TracestateHeader = S.Literal("tracestate");
|
|
7800
7845
|
const VERSION = S.String.pipe(S.check(S.isPattern(/^([0-9a-e][0-9a-f]|[0-9a-f][0-9a-e])$/)));
|
|
@@ -7891,12 +7936,20 @@ var BoundaryPayloadRejected = class extends S.TaggedError()("BoundaryPayloadReje
|
|
|
7891
7936
|
pluginName: S.String,
|
|
7892
7937
|
method: S.String,
|
|
7893
7938
|
cause: S.String
|
|
7894
|
-
}) {
|
|
7939
|
+
}) {
|
|
7940
|
+
get message() {
|
|
7941
|
+
return `Plugin "${this.pluginName}" rejected the payload for ${this.method}: ${this.cause}`;
|
|
7942
|
+
}
|
|
7943
|
+
};
|
|
7895
7944
|
var BoundaryUnrecognizedSignal = class extends S.TaggedError()("BoundaryUnrecognizedSignal", {
|
|
7896
7945
|
pluginName: S.String,
|
|
7897
7946
|
method: S.String,
|
|
7898
7947
|
signal: S.String
|
|
7899
|
-
}) {
|
|
7948
|
+
}) {
|
|
7949
|
+
get message() {
|
|
7950
|
+
return `Plugin "${this.pluginName}" sent an unrecognized signal "${this.signal}" for ${this.method}`;
|
|
7951
|
+
}
|
|
7952
|
+
};
|
|
7900
7953
|
const BoundaryErrorSchema = S.Union([
|
|
7901
7954
|
BoundaryPayloadRejected,
|
|
7902
7955
|
BoundaryUnrecognizedSignal,
|