@effect/language-service 0.42.0 → 0.43.1
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 +52 -1
- package/effect-lsp-patch-utils.js +144 -3
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +421 -275
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +144 -3
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -717,6 +717,9 @@ 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.17.8/node_modules/effect/dist/esm/internal/array.js
|
|
721
|
+
var isNonEmptyArray = (self) => self.length > 0;
|
|
722
|
+
|
|
720
723
|
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Order.js
|
|
721
724
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
722
725
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
@@ -732,6 +735,116 @@ var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nu
|
|
|
732
735
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
733
736
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
734
737
|
|
|
738
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
|
|
739
|
+
var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
740
|
+
const out = {
|
|
741
|
+
...self
|
|
742
|
+
};
|
|
743
|
+
for (const key of keys(self)) {
|
|
744
|
+
out[key] = f(self[key], key);
|
|
745
|
+
}
|
|
746
|
+
return out;
|
|
747
|
+
});
|
|
748
|
+
var keys = (self) => Object.keys(self);
|
|
749
|
+
|
|
750
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
|
|
751
|
+
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
752
|
+
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
753
|
+
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
754
|
+
var isArray = Array.isArray;
|
|
755
|
+
var isEmptyArray = (self) => self.length === 0;
|
|
756
|
+
var isEmptyReadonlyArray = isEmptyArray;
|
|
757
|
+
var isNonEmptyReadonlyArray = isNonEmptyArray;
|
|
758
|
+
var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
|
|
759
|
+
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
760
|
+
const i = Math.floor(index);
|
|
761
|
+
return isOutOfBounds(i, self) ? none2() : some2(self[i]);
|
|
762
|
+
});
|
|
763
|
+
var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
764
|
+
const i = Math.floor(index);
|
|
765
|
+
if (isOutOfBounds(i, self)) {
|
|
766
|
+
throw new Error(`Index ${i} out of bounds`);
|
|
767
|
+
}
|
|
768
|
+
return self[i];
|
|
769
|
+
});
|
|
770
|
+
var head = /* @__PURE__ */ get(0);
|
|
771
|
+
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
772
|
+
var tailNonEmpty = (self) => self.slice(1);
|
|
773
|
+
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
774
|
+
const out = Array.from(self);
|
|
775
|
+
out.sort(O);
|
|
776
|
+
return out;
|
|
777
|
+
});
|
|
778
|
+
var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
779
|
+
for (const i of self) {
|
|
780
|
+
if (isEquivalent(a, i)) {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return false;
|
|
785
|
+
});
|
|
786
|
+
var _equivalence = /* @__PURE__ */ equivalence();
|
|
787
|
+
var intersectionWith = (isEquivalent) => {
|
|
788
|
+
const has = containsWith(isEquivalent);
|
|
789
|
+
return dual(2, (self, that) => fromIterable(self).filter((a) => has(that, a)));
|
|
790
|
+
};
|
|
791
|
+
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
792
|
+
var empty = () => [];
|
|
793
|
+
var map4 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
794
|
+
var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
795
|
+
if (isEmptyReadonlyArray(self)) {
|
|
796
|
+
return [];
|
|
797
|
+
}
|
|
798
|
+
const out = [];
|
|
799
|
+
for (let i = 0; i < self.length; i++) {
|
|
800
|
+
const inner = f(self[i], i);
|
|
801
|
+
for (let j = 0; j < inner.length; j++) {
|
|
802
|
+
out.push(inner[j]);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return out;
|
|
806
|
+
});
|
|
807
|
+
var flatten = /* @__PURE__ */ flatMap(identity);
|
|
808
|
+
var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
809
|
+
const as = fromIterable(self);
|
|
810
|
+
const out = [];
|
|
811
|
+
for (let i = 0; i < as.length; i++) {
|
|
812
|
+
if (predicate(as[i], i)) {
|
|
813
|
+
out.push(as[i]);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return out;
|
|
817
|
+
});
|
|
818
|
+
var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
819
|
+
const left3 = [];
|
|
820
|
+
const right3 = [];
|
|
821
|
+
const as = fromIterable(self);
|
|
822
|
+
for (let i = 0; i < as.length; i++) {
|
|
823
|
+
if (predicate(as[i], i)) {
|
|
824
|
+
right3.push(as[i]);
|
|
825
|
+
} else {
|
|
826
|
+
left3.push(as[i]);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return [left3, right3];
|
|
830
|
+
});
|
|
831
|
+
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
832
|
+
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
833
|
+
const input = fromIterable(self);
|
|
834
|
+
if (isNonEmptyReadonlyArray(input)) {
|
|
835
|
+
const out = [headNonEmpty(input)];
|
|
836
|
+
const rest = tailNonEmpty(input);
|
|
837
|
+
for (const r of rest) {
|
|
838
|
+
if (out.every((a) => !isEquivalent(r, a))) {
|
|
839
|
+
out.push(r);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return out;
|
|
843
|
+
}
|
|
844
|
+
return [];
|
|
845
|
+
});
|
|
846
|
+
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
847
|
+
|
|
735
848
|
// src/core/Nano.ts
|
|
736
849
|
var NanoTag = class {
|
|
737
850
|
constructor(key) {
|
|
@@ -903,13 +1016,13 @@ var OnSuccessProto = {
|
|
|
903
1016
|
return this[args];
|
|
904
1017
|
}
|
|
905
1018
|
};
|
|
906
|
-
var
|
|
1019
|
+
var flatMap2 = dual(2, (fa, f) => {
|
|
907
1020
|
const nano = Object.create(OnSuccessProto);
|
|
908
1021
|
nano[args] = fa;
|
|
909
1022
|
nano[contA] = f;
|
|
910
1023
|
return nano;
|
|
911
1024
|
});
|
|
912
|
-
var
|
|
1025
|
+
var map5 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
|
|
913
1026
|
var SyncProto = {
|
|
914
1027
|
...PrimitiveProto,
|
|
915
1028
|
[evaluate](fiber) {
|
|
@@ -1060,6 +1173,78 @@ var all = fn("all")(
|
|
|
1060
1173
|
}
|
|
1061
1174
|
);
|
|
1062
1175
|
|
|
1176
|
+
// src/core/LanguageServicePluginOptions.ts
|
|
1177
|
+
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
1178
|
+
function parseDiagnosticSeverity(config) {
|
|
1179
|
+
if (!isRecord(config)) return {};
|
|
1180
|
+
return Object.fromEntries(
|
|
1181
|
+
pipe(
|
|
1182
|
+
Object.entries(config),
|
|
1183
|
+
filter(([key, value]) => isString(key) && isString(value)),
|
|
1184
|
+
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
|
+
)
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
var defaults = {
|
|
1192
|
+
refactors: true,
|
|
1193
|
+
diagnostics: true,
|
|
1194
|
+
diagnosticSeverity: {},
|
|
1195
|
+
quickinfo: true,
|
|
1196
|
+
quickinfoEffectParameters: "whentruncated",
|
|
1197
|
+
quickinfoMaximumLength: -1,
|
|
1198
|
+
completions: true,
|
|
1199
|
+
goto: true,
|
|
1200
|
+
inlays: true,
|
|
1201
|
+
allowedDuplicatedPackages: [],
|
|
1202
|
+
namespaceImportPackages: [],
|
|
1203
|
+
topLevelNamedReexports: "ignore",
|
|
1204
|
+
barrelImportPackages: [],
|
|
1205
|
+
importAliases: {},
|
|
1206
|
+
renames: true,
|
|
1207
|
+
noExternal: false,
|
|
1208
|
+
keyPatterns: [{
|
|
1209
|
+
target: "service",
|
|
1210
|
+
pattern: "default",
|
|
1211
|
+
skipLeadingPath: ["src/"]
|
|
1212
|
+
}]
|
|
1213
|
+
};
|
|
1214
|
+
function parseKeyPatterns(patterns) {
|
|
1215
|
+
const result = [];
|
|
1216
|
+
for (const entry of patterns) {
|
|
1217
|
+
if (!isObject(entry)) continue;
|
|
1218
|
+
result.push({
|
|
1219
|
+
target: hasProperty(entry, "target") && isString(entry.target) && ["service", "error"].includes(entry.target.toLowerCase()) ? entry.target.toLowerCase() : "service",
|
|
1220
|
+
pattern: hasProperty(entry, "pattern") && isString(entry.pattern) && ["package-identifier", "default"].includes(entry.pattern.toLowerCase()) ? entry.pattern.toLowerCase() : "default",
|
|
1221
|
+
skipLeadingPath: hasProperty(entry, "skipLeadingPath") && isArray(entry.skipLeadingPath) && entry.skipLeadingPath.every(isString) ? entry.skipLeadingPath : ["src/"]
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
return result;
|
|
1225
|
+
}
|
|
1226
|
+
function parse(config) {
|
|
1227
|
+
return {
|
|
1228
|
+
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1229
|
+
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1230
|
+
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1231
|
+
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1232
|
+
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1233
|
+
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
1234
|
+
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1235
|
+
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1236
|
+
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
1237
|
+
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1238
|
+
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1239
|
+
barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
|
|
1240
|
+
importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map3(config.importAliases, (value) => String(value)) : defaults.importAliases,
|
|
1241
|
+
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
|
|
1242
|
+
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1243
|
+
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
|
|
1244
|
+
keyPatterns: isObject(config) && hasProperty(config, "keyPatterns") && isArray(config.keyPatterns) ? parseKeyPatterns(config.keyPatterns) : defaults.keyPatterns
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1063
1248
|
// src/core/TypeScriptApi.ts
|
|
1064
1249
|
var TypeScriptApi = Tag("TypeScriptApi");
|
|
1065
1250
|
var TypeScriptProgram = Tag("TypeScriptProgram");
|
|
@@ -1127,124 +1312,11 @@ function makeGetEntrypointsFromPackageJsonInfo(ts) {
|
|
|
1127
1312
|
}
|
|
1128
1313
|
}
|
|
1129
1314
|
|
|
1130
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
|
|
1131
|
-
var isNonEmptyArray = (self) => self.length > 0;
|
|
1132
|
-
|
|
1133
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
|
|
1134
|
-
var map4 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
1135
|
-
const out = {
|
|
1136
|
-
...self
|
|
1137
|
-
};
|
|
1138
|
-
for (const key of keys(self)) {
|
|
1139
|
-
out[key] = f(self[key], key);
|
|
1140
|
-
}
|
|
1141
|
-
return out;
|
|
1142
|
-
});
|
|
1143
|
-
var keys = (self) => Object.keys(self);
|
|
1144
|
-
|
|
1145
|
-
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
|
|
1146
|
-
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
1147
|
-
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
1148
|
-
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
1149
|
-
var isArray = Array.isArray;
|
|
1150
|
-
var isEmptyArray = (self) => self.length === 0;
|
|
1151
|
-
var isEmptyReadonlyArray = isEmptyArray;
|
|
1152
|
-
var isNonEmptyReadonlyArray = isNonEmptyArray;
|
|
1153
|
-
var isOutOfBounds = (i, as) => i < 0 || i >= as.length;
|
|
1154
|
-
var get = /* @__PURE__ */ dual(2, (self, index) => {
|
|
1155
|
-
const i = Math.floor(index);
|
|
1156
|
-
return isOutOfBounds(i, self) ? none2() : some2(self[i]);
|
|
1157
|
-
});
|
|
1158
|
-
var unsafeGet = /* @__PURE__ */ dual(2, (self, index) => {
|
|
1159
|
-
const i = Math.floor(index);
|
|
1160
|
-
if (isOutOfBounds(i, self)) {
|
|
1161
|
-
throw new Error(`Index ${i} out of bounds`);
|
|
1162
|
-
}
|
|
1163
|
-
return self[i];
|
|
1164
|
-
});
|
|
1165
|
-
var head = /* @__PURE__ */ get(0);
|
|
1166
|
-
var headNonEmpty = /* @__PURE__ */ unsafeGet(0);
|
|
1167
|
-
var tailNonEmpty = (self) => self.slice(1);
|
|
1168
|
-
var sort = /* @__PURE__ */ dual(2, (self, O) => {
|
|
1169
|
-
const out = Array.from(self);
|
|
1170
|
-
out.sort(O);
|
|
1171
|
-
return out;
|
|
1172
|
-
});
|
|
1173
|
-
var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
1174
|
-
for (const i of self) {
|
|
1175
|
-
if (isEquivalent(a, i)) {
|
|
1176
|
-
return true;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
return false;
|
|
1180
|
-
});
|
|
1181
|
-
var _equivalence = /* @__PURE__ */ equivalence();
|
|
1182
|
-
var intersectionWith = (isEquivalent) => {
|
|
1183
|
-
const has = containsWith(isEquivalent);
|
|
1184
|
-
return dual(2, (self, that) => fromIterable(self).filter((a) => has(that, a)));
|
|
1185
|
-
};
|
|
1186
|
-
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
1187
|
-
var empty = () => [];
|
|
1188
|
-
var map5 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
1189
|
-
var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
1190
|
-
if (isEmptyReadonlyArray(self)) {
|
|
1191
|
-
return [];
|
|
1192
|
-
}
|
|
1193
|
-
const out = [];
|
|
1194
|
-
for (let i = 0; i < self.length; i++) {
|
|
1195
|
-
const inner = f(self[i], i);
|
|
1196
|
-
for (let j = 0; j < inner.length; j++) {
|
|
1197
|
-
out.push(inner[j]);
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
return out;
|
|
1201
|
-
});
|
|
1202
|
-
var flatten = /* @__PURE__ */ flatMap2(identity);
|
|
1203
|
-
var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
1204
|
-
const as = fromIterable(self);
|
|
1205
|
-
const out = [];
|
|
1206
|
-
for (let i = 0; i < as.length; i++) {
|
|
1207
|
-
if (predicate(as[i], i)) {
|
|
1208
|
-
out.push(as[i]);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
return out;
|
|
1212
|
-
});
|
|
1213
|
-
var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
1214
|
-
const left3 = [];
|
|
1215
|
-
const right3 = [];
|
|
1216
|
-
const as = fromIterable(self);
|
|
1217
|
-
for (let i = 0; i < as.length; i++) {
|
|
1218
|
-
if (predicate(as[i], i)) {
|
|
1219
|
-
right3.push(as[i]);
|
|
1220
|
-
} else {
|
|
1221
|
-
left3.push(as[i]);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return [left3, right3];
|
|
1225
|
-
});
|
|
1226
|
-
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
1227
|
-
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
1228
|
-
const input = fromIterable(self);
|
|
1229
|
-
if (isNonEmptyReadonlyArray(input)) {
|
|
1230
|
-
const out = [headNonEmpty(input)];
|
|
1231
|
-
const rest = tailNonEmpty(input);
|
|
1232
|
-
for (const r of rest) {
|
|
1233
|
-
if (out.every((a) => !isEquivalent(r, a))) {
|
|
1234
|
-
out.push(r);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return out;
|
|
1238
|
-
}
|
|
1239
|
-
return [];
|
|
1240
|
-
});
|
|
1241
|
-
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
1242
|
-
|
|
1243
1315
|
// src/core/TypeScriptUtils.ts
|
|
1244
1316
|
var TypeScriptUtils = Tag("TypeScriptUtils");
|
|
1245
1317
|
var nanoLayer = (fa) => pipe(
|
|
1246
1318
|
service(TypeScriptApi),
|
|
1247
|
-
|
|
1319
|
+
flatMap2((ts) => pipe(fa, provideService(TypeScriptUtils, makeTypeScriptUtils(ts))))
|
|
1248
1320
|
);
|
|
1249
1321
|
function makeTypeScriptUtils(ts) {
|
|
1250
1322
|
const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(ts);
|
|
@@ -1314,7 +1386,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1314
1386
|
return pipe(
|
|
1315
1387
|
referencedPackages.concat(packageJsonScope?.referencedPackages || []),
|
|
1316
1388
|
dedupe,
|
|
1317
|
-
|
|
1389
|
+
map4((packageName) => packageName.toLowerCase()),
|
|
1318
1390
|
filter(
|
|
1319
1391
|
(packageName) => pattern.endsWith("*") && packageName.startsWith(pattern.toLowerCase().substring(0, pattern.length - 1))
|
|
1320
1392
|
)
|
|
@@ -1728,59 +1800,66 @@ function makeTypeScriptUtils(ts) {
|
|
|
1728
1800
|
};
|
|
1729
1801
|
}
|
|
1730
1802
|
|
|
1731
|
-
// src/core/
|
|
1732
|
-
var
|
|
1733
|
-
function
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1803
|
+
// src/core/KeyBuilder.ts
|
|
1804
|
+
var makeKeyBuilder = fn("KeyBuilder")(
|
|
1805
|
+
function* (sourceFile) {
|
|
1806
|
+
const ts = yield* service(TypeScriptApi);
|
|
1807
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
1808
|
+
const program = yield* service(TypeScriptProgram);
|
|
1809
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
1810
|
+
const packageInfo = tsUtils.resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
|
|
1811
|
+
function createString2(classNameText, kind) {
|
|
1812
|
+
if (!packageInfo) return;
|
|
1813
|
+
for (const keyPattern of options.keyPatterns) {
|
|
1814
|
+
if (keyPattern.target !== kind) continue;
|
|
1815
|
+
const lastIndex = sourceFile.fileName.lastIndexOf("/");
|
|
1816
|
+
let onlyFileName = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
|
|
1817
|
+
const lastExtensionIndex = onlyFileName.lastIndexOf(".");
|
|
1818
|
+
if (lastExtensionIndex !== -1) onlyFileName = onlyFileName.slice(0, lastExtensionIndex);
|
|
1819
|
+
if (onlyFileName.toLowerCase().endsWith("/index")) onlyFileName = onlyFileName.slice(0, -6);
|
|
1820
|
+
if (onlyFileName.startsWith("/")) onlyFileName = onlyFileName.slice(1);
|
|
1821
|
+
let subDirectory = getDirectoryPath(ts, sourceFile.fileName);
|
|
1822
|
+
if (!subDirectory.startsWith(packageInfo.packageDirectory)) continue;
|
|
1823
|
+
subDirectory = subDirectory.slice(packageInfo.packageDirectory.length);
|
|
1824
|
+
if (!subDirectory.endsWith("/")) subDirectory = subDirectory + "/";
|
|
1825
|
+
if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
|
|
1826
|
+
for (const prefix of keyPattern.skipLeadingPath) {
|
|
1827
|
+
if (subDirectory.startsWith(prefix)) {
|
|
1828
|
+
subDirectory = subDirectory.slice(prefix.length);
|
|
1829
|
+
break;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
let parts = [packageInfo.name, subDirectory, onlyFileName].concat(
|
|
1833
|
+
onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
|
|
1834
|
+
);
|
|
1835
|
+
if (keyPattern.pattern === "package-identifier") {
|
|
1836
|
+
parts = [packageInfo.name, onlyFileName].concat(
|
|
1837
|
+
onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
parts = parts.map((part) => part.startsWith("/") ? part.slice(1) : part).map(
|
|
1841
|
+
(part) => part.endsWith("/") ? part.slice(0, -1) : part
|
|
1842
|
+
);
|
|
1843
|
+
return parts.filter((_) => String(_).trim().length > 0).join("/");
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
return {
|
|
1847
|
+
createString: createString2
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
);
|
|
1851
|
+
var keyBuilderCache = /* @__PURE__ */ new Map();
|
|
1852
|
+
var getOrMakeKeyBuilder = fn("getOrMakeKeyBuilder")(function* (sourceFile) {
|
|
1853
|
+
const keyBuilder = keyBuilderCache.get(sourceFile.fileName) || (yield* makeKeyBuilder(sourceFile));
|
|
1854
|
+
keyBuilderCache.set(sourceFile.fileName, keyBuilder);
|
|
1855
|
+
return keyBuilder;
|
|
1856
|
+
});
|
|
1857
|
+
function createString(sourceFile, identifier, kind) {
|
|
1858
|
+
return map5(
|
|
1859
|
+
getOrMakeKeyBuilder(sourceFile),
|
|
1860
|
+
(identifierBuilder) => identifierBuilder.createString(identifier, kind)
|
|
1744
1861
|
);
|
|
1745
1862
|
}
|
|
1746
|
-
var defaults = {
|
|
1747
|
-
refactors: true,
|
|
1748
|
-
diagnostics: true,
|
|
1749
|
-
diagnosticSeverity: {},
|
|
1750
|
-
quickinfo: true,
|
|
1751
|
-
quickinfoEffectParameters: "whentruncated",
|
|
1752
|
-
quickinfoMaximumLength: -1,
|
|
1753
|
-
completions: true,
|
|
1754
|
-
goto: true,
|
|
1755
|
-
inlays: true,
|
|
1756
|
-
allowedDuplicatedPackages: [],
|
|
1757
|
-
namespaceImportPackages: [],
|
|
1758
|
-
topLevelNamedReexports: "ignore",
|
|
1759
|
-
barrelImportPackages: [],
|
|
1760
|
-
importAliases: {},
|
|
1761
|
-
renames: true,
|
|
1762
|
-
noExternal: false
|
|
1763
|
-
};
|
|
1764
|
-
function parse(config) {
|
|
1765
|
-
return {
|
|
1766
|
-
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1767
|
-
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1768
|
-
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1769
|
-
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1770
|
-
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1771
|
-
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
1772
|
-
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1773
|
-
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1774
|
-
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
1775
|
-
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1776
|
-
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1777
|
-
barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
|
|
1778
|
-
importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map4(config.importAliases, (value) => String(value)) : defaults.importAliases,
|
|
1779
|
-
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
|
|
1780
|
-
renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames,
|
|
1781
|
-
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal
|
|
1782
|
-
};
|
|
1783
|
-
}
|
|
1784
1863
|
|
|
1785
1864
|
// src/core/LSP.ts
|
|
1786
1865
|
var RefactorNotApplicableError = class {
|
|
@@ -1832,7 +1911,7 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
1832
1911
|
for (const refactor of refactors2) {
|
|
1833
1912
|
yield* pipe(
|
|
1834
1913
|
refactor.apply(sourceFile, textRange),
|
|
1835
|
-
|
|
1914
|
+
map5(
|
|
1836
1915
|
(result) => effectRefactors.push({
|
|
1837
1916
|
name: refactorNameToFullyQualifiedName(refactor.name),
|
|
1838
1917
|
description: refactor.description,
|
|
@@ -1942,7 +2021,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1942
2021
|
const fixByDisableNextLine = (node) => ({
|
|
1943
2022
|
fixName: rule.name + "_skipNextLine",
|
|
1944
2023
|
description: "Disable " + rule.name + " for this line",
|
|
1945
|
-
apply:
|
|
2024
|
+
apply: flatMap2(
|
|
1946
2025
|
service(ChangeTracker),
|
|
1947
2026
|
(changeTracker) => gen(function* () {
|
|
1948
2027
|
const disableAtNode = findParentStatementForDisableNextLine(node);
|
|
@@ -1960,7 +2039,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1960
2039
|
const fixByDisableEntireFile = {
|
|
1961
2040
|
fixName: rule.name + "_skipFile",
|
|
1962
2041
|
description: "Disable " + rule.name + " for this entire file",
|
|
1963
|
-
apply:
|
|
2042
|
+
apply: flatMap2(
|
|
1964
2043
|
service(ChangeTracker),
|
|
1965
2044
|
(changeTracker) => sync(
|
|
1966
2045
|
() => changeTracker.insertText(
|
|
@@ -2079,7 +2158,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2079
2158
|
const edit = yield* codegen.apply(sourceFile, range);
|
|
2080
2159
|
const updateHashComment = pipe(
|
|
2081
2160
|
service(ChangeTracker),
|
|
2082
|
-
|
|
2161
|
+
map5((changeTracker) => {
|
|
2083
2162
|
changeTracker.deleteRange(sourceFile, range);
|
|
2084
2163
|
changeTracker.insertText(sourceFile, range.pos, `${codegen.name}:${edit.hash}`);
|
|
2085
2164
|
})
|
|
@@ -2088,7 +2167,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2088
2167
|
...edit,
|
|
2089
2168
|
apply: pipe(
|
|
2090
2169
|
edit.apply,
|
|
2091
|
-
|
|
2170
|
+
flatMap2(() => updateHashComment)
|
|
2092
2171
|
),
|
|
2093
2172
|
ignore: updateHashComment
|
|
2094
2173
|
};
|
|
@@ -2113,10 +2192,11 @@ var contextSelfInClasses = createCompletion({
|
|
|
2113
2192
|
) || "Context";
|
|
2114
2193
|
if (contextIdentifier !== ts.idText(accessedObject)) return [];
|
|
2115
2194
|
const name = ts.idText(className);
|
|
2195
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
2116
2196
|
return [{
|
|
2117
2197
|
name: `Tag("${name}")`,
|
|
2118
2198
|
kind: ts.ScriptElementKind.constElement,
|
|
2119
|
-
insertText: `${contextIdentifier}.Tag("${
|
|
2199
|
+
insertText: `${contextIdentifier}.Tag("${tagKey}")<${name}, ${"${0}"}>(){}`,
|
|
2120
2200
|
replacementSpan,
|
|
2121
2201
|
isSnippet: true
|
|
2122
2202
|
}];
|
|
@@ -2139,8 +2219,8 @@ function makeResolveExternalModuleName(typeChecker) {
|
|
|
2139
2219
|
var TypeCheckerUtils = Tag("TypeCheckerUtils");
|
|
2140
2220
|
var nanoLayer2 = (fa) => pipe(
|
|
2141
2221
|
service(TypeScriptApi),
|
|
2142
|
-
|
|
2143
|
-
(ts) =>
|
|
2222
|
+
flatMap2(
|
|
2223
|
+
(ts) => flatMap2(service(TypeCheckerApi), (typeChecker) => pipe(fa, provideService(TypeCheckerUtils, makeTypeCheckerUtils(ts, typeChecker))))
|
|
2144
2224
|
)
|
|
2145
2225
|
);
|
|
2146
2226
|
function makeTypeCheckerUtils(ts, typeChecker) {
|
|
@@ -2519,7 +2599,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2519
2599
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2520
2600
|
return invariantTypeArgument(propertyType);
|
|
2521
2601
|
};
|
|
2522
|
-
const effectVarianceStruct = (type, atLocation) =>
|
|
2602
|
+
const effectVarianceStruct = (type, atLocation) => map5(
|
|
2523
2603
|
all(
|
|
2524
2604
|
varianceStructCovariantType(type, atLocation, "_A"),
|
|
2525
2605
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2527,7 +2607,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2527
2607
|
),
|
|
2528
2608
|
([A, E, R]) => ({ A, E, R })
|
|
2529
2609
|
);
|
|
2530
|
-
const layerVarianceStruct = (type, atLocation) =>
|
|
2610
|
+
const layerVarianceStruct = (type, atLocation) => map5(
|
|
2531
2611
|
all(
|
|
2532
2612
|
varianceStructContravariantType(type, atLocation, "_ROut"),
|
|
2533
2613
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2750,7 +2830,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2750
2830
|
}
|
|
2751
2831
|
return pipe(
|
|
2752
2832
|
importedEffectModule(propertyAccess.expression),
|
|
2753
|
-
|
|
2833
|
+
map5((effectModule) => ({
|
|
2754
2834
|
node,
|
|
2755
2835
|
effectModule,
|
|
2756
2836
|
generatorFunction,
|
|
@@ -2797,7 +2877,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2797
2877
|
}
|
|
2798
2878
|
return pipe(
|
|
2799
2879
|
importedEffectModule(propertyAccess.expression),
|
|
2800
|
-
|
|
2880
|
+
map5((effectModule) => ({
|
|
2801
2881
|
node,
|
|
2802
2882
|
effectModule,
|
|
2803
2883
|
generatorFunction,
|
|
@@ -2849,7 +2929,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2849
2929
|
}
|
|
2850
2930
|
return pipe(
|
|
2851
2931
|
importedEffectModule(propertyAccess.expression),
|
|
2852
|
-
|
|
2932
|
+
map5((effectModule) => ({
|
|
2853
2933
|
node,
|
|
2854
2934
|
generatorFunction,
|
|
2855
2935
|
effectModule,
|
|
@@ -2922,7 +3002,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2922
3002
|
"TypeParser.unnecessaryEffectGen",
|
|
2923
3003
|
(node) => node
|
|
2924
3004
|
);
|
|
2925
|
-
const effectSchemaVarianceStruct = (type, atLocation) =>
|
|
3005
|
+
const effectSchemaVarianceStruct = (type, atLocation) => map5(
|
|
2926
3006
|
all(
|
|
2927
3007
|
varianceStructInvariantType(type, atLocation, "_A"),
|
|
2928
3008
|
varianceStructInvariantType(type, atLocation, "_I"),
|
|
@@ -2954,7 +3034,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2954
3034
|
"TypeParser.effectSchemaType",
|
|
2955
3035
|
(type) => type
|
|
2956
3036
|
);
|
|
2957
|
-
const contextTagVarianceStruct = (type, atLocation) =>
|
|
3037
|
+
const contextTagVarianceStruct = (type, atLocation) => map5(
|
|
2958
3038
|
all(
|
|
2959
3039
|
varianceStructInvariantType(type, atLocation, "_Identifier"),
|
|
2960
3040
|
varianceStructInvariantType(type, atLocation, "_Service")
|
|
@@ -3086,7 +3166,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3086
3166
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3087
3167
|
const parsedSchemaModule = yield* pipe(
|
|
3088
3168
|
effectSchemaType(expressionType, expression),
|
|
3089
|
-
|
|
3169
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3090
3170
|
option
|
|
3091
3171
|
);
|
|
3092
3172
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3129,7 +3209,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3129
3209
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3130
3210
|
const parsedSchemaModule = yield* pipe(
|
|
3131
3211
|
effectSchemaType(expressionType, expression),
|
|
3132
|
-
|
|
3212
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3133
3213
|
option
|
|
3134
3214
|
);
|
|
3135
3215
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3174,7 +3254,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3174
3254
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3175
3255
|
const parsedSchemaModule = yield* pipe(
|
|
3176
3256
|
effectSchemaType(expressionType, expression),
|
|
3177
|
-
|
|
3257
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3178
3258
|
option
|
|
3179
3259
|
);
|
|
3180
3260
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3295,7 +3375,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3295
3375
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3296
3376
|
const parsedSchemaModule = yield* pipe(
|
|
3297
3377
|
effectSchemaType(expressionType, expression),
|
|
3298
|
-
|
|
3378
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3299
3379
|
option
|
|
3300
3380
|
);
|
|
3301
3381
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3439,7 +3519,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3439
3519
|
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
3440
3520
|
const parsedContextTag = yield* pipe(
|
|
3441
3521
|
importedEffectModule(effectServiceIdentifier.expression),
|
|
3442
|
-
|
|
3522
|
+
flatMap2(() => contextTag(type, atLocation)),
|
|
3443
3523
|
option
|
|
3444
3524
|
);
|
|
3445
3525
|
if (isSome2(parsedContextTag)) {
|
|
@@ -3582,7 +3662,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3582
3662
|
};
|
|
3583
3663
|
const generateReturnType = (type, atLocation2, className2) => pipe(
|
|
3584
3664
|
typeParser.effectType(type, atLocation2),
|
|
3585
|
-
|
|
3665
|
+
flatMap2((returnedEffect) => {
|
|
3586
3666
|
const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(ts.idText(className2)) : ts.factory.createUnionTypeNode(
|
|
3587
3667
|
[
|
|
3588
3668
|
ts.factory.createTypeReferenceNode(ts.idText(className2)),
|
|
@@ -3613,7 +3693,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3613
3693
|
orElse2(
|
|
3614
3694
|
() => pipe(
|
|
3615
3695
|
typeParser.promiseLike(type, atLocation2),
|
|
3616
|
-
|
|
3696
|
+
flatMap2(({ type: type2 }) => {
|
|
3617
3697
|
const successType = typeChecker.typeToTypeNode(
|
|
3618
3698
|
type2,
|
|
3619
3699
|
atLocation2,
|
|
@@ -3681,7 +3761,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3681
3761
|
for (const signature of typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call)) {
|
|
3682
3762
|
yield* pipe(
|
|
3683
3763
|
proxySignature(signature, atLocation, className),
|
|
3684
|
-
|
|
3764
|
+
map5((sig) => {
|
|
3685
3765
|
callSignatures.push(sig);
|
|
3686
3766
|
}),
|
|
3687
3767
|
ignore
|
|
@@ -3714,7 +3794,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
3714
3794
|
if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
|
|
3715
3795
|
const { Service, accessors: accessors2, className } = yield* pipe(
|
|
3716
3796
|
typeParser.extendsEffectService(node),
|
|
3717
|
-
orElse2(() =>
|
|
3797
|
+
orElse2(() => map5(typeParser.extendsEffectTag(node), (_) => ({ accessors: true, ..._ }))),
|
|
3718
3798
|
orElse2(() => fail("not a class extending Effect.Service call"))
|
|
3719
3799
|
);
|
|
3720
3800
|
if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
|
|
@@ -3748,7 +3828,7 @@ var writeTagClassAccessors = createRefactor({
|
|
|
3748
3828
|
const typeParser = yield* service(TypeParser);
|
|
3749
3829
|
const parseNode = (node) => pipe(
|
|
3750
3830
|
parse2(node),
|
|
3751
|
-
|
|
3831
|
+
map5(({ Service, atLocation, className, involvedMembers }) => ({
|
|
3752
3832
|
kind: "refactor.rewrite.effect.writeTagClassAccessors",
|
|
3753
3833
|
description: "Implement Service accessors",
|
|
3754
3834
|
apply: pipe(
|
|
@@ -3781,7 +3861,7 @@ var accessors = createCodegen({
|
|
|
3781
3861
|
if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
|
|
3782
3862
|
return yield* pipe(
|
|
3783
3863
|
parse2(nodeAndCommentRange.node),
|
|
3784
|
-
|
|
3864
|
+
map5(
|
|
3785
3865
|
(_) => ({
|
|
3786
3866
|
hash: _.hash,
|
|
3787
3867
|
description: "Generate accessors for the service",
|
|
@@ -3846,10 +3926,11 @@ var effectDataClasses = createCompletion({
|
|
|
3846
3926
|
) || "Data";
|
|
3847
3927
|
if (effectDataIdentifier !== ts.idText(accessedObject)) return [];
|
|
3848
3928
|
const name = ts.idText(className);
|
|
3929
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
3849
3930
|
return [{
|
|
3850
3931
|
name: `TaggedError("${name}")`,
|
|
3851
3932
|
kind: ts.ScriptElementKind.constElement,
|
|
3852
|
-
insertText: `${effectDataIdentifier}.TaggedError("${
|
|
3933
|
+
insertText: `${effectDataIdentifier}.TaggedError("${errorTagKey}")<{${"${0}"}}>{}`,
|
|
3853
3934
|
replacementSpan,
|
|
3854
3935
|
isSnippet: true
|
|
3855
3936
|
}, {
|
|
@@ -3961,6 +4042,67 @@ var classSelfMismatch = createDiagnostic({
|
|
|
3961
4042
|
})
|
|
3962
4043
|
});
|
|
3963
4044
|
|
|
4045
|
+
// src/diagnostics/deterministicKeys.ts
|
|
4046
|
+
var deterministicKeys = createDiagnostic({
|
|
4047
|
+
name: "deterministicKeys",
|
|
4048
|
+
code: 25,
|
|
4049
|
+
severity: "off",
|
|
4050
|
+
apply: fn("deterministicKeys.apply")(function* (sourceFile, report) {
|
|
4051
|
+
const ts = yield* service(TypeScriptApi);
|
|
4052
|
+
const typeParser = yield* service(TypeParser);
|
|
4053
|
+
const nodeToVisit = [];
|
|
4054
|
+
const appendNodeToVisit = (node) => {
|
|
4055
|
+
nodeToVisit.push(node);
|
|
4056
|
+
return void 0;
|
|
4057
|
+
};
|
|
4058
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4059
|
+
while (nodeToVisit.length > 0) {
|
|
4060
|
+
const node = nodeToVisit.shift();
|
|
4061
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
4062
|
+
const result = yield* pipe(
|
|
4063
|
+
pipe(
|
|
4064
|
+
typeParser.extendsEffectService(node),
|
|
4065
|
+
orElse2(() => typeParser.extendsContextTag(node)),
|
|
4066
|
+
orElse2(() => typeParser.extendsEffectTag(node)),
|
|
4067
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "service" }))
|
|
4068
|
+
),
|
|
4069
|
+
orElse2(
|
|
4070
|
+
() => pipe(
|
|
4071
|
+
typeParser.extendsDataTaggedError(node),
|
|
4072
|
+
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
4073
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "error" }))
|
|
4074
|
+
)
|
|
4075
|
+
),
|
|
4076
|
+
orElse2(() => void_)
|
|
4077
|
+
);
|
|
4078
|
+
if (result && result.keyStringLiteral) {
|
|
4079
|
+
const { className, keyStringLiteral } = result;
|
|
4080
|
+
const classNameText = ts.idText(className);
|
|
4081
|
+
const expectedKey = yield* createString(sourceFile, classNameText, result.target);
|
|
4082
|
+
if (!expectedKey) return;
|
|
4083
|
+
const actualIdentifier = keyStringLiteral.text;
|
|
4084
|
+
if (actualIdentifier !== expectedKey) {
|
|
4085
|
+
report({
|
|
4086
|
+
location: keyStringLiteral,
|
|
4087
|
+
messageText: `Key should be '${expectedKey}'`,
|
|
4088
|
+
fixes: [{
|
|
4089
|
+
fixName: "deterministicKeys_fix",
|
|
4090
|
+
description: `Replace '${actualIdentifier}' with '${expectedKey}'`,
|
|
4091
|
+
apply: gen(function* () {
|
|
4092
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
4093
|
+
const newStringLiteral = ts.factory.createStringLiteral(expectedKey);
|
|
4094
|
+
changeTracker.replaceNode(sourceFile, keyStringLiteral, newStringLiteral);
|
|
4095
|
+
})
|
|
4096
|
+
}]
|
|
4097
|
+
});
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4102
|
+
}
|
|
4103
|
+
})
|
|
4104
|
+
});
|
|
4105
|
+
|
|
3964
4106
|
// src/diagnostics/duplicatePackage.ts
|
|
3965
4107
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
3966
4108
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
@@ -4030,7 +4172,7 @@ var effectGenUsesAdapter = createDiagnostic({
|
|
|
4030
4172
|
if (ts.isCallExpression(node)) {
|
|
4031
4173
|
yield* pipe(
|
|
4032
4174
|
typeParser.effectGen(node),
|
|
4033
|
-
|
|
4175
|
+
map5(({ generatorFunction }) => {
|
|
4034
4176
|
if (generatorFunction.parameters.length > 0) {
|
|
4035
4177
|
const adapter = generatorFunction.parameters[0];
|
|
4036
4178
|
report({
|
|
@@ -4063,7 +4205,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4063
4205
|
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
4064
4206
|
const voidValueTypes = typeCheckerUtils.unrollUnionMembers(realEffect.A);
|
|
4065
4207
|
const voidedEffect = yield* firstSuccessOf(
|
|
4066
|
-
voidValueTypes.map((_) =>
|
|
4208
|
+
voidValueTypes.map((_) => map5(typeParser.strictEffectType(_, node), () => _))
|
|
4067
4209
|
);
|
|
4068
4210
|
return { voidedEffect };
|
|
4069
4211
|
}
|
|
@@ -4079,7 +4221,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4079
4221
|
valueNode,
|
|
4080
4222
|
realType
|
|
4081
4223
|
),
|
|
4082
|
-
|
|
4224
|
+
map5(({ voidedEffect }) => {
|
|
4083
4225
|
report(
|
|
4084
4226
|
{
|
|
4085
4227
|
location: node,
|
|
@@ -4174,7 +4316,7 @@ var genericEffectServices = createDiagnostic({
|
|
|
4174
4316
|
for (const [type, reportAt] of typesToCheck) {
|
|
4175
4317
|
yield* pipe(
|
|
4176
4318
|
typeParser.contextTag(type, node),
|
|
4177
|
-
|
|
4319
|
+
map5(() => {
|
|
4178
4320
|
report({
|
|
4179
4321
|
location: reportAt,
|
|
4180
4322
|
messageText: `Effect Services with type parameters are not supported because they cannot be properly discriminated at runtime, which may cause unexpected behavior.`,
|
|
@@ -4351,7 +4493,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4351
4493
|
let effectContextType = void 0;
|
|
4352
4494
|
yield* pipe(
|
|
4353
4495
|
typeParser.effectType(servicePropertyType, atLocation),
|
|
4354
|
-
|
|
4496
|
+
map5((_) => effectContextType = _.R),
|
|
4355
4497
|
orElse2(() => {
|
|
4356
4498
|
const servicePropertyCallSignatures = typeChecker.getSignaturesOfType(
|
|
4357
4499
|
servicePropertyType,
|
|
@@ -4363,7 +4505,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4363
4505
|
typeChecker.getReturnTypeOfSignature(servicePropertyCallSignatures[0]),
|
|
4364
4506
|
atLocation
|
|
4365
4507
|
),
|
|
4366
|
-
|
|
4508
|
+
map5((_) => {
|
|
4367
4509
|
effectContextType = _.R;
|
|
4368
4510
|
})
|
|
4369
4511
|
);
|
|
@@ -4381,7 +4523,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4381
4523
|
if (type.flags & ts.TypeFlags.Never) return succeed(true);
|
|
4382
4524
|
return pipe(
|
|
4383
4525
|
typeParser.scopeType(type, atLocation),
|
|
4384
|
-
|
|
4526
|
+
map5(() => true),
|
|
4385
4527
|
orElse2(() => succeed(false))
|
|
4386
4528
|
);
|
|
4387
4529
|
}
|
|
@@ -4437,10 +4579,10 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
4437
4579
|
for (const [type, reportAt] of typesToCheck) {
|
|
4438
4580
|
yield* pipe(
|
|
4439
4581
|
typeParser.contextTag(type, node),
|
|
4440
|
-
|
|
4582
|
+
flatMap2(
|
|
4441
4583
|
({ Service }) => pipe(
|
|
4442
4584
|
parseLeakedRequirements(Service, node),
|
|
4443
|
-
|
|
4585
|
+
map5(
|
|
4444
4586
|
(requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
|
|
4445
4587
|
)
|
|
4446
4588
|
)
|
|
@@ -4467,7 +4609,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4467
4609
|
typeParser.effectType(expectedType, node),
|
|
4468
4610
|
typeParser.effectType(realType, valueNode)
|
|
4469
4611
|
),
|
|
4470
|
-
|
|
4612
|
+
map5(
|
|
4471
4613
|
([expectedEffect, realEffect]) => typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4472
4614
|
realEffect.R,
|
|
4473
4615
|
expectedEffect.R
|
|
@@ -4485,7 +4627,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4485
4627
|
valueNode,
|
|
4486
4628
|
realType
|
|
4487
4629
|
),
|
|
4488
|
-
|
|
4630
|
+
map5(
|
|
4489
4631
|
(missingTypes) => missingTypes.length > 0 ? report(
|
|
4490
4632
|
{
|
|
4491
4633
|
location: node,
|
|
@@ -4530,7 +4672,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4530
4672
|
typeParser.effectType(expectedType, node),
|
|
4531
4673
|
typeParser.effectType(realType, valueNode)
|
|
4532
4674
|
),
|
|
4533
|
-
|
|
4675
|
+
map5(
|
|
4534
4676
|
([expectedEffect, realEffect]) => pipe(
|
|
4535
4677
|
typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4536
4678
|
realEffect.E,
|
|
@@ -4551,7 +4693,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4551
4693
|
valueNode,
|
|
4552
4694
|
realType
|
|
4553
4695
|
),
|
|
4554
|
-
|
|
4696
|
+
map5((result) => {
|
|
4555
4697
|
if (result.missingErrorTypes.length === 0) return;
|
|
4556
4698
|
const fixes = [];
|
|
4557
4699
|
if (ts.isExpression(valueNode) && result.expectedErrorType.flags & ts.TypeFlags.Never) {
|
|
@@ -4578,17 +4720,17 @@ var missingEffectError = createDiagnostic({
|
|
|
4578
4720
|
if (ts.isExpression(valueNode)) {
|
|
4579
4721
|
const propertyAssignments = pipe(
|
|
4580
4722
|
result.missingErrorTypes,
|
|
4581
|
-
|
|
4723
|
+
map4((_) => typeChecker.getPropertyOfType(_, "_tag")),
|
|
4582
4724
|
filter((_) => !!_),
|
|
4583
|
-
|
|
4725
|
+
map4((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
|
|
4584
4726
|
filter((_) => !!(_.flags & ts.TypeFlags.Literal)),
|
|
4585
|
-
|
|
4727
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
4586
4728
|
filter((_) => !!_ && ts.isLiteralTypeNode(_)),
|
|
4587
|
-
|
|
4729
|
+
map4((_) => _.literal),
|
|
4588
4730
|
filter((_) => ts.isLiteralExpression(_)),
|
|
4589
|
-
|
|
4731
|
+
map4((_) => _.text),
|
|
4590
4732
|
sort(string2),
|
|
4591
|
-
|
|
4733
|
+
map4(
|
|
4592
4734
|
(_) => ts.factory.createPropertyAssignment(
|
|
4593
4735
|
ts.factory.createIdentifier(_),
|
|
4594
4736
|
ts.factory.createArrowFunction(
|
|
@@ -4825,7 +4967,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
4825
4967
|
typeParser.effectGen(effectGenNode),
|
|
4826
4968
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
4827
4969
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
4828
|
-
|
|
4970
|
+
map5(({ generatorFunction }) => {
|
|
4829
4971
|
if (generatorFunction) {
|
|
4830
4972
|
brokenGenerators.add(ts.getTokenPosOfNode(generatorFunction, tsUtils.getSourceFileOfNode(node)));
|
|
4831
4973
|
}
|
|
@@ -4894,8 +5036,8 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4894
5036
|
const type = typeChecker.getTypeAtLocation(layer);
|
|
4895
5037
|
return pipe(
|
|
4896
5038
|
typeParser.importedEffectModule(node.expression.expression),
|
|
4897
|
-
|
|
4898
|
-
|
|
5039
|
+
flatMap2(() => typeParser.layerType(type, layer)),
|
|
5040
|
+
map5(() => ({ layer, node })),
|
|
4899
5041
|
orElse2(() => void_)
|
|
4900
5042
|
);
|
|
4901
5043
|
}
|
|
@@ -5065,7 +5207,7 @@ var outdatedEffectCodegen = createDiagnostic({
|
|
|
5065
5207
|
for (const { codegen, hash: hash2, range } of codegensWithRanges) {
|
|
5066
5208
|
yield* pipe(
|
|
5067
5209
|
getEditsForCodegen([codegen], sourceFile, range),
|
|
5068
|
-
|
|
5210
|
+
map5((applicable) => {
|
|
5069
5211
|
if (applicable.hash !== hash2) {
|
|
5070
5212
|
_report({
|
|
5071
5213
|
location: range,
|
|
@@ -5125,7 +5267,7 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
5125
5267
|
const typeAtLocation = typeChecker.getTypeAtLocation(type.expression);
|
|
5126
5268
|
const isSchema = yield* pipe(
|
|
5127
5269
|
typeParser.effectSchemaType(typeAtLocation, type.expression),
|
|
5128
|
-
|
|
5270
|
+
map5(() => true),
|
|
5129
5271
|
orElse2(() => succeed(false))
|
|
5130
5272
|
);
|
|
5131
5273
|
if (isSchema) {
|
|
@@ -5196,7 +5338,7 @@ var returnEffectInGen = createDiagnostic({
|
|
|
5196
5338
|
typeParser.effectGen(effectGenNode),
|
|
5197
5339
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5198
5340
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5199
|
-
|
|
5341
|
+
map5(() => {
|
|
5200
5342
|
const fix = node.expression ? [{
|
|
5201
5343
|
fixName: "returnEffectInGen_fix",
|
|
5202
5344
|
description: "Add yield* statement",
|
|
@@ -5259,7 +5401,7 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
5259
5401
|
const entries = typeCheckerUtils.unrollUnionMembers(type);
|
|
5260
5402
|
return pipe(
|
|
5261
5403
|
firstSuccessOf(entries.map((type2) => typeParser.scopeType(type2, node))),
|
|
5262
|
-
|
|
5404
|
+
map5(
|
|
5263
5405
|
() => report({
|
|
5264
5406
|
location: node,
|
|
5265
5407
|
messageText: `Seems like you are constructing a layer with a scope in the requirements.
|
|
@@ -5294,7 +5436,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5294
5436
|
const type = typeChecker.getTypeAtLocation(node);
|
|
5295
5437
|
yield* pipe(
|
|
5296
5438
|
typeParser.layerType(type, node),
|
|
5297
|
-
|
|
5439
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, layerEffectApiCall.methodIdentifier)),
|
|
5298
5440
|
ignore
|
|
5299
5441
|
);
|
|
5300
5442
|
continue;
|
|
@@ -5308,7 +5450,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5308
5450
|
const type = typeChecker.getTypeOfSymbolAtLocation(defaultLayer, node);
|
|
5309
5451
|
yield* pipe(
|
|
5310
5452
|
typeParser.layerType(type, node),
|
|
5311
|
-
|
|
5453
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, void 0)),
|
|
5312
5454
|
ignore
|
|
5313
5455
|
);
|
|
5314
5456
|
continue;
|
|
@@ -5418,7 +5560,7 @@ var tryCatchInEffectGen = createDiagnostic({
|
|
|
5418
5560
|
typeParser.effectGen(effectGenNode),
|
|
5419
5561
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5420
5562
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5421
|
-
|
|
5563
|
+
map5(() => {
|
|
5422
5564
|
report({
|
|
5423
5565
|
location: node,
|
|
5424
5566
|
messageText: "Avoid using try/catch inside Effect generators. Use Effect's error handling mechanisms instead (e.g., Effect.try, Effect.tryPromise, Effect.catchAll, Effect.catchTag).",
|
|
@@ -5453,7 +5595,7 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
5453
5595
|
if (ts.isCallExpression(node)) {
|
|
5454
5596
|
yield* pipe(
|
|
5455
5597
|
typeParser.unnecessaryEffectGen(node),
|
|
5456
|
-
|
|
5598
|
+
map5(
|
|
5457
5599
|
({ replacementNode }) => report({
|
|
5458
5600
|
location: node,
|
|
5459
5601
|
messageText: `This Effect.gen contains a single return statement.`,
|
|
@@ -5496,7 +5638,7 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
5496
5638
|
if (ts.isCallExpression(node)) {
|
|
5497
5639
|
yield* pipe(
|
|
5498
5640
|
typeParser.pipeCall(node),
|
|
5499
|
-
|
|
5641
|
+
map5(({ args: args2, subject }) => {
|
|
5500
5642
|
if (args2.length === 0) {
|
|
5501
5643
|
report({
|
|
5502
5644
|
location: node,
|
|
@@ -5541,10 +5683,10 @@ var unnecessaryPipeChain = createDiagnostic({
|
|
|
5541
5683
|
if (ts.isCallExpression(node)) {
|
|
5542
5684
|
yield* pipe(
|
|
5543
5685
|
typeParser.pipeCall(node),
|
|
5544
|
-
|
|
5545
|
-
(pipeCall) =>
|
|
5686
|
+
flatMap2(
|
|
5687
|
+
(pipeCall) => map5(typeParser.pipeCall(pipeCall.subject), (innerCall) => ({ pipeCall, innerCall }))
|
|
5546
5688
|
),
|
|
5547
|
-
|
|
5689
|
+
map5(({ innerCall, pipeCall }) => {
|
|
5548
5690
|
report({
|
|
5549
5691
|
location: node,
|
|
5550
5692
|
messageText: `Chained pipe calls can be simplified to a single pipe call`,
|
|
@@ -5676,7 +5818,8 @@ var diagnostics = [
|
|
|
5676
5818
|
outdatedEffectCodegen,
|
|
5677
5819
|
overriddenSchemaConstructor,
|
|
5678
5820
|
unsupportedServiceAccessors,
|
|
5679
|
-
nonObjectEffectServiceType
|
|
5821
|
+
nonObjectEffectServiceType,
|
|
5822
|
+
deterministicKeys
|
|
5680
5823
|
];
|
|
5681
5824
|
|
|
5682
5825
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -5728,6 +5871,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5728
5871
|
) || "Schema";
|
|
5729
5872
|
if (schemaIdentifier !== ts.idText(accessedObject)) return [];
|
|
5730
5873
|
const name = ts.idText(className);
|
|
5874
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
5731
5875
|
return [{
|
|
5732
5876
|
name: `Class<${name}>`,
|
|
5733
5877
|
kind: ts.ScriptElementKind.constElement,
|
|
@@ -5737,7 +5881,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5737
5881
|
}, {
|
|
5738
5882
|
name: `TaggedError<${name}>`,
|
|
5739
5883
|
kind: ts.ScriptElementKind.constElement,
|
|
5740
|
-
insertText: `${schemaIdentifier}.TaggedError<${name}>("${
|
|
5884
|
+
insertText: `${schemaIdentifier}.TaggedError<${name}>("${errorTagKey}")("${errorTagKey}", {${"${0}"}}){}`,
|
|
5741
5885
|
replacementSpan,
|
|
5742
5886
|
isSnippet: true
|
|
5743
5887
|
}, {
|
|
@@ -5772,16 +5916,17 @@ var effectSelfInClasses = createCompletion({
|
|
|
5772
5916
|
) || "Effect";
|
|
5773
5917
|
if (effectIdentifier !== ts.idText(accessedObject)) return [];
|
|
5774
5918
|
const name = ts.idText(className);
|
|
5919
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
5775
5920
|
return [{
|
|
5776
5921
|
name: `Service<${name}>`,
|
|
5777
5922
|
kind: ts.ScriptElementKind.constElement,
|
|
5778
|
-
insertText: `${effectIdentifier}.Service<${name}>()("${
|
|
5923
|
+
insertText: `${effectIdentifier}.Service<${name}>()("${tagKey}", {${"${0}"}}){}`,
|
|
5779
5924
|
replacementSpan,
|
|
5780
5925
|
isSnippet: true
|
|
5781
5926
|
}, {
|
|
5782
5927
|
name: `Tag("${name}")`,
|
|
5783
5928
|
kind: ts.ScriptElementKind.constElement,
|
|
5784
|
-
insertText: `${effectIdentifier}.Tag("${
|
|
5929
|
+
insertText: `${effectIdentifier}.Tag("${tagKey}")<${name}, {${"${0}"}}>(){}`,
|
|
5785
5930
|
replacementSpan,
|
|
5786
5931
|
isSnippet: true
|
|
5787
5932
|
}];
|
|
@@ -5807,7 +5952,7 @@ var fnFunctionStar = createCompletion({
|
|
|
5807
5952
|
const maybeFnName = pipe(
|
|
5808
5953
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5809
5954
|
filter(ts.isVariableDeclaration),
|
|
5810
|
-
|
|
5955
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5811
5956
|
filter((_) => _.length > 0),
|
|
5812
5957
|
head,
|
|
5813
5958
|
map2((name) => [
|
|
@@ -5915,7 +6060,7 @@ var schemaBrand = createCompletion({
|
|
|
5915
6060
|
return pipe(
|
|
5916
6061
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5917
6062
|
filter(ts.isVariableDeclaration),
|
|
5918
|
-
|
|
6063
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5919
6064
|
filter((_) => _.length > 0),
|
|
5920
6065
|
head,
|
|
5921
6066
|
map2((name) => [
|
|
@@ -6690,7 +6835,7 @@ var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, pr
|
|
|
6690
6835
|
const possiblyGen = node.parent;
|
|
6691
6836
|
yield* pipe(
|
|
6692
6837
|
parseType(possiblyGen),
|
|
6693
|
-
|
|
6838
|
+
map5((_) => {
|
|
6694
6839
|
const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
6695
6840
|
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.end && inlayHint.position <= _.body.getStart(sourceFile)) {
|
|
6696
6841
|
shouldOmit = true;
|
|
@@ -6797,7 +6942,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6797
6942
|
type,
|
|
6798
6943
|
atLocation
|
|
6799
6944
|
),
|
|
6800
|
-
|
|
6945
|
+
map5((_) => makeSymbolDisplayParts("Effect Type Parameters", _.A, _.E, _.R)),
|
|
6801
6946
|
orElse2(() => {
|
|
6802
6947
|
const callSignatues = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
6803
6948
|
if (callSignatues.length !== 1) return succeed([]);
|
|
@@ -6807,7 +6952,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6807
6952
|
returnType,
|
|
6808
6953
|
atLocation
|
|
6809
6954
|
),
|
|
6810
|
-
|
|
6955
|
+
map5((_) => makeSymbolDisplayParts("Returned Effect Type Parameters", _.A, _.E, _.R))
|
|
6811
6956
|
);
|
|
6812
6957
|
})
|
|
6813
6958
|
);
|
|
@@ -11359,7 +11504,7 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
11359
11504
|
const { layerNode, node } = maybeNodes;
|
|
11360
11505
|
const layerInfoDisplayParts = yield* pipe(
|
|
11361
11506
|
parseLayerGraph(sourceFile, layerNode),
|
|
11362
|
-
|
|
11507
|
+
flatMap2(
|
|
11363
11508
|
({ mermaidCode, textualExplanation }) => gen(function* () {
|
|
11364
11509
|
const linkParts = [];
|
|
11365
11510
|
if (!options.noExternal) {
|
|
@@ -11791,11 +11936,11 @@ var effectGenToFn = createRefactor({
|
|
|
11791
11936
|
parentNodes,
|
|
11792
11937
|
filter((_) => ts.isVariableDeclaration(_) && _.initializer ? true : false),
|
|
11793
11938
|
filter((_) => tsUtils.isNodeInRange(textRange)(_.name)),
|
|
11794
|
-
|
|
11939
|
+
map4((_) => _.initializer)
|
|
11795
11940
|
);
|
|
11796
11941
|
const maybeNode = yield* pipe(
|
|
11797
11942
|
nodesFromInitializers.concat(parentNodes),
|
|
11798
|
-
|
|
11943
|
+
map4(parseFunctionLikeReturnEffectGen),
|
|
11799
11944
|
firstSuccessOf,
|
|
11800
11945
|
option
|
|
11801
11946
|
);
|
|
@@ -11985,7 +12130,7 @@ var layerMagic = createRefactor({
|
|
|
11985
12130
|
if (ts.isArrayLiteralExpression(node)) {
|
|
11986
12131
|
return pipe(
|
|
11987
12132
|
all(...node.elements.map((element) => extractLayers(element, false))),
|
|
11988
|
-
|
|
12133
|
+
map5(flatten)
|
|
11989
12134
|
);
|
|
11990
12135
|
}
|
|
11991
12136
|
return TypeParserIssue.issue;
|
|
@@ -11994,7 +12139,7 @@ var layerMagic = createRefactor({
|
|
|
11994
12139
|
if (ts.isExpression(node)) {
|
|
11995
12140
|
return pipe(
|
|
11996
12141
|
typeParser.layerType(typeChecker.getTypeAtLocation(node), node),
|
|
11997
|
-
|
|
12142
|
+
map5((_) => [{ node, ..._ }])
|
|
11998
12143
|
);
|
|
11999
12144
|
}
|
|
12000
12145
|
return TypeParserIssue.issue;
|
|
@@ -12005,7 +12150,7 @@ var layerMagic = createRefactor({
|
|
|
12005
12150
|
) > -1) {
|
|
12006
12151
|
return pipe(
|
|
12007
12152
|
all(...node.arguments.map((element) => extractLayers(element, false))),
|
|
12008
|
-
|
|
12153
|
+
map5(flatten)
|
|
12009
12154
|
);
|
|
12010
12155
|
}
|
|
12011
12156
|
return TypeParserIssue.issue;
|
|
@@ -12013,10 +12158,10 @@ var layerMagic = createRefactor({
|
|
|
12013
12158
|
const extractPipeSequencing = (node) => {
|
|
12014
12159
|
return pipe(
|
|
12015
12160
|
typeParser.pipeCall(node),
|
|
12016
|
-
|
|
12161
|
+
flatMap2((_) => {
|
|
12017
12162
|
return all(...[_.subject, ..._.args].map((element) => extractLayers(element, true)));
|
|
12018
12163
|
}),
|
|
12019
|
-
|
|
12164
|
+
map5(flatten)
|
|
12020
12165
|
);
|
|
12021
12166
|
};
|
|
12022
12167
|
const extractLayers = cachedBy(
|
|
@@ -12044,10 +12189,10 @@ var layerMagic = createRefactor({
|
|
|
12044
12189
|
const atLocation = adjustedNode(node);
|
|
12045
12190
|
return pipe(
|
|
12046
12191
|
extractLayers(atLocation, false),
|
|
12047
|
-
|
|
12192
|
+
flatMap2(
|
|
12048
12193
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12049
12194
|
),
|
|
12050
|
-
|
|
12195
|
+
map5((extractedLayers) => ({
|
|
12051
12196
|
kind: "refactor.rewrite.effect.layerMagicPrepare",
|
|
12052
12197
|
description: "Prepare layers for automatic composition",
|
|
12053
12198
|
apply: pipe(
|
|
@@ -12063,7 +12208,7 @@ var layerMagic = createRefactor({
|
|
|
12063
12208
|
}
|
|
12064
12209
|
const previouslyProvided = yield* pipe(
|
|
12065
12210
|
typeParser.layerType(typeChecker.getTypeAtLocation(atLocation), atLocation),
|
|
12066
|
-
|
|
12211
|
+
map5((_) => _.ROut),
|
|
12067
12212
|
option
|
|
12068
12213
|
);
|
|
12069
12214
|
const [existingBefore, newlyIntroduced] = pipe(
|
|
@@ -12075,13 +12220,13 @@ var layerMagic = createRefactor({
|
|
|
12075
12220
|
);
|
|
12076
12221
|
const typeReferences = pipe(
|
|
12077
12222
|
newlyIntroduced,
|
|
12078
|
-
|
|
12223
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
12079
12224
|
filter((_) => !!_)
|
|
12080
12225
|
);
|
|
12081
12226
|
const providesUnion = typeReferences.length === 0 ? ts.factory.createTypeReferenceNode("never") : ts.factory.createUnionTypeNode(typeReferences);
|
|
12082
12227
|
const typeStrings = pipe(
|
|
12083
12228
|
existingBefore,
|
|
12084
|
-
|
|
12229
|
+
map4((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)),
|
|
12085
12230
|
filter((_) => !!_)
|
|
12086
12231
|
);
|
|
12087
12232
|
const unionWithComment = typeStrings.length === 0 ? providesUnion : ts.addSyntheticTrailingComment(
|
|
@@ -12116,7 +12261,7 @@ var layerMagic = createRefactor({
|
|
|
12116
12261
|
if (ts.isAsExpression(expression) && expression.type.kind === ts.SyntaxKind.AnyKeyword) {
|
|
12117
12262
|
return pipe(
|
|
12118
12263
|
typeParser.layerType(typeChecker.getTypeAtLocation(node.type), node.type),
|
|
12119
|
-
|
|
12264
|
+
map5((_) => ({ node, ..._, castedStructure: expression.expression }))
|
|
12120
12265
|
);
|
|
12121
12266
|
}
|
|
12122
12267
|
}
|
|
@@ -12126,14 +12271,14 @@ var layerMagic = createRefactor({
|
|
|
12126
12271
|
const atLocation = adjustedNode(node);
|
|
12127
12272
|
return pipe(
|
|
12128
12273
|
parseAsAnyAsLayer(atLocation),
|
|
12129
|
-
|
|
12274
|
+
flatMap2(
|
|
12130
12275
|
(_targetLayer) => pipe(
|
|
12131
12276
|
extractArrayLiteral(_targetLayer.castedStructure),
|
|
12132
12277
|
orElse2(() => extractLayers(_targetLayer.castedStructure, false)),
|
|
12133
|
-
|
|
12278
|
+
flatMap2(
|
|
12134
12279
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12135
12280
|
),
|
|
12136
|
-
|
|
12281
|
+
map5((extractedLayers) => ({
|
|
12137
12282
|
kind: "refactor.rewrite.effect.layerMagicBuild",
|
|
12138
12283
|
description: "Compose layers automatically with target output services",
|
|
12139
12284
|
apply: gen(function* () {
|
|
@@ -12250,7 +12395,7 @@ var _findSchemaVariableDeclaration = fn(
|
|
|
12250
12395
|
);
|
|
12251
12396
|
return yield* pipe(
|
|
12252
12397
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
12253
|
-
|
|
12398
|
+
map4(findSchema),
|
|
12254
12399
|
firstSuccessOf,
|
|
12255
12400
|
option
|
|
12256
12401
|
);
|
|
@@ -12536,7 +12681,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12536
12681
|
filter(
|
|
12537
12682
|
(node2) => node2.arguments.length > 0
|
|
12538
12683
|
),
|
|
12539
|
-
|
|
12684
|
+
map4((node2) => {
|
|
12540
12685
|
let newNode2 = node2.arguments[0];
|
|
12541
12686
|
let didSomething = false;
|
|
12542
12687
|
for (let i = 1; i < node2.arguments.length; i++) {
|
|
@@ -12563,7 +12708,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12563
12708
|
return didSomething ? some2([node2, newNode2]) : none2();
|
|
12564
12709
|
}),
|
|
12565
12710
|
filter(isSome2),
|
|
12566
|
-
|
|
12711
|
+
map4((_) => _.value),
|
|
12567
12712
|
head
|
|
12568
12713
|
);
|
|
12569
12714
|
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
@@ -12757,7 +12902,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12757
12902
|
description: "Toggle return type annotation",
|
|
12758
12903
|
apply: pipe(
|
|
12759
12904
|
service(ChangeTracker),
|
|
12760
|
-
|
|
12905
|
+
map5((changeTracker) => removeReturnTypeAnnotation(sourceFile, changeTracker, node))
|
|
12761
12906
|
)
|
|
12762
12907
|
};
|
|
12763
12908
|
}
|
|
@@ -12774,7 +12919,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12774
12919
|
description: "Toggle return type annotation",
|
|
12775
12920
|
apply: pipe(
|
|
12776
12921
|
service(ChangeTracker),
|
|
12777
|
-
|
|
12922
|
+
map5(
|
|
12778
12923
|
(changeTracker) => addReturnTypeAnnotation(sourceFile, changeTracker, node, tsUtils.simplifyTypeNode(returnTypeNode))
|
|
12779
12924
|
)
|
|
12780
12925
|
)
|
|
@@ -13369,16 +13514,17 @@ var wrapWithEffectGen = createRefactor({
|
|
|
13369
13514
|
const findEffectToWrap = fn("wrapWithEffectGen.apply.findEffectToWrap")(
|
|
13370
13515
|
function* (node) {
|
|
13371
13516
|
if (!ts.isExpression(node)) return yield* fail("is not an expression");
|
|
13517
|
+
if (node.parent && ts.isHeritageClause(node.parent)) return yield* fail("is in a heritage clause");
|
|
13372
13518
|
const parent = node.parent;
|
|
13373
13519
|
if (parent != null && ts.isVariableDeclaration(parent) && parent.initializer !== node) return yield* fail("is LHS of variable declaration");
|
|
13374
13520
|
const type = typeChecker.getTypeAtLocation(node);
|
|
13375
|
-
yield* typeParser.
|
|
13521
|
+
yield* typeParser.strictEffectType(type, node);
|
|
13376
13522
|
return node;
|
|
13377
13523
|
}
|
|
13378
13524
|
);
|
|
13379
13525
|
const maybeNode = yield* pipe(
|
|
13380
13526
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
13381
|
-
|
|
13527
|
+
map4(findEffectToWrap),
|
|
13382
13528
|
firstSuccessOf,
|
|
13383
13529
|
option
|
|
13384
13530
|
);
|
|
@@ -13463,19 +13609,19 @@ var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _
|
|
|
13463
13609
|
const parentClass = node.parent;
|
|
13464
13610
|
if (ts.isClassDeclaration(parentClass) && parentClass.name === node) {
|
|
13465
13611
|
const baseIdentifier = yield* pipe(
|
|
13466
|
-
|
|
13467
|
-
orElse2(() =>
|
|
13468
|
-
orElse2(() =>
|
|
13612
|
+
map5(typeParser.extendsContextTag(parentClass), (_) => [_.keyStringLiteral]),
|
|
13613
|
+
orElse2(() => map5(typeParser.extendsEffectService(parentClass), (_) => [_.keyStringLiteral])),
|
|
13614
|
+
orElse2(() => map5(typeParser.extendsEffectTag(parentClass), (_) => [_.keyStringLiteral])),
|
|
13469
13615
|
orElse2(
|
|
13470
|
-
() =>
|
|
13616
|
+
() => map5(typeParser.extendsSchemaTaggedClass(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13471
13617
|
),
|
|
13472
13618
|
orElse2(
|
|
13473
|
-
() =>
|
|
13619
|
+
() => map5(typeParser.extendsSchemaTaggedError(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13474
13620
|
),
|
|
13475
|
-
orElse2(() =>
|
|
13476
|
-
orElse2(() =>
|
|
13621
|
+
orElse2(() => map5(typeParser.extendsDataTaggedError(parentClass), (_) => [_.keyStringLiteral])),
|
|
13622
|
+
orElse2(() => map5(typeParser.extendsDataTaggedClass(parentClass), (_) => [_.keyStringLiteral])),
|
|
13477
13623
|
orElse2(
|
|
13478
|
-
() =>
|
|
13624
|
+
() => map5(
|
|
13479
13625
|
typeParser.extendsSchemaTaggedRequest(parentClass),
|
|
13480
13626
|
(_) => [_.keyStringLiteral, _.tagStringLiteral]
|
|
13481
13627
|
)
|
|
@@ -13620,7 +13766,7 @@ var init = (modules) => {
|
|
|
13620
13766
|
}
|
|
13621
13767
|
return effectCodeFixes;
|
|
13622
13768
|
}),
|
|
13623
|
-
|
|
13769
|
+
flatMap2(
|
|
13624
13770
|
(effectCodeFixes) => pipe(
|
|
13625
13771
|
middlewareAutoImportQuickfixes(
|
|
13626
13772
|
sourceFile,
|
|
@@ -13629,7 +13775,7 @@ var init = (modules) => {
|
|
|
13629
13775
|
preferences,
|
|
13630
13776
|
applicableCodeFixes
|
|
13631
13777
|
),
|
|
13632
|
-
|
|
13778
|
+
map5((modifiedCodeFixes) => effectCodeFixes.concat(modifiedCodeFixes))
|
|
13633
13779
|
)
|
|
13634
13780
|
),
|
|
13635
13781
|
runNano(program),
|
|
@@ -13738,7 +13884,7 @@ var init = (modules) => {
|
|
|
13738
13884
|
if (sourceFile) {
|
|
13739
13885
|
return pipe(
|
|
13740
13886
|
appendEffectCompletionEntryData(sourceFile, applicableCompletions),
|
|
13741
|
-
|
|
13887
|
+
flatMap2(
|
|
13742
13888
|
(augmentedCompletions) => pipe(
|
|
13743
13889
|
getCompletionsAtPosition(
|
|
13744
13890
|
completions,
|
|
@@ -13747,7 +13893,7 @@ var init = (modules) => {
|
|
|
13747
13893
|
options,
|
|
13748
13894
|
formattingSettings
|
|
13749
13895
|
),
|
|
13750
|
-
|
|
13896
|
+
map5(
|
|
13751
13897
|
(effectCompletions) => augmentedCompletions ? {
|
|
13752
13898
|
...augmentedCompletions,
|
|
13753
13899
|
entries: effectCompletions.concat(augmentedCompletions.entries)
|
|
@@ -13881,7 +14027,7 @@ var init = (modules) => {
|
|
|
13881
14027
|
if (sourceFile) {
|
|
13882
14028
|
return pipe(
|
|
13883
14029
|
effectApiGetLayerGraph(sourceFile, line, character),
|
|
13884
|
-
|
|
14030
|
+
map5((response) => ({
|
|
13885
14031
|
response: {
|
|
13886
14032
|
success: true,
|
|
13887
14033
|
...response
|