@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/transform.js
CHANGED
|
@@ -80,9 +80,9 @@ var dual = function(arity, body) {
|
|
|
80
80
|
if (arguments.length >= arity) {
|
|
81
81
|
return body.apply(this, arguments);
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const args2 = arguments;
|
|
84
84
|
return function(self) {
|
|
85
|
-
return body(self, ...
|
|
85
|
+
return body(self, ...args2);
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
}
|
|
@@ -151,7 +151,6 @@ var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue
|
|
|
151
151
|
|
|
152
152
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Utils.js
|
|
153
153
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
154
|
-
var isGenKind = (u) => isObject(u) && GenKindTypeId in u;
|
|
155
154
|
var GenKindImpl = class {
|
|
156
155
|
value;
|
|
157
156
|
constructor(value) {
|
|
@@ -484,32 +483,32 @@ var redact = (u) => {
|
|
|
484
483
|
};
|
|
485
484
|
|
|
486
485
|
// node_modules/.pnpm/effect@3.16.12/node_modules/effect/dist/esm/Pipeable.js
|
|
487
|
-
var pipeArguments = (self,
|
|
488
|
-
switch (
|
|
486
|
+
var pipeArguments = (self, args2) => {
|
|
487
|
+
switch (args2.length) {
|
|
489
488
|
case 0:
|
|
490
489
|
return self;
|
|
491
490
|
case 1:
|
|
492
|
-
return
|
|
491
|
+
return args2[0](self);
|
|
493
492
|
case 2:
|
|
494
|
-
return
|
|
493
|
+
return args2[1](args2[0](self));
|
|
495
494
|
case 3:
|
|
496
|
-
return
|
|
495
|
+
return args2[2](args2[1](args2[0](self)));
|
|
497
496
|
case 4:
|
|
498
|
-
return
|
|
497
|
+
return args2[3](args2[2](args2[1](args2[0](self))));
|
|
499
498
|
case 5:
|
|
500
|
-
return
|
|
499
|
+
return args2[4](args2[3](args2[2](args2[1](args2[0](self)))));
|
|
501
500
|
case 6:
|
|
502
|
-
return
|
|
501
|
+
return args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))));
|
|
503
502
|
case 7:
|
|
504
|
-
return
|
|
503
|
+
return args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))));
|
|
505
504
|
case 8:
|
|
506
|
-
return
|
|
505
|
+
return args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self))))))));
|
|
507
506
|
case 9:
|
|
508
|
-
return
|
|
507
|
+
return args2[8](args2[7](args2[6](args2[5](args2[4](args2[3](args2[2](args2[1](args2[0](self)))))))));
|
|
509
508
|
default: {
|
|
510
509
|
let ret = self;
|
|
511
|
-
for (let i = 0, len =
|
|
512
|
-
ret =
|
|
510
|
+
for (let i = 0, len = args2.length; i < len; i++) {
|
|
511
|
+
ret = args2[i](ret);
|
|
513
512
|
}
|
|
514
513
|
return ret;
|
|
515
514
|
}
|
|
@@ -833,181 +832,278 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
|
833
832
|
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
834
833
|
|
|
835
834
|
// src/core/Nano.ts
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
835
|
+
var NanoTag = class {
|
|
836
|
+
constructor(key) {
|
|
837
|
+
this.key = key;
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
var Tag = (identifier) => new NanoTag(identifier);
|
|
841
|
+
var evaluate = Symbol.for("Nano.evaluate");
|
|
842
|
+
var contA = Symbol.for("Nano.contA");
|
|
843
|
+
var contE = Symbol.for("Nano.contE");
|
|
844
|
+
var contAll = Symbol.for("Nano.contAll");
|
|
845
|
+
var NanoYield = Symbol.for("Nano.yield");
|
|
846
|
+
var args = Symbol.for("Nano.args");
|
|
842
847
|
var NanoDefectException = class {
|
|
843
848
|
constructor(message) {
|
|
844
849
|
this.message = message;
|
|
845
850
|
}
|
|
846
851
|
_tag = "@effect/language-service/NanoDefectException";
|
|
847
852
|
};
|
|
848
|
-
var
|
|
849
|
-
|
|
850
|
-
|
|
853
|
+
var PrimitiveProto = {
|
|
854
|
+
[Symbol.iterator]() {
|
|
855
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
851
856
|
}
|
|
852
857
|
};
|
|
853
|
-
var
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
858
|
+
var SucceedProto = {
|
|
859
|
+
...PrimitiveProto,
|
|
860
|
+
_tag: "Success",
|
|
861
|
+
get value() {
|
|
862
|
+
return this[args];
|
|
863
|
+
},
|
|
864
|
+
[evaluate](fiber) {
|
|
865
|
+
const cont = fiber.getCont(contA);
|
|
866
|
+
return cont ? cont[contA](this[args], fiber) : fiber.yieldWith(this);
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
var succeed = (value) => {
|
|
870
|
+
const nano = Object.create(SucceedProto);
|
|
871
|
+
nano[args] = value;
|
|
862
872
|
return nano;
|
|
863
|
-
}
|
|
864
|
-
var
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
873
|
+
};
|
|
874
|
+
var FailureProto = {
|
|
875
|
+
...PrimitiveProto,
|
|
876
|
+
_tag: "Failure",
|
|
877
|
+
get value() {
|
|
878
|
+
return this[args];
|
|
879
|
+
},
|
|
880
|
+
[evaluate](fiber) {
|
|
881
|
+
const cont = fiber.getCont(contE);
|
|
882
|
+
return cont ? cont[contE](this[args], fiber) : fiber.yieldWith(this);
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
var fail = (error) => {
|
|
886
|
+
const nano = Object.create(FailureProto);
|
|
887
|
+
nano[args] = error;
|
|
888
|
+
return nano;
|
|
889
|
+
};
|
|
890
|
+
var SuspendProto = {
|
|
891
|
+
...PrimitiveProto,
|
|
892
|
+
[evaluate]() {
|
|
893
|
+
return this[args]();
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
var suspend = (fn2) => {
|
|
897
|
+
const nano = Object.create(SuspendProto);
|
|
898
|
+
nano[args] = fn2;
|
|
899
|
+
return nano;
|
|
900
|
+
};
|
|
901
|
+
var NanoFiber = class {
|
|
902
|
+
_stack = [];
|
|
903
|
+
_yielded = void 0;
|
|
904
|
+
_services = {};
|
|
905
|
+
_cache = {};
|
|
906
|
+
runLoop(nano) {
|
|
907
|
+
let current = nano;
|
|
908
|
+
while (true) {
|
|
909
|
+
current = current[evaluate](this);
|
|
910
|
+
if (current === NanoYield) {
|
|
911
|
+
return this._yielded;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
getCont(symbol3) {
|
|
916
|
+
while (true) {
|
|
917
|
+
const op = this._stack.pop();
|
|
918
|
+
if (!op) return void 0;
|
|
919
|
+
const cont = op[contAll] && op[contAll](this);
|
|
920
|
+
if (cont) return { [symbol3]: cont };
|
|
921
|
+
if (op[symbol3]) return op;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
yieldWith(value) {
|
|
925
|
+
this._yielded = value;
|
|
926
|
+
return NanoYield;
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
var unsafeRun = (nano) => {
|
|
930
|
+
const fiber = new NanoFiber();
|
|
931
|
+
const result = fiber.runLoop(nano);
|
|
932
|
+
if (result._tag === "Success") {
|
|
933
|
+
return right2(result.value);
|
|
934
|
+
}
|
|
935
|
+
return left2(result.value);
|
|
936
|
+
};
|
|
937
|
+
var run = (nano) => {
|
|
877
938
|
try {
|
|
878
|
-
return unsafeRun(
|
|
939
|
+
return unsafeRun(nano);
|
|
879
940
|
} catch (e) {
|
|
880
941
|
return left2(new NanoDefectException(e));
|
|
881
942
|
}
|
|
882
943
|
};
|
|
883
|
-
var
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
944
|
+
var OnSuccessProto = {
|
|
945
|
+
...PrimitiveProto,
|
|
946
|
+
[evaluate](fiber) {
|
|
947
|
+
fiber._stack.push(this);
|
|
948
|
+
return this[args];
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
var flatMap2 = dual(2, (fa, f) => {
|
|
952
|
+
const nano = Object.create(OnSuccessProto);
|
|
953
|
+
nano[args] = fa;
|
|
954
|
+
nano[contA] = f;
|
|
890
955
|
return nano;
|
|
956
|
+
});
|
|
957
|
+
var map3 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
|
|
958
|
+
var SyncProto = {
|
|
959
|
+
...PrimitiveProto,
|
|
960
|
+
[evaluate](fiber) {
|
|
961
|
+
const value = this[args]();
|
|
962
|
+
const cont = fiber.getCont(contA);
|
|
963
|
+
return cont ? cont[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
964
|
+
}
|
|
891
965
|
};
|
|
892
|
-
var
|
|
893
|
-
const nano =
|
|
894
|
-
|
|
895
|
-
[Symbol.iterator]() {
|
|
896
|
-
return new SingleShotGen(new YieldWrap(this));
|
|
897
|
-
}
|
|
898
|
-
};
|
|
966
|
+
var sync = (f) => {
|
|
967
|
+
const nano = Object.create(SyncProto);
|
|
968
|
+
nano[args] = f;
|
|
899
969
|
return nano;
|
|
900
970
|
};
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
971
|
+
var void_ = succeed(void 0);
|
|
972
|
+
var FromIteratorProto = {
|
|
973
|
+
...PrimitiveProto,
|
|
974
|
+
[contA](value, fiber) {
|
|
975
|
+
const state = this[args][0].next(value);
|
|
976
|
+
if (state.done) return succeed(state.value);
|
|
977
|
+
fiber._stack.push(this);
|
|
978
|
+
return yieldWrapGet(state.value);
|
|
979
|
+
},
|
|
980
|
+
[evaluate](fiber) {
|
|
981
|
+
return this[contA](this[args][1], fiber);
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
var unsafeFromIterator = (iterator, initial) => {
|
|
985
|
+
const nano = Object.create(FromIteratorProto);
|
|
986
|
+
nano[args] = [iterator, initial];
|
|
987
|
+
return nano;
|
|
988
|
+
};
|
|
989
|
+
var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
|
|
990
|
+
var fn = (_) => (body) => (...args2) => suspend(() => unsafeFromIterator(body(...args2)));
|
|
991
|
+
var MatchProto = {
|
|
992
|
+
...PrimitiveProto,
|
|
993
|
+
[evaluate](fiber) {
|
|
994
|
+
fiber._stack.push(this);
|
|
995
|
+
return this[args];
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
var match2 = (fa, opts) => {
|
|
999
|
+
const nano = Object.create(MatchProto);
|
|
1000
|
+
nano[args] = fa;
|
|
1001
|
+
nano[contA] = opts.onSuccess;
|
|
1002
|
+
nano[contE] = opts.onFailure;
|
|
1003
|
+
return nano;
|
|
1004
|
+
};
|
|
1005
|
+
var orElse2 = (f) => (fa) => {
|
|
1006
|
+
const nano = Object.create(MatchProto);
|
|
1007
|
+
nano[args] = fa;
|
|
1008
|
+
nano[contE] = f;
|
|
908
1009
|
return nano;
|
|
909
1010
|
};
|
|
910
|
-
var flatMap2 = dual(2, (fa, f) => make2((ctx) => {
|
|
911
|
-
const result = fa.run(ctx);
|
|
912
|
-
if (result._tag !== "Right") return result;
|
|
913
|
-
return f(result.value).run(ctx);
|
|
914
|
-
}));
|
|
915
|
-
var map3 = dual(2, (fa, f) => make2((ctx) => {
|
|
916
|
-
const result = fa.run(ctx);
|
|
917
|
-
if (result._tag !== "Right") return result;
|
|
918
|
-
return makeInternalSuccess(f(result.value));
|
|
919
|
-
}));
|
|
920
|
-
var orElse2 = (f) => (fa) => make2((ctx) => {
|
|
921
|
-
const result = fa.run(ctx);
|
|
922
|
-
if (result._tag === "Left") return f(result.value).run(ctx);
|
|
923
|
-
return result;
|
|
924
|
-
});
|
|
925
1011
|
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
|
|
926
|
-
var
|
|
927
|
-
|
|
928
|
-
)
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
return result;
|
|
946
|
-
}
|
|
947
|
-
state = iterator.next(result.value);
|
|
1012
|
+
var ProvideServiceProto = {
|
|
1013
|
+
...PrimitiveProto,
|
|
1014
|
+
[evaluate](fiber) {
|
|
1015
|
+
const prevServices = fiber._services;
|
|
1016
|
+
const [fa, tag, value] = this[args];
|
|
1017
|
+
fiber._services = {
|
|
1018
|
+
...fiber._services,
|
|
1019
|
+
[tag.key]: value
|
|
1020
|
+
};
|
|
1021
|
+
return match2(fa, {
|
|
1022
|
+
onSuccess: (_) => {
|
|
1023
|
+
fiber._services = prevServices;
|
|
1024
|
+
return succeed(_);
|
|
1025
|
+
},
|
|
1026
|
+
onFailure: (_) => {
|
|
1027
|
+
fiber._services = prevServices;
|
|
1028
|
+
return fail(_);
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
948
1031
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1032
|
+
};
|
|
1033
|
+
var provideService = (tag, value) => (fa) => {
|
|
1034
|
+
const nano = Object.create(ProvideServiceProto);
|
|
1035
|
+
nano[args] = [fa, tag, value];
|
|
1036
|
+
return nano;
|
|
1037
|
+
};
|
|
1038
|
+
var ServiceProto = {
|
|
1039
|
+
...PrimitiveProto,
|
|
1040
|
+
[evaluate](fiber) {
|
|
1041
|
+
const tag = this[args];
|
|
1042
|
+
if (tag.key in fiber._services) {
|
|
1043
|
+
const value = fiber._services[tag.key];
|
|
1044
|
+
const cont2 = fiber.getCont(contA);
|
|
1045
|
+
return cont2 ? cont2[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
1046
|
+
}
|
|
1047
|
+
const cont = fiber.getCont(contE);
|
|
1048
|
+
return cont ? cont[contE](tag, fiber) : fiber.yieldWith(fail(new NanoDefectException(`Service ${tag.key} not found`)));
|
|
961
1049
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1050
|
+
};
|
|
1051
|
+
var service = (tag) => {
|
|
1052
|
+
const nano = Object.create(ServiceProto);
|
|
1053
|
+
nano[args] = tag;
|
|
1054
|
+
return nano;
|
|
1055
|
+
};
|
|
1056
|
+
var CachedProto = {
|
|
1057
|
+
...PrimitiveProto,
|
|
1058
|
+
[evaluate](fiber) {
|
|
1059
|
+
const [fa, type, key] = this[args];
|
|
1060
|
+
const cache = fiber._cache[type] || /* @__PURE__ */ new WeakMap();
|
|
1061
|
+
fiber._cache[type] = cache;
|
|
1062
|
+
const cached2 = cache.get(key);
|
|
1063
|
+
if (cached2) return cached2;
|
|
1064
|
+
return match2(fa, {
|
|
1065
|
+
onSuccess: (_) => {
|
|
1066
|
+
cache.set(key, succeed(_));
|
|
1067
|
+
return succeed(_);
|
|
1068
|
+
},
|
|
1069
|
+
onFailure: (_) => {
|
|
1070
|
+
cache.set(key, fail(_));
|
|
1071
|
+
return fail(_);
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
973
1074
|
}
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
}
|
|
981
|
-
var all = (...args) => make2((ctx) => {
|
|
982
|
-
const results = [];
|
|
983
|
-
for (const arg of args) {
|
|
984
|
-
const result = arg.run(ctx);
|
|
985
|
-
if (result._tag !== "Right") return result;
|
|
986
|
-
results.push(result.value);
|
|
987
|
-
}
|
|
988
|
-
return makeInternalSuccess(results);
|
|
989
|
-
});
|
|
990
|
-
var internalNanoCache = Tag(
|
|
991
|
-
"@effect/language-service/internalNanoCache"
|
|
992
|
-
);
|
|
993
|
-
function cachedBy(fa, key, lookupKey) {
|
|
994
|
-
return (...args) => make2((ctx) => {
|
|
995
|
-
const cacheObj = ctx.value[internalNanoCache.key];
|
|
996
|
-
let cache = cacheObj[key];
|
|
997
|
-
if (!cache) {
|
|
998
|
-
cache = /* @__PURE__ */ new Map();
|
|
999
|
-
cacheObj[key] = cache;
|
|
1000
|
-
}
|
|
1001
|
-
const lookup = lookupKey(...args);
|
|
1002
|
-
const cached2 = cache.get(lookup);
|
|
1003
|
-
if (cached2 !== void 0) {
|
|
1004
|
-
return cached2;
|
|
1005
|
-
}
|
|
1006
|
-
const result = fa(...args).run(ctx);
|
|
1007
|
-
cache.set(lookup, result);
|
|
1008
|
-
return result;
|
|
1009
|
-
});
|
|
1075
|
+
};
|
|
1076
|
+
function cachedBy(fa, type, lookupKey) {
|
|
1077
|
+
return (...p) => {
|
|
1078
|
+
const nano = Object.create(CachedProto);
|
|
1079
|
+
nano[args] = [fa(...p), type, lookupKey(...p)];
|
|
1080
|
+
return nano;
|
|
1081
|
+
};
|
|
1010
1082
|
}
|
|
1083
|
+
var option = (fa) => {
|
|
1084
|
+
const nano = Object.create(MatchProto);
|
|
1085
|
+
nano[args] = fa;
|
|
1086
|
+
nano[contA] = (_) => succeed(some2(_));
|
|
1087
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(none2());
|
|
1088
|
+
return nano;
|
|
1089
|
+
};
|
|
1090
|
+
var ignore = (fa) => {
|
|
1091
|
+
const nano = Object.create(MatchProto);
|
|
1092
|
+
nano[args] = fa;
|
|
1093
|
+
nano[contA] = (_) => void_;
|
|
1094
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : void_;
|
|
1095
|
+
return nano;
|
|
1096
|
+
};
|
|
1097
|
+
var all = fn("all")(
|
|
1098
|
+
function* (...args2) {
|
|
1099
|
+
const results = [];
|
|
1100
|
+
for (const fa of args2) {
|
|
1101
|
+
const result = yield* fa;
|
|
1102
|
+
results.push(result);
|
|
1103
|
+
}
|
|
1104
|
+
return results;
|
|
1105
|
+
}
|
|
1106
|
+
);
|
|
1011
1107
|
|
|
1012
1108
|
// src/core/LanguageServicePluginOptions.ts
|
|
1013
1109
|
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
@@ -1213,10 +1309,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1213
1309
|
const sectionOverrides = {};
|
|
1214
1310
|
const skippedRules = [];
|
|
1215
1311
|
const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]+:(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
|
|
1216
|
-
let
|
|
1217
|
-
while ((
|
|
1218
|
-
const nextLineCaptureGroup =
|
|
1219
|
-
const rulesCaptureGroup =
|
|
1312
|
+
let match3;
|
|
1313
|
+
while ((match3 = regex.exec(sourceFile.text)) !== null) {
|
|
1314
|
+
const nextLineCaptureGroup = match3[1];
|
|
1315
|
+
const rulesCaptureGroup = match3[2];
|
|
1220
1316
|
if (rulesCaptureGroup) {
|
|
1221
1317
|
const trimmedRuleString = rulesCaptureGroup.trim();
|
|
1222
1318
|
if (trimmedRuleString) {
|
|
@@ -1228,7 +1324,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1228
1324
|
if (ruleLevel === "skip-file") skippedRules.push(ruleName);
|
|
1229
1325
|
const isOverrideNextLine = nextLineCaptureGroup && nextLineCaptureGroup.trim().toLowerCase() === "-next-line";
|
|
1230
1326
|
if (isOverrideNextLine) {
|
|
1231
|
-
const node = findNodeWithLeadingCommentAtPosition(
|
|
1327
|
+
const node = findNodeWithLeadingCommentAtPosition(match3.index);
|
|
1232
1328
|
if (node) {
|
|
1233
1329
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1234
1330
|
lineOverrides[ruleName].unshift({
|
|
@@ -1240,7 +1336,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1240
1336
|
} else {
|
|
1241
1337
|
sectionOverrides[ruleName] = sectionOverrides[ruleName] || [];
|
|
1242
1338
|
sectionOverrides[ruleName].unshift({
|
|
1243
|
-
pos:
|
|
1339
|
+
pos: match3.index,
|
|
1244
1340
|
level: ruleLevel
|
|
1245
1341
|
});
|
|
1246
1342
|
}
|
|
@@ -1543,11 +1639,23 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
|
|
|
1543
1639
|
cache.expectedAndRealType.set(sourceFile, result);
|
|
1544
1640
|
return result;
|
|
1545
1641
|
});
|
|
1642
|
+
var unrollUnionMembers = (type) => {
|
|
1643
|
+
const result = [];
|
|
1644
|
+
let toTest = [type];
|
|
1645
|
+
while (toTest.length > 0) {
|
|
1646
|
+
const type2 = toTest.pop();
|
|
1647
|
+
if (type2.isUnion()) {
|
|
1648
|
+
toTest = toTest.concat(type2.types);
|
|
1649
|
+
} else {
|
|
1650
|
+
result.push(type2);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
return result;
|
|
1654
|
+
};
|
|
1546
1655
|
var appendToUniqueTypesMap = fn(
|
|
1547
1656
|
"TypeCheckerApi.appendToUniqueTypesMap"
|
|
1548
1657
|
)(
|
|
1549
|
-
function* (memory, initialType,
|
|
1550
|
-
const ts = yield* service(TypeScriptApi);
|
|
1658
|
+
function* (memory, initialType, shouldExclude) {
|
|
1551
1659
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
1552
1660
|
const newIndexes = /* @__PURE__ */ new Set();
|
|
1553
1661
|
const knownIndexes = /* @__PURE__ */ new Set();
|
|
@@ -1555,7 +1663,7 @@ var appendToUniqueTypesMap = fn(
|
|
|
1555
1663
|
while (toTest.length > 0) {
|
|
1556
1664
|
const type = toTest.pop();
|
|
1557
1665
|
if (!type) break;
|
|
1558
|
-
if (
|
|
1666
|
+
if (yield* shouldExclude(type)) {
|
|
1559
1667
|
continue;
|
|
1560
1668
|
}
|
|
1561
1669
|
if (type.isUnion()) {
|
|
@@ -1946,10 +2054,10 @@ var TypeParserIssue = class _TypeParserIssue {
|
|
|
1946
2054
|
_tag = "@effect/language-service/TypeParserIssue";
|
|
1947
2055
|
static issue = fail(new _TypeParserIssue());
|
|
1948
2056
|
};
|
|
1949
|
-
function
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2057
|
+
function typeParserIssue(_message, _type, _node) {
|
|
2058
|
+
return TypeParserIssue.issue;
|
|
2059
|
+
}
|
|
2060
|
+
function make2(ts, typeChecker) {
|
|
1953
2061
|
function covariantTypeArgument(type) {
|
|
1954
2062
|
const signatures = type.getCallSignatures();
|
|
1955
2063
|
if (signatures.length !== 1) {
|
|
@@ -2394,8 +2502,8 @@ function make3(ts, typeChecker) {
|
|
|
2394
2502
|
return succeed({ node, subject: node.expression.expression, args: Array.from(node.arguments) });
|
|
2395
2503
|
}
|
|
2396
2504
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
|
|
2397
|
-
const [subject, ...
|
|
2398
|
-
return succeed({ node, subject, args });
|
|
2505
|
+
const [subject, ...args2] = node.arguments;
|
|
2506
|
+
return succeed({ node, subject, args: args2 });
|
|
2399
2507
|
}
|
|
2400
2508
|
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
2401
2509
|
},
|
|
@@ -2487,6 +2595,53 @@ ${versions.map((version) => `- found ${version} at ${resolvedPackages[packageNam
|
|
|
2487
2595
|
})
|
|
2488
2596
|
});
|
|
2489
2597
|
|
|
2598
|
+
// src/diagnostics/effectInVoidSuccess.ts
|
|
2599
|
+
var effectInVoidSuccess = createDiagnostic({
|
|
2600
|
+
name: "effectInVoidSuccess",
|
|
2601
|
+
code: 14,
|
|
2602
|
+
severity: "warning",
|
|
2603
|
+
apply: fn("effectInVoidSuccess.apply")(function* (sourceFile, report) {
|
|
2604
|
+
const ts = yield* service(TypeScriptApi);
|
|
2605
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
2606
|
+
const typeParser = yield* service(TypeParser);
|
|
2607
|
+
const checkForEffectInVoid = fn("effectInVoidSuccess.checkForEffectInVoid")(function* (node, expectedType, valueNode, realType) {
|
|
2608
|
+
const expectedEffect = yield* typeParser.effectType(expectedType, node);
|
|
2609
|
+
const realEffect = yield* typeParser.effectType(realType, valueNode);
|
|
2610
|
+
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
2611
|
+
const voidValueTypes = unrollUnionMembers(realEffect.A);
|
|
2612
|
+
const voidedEffect = yield* firstSuccessOf(
|
|
2613
|
+
voidValueTypes.map((_) => map3(typeParser.strictEffectType(_, node), () => _))
|
|
2614
|
+
);
|
|
2615
|
+
return { voidedEffect };
|
|
2616
|
+
}
|
|
2617
|
+
return yield* fail(typeParserIssue("expectedEffect success is not void"));
|
|
2618
|
+
});
|
|
2619
|
+
const entries = yield* expectedAndRealType(sourceFile);
|
|
2620
|
+
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
2621
|
+
if (expectedType !== realType) {
|
|
2622
|
+
yield* pipe(
|
|
2623
|
+
checkForEffectInVoid(
|
|
2624
|
+
node,
|
|
2625
|
+
expectedType,
|
|
2626
|
+
valueNode,
|
|
2627
|
+
realType
|
|
2628
|
+
),
|
|
2629
|
+
map3(({ voidedEffect }) => {
|
|
2630
|
+
report(
|
|
2631
|
+
{
|
|
2632
|
+
node,
|
|
2633
|
+
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.`,
|
|
2634
|
+
fixes: []
|
|
2635
|
+
}
|
|
2636
|
+
);
|
|
2637
|
+
}),
|
|
2638
|
+
ignore
|
|
2639
|
+
);
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
})
|
|
2643
|
+
});
|
|
2644
|
+
|
|
2490
2645
|
// src/diagnostics/floatingEffect.ts
|
|
2491
2646
|
var floatingEffect = createDiagnostic({
|
|
2492
2647
|
name: "floatingEffect",
|
|
@@ -2756,7 +2911,18 @@ var leakingRequirements = createDiagnostic({
|
|
|
2756
2911
|
);
|
|
2757
2912
|
if (effectContextType) {
|
|
2758
2913
|
effectMembers++;
|
|
2759
|
-
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
2914
|
+
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
2915
|
+
memory,
|
|
2916
|
+
effectContextType,
|
|
2917
|
+
(type) => {
|
|
2918
|
+
if (type.flags & ts.TypeFlags.Never) return succeed(true);
|
|
2919
|
+
return pipe(
|
|
2920
|
+
typeParser.scopeType(type, atLocation),
|
|
2921
|
+
map3(() => true),
|
|
2922
|
+
orElse2(() => succeed(false))
|
|
2923
|
+
);
|
|
2924
|
+
}
|
|
2925
|
+
);
|
|
2760
2926
|
if (!sharedRequirementsKeys) {
|
|
2761
2927
|
sharedRequirementsKeys = allIndexes;
|
|
2762
2928
|
} else {
|
|
@@ -3309,6 +3475,51 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
3309
3475
|
})
|
|
3310
3476
|
});
|
|
3311
3477
|
|
|
3478
|
+
// src/diagnostics/tryCatchInEffectGen.ts
|
|
3479
|
+
var tryCatchInEffectGen = createDiagnostic({
|
|
3480
|
+
name: "tryCatchInEffectGen",
|
|
3481
|
+
code: 12,
|
|
3482
|
+
severity: "suggestion",
|
|
3483
|
+
apply: fn("tryCatchInEffectGen.apply")(function* (sourceFile, report) {
|
|
3484
|
+
const ts = yield* service(TypeScriptApi);
|
|
3485
|
+
const typeParser = yield* service(TypeParser);
|
|
3486
|
+
const nodeToVisit = [];
|
|
3487
|
+
const appendNodeToVisit = (node) => {
|
|
3488
|
+
nodeToVisit.push(node);
|
|
3489
|
+
return void 0;
|
|
3490
|
+
};
|
|
3491
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3492
|
+
while (nodeToVisit.length > 0) {
|
|
3493
|
+
const node = nodeToVisit.shift();
|
|
3494
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3495
|
+
if (ts.isTryStatement(node)) {
|
|
3496
|
+
const generatorOrRegularFunction = ts.findAncestor(
|
|
3497
|
+
node,
|
|
3498
|
+
(_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isArrowFunction(_) || ts.isGetAccessor(_) || ts.isFunctionLike(_)
|
|
3499
|
+
);
|
|
3500
|
+
if (!(generatorOrRegularFunction && "asteriskToken" in generatorOrRegularFunction && generatorOrRegularFunction.asteriskToken)) continue;
|
|
3501
|
+
if (!generatorOrRegularFunction) continue;
|
|
3502
|
+
if (generatorOrRegularFunction && generatorOrRegularFunction.parent) {
|
|
3503
|
+
const effectGenNode = generatorOrRegularFunction.parent;
|
|
3504
|
+
yield* pipe(
|
|
3505
|
+
typeParser.effectGen(effectGenNode),
|
|
3506
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3507
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3508
|
+
map3(() => {
|
|
3509
|
+
report({
|
|
3510
|
+
node,
|
|
3511
|
+
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).",
|
|
3512
|
+
fixes: []
|
|
3513
|
+
});
|
|
3514
|
+
}),
|
|
3515
|
+
ignore
|
|
3516
|
+
);
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
})
|
|
3521
|
+
});
|
|
3522
|
+
|
|
3312
3523
|
// src/diagnostics/unnecessaryEffectGen.ts
|
|
3313
3524
|
var unnecessaryEffectGen = createDiagnostic({
|
|
3314
3525
|
name: "unnecessaryEffectGen",
|
|
@@ -3372,8 +3583,8 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
3372
3583
|
if (ts.isCallExpression(node)) {
|
|
3373
3584
|
yield* pipe(
|
|
3374
3585
|
typeParser.pipeCall(node),
|
|
3375
|
-
map3(({ args, subject }) => {
|
|
3376
|
-
if (
|
|
3586
|
+
map3(({ args: args2, subject }) => {
|
|
3587
|
+
if (args2.length === 0) {
|
|
3377
3588
|
report({
|
|
3378
3589
|
node,
|
|
3379
3590
|
messageText: `This pipe call contains no arguments.`,
|
|
@@ -3410,8 +3621,10 @@ var diagnostics = [
|
|
|
3410
3621
|
unnecessaryPipe,
|
|
3411
3622
|
genericEffectServices,
|
|
3412
3623
|
returnEffectInGen,
|
|
3624
|
+
tryCatchInEffectGen,
|
|
3413
3625
|
importFromBarrel,
|
|
3414
|
-
scopeInLayerEffect
|
|
3626
|
+
scopeInLayerEffect,
|
|
3627
|
+
effectInVoidSuccess
|
|
3415
3628
|
];
|
|
3416
3629
|
|
|
3417
3630
|
// src/transform.ts
|
|
@@ -3423,7 +3636,7 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
|
|
|
3423
3636
|
provideService(TypeScriptApi, tsInstance),
|
|
3424
3637
|
provideService(TypeScriptProgram, program),
|
|
3425
3638
|
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
3426
|
-
provideService(TypeParser,
|
|
3639
|
+
provideService(TypeParser, make2(tsInstance, program.getTypeChecker())),
|
|
3427
3640
|
provideService(
|
|
3428
3641
|
TypeCheckerApiCache,
|
|
3429
3642
|
makeTypeCheckerApiCache()
|