@effect/language-service 0.24.2 → 0.25.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 +2 -0
- package/cli.js +2712 -889
- package/cli.js.map +1 -1
- package/index.js +575 -318
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +399 -186
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -56,9 +56,9 @@ var dual = function(arity, body) {
|
|
|
56
56
|
if (arguments.length >= arity) {
|
|
57
57
|
return body.apply(this, arguments);
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const args2 = arguments;
|
|
60
60
|
return function(self) {
|
|
61
|
-
return body(self, ...
|
|
61
|
+
return body(self, ...args2);
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -144,7 +144,6 @@ var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue
|
|
|
144
144
|
|
|
145
145
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Utils.js
|
|
146
146
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
147
|
-
var isGenKind = (u) => isObject(u) && GenKindTypeId in u;
|
|
148
147
|
var GenKindImpl = class {
|
|
149
148
|
value;
|
|
150
149
|
constructor(value) {
|
|
@@ -477,32 +476,32 @@ var redact = (u) => {
|
|
|
477
476
|
};
|
|
478
477
|
|
|
479
478
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Pipeable.js
|
|
480
|
-
var pipeArguments = (self,
|
|
481
|
-
switch (
|
|
479
|
+
var pipeArguments = (self, args2) => {
|
|
480
|
+
switch (args2.length) {
|
|
482
481
|
case 0:
|
|
483
482
|
return self;
|
|
484
483
|
case 1:
|
|
485
|
-
return
|
|
484
|
+
return args2[0](self);
|
|
486
485
|
case 2:
|
|
487
|
-
return
|
|
486
|
+
return args2[1](args2[0](self));
|
|
488
487
|
case 3:
|
|
489
|
-
return
|
|
488
|
+
return args2[2](args2[1](args2[0](self)));
|
|
490
489
|
case 4:
|
|
491
|
-
return
|
|
490
|
+
return args2[3](args2[2](args2[1](args2[0](self))));
|
|
492
491
|
case 5:
|
|
493
|
-
return
|
|
492
|
+
return args2[4](args2[3](args2[2](args2[1](args2[0](self)))));
|
|
494
493
|
case 6:
|
|
495
|
-
return
|
|
494
|
+
return args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))));
|
|
496
495
|
case 7:
|
|
497
|
-
return
|
|
496
|
+
return args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))));
|
|
498
497
|
case 8:
|
|
499
|
-
return
|
|
498
|
+
return args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))))));
|
|
500
499
|
case 9:
|
|
501
|
-
return
|
|
500
|
+
return args2[8](args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))))));
|
|
502
501
|
default: {
|
|
503
502
|
let ret = self;
|
|
504
|
-
for (let i = 0, len =
|
|
505
|
-
ret =
|
|
503
|
+
for (let i = 0, len = args2.length; i < len; i++) {
|
|
504
|
+
ret = args2[i](ret);
|
|
506
505
|
}
|
|
507
506
|
return ret;
|
|
508
507
|
}
|
|
@@ -834,181 +833,278 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
|
834
833
|
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
835
834
|
|
|
836
835
|
// src/core/Nano.ts
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
836
|
+
var NanoTag = class {
|
|
837
|
+
constructor(key) {
|
|
838
|
+
this.key = key;
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
var Tag = (identifier) => new NanoTag(identifier);
|
|
842
|
+
var evaluate = Symbol.for("Nano.evaluate");
|
|
843
|
+
var contA = Symbol.for("Nano.contA");
|
|
844
|
+
var contE = Symbol.for("Nano.contE");
|
|
845
|
+
var contAll = Symbol.for("Nano.contAll");
|
|
846
|
+
var NanoYield = Symbol.for("Nano.yield");
|
|
847
|
+
var args = Symbol.for("Nano.args");
|
|
843
848
|
var NanoDefectException = class {
|
|
844
849
|
constructor(message) {
|
|
845
850
|
this.message = message;
|
|
846
851
|
}
|
|
847
852
|
_tag = "@effect/language-service/NanoDefectException";
|
|
848
853
|
};
|
|
849
|
-
var
|
|
850
|
-
|
|
851
|
-
|
|
854
|
+
var PrimitiveProto = {
|
|
855
|
+
[Symbol.iterator]() {
|
|
856
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
852
857
|
}
|
|
853
858
|
};
|
|
854
|
-
var
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
859
|
+
var SucceedProto = {
|
|
860
|
+
...PrimitiveProto,
|
|
861
|
+
_tag: "Success",
|
|
862
|
+
get value() {
|
|
863
|
+
return this[args];
|
|
864
|
+
},
|
|
865
|
+
[evaluate](fiber) {
|
|
866
|
+
const cont = fiber.getCont(contA);
|
|
867
|
+
return cont ? cont[contA](this[args], fiber) : fiber.yieldWith(this);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
var succeed = (value) => {
|
|
871
|
+
const nano = Object.create(SucceedProto);
|
|
872
|
+
nano[args] = value;
|
|
863
873
|
return nano;
|
|
864
|
-
}
|
|
865
|
-
var
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
874
|
+
};
|
|
875
|
+
var FailureProto = {
|
|
876
|
+
...PrimitiveProto,
|
|
877
|
+
_tag: "Failure",
|
|
878
|
+
get value() {
|
|
879
|
+
return this[args];
|
|
880
|
+
},
|
|
881
|
+
[evaluate](fiber) {
|
|
882
|
+
const cont = fiber.getCont(contE);
|
|
883
|
+
return cont ? cont[contE](this[args], fiber) : fiber.yieldWith(this);
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
var fail = (error) => {
|
|
887
|
+
const nano = Object.create(FailureProto);
|
|
888
|
+
nano[args] = error;
|
|
889
|
+
return nano;
|
|
890
|
+
};
|
|
891
|
+
var SuspendProto = {
|
|
892
|
+
...PrimitiveProto,
|
|
893
|
+
[evaluate]() {
|
|
894
|
+
return this[args]();
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
var suspend = (fn2) => {
|
|
898
|
+
const nano = Object.create(SuspendProto);
|
|
899
|
+
nano[args] = fn2;
|
|
900
|
+
return nano;
|
|
901
|
+
};
|
|
902
|
+
var NanoFiber = class {
|
|
903
|
+
_stack = [];
|
|
904
|
+
_yielded = void 0;
|
|
905
|
+
_services = {};
|
|
906
|
+
_cache = {};
|
|
907
|
+
runLoop(nano) {
|
|
908
|
+
let current = nano;
|
|
909
|
+
while (true) {
|
|
910
|
+
current = current[evaluate](this);
|
|
911
|
+
if (current === NanoYield) {
|
|
912
|
+
return this._yielded;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
getCont(symbol3) {
|
|
917
|
+
while (true) {
|
|
918
|
+
const op = this._stack.pop();
|
|
919
|
+
if (!op) return void 0;
|
|
920
|
+
const cont = op[contAll] && op[contAll](this);
|
|
921
|
+
if (cont) return { [symbol3]: cont };
|
|
922
|
+
if (op[symbol3]) return op;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
yieldWith(value) {
|
|
926
|
+
this._yielded = value;
|
|
927
|
+
return NanoYield;
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
var unsafeRun = (nano) => {
|
|
931
|
+
const fiber = new NanoFiber();
|
|
932
|
+
const result = fiber.runLoop(nano);
|
|
933
|
+
if (result._tag === "Success") {
|
|
934
|
+
return right2(result.value);
|
|
935
|
+
}
|
|
936
|
+
return left2(result.value);
|
|
937
|
+
};
|
|
938
|
+
var run = (nano) => {
|
|
878
939
|
try {
|
|
879
|
-
return unsafeRun(
|
|
940
|
+
return unsafeRun(nano);
|
|
880
941
|
} catch (e) {
|
|
881
942
|
return left2(new NanoDefectException(e));
|
|
882
943
|
}
|
|
883
944
|
};
|
|
884
|
-
var
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
945
|
+
var OnSuccessProto = {
|
|
946
|
+
...PrimitiveProto,
|
|
947
|
+
[evaluate](fiber) {
|
|
948
|
+
fiber._stack.push(this);
|
|
949
|
+
return this[args];
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
var flatMap2 = dual(2, (fa, f) => {
|
|
953
|
+
const nano = Object.create(OnSuccessProto);
|
|
954
|
+
nano[args] = fa;
|
|
955
|
+
nano[contA] = f;
|
|
956
|
+
return nano;
|
|
957
|
+
});
|
|
958
|
+
var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
|
|
959
|
+
var SyncProto = {
|
|
960
|
+
...PrimitiveProto,
|
|
961
|
+
[evaluate](fiber) {
|
|
962
|
+
const value = this[args]();
|
|
963
|
+
const cont = fiber.getCont(contA);
|
|
964
|
+
return cont ? cont[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
var sync = (f) => {
|
|
968
|
+
const nano = Object.create(SyncProto);
|
|
969
|
+
nano[args] = f;
|
|
891
970
|
return nano;
|
|
892
971
|
};
|
|
893
|
-
var
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
972
|
+
var void_ = succeed(void 0);
|
|
973
|
+
var FromIteratorProto = {
|
|
974
|
+
...PrimitiveProto,
|
|
975
|
+
[contA](value, fiber) {
|
|
976
|
+
const state = this[args][0].next(value);
|
|
977
|
+
if (state.done) return succeed(state.value);
|
|
978
|
+
fiber._stack.push(this);
|
|
979
|
+
return yieldWrapGet(state.value);
|
|
980
|
+
},
|
|
981
|
+
[evaluate](fiber) {
|
|
982
|
+
return this[contA](this[args][1], fiber);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
var unsafeFromIterator = (iterator, initial) => {
|
|
986
|
+
const nano = Object.create(FromIteratorProto);
|
|
987
|
+
nano[args] = [iterator, initial];
|
|
900
988
|
return nano;
|
|
901
989
|
};
|
|
902
|
-
var
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
990
|
+
var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
|
|
991
|
+
var fn = (_) => (body) => (...args2) => suspend(() => unsafeFromIterator(body(...args2)));
|
|
992
|
+
var MatchProto = {
|
|
993
|
+
...PrimitiveProto,
|
|
994
|
+
[evaluate](fiber) {
|
|
995
|
+
fiber._stack.push(this);
|
|
996
|
+
return this[args];
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
var match2 = (fa, opts) => {
|
|
1000
|
+
const nano = Object.create(MatchProto);
|
|
1001
|
+
nano[args] = fa;
|
|
1002
|
+
nano[contA] = opts.onSuccess;
|
|
1003
|
+
nano[contE] = opts.onFailure;
|
|
1004
|
+
return nano;
|
|
1005
|
+
};
|
|
1006
|
+
var orElse2 = (f) => (fa) => {
|
|
1007
|
+
const nano = Object.create(MatchProto);
|
|
1008
|
+
nano[args] = fa;
|
|
1009
|
+
nano[contE] = f;
|
|
909
1010
|
return nano;
|
|
910
1011
|
};
|
|
911
|
-
var flatMap2 = dual(2, (fa, f) => make3((ctx) => {
|
|
912
|
-
const result = fa.run(ctx);
|
|
913
|
-
if (result._tag !== "Right") return result;
|
|
914
|
-
return f(result.value).run(ctx);
|
|
915
|
-
}));
|
|
916
|
-
var map4 = dual(2, (fa, f) => make3((ctx) => {
|
|
917
|
-
const result = fa.run(ctx);
|
|
918
|
-
if (result._tag !== "Right") return result;
|
|
919
|
-
return makeInternalSuccess(f(result.value));
|
|
920
|
-
}));
|
|
921
|
-
var orElse2 = (f) => (fa) => make3((ctx) => {
|
|
922
|
-
const result = fa.run(ctx);
|
|
923
|
-
if (result._tag === "Left") return f(result.value).run(ctx);
|
|
924
|
-
return result;
|
|
925
|
-
});
|
|
926
1012
|
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
|
|
927
|
-
var
|
|
928
|
-
|
|
929
|
-
)
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return result;
|
|
947
|
-
}
|
|
948
|
-
state = iterator.next(result.value);
|
|
1013
|
+
var ProvideServiceProto = {
|
|
1014
|
+
...PrimitiveProto,
|
|
1015
|
+
[evaluate](fiber) {
|
|
1016
|
+
const prevServices = fiber._services;
|
|
1017
|
+
const [fa, tag, value] = this[args];
|
|
1018
|
+
fiber._services = {
|
|
1019
|
+
...fiber._services,
|
|
1020
|
+
[tag.key]: value
|
|
1021
|
+
};
|
|
1022
|
+
return match2(fa, {
|
|
1023
|
+
onSuccess: (_) => {
|
|
1024
|
+
fiber._services = prevServices;
|
|
1025
|
+
return succeed(_);
|
|
1026
|
+
},
|
|
1027
|
+
onFailure: (_) => {
|
|
1028
|
+
fiber._services = prevServices;
|
|
1029
|
+
return fail(_);
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
949
1032
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1033
|
+
};
|
|
1034
|
+
var provideService = (tag, value) => (fa) => {
|
|
1035
|
+
const nano = Object.create(ProvideServiceProto);
|
|
1036
|
+
nano[args] = [fa, tag, value];
|
|
1037
|
+
return nano;
|
|
1038
|
+
};
|
|
1039
|
+
var ServiceProto = {
|
|
1040
|
+
...PrimitiveProto,
|
|
1041
|
+
[evaluate](fiber) {
|
|
1042
|
+
const tag = this[args];
|
|
1043
|
+
if (tag.key in fiber._services) {
|
|
1044
|
+
const value = fiber._services[tag.key];
|
|
1045
|
+
const cont2 = fiber.getCont(contA);
|
|
1046
|
+
return cont2 ? cont2[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
960
1047
|
}
|
|
961
|
-
|
|
1048
|
+
const cont = fiber.getCont(contE);
|
|
1049
|
+
return cont ? cont[contE](tag, fiber) : fiber.yieldWith(fail(new NanoDefectException(`Service ${tag.key} not found`)));
|
|
962
1050
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1051
|
+
};
|
|
1052
|
+
var service = (tag) => {
|
|
1053
|
+
const nano = Object.create(ServiceProto);
|
|
1054
|
+
nano[args] = tag;
|
|
1055
|
+
return nano;
|
|
1056
|
+
};
|
|
1057
|
+
var CachedProto = {
|
|
1058
|
+
...PrimitiveProto,
|
|
1059
|
+
[evaluate](fiber) {
|
|
1060
|
+
const [fa, type, key] = this[args];
|
|
1061
|
+
const cache = fiber._cache[type] || /* @__PURE__ */ new WeakMap();
|
|
1062
|
+
fiber._cache[type] = cache;
|
|
1063
|
+
const cached2 = cache.get(key);
|
|
1064
|
+
if (cached2) return cached2;
|
|
1065
|
+
return match2(fa, {
|
|
1066
|
+
onSuccess: (_) => {
|
|
1067
|
+
cache.set(key, succeed(_));
|
|
1068
|
+
return succeed(_);
|
|
1069
|
+
},
|
|
1070
|
+
onFailure: (_) => {
|
|
1071
|
+
cache.set(key, fail(_));
|
|
1072
|
+
return fail(_);
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
974
1075
|
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
}
|
|
982
|
-
var all = (...args) => make3((ctx) => {
|
|
983
|
-
const results = [];
|
|
984
|
-
for (const arg of args) {
|
|
985
|
-
const result = arg.run(ctx);
|
|
986
|
-
if (result._tag !== "Right") return result;
|
|
987
|
-
results.push(result.value);
|
|
988
|
-
}
|
|
989
|
-
return makeInternalSuccess(results);
|
|
990
|
-
});
|
|
991
|
-
var internalNanoCache = Tag(
|
|
992
|
-
"@effect/language-service/internalNanoCache"
|
|
993
|
-
);
|
|
994
|
-
function cachedBy(fa, key, lookupKey) {
|
|
995
|
-
return (...args) => make3((ctx) => {
|
|
996
|
-
const cacheObj = ctx.value[internalNanoCache.key];
|
|
997
|
-
let cache = cacheObj[key];
|
|
998
|
-
if (!cache) {
|
|
999
|
-
cache = /* @__PURE__ */ new Map();
|
|
1000
|
-
cacheObj[key] = cache;
|
|
1001
|
-
}
|
|
1002
|
-
const lookup = lookupKey(...args);
|
|
1003
|
-
const cached2 = cache.get(lookup);
|
|
1004
|
-
if (cached2 !== void 0) {
|
|
1005
|
-
return cached2;
|
|
1006
|
-
}
|
|
1007
|
-
const result = fa(...args).run(ctx);
|
|
1008
|
-
cache.set(lookup, result);
|
|
1009
|
-
return result;
|
|
1010
|
-
});
|
|
1076
|
+
};
|
|
1077
|
+
function cachedBy(fa, type, lookupKey) {
|
|
1078
|
+
return (...p) => {
|
|
1079
|
+
const nano = Object.create(CachedProto);
|
|
1080
|
+
nano[args] = [fa(...p), type, lookupKey(...p)];
|
|
1081
|
+
return nano;
|
|
1082
|
+
};
|
|
1011
1083
|
}
|
|
1084
|
+
var option = (fa) => {
|
|
1085
|
+
const nano = Object.create(MatchProto);
|
|
1086
|
+
nano[args] = fa;
|
|
1087
|
+
nano[contA] = (_) => succeed(some2(_));
|
|
1088
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(none2());
|
|
1089
|
+
return nano;
|
|
1090
|
+
};
|
|
1091
|
+
var ignore = (fa) => {
|
|
1092
|
+
const nano = Object.create(MatchProto);
|
|
1093
|
+
nano[args] = fa;
|
|
1094
|
+
nano[contA] = (_) => void_;
|
|
1095
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : void_;
|
|
1096
|
+
return nano;
|
|
1097
|
+
};
|
|
1098
|
+
var all = fn("all")(
|
|
1099
|
+
function* (...args2) {
|
|
1100
|
+
const results = [];
|
|
1101
|
+
for (const fa of args2) {
|
|
1102
|
+
const result = yield* fa;
|
|
1103
|
+
results.push(result);
|
|
1104
|
+
}
|
|
1105
|
+
return results;
|
|
1106
|
+
}
|
|
1107
|
+
);
|
|
1012
1108
|
|
|
1013
1109
|
// src/core/TypeScriptApi.ts
|
|
1014
1110
|
var TypeScriptApi = Tag("TypeScriptApi");
|
|
@@ -1568,10 +1664,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1568
1664
|
const sectionOverrides = {};
|
|
1569
1665
|
const skippedRules = [];
|
|
1570
1666
|
const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]+:(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
|
|
1571
|
-
let
|
|
1572
|
-
while ((
|
|
1573
|
-
const nextLineCaptureGroup =
|
|
1574
|
-
const rulesCaptureGroup =
|
|
1667
|
+
let match3;
|
|
1668
|
+
while ((match3 = regex.exec(sourceFile.text)) !== null) {
|
|
1669
|
+
const nextLineCaptureGroup = match3[1];
|
|
1670
|
+
const rulesCaptureGroup = match3[2];
|
|
1575
1671
|
if (rulesCaptureGroup) {
|
|
1576
1672
|
const trimmedRuleString = rulesCaptureGroup.trim();
|
|
1577
1673
|
if (trimmedRuleString) {
|
|
@@ -1583,7 +1679,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1583
1679
|
if (ruleLevel === "skip-file") skippedRules.push(ruleName);
|
|
1584
1680
|
const isOverrideNextLine = nextLineCaptureGroup && nextLineCaptureGroup.trim().toLowerCase() === "-next-line";
|
|
1585
1681
|
if (isOverrideNextLine) {
|
|
1586
|
-
const node = findNodeWithLeadingCommentAtPosition(
|
|
1682
|
+
const node = findNodeWithLeadingCommentAtPosition(match3.index);
|
|
1587
1683
|
if (node) {
|
|
1588
1684
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1589
1685
|
lineOverrides[ruleName].unshift({
|
|
@@ -1595,7 +1691,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1595
1691
|
} else {
|
|
1596
1692
|
sectionOverrides[ruleName] = sectionOverrides[ruleName] || [];
|
|
1597
1693
|
sectionOverrides[ruleName].unshift({
|
|
1598
|
-
pos:
|
|
1694
|
+
pos: match3.index,
|
|
1599
1695
|
level: ruleLevel
|
|
1600
1696
|
});
|
|
1601
1697
|
}
|
|
@@ -1725,93 +1821,6 @@ var contextSelfInClasses = createCompletion({
|
|
|
1725
1821
|
})
|
|
1726
1822
|
});
|
|
1727
1823
|
|
|
1728
|
-
// src/completions/effectDataClasses.ts
|
|
1729
|
-
var effectDataClasses = createCompletion({
|
|
1730
|
-
name: "effectDataClasses",
|
|
1731
|
-
apply: fn("effectDataClasses")(function* (sourceFile, position) {
|
|
1732
|
-
const ts = yield* service(TypeScriptApi);
|
|
1733
|
-
const maybeInfos = yield* option(
|
|
1734
|
-
parseDataForExtendsClassCompletion(sourceFile, position)
|
|
1735
|
-
);
|
|
1736
|
-
if (isNone2(maybeInfos)) return [];
|
|
1737
|
-
const { accessedObject, className, replacementSpan } = maybeInfos.value;
|
|
1738
|
-
const dataName = yield* option(
|
|
1739
|
-
findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
1740
|
-
sourceFile,
|
|
1741
|
-
"effect",
|
|
1742
|
-
"Data"
|
|
1743
|
-
)
|
|
1744
|
-
);
|
|
1745
|
-
const effectDataIdentifier = match(dataName, {
|
|
1746
|
-
onNone: () => "Data",
|
|
1747
|
-
onSome: (_) => _.text
|
|
1748
|
-
});
|
|
1749
|
-
if (effectDataIdentifier !== accessedObject.text) return [];
|
|
1750
|
-
const name = className.text;
|
|
1751
|
-
return [{
|
|
1752
|
-
name: `TaggedError("${name}")`,
|
|
1753
|
-
kind: ts.ScriptElementKind.constElement,
|
|
1754
|
-
insertText: `${effectDataIdentifier}.TaggedError("${name}")<{${"${0}"}}>{}`,
|
|
1755
|
-
replacementSpan,
|
|
1756
|
-
isSnippet: true
|
|
1757
|
-
}, {
|
|
1758
|
-
name: `TaggedClass("${name}")`,
|
|
1759
|
-
kind: ts.ScriptElementKind.constElement,
|
|
1760
|
-
insertText: `${effectDataIdentifier}.TaggedClass("${name}")<{${"${0}"}}>{}`,
|
|
1761
|
-
replacementSpan,
|
|
1762
|
-
isSnippet: true
|
|
1763
|
-
}];
|
|
1764
|
-
})
|
|
1765
|
-
});
|
|
1766
|
-
|
|
1767
|
-
// src/diagnostics/duplicatePackage.ts
|
|
1768
|
-
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
1769
|
-
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
1770
|
-
var duplicatePackage = createDiagnostic({
|
|
1771
|
-
name: "duplicatePackage",
|
|
1772
|
-
code: 6,
|
|
1773
|
-
severity: "warning",
|
|
1774
|
-
apply: fn("duplicatePackage.apply")(function* (sourceFile, report) {
|
|
1775
|
-
const program = yield* service(TypeScriptProgram);
|
|
1776
|
-
const options = yield* service(LanguageServicePluginOptions);
|
|
1777
|
-
if (sourceFile.statements.length < 1) return;
|
|
1778
|
-
let resolvedPackages = checkedPackagesCache.get(sourceFile.fileName) || {};
|
|
1779
|
-
const newResolvedModuleSize = hasProperty(program, "resolvedModules") && hasProperty(program.resolvedModules, "size") && isNumber(program.resolvedModules.size) ? program.resolvedModules.size : 0;
|
|
1780
|
-
const oldResolvedSize = programResolvedCacheSize.get(sourceFile.fileName) || -1;
|
|
1781
|
-
if (newResolvedModuleSize !== oldResolvedSize) {
|
|
1782
|
-
const seenPackages = /* @__PURE__ */ new Set();
|
|
1783
|
-
resolvedPackages = {};
|
|
1784
|
-
program.getSourceFiles().map((_) => {
|
|
1785
|
-
const packageInfo = parsePackageContentNameAndVersionFromScope(_);
|
|
1786
|
-
if (!packageInfo) return;
|
|
1787
|
-
const packageNameAndVersion = packageInfo.name + "@" + packageInfo.version;
|
|
1788
|
-
if (seenPackages.has(packageNameAndVersion)) return;
|
|
1789
|
-
seenPackages.add(packageNameAndVersion);
|
|
1790
|
-
if (!(packageInfo.name === "effect" || packageInfo.hasEffectInPeerDependencies)) return;
|
|
1791
|
-
if (options.allowedDuplicatedPackages.indexOf(packageInfo.name) > -1) return;
|
|
1792
|
-
resolvedPackages[packageInfo.name] = resolvedPackages[packageInfo.name] || {};
|
|
1793
|
-
resolvedPackages[packageInfo.name][packageInfo.version] = packageInfo.packageDirectory;
|
|
1794
|
-
});
|
|
1795
|
-
checkedPackagesCache.set(sourceFile.fileName, resolvedPackages);
|
|
1796
|
-
programResolvedCacheSize.set(sourceFile.fileName, newResolvedModuleSize);
|
|
1797
|
-
}
|
|
1798
|
-
for (const packageName of Object.keys(resolvedPackages)) {
|
|
1799
|
-
if (Object.keys(resolvedPackages[packageName]).length > 1) {
|
|
1800
|
-
const versions = Object.keys(resolvedPackages[packageName]);
|
|
1801
|
-
report({
|
|
1802
|
-
node: sourceFile.statements[0],
|
|
1803
|
-
messageText: `Package ${packageName} is referenced multiple times with different versions (${versions.join(", ")}) and may cause unexpected type errors.
|
|
1804
|
-
Cleanup your dependencies and your package lockfile to avoid multiple instances of this package and reload the project.
|
|
1805
|
-
If this is intended set the LSP config "allowedDuplicatedPackages" to ${JSON.stringify(options.allowedDuplicatedPackages.concat([packageName]))}.
|
|
1806
|
-
|
|
1807
|
-
${versions.map((version) => `- found ${version} at ${resolvedPackages[packageName][version]}`).join("\n")}`,
|
|
1808
|
-
fixes: []
|
|
1809
|
-
});
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
})
|
|
1813
|
-
});
|
|
1814
|
-
|
|
1815
1824
|
// src/core/TypeCheckerApi.ts
|
|
1816
1825
|
var TypeCheckerApi = Tag("TypeChecker");
|
|
1817
1826
|
var TypeCheckerApiCache = Tag("TypeCheckerApiCache");
|
|
@@ -2018,11 +2027,23 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
|
|
|
2018
2027
|
cache.expectedAndRealType.set(sourceFile, result);
|
|
2019
2028
|
return result;
|
|
2020
2029
|
});
|
|
2030
|
+
var unrollUnionMembers = (type) => {
|
|
2031
|
+
const result = [];
|
|
2032
|
+
let toTest = [type];
|
|
2033
|
+
while (toTest.length > 0) {
|
|
2034
|
+
const type2 = toTest.pop();
|
|
2035
|
+
if (type2.isUnion()) {
|
|
2036
|
+
toTest = toTest.concat(type2.types);
|
|
2037
|
+
} else {
|
|
2038
|
+
result.push(type2);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
return result;
|
|
2042
|
+
};
|
|
2021
2043
|
var appendToUniqueTypesMap = fn(
|
|
2022
2044
|
"TypeCheckerApi.appendToUniqueTypesMap"
|
|
2023
2045
|
)(
|
|
2024
|
-
function* (memory, initialType,
|
|
2025
|
-
const ts = yield* service(TypeScriptApi);
|
|
2046
|
+
function* (memory, initialType, shouldExclude) {
|
|
2026
2047
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2027
2048
|
const newIndexes = /* @__PURE__ */ new Set();
|
|
2028
2049
|
const knownIndexes = /* @__PURE__ */ new Set();
|
|
@@ -2030,7 +2051,7 @@ var appendToUniqueTypesMap = fn(
|
|
|
2030
2051
|
while (toTest.length > 0) {
|
|
2031
2052
|
const type = toTest.pop();
|
|
2032
2053
|
if (!type) break;
|
|
2033
|
-
if (
|
|
2054
|
+
if (yield* shouldExclude(type)) {
|
|
2034
2055
|
continue;
|
|
2035
2056
|
}
|
|
2036
2057
|
if (type.isUnion()) {
|
|
@@ -2073,16 +2094,145 @@ function makeResolveExternalModuleName(typeChecker) {
|
|
|
2073
2094
|
};
|
|
2074
2095
|
}
|
|
2075
2096
|
|
|
2097
|
+
// src/completions/durationInput.ts
|
|
2098
|
+
var durationInput = createCompletion({
|
|
2099
|
+
name: "durationInput",
|
|
2100
|
+
apply: fn("durationInput")(function* (sourceFile, position) {
|
|
2101
|
+
const ts = yield* service(TypeScriptApi);
|
|
2102
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
2103
|
+
let isInString = false;
|
|
2104
|
+
const previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
2105
|
+
if (previousToken && ts.isStringTextContainingNode(previousToken)) {
|
|
2106
|
+
const start = previousToken.getStart(sourceFile);
|
|
2107
|
+
const end = previousToken.getEnd();
|
|
2108
|
+
if (start < position && position < end) {
|
|
2109
|
+
isInString = true;
|
|
2110
|
+
}
|
|
2111
|
+
if (position === end) {
|
|
2112
|
+
isInString = !!previousToken.isUnterminated;
|
|
2113
|
+
}
|
|
2114
|
+
if (isInString && ts.isExpression(previousToken)) {
|
|
2115
|
+
const type = typeChecker.getContextualType(previousToken);
|
|
2116
|
+
if (type) {
|
|
2117
|
+
if (!type.isUnion()) return [];
|
|
2118
|
+
for (const member of type.types) {
|
|
2119
|
+
if (member.flags & ts.TypeFlags.TemplateLiteral) {
|
|
2120
|
+
if (hasProperty(member, "texts") && isArray(member.texts) && member.texts.length === 2 && String(member.texts[1]).trim() === "nanos") {
|
|
2121
|
+
return ["nanos", "micros", "millis", "seconds", "minutes", "hours", "days", "weeks"].map(
|
|
2122
|
+
(name) => ({
|
|
2123
|
+
name,
|
|
2124
|
+
kind: ts.ScriptElementKind.string,
|
|
2125
|
+
insertText: `${"${0}"} ${name}`,
|
|
2126
|
+
isSnippet: true
|
|
2127
|
+
})
|
|
2128
|
+
);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
return [];
|
|
2136
|
+
})
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
// src/completions/effectDataClasses.ts
|
|
2140
|
+
var effectDataClasses = createCompletion({
|
|
2141
|
+
name: "effectDataClasses",
|
|
2142
|
+
apply: fn("effectDataClasses")(function* (sourceFile, position) {
|
|
2143
|
+
const ts = yield* service(TypeScriptApi);
|
|
2144
|
+
const maybeInfos = yield* option(
|
|
2145
|
+
parseDataForExtendsClassCompletion(sourceFile, position)
|
|
2146
|
+
);
|
|
2147
|
+
if (isNone2(maybeInfos)) return [];
|
|
2148
|
+
const { accessedObject, className, replacementSpan } = maybeInfos.value;
|
|
2149
|
+
const dataName = yield* option(
|
|
2150
|
+
findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
2151
|
+
sourceFile,
|
|
2152
|
+
"effect",
|
|
2153
|
+
"Data"
|
|
2154
|
+
)
|
|
2155
|
+
);
|
|
2156
|
+
const effectDataIdentifier = match(dataName, {
|
|
2157
|
+
onNone: () => "Data",
|
|
2158
|
+
onSome: (_) => _.text
|
|
2159
|
+
});
|
|
2160
|
+
if (effectDataIdentifier !== accessedObject.text) return [];
|
|
2161
|
+
const name = className.text;
|
|
2162
|
+
return [{
|
|
2163
|
+
name: `TaggedError("${name}")`,
|
|
2164
|
+
kind: ts.ScriptElementKind.constElement,
|
|
2165
|
+
insertText: `${effectDataIdentifier}.TaggedError("${name}")<{${"${0}"}}>{}`,
|
|
2166
|
+
replacementSpan,
|
|
2167
|
+
isSnippet: true
|
|
2168
|
+
}, {
|
|
2169
|
+
name: `TaggedClass("${name}")`,
|
|
2170
|
+
kind: ts.ScriptElementKind.constElement,
|
|
2171
|
+
insertText: `${effectDataIdentifier}.TaggedClass("${name}")<{${"${0}"}}>{}`,
|
|
2172
|
+
replacementSpan,
|
|
2173
|
+
isSnippet: true
|
|
2174
|
+
}];
|
|
2175
|
+
})
|
|
2176
|
+
});
|
|
2177
|
+
|
|
2178
|
+
// src/diagnostics/duplicatePackage.ts
|
|
2179
|
+
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
2180
|
+
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
2181
|
+
var duplicatePackage = createDiagnostic({
|
|
2182
|
+
name: "duplicatePackage",
|
|
2183
|
+
code: 6,
|
|
2184
|
+
severity: "warning",
|
|
2185
|
+
apply: fn("duplicatePackage.apply")(function* (sourceFile, report) {
|
|
2186
|
+
const program = yield* service(TypeScriptProgram);
|
|
2187
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
2188
|
+
if (sourceFile.statements.length < 1) return;
|
|
2189
|
+
let resolvedPackages = checkedPackagesCache.get(sourceFile.fileName) || {};
|
|
2190
|
+
const newResolvedModuleSize = hasProperty(program, "resolvedModules") && hasProperty(program.resolvedModules, "size") && isNumber(program.resolvedModules.size) ? program.resolvedModules.size : 0;
|
|
2191
|
+
const oldResolvedSize = programResolvedCacheSize.get(sourceFile.fileName) || -1;
|
|
2192
|
+
if (newResolvedModuleSize !== oldResolvedSize) {
|
|
2193
|
+
const seenPackages = /* @__PURE__ */ new Set();
|
|
2194
|
+
resolvedPackages = {};
|
|
2195
|
+
program.getSourceFiles().map((_) => {
|
|
2196
|
+
const packageInfo = parsePackageContentNameAndVersionFromScope(_);
|
|
2197
|
+
if (!packageInfo) return;
|
|
2198
|
+
const packageNameAndVersion = packageInfo.name + "@" + packageInfo.version;
|
|
2199
|
+
if (seenPackages.has(packageNameAndVersion)) return;
|
|
2200
|
+
seenPackages.add(packageNameAndVersion);
|
|
2201
|
+
if (!(packageInfo.name === "effect" || packageInfo.hasEffectInPeerDependencies)) return;
|
|
2202
|
+
if (options.allowedDuplicatedPackages.indexOf(packageInfo.name) > -1) return;
|
|
2203
|
+
resolvedPackages[packageInfo.name] = resolvedPackages[packageInfo.name] || {};
|
|
2204
|
+
resolvedPackages[packageInfo.name][packageInfo.version] = packageInfo.packageDirectory;
|
|
2205
|
+
});
|
|
2206
|
+
checkedPackagesCache.set(sourceFile.fileName, resolvedPackages);
|
|
2207
|
+
programResolvedCacheSize.set(sourceFile.fileName, newResolvedModuleSize);
|
|
2208
|
+
}
|
|
2209
|
+
for (const packageName of Object.keys(resolvedPackages)) {
|
|
2210
|
+
if (Object.keys(resolvedPackages[packageName]).length > 1) {
|
|
2211
|
+
const versions = Object.keys(resolvedPackages[packageName]);
|
|
2212
|
+
report({
|
|
2213
|
+
node: sourceFile.statements[0],
|
|
2214
|
+
messageText: `Package ${packageName} is referenced multiple times with different versions (${versions.join(", ")}) and may cause unexpected type errors.
|
|
2215
|
+
Cleanup your dependencies and your package lockfile to avoid multiple instances of this package and reload the project.
|
|
2216
|
+
If this is intended set the LSP config "allowedDuplicatedPackages" to ${JSON.stringify(options.allowedDuplicatedPackages.concat([packageName]))}.
|
|
2217
|
+
|
|
2218
|
+
${versions.map((version) => `- found ${version} at ${resolvedPackages[packageName][version]}`).join("\n")}`,
|
|
2219
|
+
fixes: []
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
})
|
|
2224
|
+
});
|
|
2225
|
+
|
|
2076
2226
|
// src/core/TypeParser.ts
|
|
2077
2227
|
var TypeParser = Tag("@effect/language-service/TypeParser");
|
|
2078
2228
|
var TypeParserIssue = class _TypeParserIssue {
|
|
2079
2229
|
_tag = "@effect/language-service/TypeParserIssue";
|
|
2080
2230
|
static issue = fail(new _TypeParserIssue());
|
|
2081
2231
|
};
|
|
2082
|
-
function
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2232
|
+
function typeParserIssue(_message, _type, _node) {
|
|
2233
|
+
return TypeParserIssue.issue;
|
|
2234
|
+
}
|
|
2235
|
+
function make3(ts, typeChecker) {
|
|
2086
2236
|
function covariantTypeArgument(type) {
|
|
2087
2237
|
const signatures = type.getCallSignatures();
|
|
2088
2238
|
if (signatures.length !== 1) {
|
|
@@ -2527,8 +2677,8 @@ function make4(ts, typeChecker) {
|
|
|
2527
2677
|
return succeed({ node, subject: node.expression.expression, args: Array.from(node.arguments) });
|
|
2528
2678
|
}
|
|
2529
2679
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
|
|
2530
|
-
const [subject, ...
|
|
2531
|
-
return succeed({ node, subject, args });
|
|
2680
|
+
const [subject, ...args2] = node.arguments;
|
|
2681
|
+
return succeed({ node, subject, args: args2 });
|
|
2532
2682
|
}
|
|
2533
2683
|
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
2534
2684
|
},
|
|
@@ -2572,6 +2722,53 @@ function make4(ts, typeChecker) {
|
|
|
2572
2722
|
};
|
|
2573
2723
|
}
|
|
2574
2724
|
|
|
2725
|
+
// src/diagnostics/effectInVoidSuccess.ts
|
|
2726
|
+
var effectInVoidSuccess = createDiagnostic({
|
|
2727
|
+
name: "effectInVoidSuccess",
|
|
2728
|
+
code: 14,
|
|
2729
|
+
severity: "warning",
|
|
2730
|
+
apply: fn("effectInVoidSuccess.apply")(function* (sourceFile, report) {
|
|
2731
|
+
const ts = yield* service(TypeScriptApi);
|
|
2732
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
2733
|
+
const typeParser = yield* service(TypeParser);
|
|
2734
|
+
const checkForEffectInVoid = fn("effectInVoidSuccess.checkForEffectInVoid")(function* (node, expectedType, valueNode, realType) {
|
|
2735
|
+
const expectedEffect = yield* typeParser.effectType(expectedType, node);
|
|
2736
|
+
const realEffect = yield* typeParser.effectType(realType, valueNode);
|
|
2737
|
+
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
2738
|
+
const voidValueTypes = unrollUnionMembers(realEffect.A);
|
|
2739
|
+
const voidedEffect = yield* firstSuccessOf(
|
|
2740
|
+
voidValueTypes.map((_) => map4(typeParser.strictEffectType(_, node), () => _))
|
|
2741
|
+
);
|
|
2742
|
+
return { voidedEffect };
|
|
2743
|
+
}
|
|
2744
|
+
return yield* fail(typeParserIssue("expectedEffect success is not void"));
|
|
2745
|
+
});
|
|
2746
|
+
const entries = yield* expectedAndRealType(sourceFile);
|
|
2747
|
+
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
2748
|
+
if (expectedType !== realType) {
|
|
2749
|
+
yield* pipe(
|
|
2750
|
+
checkForEffectInVoid(
|
|
2751
|
+
node,
|
|
2752
|
+
expectedType,
|
|
2753
|
+
valueNode,
|
|
2754
|
+
realType
|
|
2755
|
+
),
|
|
2756
|
+
map4(({ voidedEffect }) => {
|
|
2757
|
+
report(
|
|
2758
|
+
{
|
|
2759
|
+
node,
|
|
2760
|
+
messageText: `There is a nested '${typeChecker.typeToString(voidedEffect)}' in the 'void' success channel, beware that this could lead to nested Effect<Effect<...>> that won't be executed.`,
|
|
2761
|
+
fixes: []
|
|
2762
|
+
}
|
|
2763
|
+
);
|
|
2764
|
+
}),
|
|
2765
|
+
ignore
|
|
2766
|
+
);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
})
|
|
2770
|
+
});
|
|
2771
|
+
|
|
2575
2772
|
// src/diagnostics/floatingEffect.ts
|
|
2576
2773
|
var floatingEffect = createDiagnostic({
|
|
2577
2774
|
name: "floatingEffect",
|
|
@@ -2841,7 +3038,18 @@ var leakingRequirements = createDiagnostic({
|
|
|
2841
3038
|
);
|
|
2842
3039
|
if (effectContextType) {
|
|
2843
3040
|
effectMembers++;
|
|
2844
|
-
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
3041
|
+
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
3042
|
+
memory,
|
|
3043
|
+
effectContextType,
|
|
3044
|
+
(type) => {
|
|
3045
|
+
if (type.flags & ts.TypeFlags.Never) return succeed(true);
|
|
3046
|
+
return pipe(
|
|
3047
|
+
typeParser.scopeType(type, atLocation),
|
|
3048
|
+
map4(() => true),
|
|
3049
|
+
orElse2(() => succeed(false))
|
|
3050
|
+
);
|
|
3051
|
+
}
|
|
3052
|
+
);
|
|
2845
3053
|
if (!sharedRequirementsKeys) {
|
|
2846
3054
|
sharedRequirementsKeys = allIndexes;
|
|
2847
3055
|
} else {
|
|
@@ -3394,6 +3602,51 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
3394
3602
|
})
|
|
3395
3603
|
});
|
|
3396
3604
|
|
|
3605
|
+
// src/diagnostics/tryCatchInEffectGen.ts
|
|
3606
|
+
var tryCatchInEffectGen = createDiagnostic({
|
|
3607
|
+
name: "tryCatchInEffectGen",
|
|
3608
|
+
code: 12,
|
|
3609
|
+
severity: "suggestion",
|
|
3610
|
+
apply: fn("tryCatchInEffectGen.apply")(function* (sourceFile, report) {
|
|
3611
|
+
const ts = yield* service(TypeScriptApi);
|
|
3612
|
+
const typeParser = yield* service(TypeParser);
|
|
3613
|
+
const nodeToVisit = [];
|
|
3614
|
+
const appendNodeToVisit = (node) => {
|
|
3615
|
+
nodeToVisit.push(node);
|
|
3616
|
+
return void 0;
|
|
3617
|
+
};
|
|
3618
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3619
|
+
while (nodeToVisit.length > 0) {
|
|
3620
|
+
const node = nodeToVisit.shift();
|
|
3621
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3622
|
+
if (ts.isTryStatement(node)) {
|
|
3623
|
+
const generatorOrRegularFunction = ts.findAncestor(
|
|
3624
|
+
node,
|
|
3625
|
+
(_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isArrowFunction(_) || ts.isGetAccessor(_) || ts.isFunctionLike(_)
|
|
3626
|
+
);
|
|
3627
|
+
if (!(generatorOrRegularFunction && "asteriskToken" in generatorOrRegularFunction && generatorOrRegularFunction.asteriskToken)) continue;
|
|
3628
|
+
if (!generatorOrRegularFunction) continue;
|
|
3629
|
+
if (generatorOrRegularFunction && generatorOrRegularFunction.parent) {
|
|
3630
|
+
const effectGenNode = generatorOrRegularFunction.parent;
|
|
3631
|
+
yield* pipe(
|
|
3632
|
+
typeParser.effectGen(effectGenNode),
|
|
3633
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3634
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3635
|
+
map4(() => {
|
|
3636
|
+
report({
|
|
3637
|
+
node,
|
|
3638
|
+
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).",
|
|
3639
|
+
fixes: []
|
|
3640
|
+
});
|
|
3641
|
+
}),
|
|
3642
|
+
ignore
|
|
3643
|
+
);
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
})
|
|
3648
|
+
});
|
|
3649
|
+
|
|
3397
3650
|
// src/diagnostics/unnecessaryEffectGen.ts
|
|
3398
3651
|
var unnecessaryEffectGen = createDiagnostic({
|
|
3399
3652
|
name: "unnecessaryEffectGen",
|
|
@@ -3457,8 +3710,8 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
3457
3710
|
if (ts.isCallExpression(node)) {
|
|
3458
3711
|
yield* pipe(
|
|
3459
3712
|
typeParser.pipeCall(node),
|
|
3460
|
-
map4(({ args, subject }) => {
|
|
3461
|
-
if (
|
|
3713
|
+
map4(({ args: args2, subject }) => {
|
|
3714
|
+
if (args2.length === 0) {
|
|
3462
3715
|
report({
|
|
3463
3716
|
node,
|
|
3464
3717
|
messageText: `This pipe call contains no arguments.`,
|
|
@@ -3495,8 +3748,10 @@ var diagnostics = [
|
|
|
3495
3748
|
unnecessaryPipe,
|
|
3496
3749
|
genericEffectServices,
|
|
3497
3750
|
returnEffectInGen,
|
|
3751
|
+
tryCatchInEffectGen,
|
|
3498
3752
|
importFromBarrel,
|
|
3499
|
-
scopeInLayerEffect
|
|
3753
|
+
scopeInLayerEffect,
|
|
3754
|
+
effectInVoidSuccess
|
|
3500
3755
|
];
|
|
3501
3756
|
|
|
3502
3757
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -3505,9 +3760,9 @@ var effectDiagnosticsComment = createCompletion({
|
|
|
3505
3760
|
apply: fn("effectDiagnosticsComment")(function* (sourceFile, position) {
|
|
3506
3761
|
const ts = yield* service(TypeScriptApi);
|
|
3507
3762
|
const sourceText = sourceFile.text;
|
|
3508
|
-
const
|
|
3509
|
-
if (
|
|
3510
|
-
const lastIndex =
|
|
3763
|
+
const match3 = /(\/\/|\/\*(?:\*?))\s*(@)\s*$/id.exec(sourceText.substring(0, position));
|
|
3764
|
+
if (match3 && match3.indices) {
|
|
3765
|
+
const lastIndex = match3.indices[2][0];
|
|
3511
3766
|
const replacementSpan = {
|
|
3512
3767
|
start: lastIndex,
|
|
3513
3768
|
length: Math.max(0, position - lastIndex)
|
|
@@ -3738,7 +3993,8 @@ var completions = [
|
|
|
3738
3993
|
genFunctionStar,
|
|
3739
3994
|
fnFunctionStar,
|
|
3740
3995
|
effectDataClasses,
|
|
3741
|
-
effectDiagnosticsComment
|
|
3996
|
+
effectDiagnosticsComment,
|
|
3997
|
+
durationInput
|
|
3742
3998
|
];
|
|
3743
3999
|
|
|
3744
4000
|
// src/completions/middlewareAutoImports.ts
|
|
@@ -5238,7 +5494,7 @@ var read_buf = (strm, buf, start, size) => {
|
|
|
5238
5494
|
var longest_match = (s, cur_match) => {
|
|
5239
5495
|
let chain_length = s.max_chain_length;
|
|
5240
5496
|
let scan = s.strstart;
|
|
5241
|
-
let
|
|
5497
|
+
let match3;
|
|
5242
5498
|
let len;
|
|
5243
5499
|
let best_len = s.prev_length;
|
|
5244
5500
|
let nice_match = s.nice_match;
|
|
@@ -5256,14 +5512,14 @@ var longest_match = (s, cur_match) => {
|
|
|
5256
5512
|
nice_match = s.lookahead;
|
|
5257
5513
|
}
|
|
5258
5514
|
do {
|
|
5259
|
-
|
|
5260
|
-
if (_win[
|
|
5515
|
+
match3 = cur_match;
|
|
5516
|
+
if (_win[match3 + best_len] !== scan_end || _win[match3 + best_len - 1] !== scan_end1 || _win[match3] !== _win[scan] || _win[++match3] !== _win[scan + 1]) {
|
|
5261
5517
|
continue;
|
|
5262
5518
|
}
|
|
5263
5519
|
scan += 2;
|
|
5264
|
-
|
|
5520
|
+
match3++;
|
|
5265
5521
|
do {
|
|
5266
|
-
} while (_win[++scan] === _win[++
|
|
5522
|
+
} while (_win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && _win[++scan] === _win[++match3] && scan < strend);
|
|
5267
5523
|
len = MAX_MATCH - (strend - scan);
|
|
5268
5524
|
scan = strend - MAX_MATCH;
|
|
5269
5525
|
if (len > best_len) {
|
|
@@ -6964,7 +7220,7 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
6964
7220
|
let mask;
|
|
6965
7221
|
let next;
|
|
6966
7222
|
let base = null;
|
|
6967
|
-
let
|
|
7223
|
+
let match3;
|
|
6968
7224
|
const count = new Uint16Array(MAXBITS + 1);
|
|
6969
7225
|
const offs = new Uint16Array(MAXBITS + 1);
|
|
6970
7226
|
let extra = null;
|
|
@@ -7020,15 +7276,15 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
7020
7276
|
}
|
|
7021
7277
|
if (type === CODES$1) {
|
|
7022
7278
|
base = extra = work;
|
|
7023
|
-
|
|
7279
|
+
match3 = 20;
|
|
7024
7280
|
} else if (type === LENS$1) {
|
|
7025
7281
|
base = lbase;
|
|
7026
7282
|
extra = lext;
|
|
7027
|
-
|
|
7283
|
+
match3 = 257;
|
|
7028
7284
|
} else {
|
|
7029
7285
|
base = dbase;
|
|
7030
7286
|
extra = dext;
|
|
7031
|
-
|
|
7287
|
+
match3 = 0;
|
|
7032
7288
|
}
|
|
7033
7289
|
huff = 0;
|
|
7034
7290
|
sym = 0;
|
|
@@ -7044,12 +7300,12 @@ var inflate_table = (type, lens, lens_index, codes, table, table_index, work, op
|
|
|
7044
7300
|
}
|
|
7045
7301
|
for (; ; ) {
|
|
7046
7302
|
here_bits = len - drop;
|
|
7047
|
-
if (work[sym] + 1 <
|
|
7303
|
+
if (work[sym] + 1 < match3) {
|
|
7048
7304
|
here_op = 0;
|
|
7049
7305
|
here_val = work[sym];
|
|
7050
|
-
} else if (work[sym] >=
|
|
7051
|
-
here_op = extra[work[sym] -
|
|
7052
|
-
here_val = base[work[sym] -
|
|
7306
|
+
} else if (work[sym] >= match3) {
|
|
7307
|
+
here_op = extra[work[sym] - match3];
|
|
7308
|
+
here_val = base[work[sym] - match3];
|
|
7053
7309
|
} else {
|
|
7054
7310
|
here_op = 32 + 64;
|
|
7055
7311
|
here_val = 0;
|
|
@@ -8561,10 +8817,10 @@ var GraphNodeLeaf = class {
|
|
|
8561
8817
|
_tag = "GraphNodeLeaf";
|
|
8562
8818
|
};
|
|
8563
8819
|
var GraphNodeCompoundTransform = class {
|
|
8564
|
-
constructor(id, node,
|
|
8820
|
+
constructor(id, node, args2, rout, rin) {
|
|
8565
8821
|
this.id = id;
|
|
8566
8822
|
this.node = node;
|
|
8567
|
-
this.args =
|
|
8823
|
+
this.args = args2;
|
|
8568
8824
|
this.rout = rout;
|
|
8569
8825
|
this.rin = rin;
|
|
8570
8826
|
}
|
|
@@ -8575,6 +8831,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
8575
8831
|
const ts = yield* service(TypeScriptApi);
|
|
8576
8832
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
8577
8833
|
const typeParser = yield* service(TypeParser);
|
|
8834
|
+
const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
|
|
8578
8835
|
const maybePipe = yield* option(typeParser.pipeCall(node));
|
|
8579
8836
|
if (isSome2(maybePipe)) {
|
|
8580
8837
|
let graphNode = yield* processLayerGraphNode(ctx, maybePipe.value.subject, void 0);
|
|
@@ -8594,12 +8851,12 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
8594
8851
|
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
8595
8852
|
ctx.services,
|
|
8596
8853
|
maybeLayer.value.ROut,
|
|
8597
|
-
|
|
8854
|
+
excludeNever
|
|
8598
8855
|
);
|
|
8599
8856
|
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
8600
8857
|
ctx.services,
|
|
8601
8858
|
maybeLayer.value.RIn,
|
|
8602
|
-
|
|
8859
|
+
excludeNever
|
|
8603
8860
|
);
|
|
8604
8861
|
return new GraphNodeCompoundTransform(
|
|
8605
8862
|
ctx.nextId(),
|
|
@@ -8623,12 +8880,12 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
8623
8880
|
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
8624
8881
|
ctx.services,
|
|
8625
8882
|
maybeLayer.value.ROut,
|
|
8626
|
-
|
|
8883
|
+
excludeNever
|
|
8627
8884
|
);
|
|
8628
8885
|
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
8629
8886
|
ctx.services,
|
|
8630
8887
|
maybeLayer.value.RIn,
|
|
8631
|
-
|
|
8888
|
+
excludeNever
|
|
8632
8889
|
);
|
|
8633
8890
|
if (ts.isCallExpression(node)) {
|
|
8634
8891
|
const argNodes = yield* option(
|
|
@@ -8673,12 +8930,12 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
8673
8930
|
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
8674
8931
|
ctx.services,
|
|
8675
8932
|
maybeLayer.value.ROut,
|
|
8676
|
-
|
|
8933
|
+
excludeNever
|
|
8677
8934
|
);
|
|
8678
8935
|
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
8679
8936
|
ctx.services,
|
|
8680
8937
|
maybeLayer.value.RIn,
|
|
8681
|
-
|
|
8938
|
+
excludeNever
|
|
8682
8939
|
);
|
|
8683
8940
|
return new GraphNodeLeaf(ctx.nextId(), node, outTypes, inTypes);
|
|
8684
8941
|
}
|
|
@@ -9842,13 +10099,13 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
|
|
|
9842
10099
|
ts.factory.createIdentifier(effectSchemaIdentifier),
|
|
9843
10100
|
apiName
|
|
9844
10101
|
),
|
|
9845
|
-
createApiCall: (apiName,
|
|
10102
|
+
createApiCall: (apiName, args2) => ts.factory.createCallExpression(
|
|
9846
10103
|
ts.factory.createPropertyAccessExpression(
|
|
9847
10104
|
ts.factory.createIdentifier(effectSchemaIdentifier),
|
|
9848
10105
|
apiName
|
|
9849
10106
|
),
|
|
9850
10107
|
[],
|
|
9851
|
-
|
|
10108
|
+
args2
|
|
9852
10109
|
),
|
|
9853
10110
|
entityNameToDataTypeName: (name) => {
|
|
9854
10111
|
if (ts.isIdentifier(name)) {
|
|
@@ -10414,12 +10671,12 @@ var init = (modules) => {
|
|
|
10414
10671
|
const proxy = /* @__PURE__ */ Object.create(null);
|
|
10415
10672
|
proxy[LSP_INJECTED_URI] = true;
|
|
10416
10673
|
for (const k of Object.keys(languageService)) {
|
|
10417
|
-
proxy[k] = (...
|
|
10674
|
+
proxy[k] = (...args2) => languageService[k].apply(languageService, args2);
|
|
10418
10675
|
}
|
|
10419
10676
|
function runNano(program) {
|
|
10420
10677
|
return (fa) => pipe(
|
|
10421
10678
|
fa,
|
|
10422
|
-
provideService(TypeParser,
|
|
10679
|
+
provideService(TypeParser, make3(modules.typescript, program.getTypeChecker())),
|
|
10423
10680
|
provideService(TypeScriptProgram, program),
|
|
10424
10681
|
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
10425
10682
|
provideService(
|
|
@@ -10435,8 +10692,8 @@ var init = (modules) => {
|
|
|
10435
10692
|
);
|
|
10436
10693
|
}
|
|
10437
10694
|
const effectCodeFixesForFile = /* @__PURE__ */ new Map();
|
|
10438
|
-
proxy.getSemanticDiagnostics = (fileName, ...
|
|
10439
|
-
const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...
|
|
10695
|
+
proxy.getSemanticDiagnostics = (fileName, ...args2) => {
|
|
10696
|
+
const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
|
|
10440
10697
|
const program = languageService.getProgram();
|
|
10441
10698
|
if (languageServicePluginOptions.diagnostics && program) {
|
|
10442
10699
|
effectCodeFixesForFile.delete(fileName);
|
|
@@ -10455,10 +10712,10 @@ var init = (modules) => {
|
|
|
10455
10712
|
}
|
|
10456
10713
|
return applicableDiagnostics;
|
|
10457
10714
|
};
|
|
10458
|
-
proxy.getSupportedCodeFixes = (...
|
|
10715
|
+
proxy.getSupportedCodeFixes = (...args2) => languageService.getSupportedCodeFixes(...args2).concat(
|
|
10459
10716
|
diagnosticsErrorCodes.map((_) => "" + _)
|
|
10460
10717
|
);
|
|
10461
|
-
proxy.getCodeFixesAtPosition = (fileName, start, end, errorCodes, formatOptions, preferences, ...
|
|
10718
|
+
proxy.getCodeFixesAtPosition = (fileName, start, end, errorCodes, formatOptions, preferences, ...args2) => {
|
|
10462
10719
|
const applicableCodeFixes = languageService.getCodeFixesAtPosition(
|
|
10463
10720
|
fileName,
|
|
10464
10721
|
start,
|
|
@@ -10466,7 +10723,7 @@ var init = (modules) => {
|
|
|
10466
10723
|
errorCodes,
|
|
10467
10724
|
formatOptions,
|
|
10468
10725
|
preferences,
|
|
10469
|
-
...
|
|
10726
|
+
...args2
|
|
10470
10727
|
);
|
|
10471
10728
|
return pipe(
|
|
10472
10729
|
sync(() => {
|
|
@@ -10504,9 +10761,9 @@ var init = (modules) => {
|
|
|
10504
10761
|
getOrElse(() => applicableCodeFixes)
|
|
10505
10762
|
);
|
|
10506
10763
|
};
|
|
10507
|
-
proxy.getApplicableRefactors = (...
|
|
10508
|
-
const applicableRefactors = languageService.getApplicableRefactors(...
|
|
10509
|
-
const [fileName, positionOrRange] =
|
|
10764
|
+
proxy.getApplicableRefactors = (...args2) => {
|
|
10765
|
+
const applicableRefactors = languageService.getApplicableRefactors(...args2);
|
|
10766
|
+
const [fileName, positionOrRange] = args2;
|
|
10510
10767
|
const program = languageService.getProgram();
|
|
10511
10768
|
if (program) {
|
|
10512
10769
|
const sourceFile = program.getSourceFile(fileName);
|
|
@@ -10521,7 +10778,7 @@ var init = (modules) => {
|
|
|
10521
10778
|
}
|
|
10522
10779
|
return applicableRefactors;
|
|
10523
10780
|
};
|
|
10524
|
-
proxy.getEditsForRefactor = (fileName, formatOptions, positionOrRange, refactorName, actionName, preferences, ...
|
|
10781
|
+
proxy.getEditsForRefactor = (fileName, formatOptions, positionOrRange, refactorName, actionName, preferences, ...args2) => {
|
|
10525
10782
|
const program = languageService.getProgram();
|
|
10526
10783
|
if (program) {
|
|
10527
10784
|
const sourceFile = program.getSourceFile(fileName);
|
|
@@ -10564,11 +10821,11 @@ var init = (modules) => {
|
|
|
10564
10821
|
refactorName,
|
|
10565
10822
|
actionName,
|
|
10566
10823
|
preferences,
|
|
10567
|
-
...
|
|
10824
|
+
...args2
|
|
10568
10825
|
);
|
|
10569
10826
|
};
|
|
10570
|
-
proxy.getQuickInfoAtPosition = (fileName, position, ...
|
|
10571
|
-
const applicableQuickInfo = languageService.getQuickInfoAtPosition(fileName, position, ...
|
|
10827
|
+
proxy.getQuickInfoAtPosition = (fileName, position, ...args2) => {
|
|
10828
|
+
const applicableQuickInfo = languageService.getQuickInfoAtPosition(fileName, position, ...args2);
|
|
10572
10829
|
if (languageServicePluginOptions.quickinfo) {
|
|
10573
10830
|
const program = languageService.getProgram();
|
|
10574
10831
|
if (program) {
|
|
@@ -10588,13 +10845,13 @@ var init = (modules) => {
|
|
|
10588
10845
|
}
|
|
10589
10846
|
return applicableQuickInfo;
|
|
10590
10847
|
};
|
|
10591
|
-
proxy.getCompletionsAtPosition = (fileName, position, options, formattingSettings, ...
|
|
10848
|
+
proxy.getCompletionsAtPosition = (fileName, position, options, formattingSettings, ...args2) => {
|
|
10592
10849
|
const applicableCompletions = languageService.getCompletionsAtPosition(
|
|
10593
10850
|
fileName,
|
|
10594
10851
|
position,
|
|
10595
10852
|
options,
|
|
10596
10853
|
formattingSettings,
|
|
10597
|
-
...
|
|
10854
|
+
...args2
|
|
10598
10855
|
);
|
|
10599
10856
|
if (languageServicePluginOptions.completions) {
|
|
10600
10857
|
const program = languageService.getProgram();
|
|
@@ -10633,7 +10890,7 @@ var init = (modules) => {
|
|
|
10633
10890
|
}
|
|
10634
10891
|
return applicableCompletions;
|
|
10635
10892
|
};
|
|
10636
|
-
proxy.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, _data, ...
|
|
10893
|
+
proxy.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, _data, ...args2) => {
|
|
10637
10894
|
const applicableCompletionEntryDetails = languageService.getCompletionEntryDetails(
|
|
10638
10895
|
fileName,
|
|
10639
10896
|
position,
|
|
@@ -10642,7 +10899,7 @@ var init = (modules) => {
|
|
|
10642
10899
|
source,
|
|
10643
10900
|
preferences,
|
|
10644
10901
|
_data,
|
|
10645
|
-
...
|
|
10902
|
+
...args2
|
|
10646
10903
|
);
|
|
10647
10904
|
if (languageServicePluginOptions.completions) {
|
|
10648
10905
|
const program = languageService.getProgram();
|
|
@@ -10666,8 +10923,8 @@ var init = (modules) => {
|
|
|
10666
10923
|
}
|
|
10667
10924
|
return applicableCompletionEntryDetails;
|
|
10668
10925
|
};
|
|
10669
|
-
proxy.getDefinitionAndBoundSpan = (fileName, position, ...
|
|
10670
|
-
const applicableDefinition = languageService.getDefinitionAndBoundSpan(fileName, position, ...
|
|
10926
|
+
proxy.getDefinitionAndBoundSpan = (fileName, position, ...args2) => {
|
|
10927
|
+
const applicableDefinition = languageService.getDefinitionAndBoundSpan(fileName, position, ...args2);
|
|
10671
10928
|
if (languageServicePluginOptions.goto) {
|
|
10672
10929
|
const program = languageService.getProgram();
|
|
10673
10930
|
if (program) {
|