@effect/language-service 0.24.2 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cli.js +747 -520
- package/cli.js.map +1 -1
- package/index.js +529 -308
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +360 -182
- 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,253 @@ 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
|
+
runLoop(nano) {
|
|
906
|
+
let current = nano;
|
|
907
|
+
while (true) {
|
|
908
|
+
current = current[evaluate](this);
|
|
909
|
+
if (current === NanoYield) {
|
|
910
|
+
return this._yielded;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
getCont(symbol3) {
|
|
915
|
+
while (true) {
|
|
916
|
+
const op = this._stack.pop();
|
|
917
|
+
if (!op) return void 0;
|
|
918
|
+
const cont = op[contAll] && op[contAll](this);
|
|
919
|
+
if (cont) return { [symbol3]: cont };
|
|
920
|
+
if (op[symbol3]) return op;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
yieldWith(value) {
|
|
924
|
+
this._yielded = value;
|
|
925
|
+
return NanoYield;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
var unsafeRun = (nano) => {
|
|
929
|
+
const fiber = new NanoFiber();
|
|
930
|
+
const result = fiber.runLoop(nano);
|
|
931
|
+
if (result._tag === "Success") {
|
|
932
|
+
return right2(result.value);
|
|
933
|
+
}
|
|
934
|
+
return left2(result.value);
|
|
935
|
+
};
|
|
936
|
+
var run = (nano) => {
|
|
877
937
|
try {
|
|
878
|
-
return unsafeRun(
|
|
938
|
+
return unsafeRun(nano);
|
|
879
939
|
} catch (e) {
|
|
880
940
|
return left2(new NanoDefectException(e));
|
|
881
941
|
}
|
|
882
942
|
};
|
|
883
|
-
var
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
943
|
+
var OnSuccessProto = {
|
|
944
|
+
...PrimitiveProto,
|
|
945
|
+
[evaluate](fiber) {
|
|
946
|
+
fiber._stack.push(this);
|
|
947
|
+
return this[args];
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
var flatMap2 = dual(2, (fa, f) => {
|
|
951
|
+
const nano = Object.create(OnSuccessProto);
|
|
952
|
+
nano[args] = fa;
|
|
953
|
+
nano[contA] = f;
|
|
890
954
|
return nano;
|
|
955
|
+
});
|
|
956
|
+
var map3 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
|
|
957
|
+
var SyncProto = {
|
|
958
|
+
...PrimitiveProto,
|
|
959
|
+
[evaluate](fiber) {
|
|
960
|
+
const value = this[args]();
|
|
961
|
+
const cont = fiber.getCont(contA);
|
|
962
|
+
return cont ? cont[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
963
|
+
}
|
|
891
964
|
};
|
|
892
|
-
var
|
|
893
|
-
const nano =
|
|
894
|
-
|
|
895
|
-
[Symbol.iterator]() {
|
|
896
|
-
return new SingleShotGen(new YieldWrap(this));
|
|
897
|
-
}
|
|
898
|
-
};
|
|
965
|
+
var sync = (f) => {
|
|
966
|
+
const nano = Object.create(SyncProto);
|
|
967
|
+
nano[args] = f;
|
|
899
968
|
return nano;
|
|
900
969
|
};
|
|
901
|
-
var
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
970
|
+
var void_ = succeed(void 0);
|
|
971
|
+
var FromIteratorProto = {
|
|
972
|
+
...PrimitiveProto,
|
|
973
|
+
[contA](value, fiber) {
|
|
974
|
+
const state = this[args][0].next(value);
|
|
975
|
+
if (state.done) return succeed(state.value);
|
|
976
|
+
fiber._stack.push(this);
|
|
977
|
+
return yieldWrapGet(state.value);
|
|
978
|
+
},
|
|
979
|
+
[evaluate](fiber) {
|
|
980
|
+
return this[contA](this[args][1], fiber);
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
var unsafeFromIterator = (iterator, initial) => {
|
|
984
|
+
const nano = Object.create(FromIteratorProto);
|
|
985
|
+
nano[args] = [iterator, initial];
|
|
986
|
+
return nano;
|
|
987
|
+
};
|
|
988
|
+
var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
|
|
989
|
+
var fn = (_) => (body) => (...args2) => suspend(() => unsafeFromIterator(body(...args2)));
|
|
990
|
+
var MatchProto = {
|
|
991
|
+
...PrimitiveProto,
|
|
992
|
+
[evaluate](fiber) {
|
|
993
|
+
fiber._stack.push(this);
|
|
994
|
+
return this[args];
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
var match2 = (fa, opts) => {
|
|
998
|
+
const nano = Object.create(MatchProto);
|
|
999
|
+
nano[args] = fa;
|
|
1000
|
+
nano[contA] = opts.onSuccess;
|
|
1001
|
+
nano[contE] = opts.onFailure;
|
|
1002
|
+
return nano;
|
|
1003
|
+
};
|
|
1004
|
+
var orElse2 = (f) => (fa) => {
|
|
1005
|
+
const nano = Object.create(MatchProto);
|
|
1006
|
+
nano[args] = fa;
|
|
1007
|
+
nano[contE] = f;
|
|
908
1008
|
return nano;
|
|
909
1009
|
};
|
|
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
1010
|
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);
|
|
1011
|
+
var ProvideServiceProto = {
|
|
1012
|
+
...PrimitiveProto,
|
|
1013
|
+
[evaluate](fiber) {
|
|
1014
|
+
const prevServices = fiber._services;
|
|
1015
|
+
const [fa, tag, value] = this[args];
|
|
1016
|
+
fiber._services = {
|
|
1017
|
+
...fiber._services,
|
|
1018
|
+
[tag.key]: value
|
|
1019
|
+
};
|
|
1020
|
+
return match2(fa, {
|
|
1021
|
+
onSuccess: (_) => {
|
|
1022
|
+
fiber._services = prevServices;
|
|
1023
|
+
return succeed(_);
|
|
1024
|
+
},
|
|
1025
|
+
onFailure: (_) => {
|
|
1026
|
+
fiber._services = prevServices;
|
|
1027
|
+
return fail(_);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
948
1030
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1031
|
+
};
|
|
1032
|
+
var provideService = (tag, value) => (fa) => {
|
|
1033
|
+
const nano = Object.create(ProvideServiceProto);
|
|
1034
|
+
nano[args] = [fa, tag, value];
|
|
1035
|
+
return nano;
|
|
1036
|
+
};
|
|
1037
|
+
var ServiceProto = {
|
|
1038
|
+
...PrimitiveProto,
|
|
1039
|
+
[evaluate](fiber) {
|
|
1040
|
+
const tag = this[args];
|
|
1041
|
+
if (tag.key in fiber._services) {
|
|
1042
|
+
const value = fiber._services[tag.key];
|
|
1043
|
+
const cont2 = fiber.getCont(contA);
|
|
1044
|
+
return cont2 ? cont2[contA](value, fiber) : fiber.yieldWith(succeed(value));
|
|
1045
|
+
}
|
|
1046
|
+
const cont = fiber.getCont(contE);
|
|
1047
|
+
return cont ? cont[contE](tag, fiber) : fiber.yieldWith(fail(new NanoDefectException(`Service ${tag.key} not found`)));
|
|
961
1048
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1049
|
+
};
|
|
1050
|
+
var service = (tag) => {
|
|
1051
|
+
const nano = Object.create(ServiceProto);
|
|
1052
|
+
nano[args] = tag;
|
|
1053
|
+
return nano;
|
|
1054
|
+
};
|
|
1055
|
+
function cachedBy(fa, _key, _lookupKey) {
|
|
1056
|
+
return (...args2) => fa(...args2);
|
|
1057
|
+
}
|
|
1058
|
+
var option = (fa) => {
|
|
1059
|
+
const nano = Object.create(MatchProto);
|
|
1060
|
+
nano[args] = fa;
|
|
1061
|
+
nano[contA] = (_) => succeed(some2(_));
|
|
1062
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : succeed(none2());
|
|
1063
|
+
return nano;
|
|
1064
|
+
};
|
|
1065
|
+
var ignore = (fa) => {
|
|
1066
|
+
const nano = Object.create(MatchProto);
|
|
1067
|
+
nano[args] = fa;
|
|
1068
|
+
nano[contA] = (_) => void_;
|
|
1069
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : void_;
|
|
1070
|
+
return nano;
|
|
1071
|
+
};
|
|
1072
|
+
var all = fn("all")(
|
|
1073
|
+
function* (...args2) {
|
|
1074
|
+
const results = [];
|
|
1075
|
+
for (const fa of args2) {
|
|
1076
|
+
const result = yield* fa;
|
|
1077
|
+
results.push(result);
|
|
1078
|
+
}
|
|
1079
|
+
return results;
|
|
973
1080
|
}
|
|
974
|
-
});
|
|
975
|
-
var successUndefined = makeInternalSuccess(void 0);
|
|
976
|
-
var void_ = make2(() => successUndefined);
|
|
977
|
-
var ignore = (fa) => make2((ctx) => {
|
|
978
|
-
fa.run(ctx);
|
|
979
|
-
return successUndefined;
|
|
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
1081
|
);
|
|
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
|
-
});
|
|
1010
|
-
}
|
|
1011
1082
|
|
|
1012
1083
|
// src/core/LanguageServicePluginOptions.ts
|
|
1013
1084
|
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
@@ -1213,10 +1284,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1213
1284
|
const sectionOverrides = {};
|
|
1214
1285
|
const skippedRules = [];
|
|
1215
1286
|
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 =
|
|
1287
|
+
let match3;
|
|
1288
|
+
while ((match3 = regex.exec(sourceFile.text)) !== null) {
|
|
1289
|
+
const nextLineCaptureGroup = match3[1];
|
|
1290
|
+
const rulesCaptureGroup = match3[2];
|
|
1220
1291
|
if (rulesCaptureGroup) {
|
|
1221
1292
|
const trimmedRuleString = rulesCaptureGroup.trim();
|
|
1222
1293
|
if (trimmedRuleString) {
|
|
@@ -1228,7 +1299,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1228
1299
|
if (ruleLevel === "skip-file") skippedRules.push(ruleName);
|
|
1229
1300
|
const isOverrideNextLine = nextLineCaptureGroup && nextLineCaptureGroup.trim().toLowerCase() === "-next-line";
|
|
1230
1301
|
if (isOverrideNextLine) {
|
|
1231
|
-
const node = findNodeWithLeadingCommentAtPosition(
|
|
1302
|
+
const node = findNodeWithLeadingCommentAtPosition(match3.index);
|
|
1232
1303
|
if (node) {
|
|
1233
1304
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1234
1305
|
lineOverrides[ruleName].unshift({
|
|
@@ -1240,7 +1311,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1240
1311
|
} else {
|
|
1241
1312
|
sectionOverrides[ruleName] = sectionOverrides[ruleName] || [];
|
|
1242
1313
|
sectionOverrides[ruleName].unshift({
|
|
1243
|
-
pos:
|
|
1314
|
+
pos: match3.index,
|
|
1244
1315
|
level: ruleLevel
|
|
1245
1316
|
});
|
|
1246
1317
|
}
|
|
@@ -1543,6 +1614,19 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
|
|
|
1543
1614
|
cache.expectedAndRealType.set(sourceFile, result);
|
|
1544
1615
|
return result;
|
|
1545
1616
|
});
|
|
1617
|
+
var unrollUnionMembers = (type) => {
|
|
1618
|
+
const result = [];
|
|
1619
|
+
let toTest = [type];
|
|
1620
|
+
while (toTest.length > 0) {
|
|
1621
|
+
const type2 = toTest.pop();
|
|
1622
|
+
if (type2.isUnion()) {
|
|
1623
|
+
toTest = toTest.concat(type2.types);
|
|
1624
|
+
} else {
|
|
1625
|
+
result.push(type2);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
return result;
|
|
1629
|
+
};
|
|
1546
1630
|
var appendToUniqueTypesMap = fn(
|
|
1547
1631
|
"TypeCheckerApi.appendToUniqueTypesMap"
|
|
1548
1632
|
)(
|
|
@@ -1946,10 +2030,10 @@ var TypeParserIssue = class _TypeParserIssue {
|
|
|
1946
2030
|
_tag = "@effect/language-service/TypeParserIssue";
|
|
1947
2031
|
static issue = fail(new _TypeParserIssue());
|
|
1948
2032
|
};
|
|
1949
|
-
function
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2033
|
+
function typeParserIssue(_message, _type, _node) {
|
|
2034
|
+
return TypeParserIssue.issue;
|
|
2035
|
+
}
|
|
2036
|
+
function make2(ts, typeChecker) {
|
|
1953
2037
|
function covariantTypeArgument(type) {
|
|
1954
2038
|
const signatures = type.getCallSignatures();
|
|
1955
2039
|
if (signatures.length !== 1) {
|
|
@@ -2394,8 +2478,8 @@ function make3(ts, typeChecker) {
|
|
|
2394
2478
|
return succeed({ node, subject: node.expression.expression, args: Array.from(node.arguments) });
|
|
2395
2479
|
}
|
|
2396
2480
|
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 });
|
|
2481
|
+
const [subject, ...args2] = node.arguments;
|
|
2482
|
+
return succeed({ node, subject, args: args2 });
|
|
2399
2483
|
}
|
|
2400
2484
|
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
2401
2485
|
},
|
|
@@ -2487,6 +2571,53 @@ ${versions.map((version) => `- found ${version} at ${resolvedPackages[packageNam
|
|
|
2487
2571
|
})
|
|
2488
2572
|
});
|
|
2489
2573
|
|
|
2574
|
+
// src/diagnostics/effectInVoidSuccess.ts
|
|
2575
|
+
var effectInVoidSuccess = createDiagnostic({
|
|
2576
|
+
name: "effectInVoidSuccess",
|
|
2577
|
+
code: 14,
|
|
2578
|
+
severity: "warning",
|
|
2579
|
+
apply: fn("effectInVoidSuccess.apply")(function* (sourceFile, report) {
|
|
2580
|
+
const ts = yield* service(TypeScriptApi);
|
|
2581
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
2582
|
+
const typeParser = yield* service(TypeParser);
|
|
2583
|
+
const checkForEffectInVoid = fn("effectInVoidSuccess.checkForEffectInVoid")(function* (node, expectedType, valueNode, realType) {
|
|
2584
|
+
const expectedEffect = yield* typeParser.effectType(expectedType, node);
|
|
2585
|
+
const realEffect = yield* typeParser.effectType(realType, valueNode);
|
|
2586
|
+
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
2587
|
+
const voidValueTypes = unrollUnionMembers(realEffect.A);
|
|
2588
|
+
const voidedEffect = yield* firstSuccessOf(
|
|
2589
|
+
voidValueTypes.map((_) => map3(typeParser.strictEffectType(_, node), () => _))
|
|
2590
|
+
);
|
|
2591
|
+
return { voidedEffect };
|
|
2592
|
+
}
|
|
2593
|
+
return yield* fail(typeParserIssue("expectedEffect success is not void"));
|
|
2594
|
+
});
|
|
2595
|
+
const entries = yield* expectedAndRealType(sourceFile);
|
|
2596
|
+
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
2597
|
+
if (expectedType !== realType) {
|
|
2598
|
+
yield* pipe(
|
|
2599
|
+
checkForEffectInVoid(
|
|
2600
|
+
node,
|
|
2601
|
+
expectedType,
|
|
2602
|
+
valueNode,
|
|
2603
|
+
realType
|
|
2604
|
+
),
|
|
2605
|
+
map3(({ voidedEffect }) => {
|
|
2606
|
+
report(
|
|
2607
|
+
{
|
|
2608
|
+
node,
|
|
2609
|
+
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.`,
|
|
2610
|
+
fixes: []
|
|
2611
|
+
}
|
|
2612
|
+
);
|
|
2613
|
+
}),
|
|
2614
|
+
ignore
|
|
2615
|
+
);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
})
|
|
2619
|
+
});
|
|
2620
|
+
|
|
2490
2621
|
// src/diagnostics/floatingEffect.ts
|
|
2491
2622
|
var floatingEffect = createDiagnostic({
|
|
2492
2623
|
name: "floatingEffect",
|
|
@@ -3309,6 +3440,51 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
3309
3440
|
})
|
|
3310
3441
|
});
|
|
3311
3442
|
|
|
3443
|
+
// src/diagnostics/tryCatchInEffectGen.ts
|
|
3444
|
+
var tryCatchInEffectGen = createDiagnostic({
|
|
3445
|
+
name: "tryCatchInEffectGen",
|
|
3446
|
+
code: 12,
|
|
3447
|
+
severity: "warning",
|
|
3448
|
+
apply: fn("tryCatchInEffectGen.apply")(function* (sourceFile, report) {
|
|
3449
|
+
const ts = yield* service(TypeScriptApi);
|
|
3450
|
+
const typeParser = yield* service(TypeParser);
|
|
3451
|
+
const nodeToVisit = [];
|
|
3452
|
+
const appendNodeToVisit = (node) => {
|
|
3453
|
+
nodeToVisit.push(node);
|
|
3454
|
+
return void 0;
|
|
3455
|
+
};
|
|
3456
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3457
|
+
while (nodeToVisit.length > 0) {
|
|
3458
|
+
const node = nodeToVisit.shift();
|
|
3459
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3460
|
+
if (ts.isTryStatement(node)) {
|
|
3461
|
+
const generatorOrRegularFunction = ts.findAncestor(
|
|
3462
|
+
node,
|
|
3463
|
+
(_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isArrowFunction(_) || ts.isGetAccessor(_) || ts.isFunctionLike(_)
|
|
3464
|
+
);
|
|
3465
|
+
if (!(generatorOrRegularFunction && "asteriskToken" in generatorOrRegularFunction && generatorOrRegularFunction.asteriskToken)) continue;
|
|
3466
|
+
if (!generatorOrRegularFunction) continue;
|
|
3467
|
+
if (generatorOrRegularFunction && generatorOrRegularFunction.parent) {
|
|
3468
|
+
const effectGenNode = generatorOrRegularFunction.parent;
|
|
3469
|
+
yield* pipe(
|
|
3470
|
+
typeParser.effectGen(effectGenNode),
|
|
3471
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3472
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3473
|
+
map3(() => {
|
|
3474
|
+
report({
|
|
3475
|
+
node,
|
|
3476
|
+
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).",
|
|
3477
|
+
fixes: []
|
|
3478
|
+
});
|
|
3479
|
+
}),
|
|
3480
|
+
ignore
|
|
3481
|
+
);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
})
|
|
3486
|
+
});
|
|
3487
|
+
|
|
3312
3488
|
// src/diagnostics/unnecessaryEffectGen.ts
|
|
3313
3489
|
var unnecessaryEffectGen = createDiagnostic({
|
|
3314
3490
|
name: "unnecessaryEffectGen",
|
|
@@ -3372,8 +3548,8 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
3372
3548
|
if (ts.isCallExpression(node)) {
|
|
3373
3549
|
yield* pipe(
|
|
3374
3550
|
typeParser.pipeCall(node),
|
|
3375
|
-
map3(({ args, subject }) => {
|
|
3376
|
-
if (
|
|
3551
|
+
map3(({ args: args2, subject }) => {
|
|
3552
|
+
if (args2.length === 0) {
|
|
3377
3553
|
report({
|
|
3378
3554
|
node,
|
|
3379
3555
|
messageText: `This pipe call contains no arguments.`,
|
|
@@ -3410,8 +3586,10 @@ var diagnostics = [
|
|
|
3410
3586
|
unnecessaryPipe,
|
|
3411
3587
|
genericEffectServices,
|
|
3412
3588
|
returnEffectInGen,
|
|
3589
|
+
tryCatchInEffectGen,
|
|
3413
3590
|
importFromBarrel,
|
|
3414
|
-
scopeInLayerEffect
|
|
3591
|
+
scopeInLayerEffect,
|
|
3592
|
+
effectInVoidSuccess
|
|
3415
3593
|
];
|
|
3416
3594
|
|
|
3417
3595
|
// src/transform.ts
|
|
@@ -3423,7 +3601,7 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
|
|
|
3423
3601
|
provideService(TypeScriptApi, tsInstance),
|
|
3424
3602
|
provideService(TypeScriptProgram, program),
|
|
3425
3603
|
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
3426
|
-
provideService(TypeParser,
|
|
3604
|
+
provideService(TypeParser, make2(tsInstance, program.getTypeChecker())),
|
|
3427
3605
|
provideService(
|
|
3428
3606
|
TypeCheckerApiCache,
|
|
3429
3607
|
makeTypeCheckerApiCache()
|