@effect/language-service 0.45.0 → 0.46.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/README.md +2 -0
- package/cli.js +613 -558
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +113 -29
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +131 -38
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +113 -29
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm/effect@3.
|
|
3
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Function.js
|
|
4
4
|
var isFunction = (input) => typeof input === "function";
|
|
5
5
|
var dual = function(arity, body) {
|
|
6
6
|
if (typeof arity === "function") {
|
|
@@ -96,7 +96,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// node_modules/.pnpm/effect@3.
|
|
99
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Equivalence.js
|
|
100
100
|
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
101
101
|
var array = (item) => make((self, that) => {
|
|
102
102
|
if (self.length !== that.length) {
|
|
@@ -111,7 +111,7 @@ var array = (item) => make((self, that) => {
|
|
|
111
111
|
return true;
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
// node_modules/.pnpm/effect@3.
|
|
114
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/GlobalValue.js
|
|
115
115
|
var globalStoreId = `effect/GlobalValue`;
|
|
116
116
|
var globalStore;
|
|
117
117
|
var globalValue = (id, compute) => {
|
|
@@ -125,7 +125,7 @@ var globalValue = (id, compute) => {
|
|
|
125
125
|
return globalStore.get(id);
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
// node_modules/.pnpm/effect@3.
|
|
128
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Predicate.js
|
|
129
129
|
var isString = (input) => typeof input === "string";
|
|
130
130
|
var isNumber = (input) => typeof input === "number";
|
|
131
131
|
var isBoolean = (input) => typeof input === "boolean";
|
|
@@ -135,7 +135,7 @@ var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
|
135
135
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
136
136
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
137
137
|
|
|
138
|
-
// node_modules/.pnpm/effect@3.
|
|
138
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Utils.js
|
|
139
139
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
140
140
|
var GenKindImpl = class {
|
|
141
141
|
value;
|
|
@@ -257,7 +257,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
|
|
|
257
257
|
var genConstructor = function* () {
|
|
258
258
|
}.constructor;
|
|
259
259
|
|
|
260
|
-
// node_modules/.pnpm/effect@3.
|
|
260
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Hash.js
|
|
261
261
|
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
|
|
262
262
|
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
263
263
|
var hash = (self) => {
|
|
@@ -356,7 +356,7 @@ var cached = function() {
|
|
|
356
356
|
return hash2;
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
-
// node_modules/.pnpm/effect@3.
|
|
359
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Equal.js
|
|
360
360
|
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
|
|
361
361
|
function equals() {
|
|
362
362
|
if (arguments.length === 1) {
|
|
@@ -410,7 +410,7 @@ function compareBoth(self, that) {
|
|
|
410
410
|
var isEqual = (u) => hasProperty(u, symbol2);
|
|
411
411
|
var equivalence = () => equals;
|
|
412
412
|
|
|
413
|
-
// node_modules/.pnpm/effect@3.
|
|
413
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Inspectable.js
|
|
414
414
|
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
415
415
|
var toJSON = (x) => {
|
|
416
416
|
try {
|
|
@@ -462,7 +462,7 @@ var redact = (u) => {
|
|
|
462
462
|
return u;
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
-
// node_modules/.pnpm/effect@3.
|
|
465
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Pipeable.js
|
|
466
466
|
var pipeArguments = (self, args2) => {
|
|
467
467
|
switch (args2.length) {
|
|
468
468
|
case 0:
|
|
@@ -495,14 +495,14 @@ var pipeArguments = (self, args2) => {
|
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
497
|
|
|
498
|
-
// node_modules/.pnpm/effect@3.
|
|
498
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/opCodes/effect.js
|
|
499
499
|
var OP_COMMIT = "Commit";
|
|
500
500
|
|
|
501
|
-
// node_modules/.pnpm/effect@3.
|
|
502
|
-
var moduleVersion = "3.
|
|
501
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/version.js
|
|
502
|
+
var moduleVersion = "3.18.4";
|
|
503
503
|
var getCurrentVersion = () => moduleVersion;
|
|
504
504
|
|
|
505
|
-
// node_modules/.pnpm/effect@3.
|
|
505
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/effectable.js
|
|
506
506
|
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
507
507
|
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
|
|
508
508
|
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
|
|
@@ -589,7 +589,7 @@ var StructuralCommitPrototype = {
|
|
|
589
589
|
...StructuralPrototype
|
|
590
590
|
};
|
|
591
591
|
|
|
592
|
-
// node_modules/.pnpm/effect@3.
|
|
592
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/option.js
|
|
593
593
|
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
594
594
|
var CommonProto = {
|
|
595
595
|
...EffectPrototype,
|
|
@@ -647,7 +647,7 @@ var some = (value) => {
|
|
|
647
647
|
return a;
|
|
648
648
|
};
|
|
649
649
|
|
|
650
|
-
// node_modules/.pnpm/effect@3.
|
|
650
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/either.js
|
|
651
651
|
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
|
|
652
652
|
var CommonProto2 = {
|
|
653
653
|
...EffectPrototype,
|
|
@@ -709,7 +709,7 @@ var right = (right3) => {
|
|
|
709
709
|
return a;
|
|
710
710
|
};
|
|
711
711
|
|
|
712
|
-
// node_modules/.pnpm/effect@3.
|
|
712
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Either.js
|
|
713
713
|
var right2 = right;
|
|
714
714
|
var left2 = left;
|
|
715
715
|
var isLeft2 = isLeft;
|
|
@@ -717,14 +717,14 @@ var isRight2 = isRight;
|
|
|
717
717
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
718
718
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
719
719
|
|
|
720
|
-
// node_modules/.pnpm/effect@3.
|
|
720
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/array.js
|
|
721
721
|
var isNonEmptyArray = (self) => self.length > 0;
|
|
722
722
|
|
|
723
|
-
// node_modules/.pnpm/effect@3.
|
|
723
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Order.js
|
|
724
724
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
725
725
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
726
726
|
|
|
727
|
-
// node_modules/.pnpm/effect@3.
|
|
727
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Option.js
|
|
728
728
|
var none2 = () => none;
|
|
729
729
|
var some2 = some;
|
|
730
730
|
var isNone2 = isNone;
|
|
@@ -735,7 +735,7 @@ var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nu
|
|
|
735
735
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
736
736
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
737
737
|
|
|
738
|
-
// node_modules/.pnpm/effect@3.
|
|
738
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Record.js
|
|
739
739
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
740
740
|
const out = {
|
|
741
741
|
...self
|
|
@@ -747,7 +747,7 @@ var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
747
747
|
});
|
|
748
748
|
var keys = (self) => Object.keys(self);
|
|
749
749
|
|
|
750
|
-
// node_modules/.pnpm/effect@3.
|
|
750
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Array.js
|
|
751
751
|
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
752
752
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
753
753
|
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
@@ -1175,6 +1175,9 @@ var all = fn("all")(
|
|
|
1175
1175
|
|
|
1176
1176
|
// src/core/LanguageServicePluginOptions.ts
|
|
1177
1177
|
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
1178
|
+
function isValidSeverityLevel(value) {
|
|
1179
|
+
return value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion";
|
|
1180
|
+
}
|
|
1178
1181
|
function parseDiagnosticSeverity(config) {
|
|
1179
1182
|
if (!isRecord(config)) return {};
|
|
1180
1183
|
return Object.fromEntries(
|
|
@@ -1182,9 +1185,7 @@ function parseDiagnosticSeverity(config) {
|
|
|
1182
1185
|
Object.entries(config),
|
|
1183
1186
|
filter(([key, value]) => isString(key) && isString(value)),
|
|
1184
1187
|
map4(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
|
|
1185
|
-
filter(
|
|
1186
|
-
([_, value]) => value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion"
|
|
1187
|
-
)
|
|
1188
|
+
filter(([_, value]) => isValidSeverityLevel(value))
|
|
1188
1189
|
)
|
|
1189
1190
|
);
|
|
1190
1191
|
}
|
|
@@ -1193,6 +1194,7 @@ var defaults = {
|
|
|
1193
1194
|
diagnostics: true,
|
|
1194
1195
|
diagnosticSeverity: {},
|
|
1195
1196
|
diagnosticsName: true,
|
|
1197
|
+
missingDiagnosticNextLine: "warning",
|
|
1196
1198
|
quickinfo: true,
|
|
1197
1199
|
quickinfoEffectParameters: "whentruncated",
|
|
1198
1200
|
quickinfoMaximumLength: -1,
|
|
@@ -1235,6 +1237,7 @@ function parse(config) {
|
|
|
1235
1237
|
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1236
1238
|
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1237
1239
|
diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
|
|
1240
|
+
missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
|
|
1238
1241
|
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1239
1242
|
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1240
1243
|
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
@@ -1996,7 +1999,8 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1996
1999
|
lineOverrides[ruleName].unshift({
|
|
1997
2000
|
pos: foundNode.node.pos,
|
|
1998
2001
|
end: foundNode.node.end,
|
|
1999
|
-
level: ruleLevel
|
|
2002
|
+
level: ruleLevel,
|
|
2003
|
+
commentRange: foundNode.commentRange
|
|
2000
2004
|
});
|
|
2001
2005
|
}
|
|
2002
2006
|
} else {
|
|
@@ -2069,6 +2073,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
2069
2073
|
fixes: entry.fixes.concat(node ? [fixByDisableNextLine(node)] : []).concat([fixByDisableEntireFile])
|
|
2070
2074
|
});
|
|
2071
2075
|
});
|
|
2076
|
+
const unusedLineOverrides = new Set(lineOverrides[ruleNameLowered] || []);
|
|
2072
2077
|
for (const emitted of applicableDiagnostics.slice(0)) {
|
|
2073
2078
|
let newLevel = defaultLevel;
|
|
2074
2079
|
const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
@@ -2076,6 +2081,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
2076
2081
|
);
|
|
2077
2082
|
if (lineOverride) {
|
|
2078
2083
|
newLevel = lineOverride.level;
|
|
2084
|
+
unusedLineOverrides.delete(lineOverride);
|
|
2079
2085
|
} else {
|
|
2080
2086
|
const sectionOverride = (sectionOverrides[ruleNameLowered] || []).find((_) => _.pos < emitted.range.pos);
|
|
2081
2087
|
if (sectionOverride) newLevel = sectionOverride.level;
|
|
@@ -2099,6 +2105,19 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
2099
2105
|
});
|
|
2100
2106
|
}
|
|
2101
2107
|
}
|
|
2108
|
+
if (pluginOptions.missingDiagnosticNextLine !== "off" && unusedLineOverrides.size > 0) {
|
|
2109
|
+
for (const unusedLineOverride of unusedLineOverrides) {
|
|
2110
|
+
diagnostics2.push({
|
|
2111
|
+
file: sourceFile,
|
|
2112
|
+
start: unusedLineOverride.commentRange.pos,
|
|
2113
|
+
length: unusedLineOverride.commentRange.end - unusedLineOverride.commentRange.pos,
|
|
2114
|
+
messageText: `@effect-diagnostics-next-line ${rule.name}:${unusedLineOverride.level} has no effect, make sure you are suppressing the right rule.`,
|
|
2115
|
+
category: levelToDiagnosticCategory[pluginOptions.missingDiagnosticNextLine],
|
|
2116
|
+
code: -1,
|
|
2117
|
+
source: "effect"
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2102
2121
|
return { diagnostics: diagnostics2, codeFixes };
|
|
2103
2122
|
});
|
|
2104
2123
|
return { execute };
|
|
@@ -3951,10 +3970,10 @@ var effectDataClasses = createCompletion({
|
|
|
3951
3970
|
})
|
|
3952
3971
|
});
|
|
3953
3972
|
|
|
3954
|
-
// node_modules/.pnpm/effect@3.
|
|
3973
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
3955
3974
|
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
3956
3975
|
|
|
3957
|
-
// node_modules/.pnpm/effect@3.
|
|
3976
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
3958
3977
|
var encode = (bytes) => {
|
|
3959
3978
|
const length = bytes.length;
|
|
3960
3979
|
let result = "";
|
|
@@ -3980,10 +3999,10 @@ var encode = (bytes) => {
|
|
|
3980
3999
|
};
|
|
3981
4000
|
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
3982
4001
|
|
|
3983
|
-
// node_modules/.pnpm/effect@3.
|
|
4002
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
3984
4003
|
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
3985
4004
|
|
|
3986
|
-
// node_modules/.pnpm/effect@3.
|
|
4005
|
+
// node_modules/.pnpm/effect@3.18.4/node_modules/effect/dist/esm/Encoding.js
|
|
3987
4006
|
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
3988
4007
|
|
|
3989
4008
|
// src/diagnostics/classSelfMismatch.ts
|
|
@@ -4545,6 +4564,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4545
4564
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4546
4565
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4547
4566
|
const typeParser = yield* service(TypeParser);
|
|
4567
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
4548
4568
|
const parseLeakedRequirements = cachedBy(
|
|
4549
4569
|
fn("leakingServices.checkServiceLeaking")(
|
|
4550
4570
|
function* (service2, atLocation) {
|
|
@@ -4602,7 +4622,21 @@ var leakingRequirements = createDiagnostic({
|
|
|
4602
4622
|
}
|
|
4603
4623
|
}
|
|
4604
4624
|
if (sharedRequirementsKeys && sharedRequirementsKeys.length > 0 && effectMembers >= 2) {
|
|
4605
|
-
return sharedRequirementsKeys.map((key) => memory.get(key))
|
|
4625
|
+
return sharedRequirementsKeys.map((key) => memory.get(key)).filter(
|
|
4626
|
+
(type) => {
|
|
4627
|
+
let symbol3 = type.symbol;
|
|
4628
|
+
if (symbol3 && symbol3.flags & ts.SymbolFlags.Alias) {
|
|
4629
|
+
symbol3 = typeChecker.getAliasedSymbol(symbol3);
|
|
4630
|
+
}
|
|
4631
|
+
return !(symbol3.declarations || []).some((declaration) => {
|
|
4632
|
+
const declarationSource = tsUtils.getSourceFileOfNode(declaration);
|
|
4633
|
+
if (!declarationSource) return false;
|
|
4634
|
+
return declarationSource.text.substring(declaration.pos, declaration.end).toLowerCase().indexOf(
|
|
4635
|
+
"@effect-leakable-service"
|
|
4636
|
+
) > -1;
|
|
4637
|
+
});
|
|
4638
|
+
}
|
|
4639
|
+
);
|
|
4606
4640
|
}
|
|
4607
4641
|
return [];
|
|
4608
4642
|
}
|
|
@@ -4615,7 +4649,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4615
4649
|
report({
|
|
4616
4650
|
location: node,
|
|
4617
4651
|
messageText: `This Service is leaking the ${requirements.map((_) => typeChecker.typeToString(_)).join(" | ")} requirement.
|
|
4618
|
-
If these requirements cannot be cached and are expected to be provided per method invocation (e.g. HttpServerRequest), you can safely disable this diagnostic for this line through quickfixes.
|
|
4652
|
+
If these requirements cannot be cached and are expected to be provided per method invocation (e.g. HttpServerRequest), you can either safely disable this diagnostic for this line through quickfixes or mark the service declaration with a JSDoc @effect-leakable-service.
|
|
4619
4653
|
More info at https://effect.website/docs/requirements-management/layers/#avoiding-requirement-leakage`,
|
|
4620
4654
|
fixes: []
|
|
4621
4655
|
});
|
|
@@ -5347,17 +5381,67 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
5347
5381
|
const members = node.members;
|
|
5348
5382
|
for (const member of members) {
|
|
5349
5383
|
if (ts.isConstructorDeclaration(member)) {
|
|
5384
|
+
const fixAsStaticNew = {
|
|
5385
|
+
fixName: "overriddenSchemaConstructor_static",
|
|
5386
|
+
description: "Rewrite using the static 'new' pattern",
|
|
5387
|
+
apply: gen(function* () {
|
|
5388
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
5389
|
+
const visitor = (node2) => {
|
|
5390
|
+
if (ts.isExpressionStatement(node2) && ts.isCallExpression(node2.expression) && ts.isToken(node2.expression.expression) && node2.expression.expression.kind === ts.SyntaxKind.SuperKeyword) {
|
|
5391
|
+
const constructThis = ts.factory.createNewExpression(
|
|
5392
|
+
ts.factory.createIdentifier("this"),
|
|
5393
|
+
void 0,
|
|
5394
|
+
node2.expression.arguments
|
|
5395
|
+
);
|
|
5396
|
+
return ts.factory.createVariableStatement(
|
|
5397
|
+
void 0,
|
|
5398
|
+
ts.factory.createVariableDeclarationList(
|
|
5399
|
+
[ts.factory.createVariableDeclaration(
|
|
5400
|
+
"_this",
|
|
5401
|
+
void 0,
|
|
5402
|
+
void 0,
|
|
5403
|
+
constructThis
|
|
5404
|
+
)],
|
|
5405
|
+
ts.NodeFlags.Const
|
|
5406
|
+
)
|
|
5407
|
+
);
|
|
5408
|
+
}
|
|
5409
|
+
if (ts.isToken(node2) && node2.kind === ts.SyntaxKind.ThisKeyword) {
|
|
5410
|
+
return ts.factory.createIdentifier("_this");
|
|
5411
|
+
}
|
|
5412
|
+
return ts.visitEachChild(node2, visitor, ts.nullTransformationContext);
|
|
5413
|
+
};
|
|
5414
|
+
const newBody = visitor(member.body);
|
|
5415
|
+
const bodyWithReturn = ts.factory.updateBlock(
|
|
5416
|
+
newBody,
|
|
5417
|
+
newBody.statements.concat([
|
|
5418
|
+
ts.factory.createReturnStatement(ts.factory.createIdentifier("_this"))
|
|
5419
|
+
])
|
|
5420
|
+
);
|
|
5421
|
+
const newMethod = ts.factory.createMethodDeclaration(
|
|
5422
|
+
ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Public | ts.ModifierFlags.Static),
|
|
5423
|
+
void 0,
|
|
5424
|
+
"new",
|
|
5425
|
+
void 0,
|
|
5426
|
+
member.typeParameters,
|
|
5427
|
+
member.parameters,
|
|
5428
|
+
member.type,
|
|
5429
|
+
bodyWithReturn
|
|
5430
|
+
);
|
|
5431
|
+
changeTracker.replaceNode(sourceFile, member, newMethod);
|
|
5432
|
+
})
|
|
5433
|
+
};
|
|
5350
5434
|
report({
|
|
5351
5435
|
location: member,
|
|
5352
|
-
messageText: "Classes extending Schema must not override the constructor",
|
|
5353
|
-
fixes: [{
|
|
5436
|
+
messageText: "Classes extending Schema must not override the constructor; this is because it silently breaks the schema decoding behaviour. If that's needed, we recommend instead to use a static 'new' method that constructs the instance.",
|
|
5437
|
+
fixes: (member.body ? [fixAsStaticNew] : []).concat([{
|
|
5354
5438
|
fixName: "overriddenSchemaConstructor_fix",
|
|
5355
5439
|
description: "Remove the constructor override",
|
|
5356
5440
|
apply: gen(function* () {
|
|
5357
5441
|
const changeTracker = yield* service(ChangeTracker);
|
|
5358
5442
|
changeTracker.delete(sourceFile, member);
|
|
5359
5443
|
})
|
|
5360
|
-
}]
|
|
5444
|
+
}])
|
|
5361
5445
|
});
|
|
5362
5446
|
break;
|
|
5363
5447
|
}
|
|
@@ -12281,7 +12365,7 @@ var layerMagic = createRefactor({
|
|
|
12281
12365
|
return pipe(
|
|
12282
12366
|
extractLayers(atLocation, false),
|
|
12283
12367
|
flatMap2(
|
|
12284
|
-
(extractedLayer) => extractedLayer.length
|
|
12368
|
+
(extractedLayer) => extractedLayer.length <= 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12285
12369
|
),
|
|
12286
12370
|
map5((extractedLayers) => ({
|
|
12287
12371
|
kind: "refactor.rewrite.effect.layerMagicPrepare",
|
|
@@ -12367,7 +12451,7 @@ var layerMagic = createRefactor({
|
|
|
12367
12451
|
extractArrayLiteral(_targetLayer.castedStructure),
|
|
12368
12452
|
orElse2(() => extractLayers(_targetLayer.castedStructure, false)),
|
|
12369
12453
|
flatMap2(
|
|
12370
|
-
(extractedLayer) => extractedLayer.length
|
|
12454
|
+
(extractedLayer) => extractedLayer.length <= 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12371
12455
|
),
|
|
12372
12456
|
map5((extractedLayers) => ({
|
|
12373
12457
|
kind: "refactor.rewrite.effect.layerMagicBuild",
|
|
@@ -12405,7 +12489,8 @@ var layerMagic = createRefactor({
|
|
|
12405
12489
|
const missingOutput = new Set(outputIndexes);
|
|
12406
12490
|
const missingInternal = /* @__PURE__ */ new Set();
|
|
12407
12491
|
const outputEntry = [];
|
|
12408
|
-
for (
|
|
12492
|
+
for (let i = 0; i < sortedNodes.length; i++) {
|
|
12493
|
+
const graphNode = sortedNodes[i];
|
|
12409
12494
|
const mergeOutput = graphNode.provides.filter((_) => missingOutput.has(_));
|
|
12410
12495
|
const provideInternal = graphNode.provides.filter((_) => missingInternal.has(_));
|
|
12411
12496
|
graphNode.requires.forEach((_) => missingInternal.add(_));
|
|
@@ -12433,7 +12518,15 @@ var layerMagic = createRefactor({
|
|
|
12433
12518
|
)
|
|
12434
12519
|
)
|
|
12435
12520
|
);
|
|
12436
|
-
|
|
12521
|
+
const newDeclarationWithComment = missingOutput.size > 0 ? ts.addSyntheticTrailingComment(
|
|
12522
|
+
newDeclaration,
|
|
12523
|
+
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
12524
|
+
" Unable to find " + fromIterable(missingOutput).map((key) => memory.get(key)).map(
|
|
12525
|
+
(_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)
|
|
12526
|
+
).join(", ") + " in the provided layers. ",
|
|
12527
|
+
false
|
|
12528
|
+
) : newDeclaration;
|
|
12529
|
+
changeTracker.replaceNode(sourceFile, atLocation, newDeclarationWithComment, {
|
|
12437
12530
|
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
|
|
12438
12531
|
trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude
|
|
12439
12532
|
});
|