@effect/language-service 0.42.0 → 0.43.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 +52 -1
- package/effect-lsp-patch-utils.js +142 -3
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +419 -275
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +142 -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,64 @@ 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
|
+
if (keyPattern.pattern === "package-identifier") {
|
|
1816
|
+
return packageInfo.name + "/" + classNameText;
|
|
1817
|
+
}
|
|
1818
|
+
const dirPath = getDirectoryPath(ts, sourceFile.fileName);
|
|
1819
|
+
if (!dirPath.startsWith(packageInfo.packageDirectory)) return;
|
|
1820
|
+
let subDirectory = dirPath.slice(packageInfo.packageDirectory.length);
|
|
1821
|
+
if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
|
|
1822
|
+
const lastIndex = sourceFile.fileName.lastIndexOf("/");
|
|
1823
|
+
let subModule = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
|
|
1824
|
+
for (const extension of [".ts", ".tsx", ".js", ".jsx"]) {
|
|
1825
|
+
if (subModule.toLowerCase().endsWith(extension)) {
|
|
1826
|
+
subModule = subModule.slice(0, -extension.length);
|
|
1827
|
+
break;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
if (subModule.toLowerCase().endsWith("/index")) subModule = subModule.slice(0, -6);
|
|
1831
|
+
if (subModule.startsWith("/")) subModule = subModule.slice(1);
|
|
1832
|
+
for (const prefix of keyPattern.skipLeadingPath) {
|
|
1833
|
+
if (subDirectory.startsWith(prefix)) {
|
|
1834
|
+
subDirectory = subDirectory.slice(prefix.length);
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
const parts = [packageInfo.name, subDirectory, subModule].concat(
|
|
1839
|
+
subModule.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
|
|
1840
|
+
);
|
|
1841
|
+
return parts.filter((_) => String(_).trim().length > 0).join("/");
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
return {
|
|
1845
|
+
createString: createString2
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
);
|
|
1849
|
+
var keyBuilderCache = /* @__PURE__ */ new Map();
|
|
1850
|
+
var getOrMakeKeyBuilder = fn("getOrMakeKeyBuilder")(function* (sourceFile) {
|
|
1851
|
+
const keyBuilder = keyBuilderCache.get(sourceFile.fileName) || (yield* makeKeyBuilder(sourceFile));
|
|
1852
|
+
keyBuilderCache.set(sourceFile.fileName, keyBuilder);
|
|
1853
|
+
return keyBuilder;
|
|
1854
|
+
});
|
|
1855
|
+
function createString(sourceFile, identifier, kind) {
|
|
1856
|
+
return map5(
|
|
1857
|
+
getOrMakeKeyBuilder(sourceFile),
|
|
1858
|
+
(identifierBuilder) => identifierBuilder.createString(identifier, kind)
|
|
1744
1859
|
);
|
|
1745
1860
|
}
|
|
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
1861
|
|
|
1785
1862
|
// src/core/LSP.ts
|
|
1786
1863
|
var RefactorNotApplicableError = class {
|
|
@@ -1832,7 +1909,7 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
1832
1909
|
for (const refactor of refactors2) {
|
|
1833
1910
|
yield* pipe(
|
|
1834
1911
|
refactor.apply(sourceFile, textRange),
|
|
1835
|
-
|
|
1912
|
+
map5(
|
|
1836
1913
|
(result) => effectRefactors.push({
|
|
1837
1914
|
name: refactorNameToFullyQualifiedName(refactor.name),
|
|
1838
1915
|
description: refactor.description,
|
|
@@ -1942,7 +2019,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1942
2019
|
const fixByDisableNextLine = (node) => ({
|
|
1943
2020
|
fixName: rule.name + "_skipNextLine",
|
|
1944
2021
|
description: "Disable " + rule.name + " for this line",
|
|
1945
|
-
apply:
|
|
2022
|
+
apply: flatMap2(
|
|
1946
2023
|
service(ChangeTracker),
|
|
1947
2024
|
(changeTracker) => gen(function* () {
|
|
1948
2025
|
const disableAtNode = findParentStatementForDisableNextLine(node);
|
|
@@ -1960,7 +2037,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1960
2037
|
const fixByDisableEntireFile = {
|
|
1961
2038
|
fixName: rule.name + "_skipFile",
|
|
1962
2039
|
description: "Disable " + rule.name + " for this entire file",
|
|
1963
|
-
apply:
|
|
2040
|
+
apply: flatMap2(
|
|
1964
2041
|
service(ChangeTracker),
|
|
1965
2042
|
(changeTracker) => sync(
|
|
1966
2043
|
() => changeTracker.insertText(
|
|
@@ -2079,7 +2156,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2079
2156
|
const edit = yield* codegen.apply(sourceFile, range);
|
|
2080
2157
|
const updateHashComment = pipe(
|
|
2081
2158
|
service(ChangeTracker),
|
|
2082
|
-
|
|
2159
|
+
map5((changeTracker) => {
|
|
2083
2160
|
changeTracker.deleteRange(sourceFile, range);
|
|
2084
2161
|
changeTracker.insertText(sourceFile, range.pos, `${codegen.name}:${edit.hash}`);
|
|
2085
2162
|
})
|
|
@@ -2088,7 +2165,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
|
|
|
2088
2165
|
...edit,
|
|
2089
2166
|
apply: pipe(
|
|
2090
2167
|
edit.apply,
|
|
2091
|
-
|
|
2168
|
+
flatMap2(() => updateHashComment)
|
|
2092
2169
|
),
|
|
2093
2170
|
ignore: updateHashComment
|
|
2094
2171
|
};
|
|
@@ -2113,10 +2190,11 @@ var contextSelfInClasses = createCompletion({
|
|
|
2113
2190
|
) || "Context";
|
|
2114
2191
|
if (contextIdentifier !== ts.idText(accessedObject)) return [];
|
|
2115
2192
|
const name = ts.idText(className);
|
|
2193
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
2116
2194
|
return [{
|
|
2117
2195
|
name: `Tag("${name}")`,
|
|
2118
2196
|
kind: ts.ScriptElementKind.constElement,
|
|
2119
|
-
insertText: `${contextIdentifier}.Tag("${
|
|
2197
|
+
insertText: `${contextIdentifier}.Tag("${tagKey}")<${name}, ${"${0}"}>(){}`,
|
|
2120
2198
|
replacementSpan,
|
|
2121
2199
|
isSnippet: true
|
|
2122
2200
|
}];
|
|
@@ -2139,8 +2217,8 @@ function makeResolveExternalModuleName(typeChecker) {
|
|
|
2139
2217
|
var TypeCheckerUtils = Tag("TypeCheckerUtils");
|
|
2140
2218
|
var nanoLayer2 = (fa) => pipe(
|
|
2141
2219
|
service(TypeScriptApi),
|
|
2142
|
-
|
|
2143
|
-
(ts) =>
|
|
2220
|
+
flatMap2(
|
|
2221
|
+
(ts) => flatMap2(service(TypeCheckerApi), (typeChecker) => pipe(fa, provideService(TypeCheckerUtils, makeTypeCheckerUtils(ts, typeChecker))))
|
|
2144
2222
|
)
|
|
2145
2223
|
);
|
|
2146
2224
|
function makeTypeCheckerUtils(ts, typeChecker) {
|
|
@@ -2519,7 +2597,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2519
2597
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2520
2598
|
return invariantTypeArgument(propertyType);
|
|
2521
2599
|
};
|
|
2522
|
-
const effectVarianceStruct = (type, atLocation) =>
|
|
2600
|
+
const effectVarianceStruct = (type, atLocation) => map5(
|
|
2523
2601
|
all(
|
|
2524
2602
|
varianceStructCovariantType(type, atLocation, "_A"),
|
|
2525
2603
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2527,7 +2605,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2527
2605
|
),
|
|
2528
2606
|
([A, E, R]) => ({ A, E, R })
|
|
2529
2607
|
);
|
|
2530
|
-
const layerVarianceStruct = (type, atLocation) =>
|
|
2608
|
+
const layerVarianceStruct = (type, atLocation) => map5(
|
|
2531
2609
|
all(
|
|
2532
2610
|
varianceStructContravariantType(type, atLocation, "_ROut"),
|
|
2533
2611
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
@@ -2750,7 +2828,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2750
2828
|
}
|
|
2751
2829
|
return pipe(
|
|
2752
2830
|
importedEffectModule(propertyAccess.expression),
|
|
2753
|
-
|
|
2831
|
+
map5((effectModule) => ({
|
|
2754
2832
|
node,
|
|
2755
2833
|
effectModule,
|
|
2756
2834
|
generatorFunction,
|
|
@@ -2797,7 +2875,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2797
2875
|
}
|
|
2798
2876
|
return pipe(
|
|
2799
2877
|
importedEffectModule(propertyAccess.expression),
|
|
2800
|
-
|
|
2878
|
+
map5((effectModule) => ({
|
|
2801
2879
|
node,
|
|
2802
2880
|
effectModule,
|
|
2803
2881
|
generatorFunction,
|
|
@@ -2849,7 +2927,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2849
2927
|
}
|
|
2850
2928
|
return pipe(
|
|
2851
2929
|
importedEffectModule(propertyAccess.expression),
|
|
2852
|
-
|
|
2930
|
+
map5((effectModule) => ({
|
|
2853
2931
|
node,
|
|
2854
2932
|
generatorFunction,
|
|
2855
2933
|
effectModule,
|
|
@@ -2922,7 +3000,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2922
3000
|
"TypeParser.unnecessaryEffectGen",
|
|
2923
3001
|
(node) => node
|
|
2924
3002
|
);
|
|
2925
|
-
const effectSchemaVarianceStruct = (type, atLocation) =>
|
|
3003
|
+
const effectSchemaVarianceStruct = (type, atLocation) => map5(
|
|
2926
3004
|
all(
|
|
2927
3005
|
varianceStructInvariantType(type, atLocation, "_A"),
|
|
2928
3006
|
varianceStructInvariantType(type, atLocation, "_I"),
|
|
@@ -2954,7 +3032,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
2954
3032
|
"TypeParser.effectSchemaType",
|
|
2955
3033
|
(type) => type
|
|
2956
3034
|
);
|
|
2957
|
-
const contextTagVarianceStruct = (type, atLocation) =>
|
|
3035
|
+
const contextTagVarianceStruct = (type, atLocation) => map5(
|
|
2958
3036
|
all(
|
|
2959
3037
|
varianceStructInvariantType(type, atLocation, "_Identifier"),
|
|
2960
3038
|
varianceStructInvariantType(type, atLocation, "_Service")
|
|
@@ -3086,7 +3164,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3086
3164
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3087
3165
|
const parsedSchemaModule = yield* pipe(
|
|
3088
3166
|
effectSchemaType(expressionType, expression),
|
|
3089
|
-
|
|
3167
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3090
3168
|
option
|
|
3091
3169
|
);
|
|
3092
3170
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3129,7 +3207,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3129
3207
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3130
3208
|
const parsedSchemaModule = yield* pipe(
|
|
3131
3209
|
effectSchemaType(expressionType, expression),
|
|
3132
|
-
|
|
3210
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3133
3211
|
option
|
|
3134
3212
|
);
|
|
3135
3213
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3174,7 +3252,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3174
3252
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3175
3253
|
const parsedSchemaModule = yield* pipe(
|
|
3176
3254
|
effectSchemaType(expressionType, expression),
|
|
3177
|
-
|
|
3255
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3178
3256
|
option
|
|
3179
3257
|
);
|
|
3180
3258
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3295,7 +3373,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3295
3373
|
const expressionType = typeChecker.getTypeAtLocation(expression);
|
|
3296
3374
|
const parsedSchemaModule = yield* pipe(
|
|
3297
3375
|
effectSchemaType(expressionType, expression),
|
|
3298
|
-
|
|
3376
|
+
flatMap2(() => importedSchemaModule(schemaIdentifier.expression)),
|
|
3299
3377
|
option
|
|
3300
3378
|
);
|
|
3301
3379
|
if (isSome2(parsedSchemaModule)) {
|
|
@@ -3439,7 +3517,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3439
3517
|
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
3440
3518
|
const parsedContextTag = yield* pipe(
|
|
3441
3519
|
importedEffectModule(effectServiceIdentifier.expression),
|
|
3442
|
-
|
|
3520
|
+
flatMap2(() => contextTag(type, atLocation)),
|
|
3443
3521
|
option
|
|
3444
3522
|
);
|
|
3445
3523
|
if (isSome2(parsedContextTag)) {
|
|
@@ -3582,7 +3660,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3582
3660
|
};
|
|
3583
3661
|
const generateReturnType = (type, atLocation2, className2) => pipe(
|
|
3584
3662
|
typeParser.effectType(type, atLocation2),
|
|
3585
|
-
|
|
3663
|
+
flatMap2((returnedEffect) => {
|
|
3586
3664
|
const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(ts.idText(className2)) : ts.factory.createUnionTypeNode(
|
|
3587
3665
|
[
|
|
3588
3666
|
ts.factory.createTypeReferenceNode(ts.idText(className2)),
|
|
@@ -3613,7 +3691,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3613
3691
|
orElse2(
|
|
3614
3692
|
() => pipe(
|
|
3615
3693
|
typeParser.promiseLike(type, atLocation2),
|
|
3616
|
-
|
|
3694
|
+
flatMap2(({ type: type2 }) => {
|
|
3617
3695
|
const successType = typeChecker.typeToTypeNode(
|
|
3618
3696
|
type2,
|
|
3619
3697
|
atLocation2,
|
|
@@ -3681,7 +3759,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3681
3759
|
for (const signature of typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call)) {
|
|
3682
3760
|
yield* pipe(
|
|
3683
3761
|
proxySignature(signature, atLocation, className),
|
|
3684
|
-
|
|
3762
|
+
map5((sig) => {
|
|
3685
3763
|
callSignatures.push(sig);
|
|
3686
3764
|
}),
|
|
3687
3765
|
ignore
|
|
@@ -3714,7 +3792,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
3714
3792
|
if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
|
|
3715
3793
|
const { Service, accessors: accessors2, className } = yield* pipe(
|
|
3716
3794
|
typeParser.extendsEffectService(node),
|
|
3717
|
-
orElse2(() =>
|
|
3795
|
+
orElse2(() => map5(typeParser.extendsEffectTag(node), (_) => ({ accessors: true, ..._ }))),
|
|
3718
3796
|
orElse2(() => fail("not a class extending Effect.Service call"))
|
|
3719
3797
|
);
|
|
3720
3798
|
if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
|
|
@@ -3748,7 +3826,7 @@ var writeTagClassAccessors = createRefactor({
|
|
|
3748
3826
|
const typeParser = yield* service(TypeParser);
|
|
3749
3827
|
const parseNode = (node) => pipe(
|
|
3750
3828
|
parse2(node),
|
|
3751
|
-
|
|
3829
|
+
map5(({ Service, atLocation, className, involvedMembers }) => ({
|
|
3752
3830
|
kind: "refactor.rewrite.effect.writeTagClassAccessors",
|
|
3753
3831
|
description: "Implement Service accessors",
|
|
3754
3832
|
apply: pipe(
|
|
@@ -3781,7 +3859,7 @@ var accessors = createCodegen({
|
|
|
3781
3859
|
if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
|
|
3782
3860
|
return yield* pipe(
|
|
3783
3861
|
parse2(nodeAndCommentRange.node),
|
|
3784
|
-
|
|
3862
|
+
map5(
|
|
3785
3863
|
(_) => ({
|
|
3786
3864
|
hash: _.hash,
|
|
3787
3865
|
description: "Generate accessors for the service",
|
|
@@ -3846,10 +3924,11 @@ var effectDataClasses = createCompletion({
|
|
|
3846
3924
|
) || "Data";
|
|
3847
3925
|
if (effectDataIdentifier !== ts.idText(accessedObject)) return [];
|
|
3848
3926
|
const name = ts.idText(className);
|
|
3927
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
3849
3928
|
return [{
|
|
3850
3929
|
name: `TaggedError("${name}")`,
|
|
3851
3930
|
kind: ts.ScriptElementKind.constElement,
|
|
3852
|
-
insertText: `${effectDataIdentifier}.TaggedError("${
|
|
3931
|
+
insertText: `${effectDataIdentifier}.TaggedError("${errorTagKey}")<{${"${0}"}}>{}`,
|
|
3853
3932
|
replacementSpan,
|
|
3854
3933
|
isSnippet: true
|
|
3855
3934
|
}, {
|
|
@@ -3961,6 +4040,67 @@ var classSelfMismatch = createDiagnostic({
|
|
|
3961
4040
|
})
|
|
3962
4041
|
});
|
|
3963
4042
|
|
|
4043
|
+
// src/diagnostics/deterministicKeys.ts
|
|
4044
|
+
var deterministicKeys = createDiagnostic({
|
|
4045
|
+
name: "deterministicKeys",
|
|
4046
|
+
code: 25,
|
|
4047
|
+
severity: "off",
|
|
4048
|
+
apply: fn("deterministicKeys.apply")(function* (sourceFile, report) {
|
|
4049
|
+
const ts = yield* service(TypeScriptApi);
|
|
4050
|
+
const typeParser = yield* service(TypeParser);
|
|
4051
|
+
const nodeToVisit = [];
|
|
4052
|
+
const appendNodeToVisit = (node) => {
|
|
4053
|
+
nodeToVisit.push(node);
|
|
4054
|
+
return void 0;
|
|
4055
|
+
};
|
|
4056
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4057
|
+
while (nodeToVisit.length > 0) {
|
|
4058
|
+
const node = nodeToVisit.shift();
|
|
4059
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
4060
|
+
const result = yield* pipe(
|
|
4061
|
+
pipe(
|
|
4062
|
+
typeParser.extendsEffectService(node),
|
|
4063
|
+
orElse2(() => typeParser.extendsContextTag(node)),
|
|
4064
|
+
orElse2(() => typeParser.extendsEffectTag(node)),
|
|
4065
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "service" }))
|
|
4066
|
+
),
|
|
4067
|
+
orElse2(
|
|
4068
|
+
() => pipe(
|
|
4069
|
+
typeParser.extendsDataTaggedError(node),
|
|
4070
|
+
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
4071
|
+
map5(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "error" }))
|
|
4072
|
+
)
|
|
4073
|
+
),
|
|
4074
|
+
orElse2(() => void_)
|
|
4075
|
+
);
|
|
4076
|
+
if (result && result.keyStringLiteral) {
|
|
4077
|
+
const { className, keyStringLiteral } = result;
|
|
4078
|
+
const classNameText = ts.idText(className);
|
|
4079
|
+
const expectedKey = yield* createString(sourceFile, classNameText, result.target);
|
|
4080
|
+
if (!expectedKey) return;
|
|
4081
|
+
const actualIdentifier = keyStringLiteral.text;
|
|
4082
|
+
if (actualIdentifier !== expectedKey) {
|
|
4083
|
+
report({
|
|
4084
|
+
location: keyStringLiteral,
|
|
4085
|
+
messageText: `Key should be '${expectedKey}'`,
|
|
4086
|
+
fixes: [{
|
|
4087
|
+
fixName: "deterministicKeys_fix",
|
|
4088
|
+
description: `Replace '${actualIdentifier}' with '${expectedKey}'`,
|
|
4089
|
+
apply: gen(function* () {
|
|
4090
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
4091
|
+
const newStringLiteral = ts.factory.createStringLiteral(expectedKey);
|
|
4092
|
+
changeTracker.replaceNode(sourceFile, keyStringLiteral, newStringLiteral);
|
|
4093
|
+
})
|
|
4094
|
+
}]
|
|
4095
|
+
});
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4100
|
+
}
|
|
4101
|
+
})
|
|
4102
|
+
});
|
|
4103
|
+
|
|
3964
4104
|
// src/diagnostics/duplicatePackage.ts
|
|
3965
4105
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
3966
4106
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
@@ -4030,7 +4170,7 @@ var effectGenUsesAdapter = createDiagnostic({
|
|
|
4030
4170
|
if (ts.isCallExpression(node)) {
|
|
4031
4171
|
yield* pipe(
|
|
4032
4172
|
typeParser.effectGen(node),
|
|
4033
|
-
|
|
4173
|
+
map5(({ generatorFunction }) => {
|
|
4034
4174
|
if (generatorFunction.parameters.length > 0) {
|
|
4035
4175
|
const adapter = generatorFunction.parameters[0];
|
|
4036
4176
|
report({
|
|
@@ -4063,7 +4203,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4063
4203
|
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
4064
4204
|
const voidValueTypes = typeCheckerUtils.unrollUnionMembers(realEffect.A);
|
|
4065
4205
|
const voidedEffect = yield* firstSuccessOf(
|
|
4066
|
-
voidValueTypes.map((_) =>
|
|
4206
|
+
voidValueTypes.map((_) => map5(typeParser.strictEffectType(_, node), () => _))
|
|
4067
4207
|
);
|
|
4068
4208
|
return { voidedEffect };
|
|
4069
4209
|
}
|
|
@@ -4079,7 +4219,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
4079
4219
|
valueNode,
|
|
4080
4220
|
realType
|
|
4081
4221
|
),
|
|
4082
|
-
|
|
4222
|
+
map5(({ voidedEffect }) => {
|
|
4083
4223
|
report(
|
|
4084
4224
|
{
|
|
4085
4225
|
location: node,
|
|
@@ -4174,7 +4314,7 @@ var genericEffectServices = createDiagnostic({
|
|
|
4174
4314
|
for (const [type, reportAt] of typesToCheck) {
|
|
4175
4315
|
yield* pipe(
|
|
4176
4316
|
typeParser.contextTag(type, node),
|
|
4177
|
-
|
|
4317
|
+
map5(() => {
|
|
4178
4318
|
report({
|
|
4179
4319
|
location: reportAt,
|
|
4180
4320
|
messageText: `Effect Services with type parameters are not supported because they cannot be properly discriminated at runtime, which may cause unexpected behavior.`,
|
|
@@ -4351,7 +4491,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4351
4491
|
let effectContextType = void 0;
|
|
4352
4492
|
yield* pipe(
|
|
4353
4493
|
typeParser.effectType(servicePropertyType, atLocation),
|
|
4354
|
-
|
|
4494
|
+
map5((_) => effectContextType = _.R),
|
|
4355
4495
|
orElse2(() => {
|
|
4356
4496
|
const servicePropertyCallSignatures = typeChecker.getSignaturesOfType(
|
|
4357
4497
|
servicePropertyType,
|
|
@@ -4363,7 +4503,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4363
4503
|
typeChecker.getReturnTypeOfSignature(servicePropertyCallSignatures[0]),
|
|
4364
4504
|
atLocation
|
|
4365
4505
|
),
|
|
4366
|
-
|
|
4506
|
+
map5((_) => {
|
|
4367
4507
|
effectContextType = _.R;
|
|
4368
4508
|
})
|
|
4369
4509
|
);
|
|
@@ -4381,7 +4521,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
4381
4521
|
if (type.flags & ts.TypeFlags.Never) return succeed(true);
|
|
4382
4522
|
return pipe(
|
|
4383
4523
|
typeParser.scopeType(type, atLocation),
|
|
4384
|
-
|
|
4524
|
+
map5(() => true),
|
|
4385
4525
|
orElse2(() => succeed(false))
|
|
4386
4526
|
);
|
|
4387
4527
|
}
|
|
@@ -4437,10 +4577,10 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
4437
4577
|
for (const [type, reportAt] of typesToCheck) {
|
|
4438
4578
|
yield* pipe(
|
|
4439
4579
|
typeParser.contextTag(type, node),
|
|
4440
|
-
|
|
4580
|
+
flatMap2(
|
|
4441
4581
|
({ Service }) => pipe(
|
|
4442
4582
|
parseLeakedRequirements(Service, node),
|
|
4443
|
-
|
|
4583
|
+
map5(
|
|
4444
4584
|
(requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
|
|
4445
4585
|
)
|
|
4446
4586
|
)
|
|
@@ -4467,7 +4607,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4467
4607
|
typeParser.effectType(expectedType, node),
|
|
4468
4608
|
typeParser.effectType(realType, valueNode)
|
|
4469
4609
|
),
|
|
4470
|
-
|
|
4610
|
+
map5(
|
|
4471
4611
|
([expectedEffect, realEffect]) => typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4472
4612
|
realEffect.R,
|
|
4473
4613
|
expectedEffect.R
|
|
@@ -4485,7 +4625,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
4485
4625
|
valueNode,
|
|
4486
4626
|
realType
|
|
4487
4627
|
),
|
|
4488
|
-
|
|
4628
|
+
map5(
|
|
4489
4629
|
(missingTypes) => missingTypes.length > 0 ? report(
|
|
4490
4630
|
{
|
|
4491
4631
|
location: node,
|
|
@@ -4530,7 +4670,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4530
4670
|
typeParser.effectType(expectedType, node),
|
|
4531
4671
|
typeParser.effectType(realType, valueNode)
|
|
4532
4672
|
),
|
|
4533
|
-
|
|
4673
|
+
map5(
|
|
4534
4674
|
([expectedEffect, realEffect]) => pipe(
|
|
4535
4675
|
typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4536
4676
|
realEffect.E,
|
|
@@ -4551,7 +4691,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4551
4691
|
valueNode,
|
|
4552
4692
|
realType
|
|
4553
4693
|
),
|
|
4554
|
-
|
|
4694
|
+
map5((result) => {
|
|
4555
4695
|
if (result.missingErrorTypes.length === 0) return;
|
|
4556
4696
|
const fixes = [];
|
|
4557
4697
|
if (ts.isExpression(valueNode) && result.expectedErrorType.flags & ts.TypeFlags.Never) {
|
|
@@ -4578,17 +4718,17 @@ var missingEffectError = createDiagnostic({
|
|
|
4578
4718
|
if (ts.isExpression(valueNode)) {
|
|
4579
4719
|
const propertyAssignments = pipe(
|
|
4580
4720
|
result.missingErrorTypes,
|
|
4581
|
-
|
|
4721
|
+
map4((_) => typeChecker.getPropertyOfType(_, "_tag")),
|
|
4582
4722
|
filter((_) => !!_),
|
|
4583
|
-
|
|
4723
|
+
map4((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
|
|
4584
4724
|
filter((_) => !!(_.flags & ts.TypeFlags.Literal)),
|
|
4585
|
-
|
|
4725
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
4586
4726
|
filter((_) => !!_ && ts.isLiteralTypeNode(_)),
|
|
4587
|
-
|
|
4727
|
+
map4((_) => _.literal),
|
|
4588
4728
|
filter((_) => ts.isLiteralExpression(_)),
|
|
4589
|
-
|
|
4729
|
+
map4((_) => _.text),
|
|
4590
4730
|
sort(string2),
|
|
4591
|
-
|
|
4731
|
+
map4(
|
|
4592
4732
|
(_) => ts.factory.createPropertyAssignment(
|
|
4593
4733
|
ts.factory.createIdentifier(_),
|
|
4594
4734
|
ts.factory.createArrowFunction(
|
|
@@ -4825,7 +4965,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
4825
4965
|
typeParser.effectGen(effectGenNode),
|
|
4826
4966
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
4827
4967
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
4828
|
-
|
|
4968
|
+
map5(({ generatorFunction }) => {
|
|
4829
4969
|
if (generatorFunction) {
|
|
4830
4970
|
brokenGenerators.add(ts.getTokenPosOfNode(generatorFunction, tsUtils.getSourceFileOfNode(node)));
|
|
4831
4971
|
}
|
|
@@ -4894,8 +5034,8 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4894
5034
|
const type = typeChecker.getTypeAtLocation(layer);
|
|
4895
5035
|
return pipe(
|
|
4896
5036
|
typeParser.importedEffectModule(node.expression.expression),
|
|
4897
|
-
|
|
4898
|
-
|
|
5037
|
+
flatMap2(() => typeParser.layerType(type, layer)),
|
|
5038
|
+
map5(() => ({ layer, node })),
|
|
4899
5039
|
orElse2(() => void_)
|
|
4900
5040
|
);
|
|
4901
5041
|
}
|
|
@@ -5065,7 +5205,7 @@ var outdatedEffectCodegen = createDiagnostic({
|
|
|
5065
5205
|
for (const { codegen, hash: hash2, range } of codegensWithRanges) {
|
|
5066
5206
|
yield* pipe(
|
|
5067
5207
|
getEditsForCodegen([codegen], sourceFile, range),
|
|
5068
|
-
|
|
5208
|
+
map5((applicable) => {
|
|
5069
5209
|
if (applicable.hash !== hash2) {
|
|
5070
5210
|
_report({
|
|
5071
5211
|
location: range,
|
|
@@ -5125,7 +5265,7 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
5125
5265
|
const typeAtLocation = typeChecker.getTypeAtLocation(type.expression);
|
|
5126
5266
|
const isSchema = yield* pipe(
|
|
5127
5267
|
typeParser.effectSchemaType(typeAtLocation, type.expression),
|
|
5128
|
-
|
|
5268
|
+
map5(() => true),
|
|
5129
5269
|
orElse2(() => succeed(false))
|
|
5130
5270
|
);
|
|
5131
5271
|
if (isSchema) {
|
|
@@ -5196,7 +5336,7 @@ var returnEffectInGen = createDiagnostic({
|
|
|
5196
5336
|
typeParser.effectGen(effectGenNode),
|
|
5197
5337
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5198
5338
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5199
|
-
|
|
5339
|
+
map5(() => {
|
|
5200
5340
|
const fix = node.expression ? [{
|
|
5201
5341
|
fixName: "returnEffectInGen_fix",
|
|
5202
5342
|
description: "Add yield* statement",
|
|
@@ -5259,7 +5399,7 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
5259
5399
|
const entries = typeCheckerUtils.unrollUnionMembers(type);
|
|
5260
5400
|
return pipe(
|
|
5261
5401
|
firstSuccessOf(entries.map((type2) => typeParser.scopeType(type2, node))),
|
|
5262
|
-
|
|
5402
|
+
map5(
|
|
5263
5403
|
() => report({
|
|
5264
5404
|
location: node,
|
|
5265
5405
|
messageText: `Seems like you are constructing a layer with a scope in the requirements.
|
|
@@ -5294,7 +5434,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5294
5434
|
const type = typeChecker.getTypeAtLocation(node);
|
|
5295
5435
|
yield* pipe(
|
|
5296
5436
|
typeParser.layerType(type, node),
|
|
5297
|
-
|
|
5437
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, layerEffectApiCall.methodIdentifier)),
|
|
5298
5438
|
ignore
|
|
5299
5439
|
);
|
|
5300
5440
|
continue;
|
|
@@ -5308,7 +5448,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
5308
5448
|
const type = typeChecker.getTypeOfSymbolAtLocation(defaultLayer, node);
|
|
5309
5449
|
yield* pipe(
|
|
5310
5450
|
typeParser.layerType(type, node),
|
|
5311
|
-
|
|
5451
|
+
flatMap2(({ RIn }) => reportIfLayerRequireScope(RIn, node, void 0)),
|
|
5312
5452
|
ignore
|
|
5313
5453
|
);
|
|
5314
5454
|
continue;
|
|
@@ -5418,7 +5558,7 @@ var tryCatchInEffectGen = createDiagnostic({
|
|
|
5418
5558
|
typeParser.effectGen(effectGenNode),
|
|
5419
5559
|
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
5420
5560
|
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
5421
|
-
|
|
5561
|
+
map5(() => {
|
|
5422
5562
|
report({
|
|
5423
5563
|
location: node,
|
|
5424
5564
|
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 +5593,7 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
5453
5593
|
if (ts.isCallExpression(node)) {
|
|
5454
5594
|
yield* pipe(
|
|
5455
5595
|
typeParser.unnecessaryEffectGen(node),
|
|
5456
|
-
|
|
5596
|
+
map5(
|
|
5457
5597
|
({ replacementNode }) => report({
|
|
5458
5598
|
location: node,
|
|
5459
5599
|
messageText: `This Effect.gen contains a single return statement.`,
|
|
@@ -5496,7 +5636,7 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
5496
5636
|
if (ts.isCallExpression(node)) {
|
|
5497
5637
|
yield* pipe(
|
|
5498
5638
|
typeParser.pipeCall(node),
|
|
5499
|
-
|
|
5639
|
+
map5(({ args: args2, subject }) => {
|
|
5500
5640
|
if (args2.length === 0) {
|
|
5501
5641
|
report({
|
|
5502
5642
|
location: node,
|
|
@@ -5541,10 +5681,10 @@ var unnecessaryPipeChain = createDiagnostic({
|
|
|
5541
5681
|
if (ts.isCallExpression(node)) {
|
|
5542
5682
|
yield* pipe(
|
|
5543
5683
|
typeParser.pipeCall(node),
|
|
5544
|
-
|
|
5545
|
-
(pipeCall) =>
|
|
5684
|
+
flatMap2(
|
|
5685
|
+
(pipeCall) => map5(typeParser.pipeCall(pipeCall.subject), (innerCall) => ({ pipeCall, innerCall }))
|
|
5546
5686
|
),
|
|
5547
|
-
|
|
5687
|
+
map5(({ innerCall, pipeCall }) => {
|
|
5548
5688
|
report({
|
|
5549
5689
|
location: node,
|
|
5550
5690
|
messageText: `Chained pipe calls can be simplified to a single pipe call`,
|
|
@@ -5676,7 +5816,8 @@ var diagnostics = [
|
|
|
5676
5816
|
outdatedEffectCodegen,
|
|
5677
5817
|
overriddenSchemaConstructor,
|
|
5678
5818
|
unsupportedServiceAccessors,
|
|
5679
|
-
nonObjectEffectServiceType
|
|
5819
|
+
nonObjectEffectServiceType,
|
|
5820
|
+
deterministicKeys
|
|
5680
5821
|
];
|
|
5681
5822
|
|
|
5682
5823
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -5728,6 +5869,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5728
5869
|
) || "Schema";
|
|
5729
5870
|
if (schemaIdentifier !== ts.idText(accessedObject)) return [];
|
|
5730
5871
|
const name = ts.idText(className);
|
|
5872
|
+
const errorTagKey = (yield* createString(sourceFile, name, "error")) || name;
|
|
5731
5873
|
return [{
|
|
5732
5874
|
name: `Class<${name}>`,
|
|
5733
5875
|
kind: ts.ScriptElementKind.constElement,
|
|
@@ -5737,7 +5879,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
5737
5879
|
}, {
|
|
5738
5880
|
name: `TaggedError<${name}>`,
|
|
5739
5881
|
kind: ts.ScriptElementKind.constElement,
|
|
5740
|
-
insertText: `${schemaIdentifier}.TaggedError<${name}>("${
|
|
5882
|
+
insertText: `${schemaIdentifier}.TaggedError<${name}>("${errorTagKey}")("${errorTagKey}", {${"${0}"}}){}`,
|
|
5741
5883
|
replacementSpan,
|
|
5742
5884
|
isSnippet: true
|
|
5743
5885
|
}, {
|
|
@@ -5772,16 +5914,17 @@ var effectSelfInClasses = createCompletion({
|
|
|
5772
5914
|
) || "Effect";
|
|
5773
5915
|
if (effectIdentifier !== ts.idText(accessedObject)) return [];
|
|
5774
5916
|
const name = ts.idText(className);
|
|
5917
|
+
const tagKey = (yield* createString(sourceFile, name, "service")) || name;
|
|
5775
5918
|
return [{
|
|
5776
5919
|
name: `Service<${name}>`,
|
|
5777
5920
|
kind: ts.ScriptElementKind.constElement,
|
|
5778
|
-
insertText: `${effectIdentifier}.Service<${name}>()("${
|
|
5921
|
+
insertText: `${effectIdentifier}.Service<${name}>()("${tagKey}", {${"${0}"}}){}`,
|
|
5779
5922
|
replacementSpan,
|
|
5780
5923
|
isSnippet: true
|
|
5781
5924
|
}, {
|
|
5782
5925
|
name: `Tag("${name}")`,
|
|
5783
5926
|
kind: ts.ScriptElementKind.constElement,
|
|
5784
|
-
insertText: `${effectIdentifier}.Tag("${
|
|
5927
|
+
insertText: `${effectIdentifier}.Tag("${tagKey}")<${name}, {${"${0}"}}>(){}`,
|
|
5785
5928
|
replacementSpan,
|
|
5786
5929
|
isSnippet: true
|
|
5787
5930
|
}];
|
|
@@ -5807,7 +5950,7 @@ var fnFunctionStar = createCompletion({
|
|
|
5807
5950
|
const maybeFnName = pipe(
|
|
5808
5951
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5809
5952
|
filter(ts.isVariableDeclaration),
|
|
5810
|
-
|
|
5953
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5811
5954
|
filter((_) => _.length > 0),
|
|
5812
5955
|
head,
|
|
5813
5956
|
map2((name) => [
|
|
@@ -5915,7 +6058,7 @@ var schemaBrand = createCompletion({
|
|
|
5915
6058
|
return pipe(
|
|
5916
6059
|
tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
|
|
5917
6060
|
filter(ts.isVariableDeclaration),
|
|
5918
|
-
|
|
6061
|
+
map4((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
|
|
5919
6062
|
filter((_) => _.length > 0),
|
|
5920
6063
|
head,
|
|
5921
6064
|
map2((name) => [
|
|
@@ -6690,7 +6833,7 @@ var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, pr
|
|
|
6690
6833
|
const possiblyGen = node.parent;
|
|
6691
6834
|
yield* pipe(
|
|
6692
6835
|
parseType(possiblyGen),
|
|
6693
|
-
|
|
6836
|
+
map5((_) => {
|
|
6694
6837
|
const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
6695
6838
|
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.end && inlayHint.position <= _.body.getStart(sourceFile)) {
|
|
6696
6839
|
shouldOmit = true;
|
|
@@ -6797,7 +6940,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6797
6940
|
type,
|
|
6798
6941
|
atLocation
|
|
6799
6942
|
),
|
|
6800
|
-
|
|
6943
|
+
map5((_) => makeSymbolDisplayParts("Effect Type Parameters", _.A, _.E, _.R)),
|
|
6801
6944
|
orElse2(() => {
|
|
6802
6945
|
const callSignatues = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
6803
6946
|
if (callSignatues.length !== 1) return succeed([]);
|
|
@@ -6807,7 +6950,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6807
6950
|
returnType,
|
|
6808
6951
|
atLocation
|
|
6809
6952
|
),
|
|
6810
|
-
|
|
6953
|
+
map5((_) => makeSymbolDisplayParts("Returned Effect Type Parameters", _.A, _.E, _.R))
|
|
6811
6954
|
);
|
|
6812
6955
|
})
|
|
6813
6956
|
);
|
|
@@ -11359,7 +11502,7 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
11359
11502
|
const { layerNode, node } = maybeNodes;
|
|
11360
11503
|
const layerInfoDisplayParts = yield* pipe(
|
|
11361
11504
|
parseLayerGraph(sourceFile, layerNode),
|
|
11362
|
-
|
|
11505
|
+
flatMap2(
|
|
11363
11506
|
({ mermaidCode, textualExplanation }) => gen(function* () {
|
|
11364
11507
|
const linkParts = [];
|
|
11365
11508
|
if (!options.noExternal) {
|
|
@@ -11791,11 +11934,11 @@ var effectGenToFn = createRefactor({
|
|
|
11791
11934
|
parentNodes,
|
|
11792
11935
|
filter((_) => ts.isVariableDeclaration(_) && _.initializer ? true : false),
|
|
11793
11936
|
filter((_) => tsUtils.isNodeInRange(textRange)(_.name)),
|
|
11794
|
-
|
|
11937
|
+
map4((_) => _.initializer)
|
|
11795
11938
|
);
|
|
11796
11939
|
const maybeNode = yield* pipe(
|
|
11797
11940
|
nodesFromInitializers.concat(parentNodes),
|
|
11798
|
-
|
|
11941
|
+
map4(parseFunctionLikeReturnEffectGen),
|
|
11799
11942
|
firstSuccessOf,
|
|
11800
11943
|
option
|
|
11801
11944
|
);
|
|
@@ -11985,7 +12128,7 @@ var layerMagic = createRefactor({
|
|
|
11985
12128
|
if (ts.isArrayLiteralExpression(node)) {
|
|
11986
12129
|
return pipe(
|
|
11987
12130
|
all(...node.elements.map((element) => extractLayers(element, false))),
|
|
11988
|
-
|
|
12131
|
+
map5(flatten)
|
|
11989
12132
|
);
|
|
11990
12133
|
}
|
|
11991
12134
|
return TypeParserIssue.issue;
|
|
@@ -11994,7 +12137,7 @@ var layerMagic = createRefactor({
|
|
|
11994
12137
|
if (ts.isExpression(node)) {
|
|
11995
12138
|
return pipe(
|
|
11996
12139
|
typeParser.layerType(typeChecker.getTypeAtLocation(node), node),
|
|
11997
|
-
|
|
12140
|
+
map5((_) => [{ node, ..._ }])
|
|
11998
12141
|
);
|
|
11999
12142
|
}
|
|
12000
12143
|
return TypeParserIssue.issue;
|
|
@@ -12005,7 +12148,7 @@ var layerMagic = createRefactor({
|
|
|
12005
12148
|
) > -1) {
|
|
12006
12149
|
return pipe(
|
|
12007
12150
|
all(...node.arguments.map((element) => extractLayers(element, false))),
|
|
12008
|
-
|
|
12151
|
+
map5(flatten)
|
|
12009
12152
|
);
|
|
12010
12153
|
}
|
|
12011
12154
|
return TypeParserIssue.issue;
|
|
@@ -12013,10 +12156,10 @@ var layerMagic = createRefactor({
|
|
|
12013
12156
|
const extractPipeSequencing = (node) => {
|
|
12014
12157
|
return pipe(
|
|
12015
12158
|
typeParser.pipeCall(node),
|
|
12016
|
-
|
|
12159
|
+
flatMap2((_) => {
|
|
12017
12160
|
return all(...[_.subject, ..._.args].map((element) => extractLayers(element, true)));
|
|
12018
12161
|
}),
|
|
12019
|
-
|
|
12162
|
+
map5(flatten)
|
|
12020
12163
|
);
|
|
12021
12164
|
};
|
|
12022
12165
|
const extractLayers = cachedBy(
|
|
@@ -12044,10 +12187,10 @@ var layerMagic = createRefactor({
|
|
|
12044
12187
|
const atLocation = adjustedNode(node);
|
|
12045
12188
|
return pipe(
|
|
12046
12189
|
extractLayers(atLocation, false),
|
|
12047
|
-
|
|
12190
|
+
flatMap2(
|
|
12048
12191
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12049
12192
|
),
|
|
12050
|
-
|
|
12193
|
+
map5((extractedLayers) => ({
|
|
12051
12194
|
kind: "refactor.rewrite.effect.layerMagicPrepare",
|
|
12052
12195
|
description: "Prepare layers for automatic composition",
|
|
12053
12196
|
apply: pipe(
|
|
@@ -12063,7 +12206,7 @@ var layerMagic = createRefactor({
|
|
|
12063
12206
|
}
|
|
12064
12207
|
const previouslyProvided = yield* pipe(
|
|
12065
12208
|
typeParser.layerType(typeChecker.getTypeAtLocation(atLocation), atLocation),
|
|
12066
|
-
|
|
12209
|
+
map5((_) => _.ROut),
|
|
12067
12210
|
option
|
|
12068
12211
|
);
|
|
12069
12212
|
const [existingBefore, newlyIntroduced] = pipe(
|
|
@@ -12075,13 +12218,13 @@ var layerMagic = createRefactor({
|
|
|
12075
12218
|
);
|
|
12076
12219
|
const typeReferences = pipe(
|
|
12077
12220
|
newlyIntroduced,
|
|
12078
|
-
|
|
12221
|
+
map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
12079
12222
|
filter((_) => !!_)
|
|
12080
12223
|
);
|
|
12081
12224
|
const providesUnion = typeReferences.length === 0 ? ts.factory.createTypeReferenceNode("never") : ts.factory.createUnionTypeNode(typeReferences);
|
|
12082
12225
|
const typeStrings = pipe(
|
|
12083
12226
|
existingBefore,
|
|
12084
|
-
|
|
12227
|
+
map4((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)),
|
|
12085
12228
|
filter((_) => !!_)
|
|
12086
12229
|
);
|
|
12087
12230
|
const unionWithComment = typeStrings.length === 0 ? providesUnion : ts.addSyntheticTrailingComment(
|
|
@@ -12116,7 +12259,7 @@ var layerMagic = createRefactor({
|
|
|
12116
12259
|
if (ts.isAsExpression(expression) && expression.type.kind === ts.SyntaxKind.AnyKeyword) {
|
|
12117
12260
|
return pipe(
|
|
12118
12261
|
typeParser.layerType(typeChecker.getTypeAtLocation(node.type), node.type),
|
|
12119
|
-
|
|
12262
|
+
map5((_) => ({ node, ..._, castedStructure: expression.expression }))
|
|
12120
12263
|
);
|
|
12121
12264
|
}
|
|
12122
12265
|
}
|
|
@@ -12126,14 +12269,14 @@ var layerMagic = createRefactor({
|
|
|
12126
12269
|
const atLocation = adjustedNode(node);
|
|
12127
12270
|
return pipe(
|
|
12128
12271
|
parseAsAnyAsLayer(atLocation),
|
|
12129
|
-
|
|
12272
|
+
flatMap2(
|
|
12130
12273
|
(_targetLayer) => pipe(
|
|
12131
12274
|
extractArrayLiteral(_targetLayer.castedStructure),
|
|
12132
12275
|
orElse2(() => extractLayers(_targetLayer.castedStructure, false)),
|
|
12133
|
-
|
|
12276
|
+
flatMap2(
|
|
12134
12277
|
(extractedLayer) => extractedLayer.length < 1 ? TypeParserIssue.issue : succeed(extractedLayer)
|
|
12135
12278
|
),
|
|
12136
|
-
|
|
12279
|
+
map5((extractedLayers) => ({
|
|
12137
12280
|
kind: "refactor.rewrite.effect.layerMagicBuild",
|
|
12138
12281
|
description: "Compose layers automatically with target output services",
|
|
12139
12282
|
apply: gen(function* () {
|
|
@@ -12250,7 +12393,7 @@ var _findSchemaVariableDeclaration = fn(
|
|
|
12250
12393
|
);
|
|
12251
12394
|
return yield* pipe(
|
|
12252
12395
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
12253
|
-
|
|
12396
|
+
map4(findSchema),
|
|
12254
12397
|
firstSuccessOf,
|
|
12255
12398
|
option
|
|
12256
12399
|
);
|
|
@@ -12536,7 +12679,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12536
12679
|
filter(
|
|
12537
12680
|
(node2) => node2.arguments.length > 0
|
|
12538
12681
|
),
|
|
12539
|
-
|
|
12682
|
+
map4((node2) => {
|
|
12540
12683
|
let newNode2 = node2.arguments[0];
|
|
12541
12684
|
let didSomething = false;
|
|
12542
12685
|
for (let i = 1; i < node2.arguments.length; i++) {
|
|
@@ -12563,7 +12706,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
12563
12706
|
return didSomething ? some2([node2, newNode2]) : none2();
|
|
12564
12707
|
}),
|
|
12565
12708
|
filter(isSome2),
|
|
12566
|
-
|
|
12709
|
+
map4((_) => _.value),
|
|
12567
12710
|
head
|
|
12568
12711
|
);
|
|
12569
12712
|
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
@@ -12757,7 +12900,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12757
12900
|
description: "Toggle return type annotation",
|
|
12758
12901
|
apply: pipe(
|
|
12759
12902
|
service(ChangeTracker),
|
|
12760
|
-
|
|
12903
|
+
map5((changeTracker) => removeReturnTypeAnnotation(sourceFile, changeTracker, node))
|
|
12761
12904
|
)
|
|
12762
12905
|
};
|
|
12763
12906
|
}
|
|
@@ -12774,7 +12917,7 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
12774
12917
|
description: "Toggle return type annotation",
|
|
12775
12918
|
apply: pipe(
|
|
12776
12919
|
service(ChangeTracker),
|
|
12777
|
-
|
|
12920
|
+
map5(
|
|
12778
12921
|
(changeTracker) => addReturnTypeAnnotation(sourceFile, changeTracker, node, tsUtils.simplifyTypeNode(returnTypeNode))
|
|
12779
12922
|
)
|
|
12780
12923
|
)
|
|
@@ -13369,16 +13512,17 @@ var wrapWithEffectGen = createRefactor({
|
|
|
13369
13512
|
const findEffectToWrap = fn("wrapWithEffectGen.apply.findEffectToWrap")(
|
|
13370
13513
|
function* (node) {
|
|
13371
13514
|
if (!ts.isExpression(node)) return yield* fail("is not an expression");
|
|
13515
|
+
if (node.parent && ts.isHeritageClause(node.parent)) return yield* fail("is in a heritage clause");
|
|
13372
13516
|
const parent = node.parent;
|
|
13373
13517
|
if (parent != null && ts.isVariableDeclaration(parent) && parent.initializer !== node) return yield* fail("is LHS of variable declaration");
|
|
13374
13518
|
const type = typeChecker.getTypeAtLocation(node);
|
|
13375
|
-
yield* typeParser.
|
|
13519
|
+
yield* typeParser.strictEffectType(type, node);
|
|
13376
13520
|
return node;
|
|
13377
13521
|
}
|
|
13378
13522
|
);
|
|
13379
13523
|
const maybeNode = yield* pipe(
|
|
13380
13524
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
13381
|
-
|
|
13525
|
+
map4(findEffectToWrap),
|
|
13382
13526
|
firstSuccessOf,
|
|
13383
13527
|
option
|
|
13384
13528
|
);
|
|
@@ -13463,19 +13607,19 @@ var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _
|
|
|
13463
13607
|
const parentClass = node.parent;
|
|
13464
13608
|
if (ts.isClassDeclaration(parentClass) && parentClass.name === node) {
|
|
13465
13609
|
const baseIdentifier = yield* pipe(
|
|
13466
|
-
|
|
13467
|
-
orElse2(() =>
|
|
13468
|
-
orElse2(() =>
|
|
13610
|
+
map5(typeParser.extendsContextTag(parentClass), (_) => [_.keyStringLiteral]),
|
|
13611
|
+
orElse2(() => map5(typeParser.extendsEffectService(parentClass), (_) => [_.keyStringLiteral])),
|
|
13612
|
+
orElse2(() => map5(typeParser.extendsEffectTag(parentClass), (_) => [_.keyStringLiteral])),
|
|
13469
13613
|
orElse2(
|
|
13470
|
-
() =>
|
|
13614
|
+
() => map5(typeParser.extendsSchemaTaggedClass(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13471
13615
|
),
|
|
13472
13616
|
orElse2(
|
|
13473
|
-
() =>
|
|
13617
|
+
() => map5(typeParser.extendsSchemaTaggedError(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13474
13618
|
),
|
|
13475
|
-
orElse2(() =>
|
|
13476
|
-
orElse2(() =>
|
|
13619
|
+
orElse2(() => map5(typeParser.extendsDataTaggedError(parentClass), (_) => [_.keyStringLiteral])),
|
|
13620
|
+
orElse2(() => map5(typeParser.extendsDataTaggedClass(parentClass), (_) => [_.keyStringLiteral])),
|
|
13477
13621
|
orElse2(
|
|
13478
|
-
() =>
|
|
13622
|
+
() => map5(
|
|
13479
13623
|
typeParser.extendsSchemaTaggedRequest(parentClass),
|
|
13480
13624
|
(_) => [_.keyStringLiteral, _.tagStringLiteral]
|
|
13481
13625
|
)
|
|
@@ -13620,7 +13764,7 @@ var init = (modules) => {
|
|
|
13620
13764
|
}
|
|
13621
13765
|
return effectCodeFixes;
|
|
13622
13766
|
}),
|
|
13623
|
-
|
|
13767
|
+
flatMap2(
|
|
13624
13768
|
(effectCodeFixes) => pipe(
|
|
13625
13769
|
middlewareAutoImportQuickfixes(
|
|
13626
13770
|
sourceFile,
|
|
@@ -13629,7 +13773,7 @@ var init = (modules) => {
|
|
|
13629
13773
|
preferences,
|
|
13630
13774
|
applicableCodeFixes
|
|
13631
13775
|
),
|
|
13632
|
-
|
|
13776
|
+
map5((modifiedCodeFixes) => effectCodeFixes.concat(modifiedCodeFixes))
|
|
13633
13777
|
)
|
|
13634
13778
|
),
|
|
13635
13779
|
runNano(program),
|
|
@@ -13738,7 +13882,7 @@ var init = (modules) => {
|
|
|
13738
13882
|
if (sourceFile) {
|
|
13739
13883
|
return pipe(
|
|
13740
13884
|
appendEffectCompletionEntryData(sourceFile, applicableCompletions),
|
|
13741
|
-
|
|
13885
|
+
flatMap2(
|
|
13742
13886
|
(augmentedCompletions) => pipe(
|
|
13743
13887
|
getCompletionsAtPosition(
|
|
13744
13888
|
completions,
|
|
@@ -13747,7 +13891,7 @@ var init = (modules) => {
|
|
|
13747
13891
|
options,
|
|
13748
13892
|
formattingSettings
|
|
13749
13893
|
),
|
|
13750
|
-
|
|
13894
|
+
map5(
|
|
13751
13895
|
(effectCompletions) => augmentedCompletions ? {
|
|
13752
13896
|
...augmentedCompletions,
|
|
13753
13897
|
entries: effectCompletions.concat(augmentedCompletions.entries)
|
|
@@ -13881,7 +14025,7 @@ var init = (modules) => {
|
|
|
13881
14025
|
if (sourceFile) {
|
|
13882
14026
|
return pipe(
|
|
13883
14027
|
effectApiGetLayerGraph(sourceFile, line, character),
|
|
13884
|
-
|
|
14028
|
+
map5((response) => ({
|
|
13885
14029
|
response: {
|
|
13886
14030
|
success: true,
|
|
13887
14031
|
...response
|