@effect/language-service 0.21.8 → 0.22.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 +10 -6
- package/index.js +617 -433
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +258 -149
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __export = (target, all3) => {
|
|
4
|
-
for (var name in all3)
|
|
5
|
-
__defProp(target, name, { get: all3[name], enumerable: true });
|
|
6
|
-
};
|
|
7
2
|
|
|
8
3
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Function.js
|
|
9
4
|
var isFunction = (input) => typeof input === "function";
|
|
@@ -70,7 +65,6 @@ var dual = function(arity, body) {
|
|
|
70
65
|
};
|
|
71
66
|
var identity = (a) => a;
|
|
72
67
|
var constant = (value) => () => value;
|
|
73
|
-
var constNull = /* @__PURE__ */ constant(null);
|
|
74
68
|
var constUndefined = /* @__PURE__ */ constant(void 0);
|
|
75
69
|
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
76
70
|
switch (arguments.length) {
|
|
@@ -102,50 +96,6 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
102
96
|
}
|
|
103
97
|
}
|
|
104
98
|
|
|
105
|
-
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Either.js
|
|
106
|
-
var Either_exports = {};
|
|
107
|
-
__export(Either_exports, {
|
|
108
|
-
Do: () => Do,
|
|
109
|
-
TypeId: () => TypeId3,
|
|
110
|
-
all: () => all,
|
|
111
|
-
andThen: () => andThen,
|
|
112
|
-
ap: () => ap,
|
|
113
|
-
bind: () => bind2,
|
|
114
|
-
bindTo: () => bindTo2,
|
|
115
|
-
filterOrLeft: () => filterOrLeft,
|
|
116
|
-
flatMap: () => flatMap,
|
|
117
|
-
flip: () => flip,
|
|
118
|
-
fromNullable: () => fromNullable,
|
|
119
|
-
fromOption: () => fromOption2,
|
|
120
|
-
gen: () => gen,
|
|
121
|
-
getEquivalence: () => getEquivalence,
|
|
122
|
-
getLeft: () => getLeft2,
|
|
123
|
-
getOrElse: () => getOrElse,
|
|
124
|
-
getOrNull: () => getOrNull,
|
|
125
|
-
getOrThrow: () => getOrThrow,
|
|
126
|
-
getOrThrowWith: () => getOrThrowWith,
|
|
127
|
-
getOrUndefined: () => getOrUndefined,
|
|
128
|
-
getRight: () => getRight2,
|
|
129
|
-
isEither: () => isEither2,
|
|
130
|
-
isLeft: () => isLeft2,
|
|
131
|
-
isRight: () => isRight2,
|
|
132
|
-
left: () => left2,
|
|
133
|
-
let: () => let_2,
|
|
134
|
-
liftPredicate: () => liftPredicate,
|
|
135
|
-
map: () => map,
|
|
136
|
-
mapBoth: () => mapBoth,
|
|
137
|
-
mapLeft: () => mapLeft,
|
|
138
|
-
match: () => match,
|
|
139
|
-
merge: () => merge,
|
|
140
|
-
orElse: () => orElse,
|
|
141
|
-
right: () => right2,
|
|
142
|
-
transposeMapOption: () => transposeMapOption,
|
|
143
|
-
transposeOption: () => transposeOption,
|
|
144
|
-
try: () => try_,
|
|
145
|
-
void: () => void_,
|
|
146
|
-
zipWith: () => zipWith
|
|
147
|
-
});
|
|
148
|
-
|
|
149
99
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Equivalence.js
|
|
150
100
|
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
151
101
|
var array = (item) => make((self, that) => {
|
|
@@ -161,17 +111,6 @@ var array = (item) => make((self, that) => {
|
|
|
161
111
|
return true;
|
|
162
112
|
});
|
|
163
113
|
|
|
164
|
-
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/doNotation.js
|
|
165
|
-
var let_ = (map5) => dual(3, (self, name, f) => map5(self, (a) => Object.assign({}, a, {
|
|
166
|
-
[name]: f(a)
|
|
167
|
-
})));
|
|
168
|
-
var bindTo = (map5) => dual(2, (self, name) => map5(self, (a) => ({
|
|
169
|
-
[name]: a
|
|
170
|
-
})));
|
|
171
|
-
var bind = (map5, flatMap4) => dual(3, (self, name, f) => flatMap4(self, (a) => map5(f(a), (b) => Object.assign({}, a, {
|
|
172
|
-
[name]: b
|
|
173
|
-
}))));
|
|
174
|
-
|
|
175
114
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/version.js
|
|
176
115
|
var moduleVersion = "3.16.5";
|
|
177
116
|
var getCurrentVersion = () => moduleVersion;
|
|
@@ -286,13 +225,6 @@ var SingleShotGen = class _SingleShotGen {
|
|
|
286
225
|
return new _SingleShotGen(this.self);
|
|
287
226
|
}
|
|
288
227
|
};
|
|
289
|
-
var adapter = () => function() {
|
|
290
|
-
let x = arguments[0];
|
|
291
|
-
for (let i = 1; i < arguments.length; i++) {
|
|
292
|
-
x = arguments[i](x);
|
|
293
|
-
}
|
|
294
|
-
return new GenKindImpl(x);
|
|
295
|
-
};
|
|
296
228
|
var MUL_HI = 1481765933 >>> 0;
|
|
297
229
|
var MUL_LO = 1284865837 >>> 0;
|
|
298
230
|
var YieldWrapTypeId = /* @__PURE__ */ Symbol.for("effect/Utils/YieldWrap");
|
|
@@ -786,122 +718,14 @@ var right = (right3) => {
|
|
|
786
718
|
a.right = right3;
|
|
787
719
|
return a;
|
|
788
720
|
};
|
|
789
|
-
var getLeft = (self) => isRight(self) ? none : some(self.left);
|
|
790
|
-
var getRight = (self) => isLeft(self) ? none : some(self.right);
|
|
791
|
-
var fromOption = /* @__PURE__ */ dual(2, (self, onNone) => isNone(self) ? left(onNone()) : right(self.value));
|
|
792
721
|
|
|
793
722
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Either.js
|
|
794
|
-
var TypeId3 = TypeId2;
|
|
795
723
|
var right2 = right;
|
|
796
|
-
var void_ = /* @__PURE__ */ right2(void 0);
|
|
797
724
|
var left2 = left;
|
|
798
|
-
var fromNullable = /* @__PURE__ */ dual(2, (self, onNullable) => self == null ? left2(onNullable(self)) : right2(self));
|
|
799
|
-
var fromOption2 = fromOption;
|
|
800
|
-
var try_ = (evaluate) => {
|
|
801
|
-
if (isFunction2(evaluate)) {
|
|
802
|
-
try {
|
|
803
|
-
return right2(evaluate());
|
|
804
|
-
} catch (e) {
|
|
805
|
-
return left2(e);
|
|
806
|
-
}
|
|
807
|
-
} else {
|
|
808
|
-
try {
|
|
809
|
-
return right2(evaluate.try());
|
|
810
|
-
} catch (e) {
|
|
811
|
-
return left2(evaluate.catch(e));
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
};
|
|
815
|
-
var isEither2 = isEither;
|
|
816
725
|
var isLeft2 = isLeft;
|
|
817
726
|
var isRight2 = isRight;
|
|
818
|
-
var getRight2 = getRight;
|
|
819
|
-
var getLeft2 = getLeft;
|
|
820
|
-
var getEquivalence = ({
|
|
821
|
-
left: left3,
|
|
822
|
-
right: right3
|
|
823
|
-
}) => make((x, y) => isLeft2(x) ? isLeft2(y) && left3(x.left, y.left) : isRight2(y) && right3(x.right, y.right));
|
|
824
|
-
var mapBoth = /* @__PURE__ */ dual(2, (self, {
|
|
825
|
-
onLeft,
|
|
826
|
-
onRight
|
|
827
|
-
}) => isLeft2(self) ? left2(onLeft(self.left)) : right2(onRight(self.right)));
|
|
828
|
-
var mapLeft = /* @__PURE__ */ dual(2, (self, f) => isLeft2(self) ? left2(f(self.left)) : right2(self.right));
|
|
829
727
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
830
|
-
var match = /* @__PURE__ */ dual(2, (self, {
|
|
831
|
-
onLeft,
|
|
832
|
-
onRight
|
|
833
|
-
}) => isLeft2(self) ? onLeft(self.left) : onRight(self.right));
|
|
834
|
-
var liftPredicate = /* @__PURE__ */ dual(3, (a, predicate, orLeftWith) => predicate(a) ? right2(a) : left2(orLeftWith(a)));
|
|
835
|
-
var filterOrLeft = /* @__PURE__ */ dual(3, (self, predicate, orLeftWith) => flatMap(self, (r) => predicate(r) ? right2(r) : left2(orLeftWith(r))));
|
|
836
|
-
var merge = /* @__PURE__ */ match({
|
|
837
|
-
onLeft: identity,
|
|
838
|
-
onRight: identity
|
|
839
|
-
});
|
|
840
728
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
841
|
-
var getOrNull = /* @__PURE__ */ getOrElse(constNull);
|
|
842
|
-
var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
|
|
843
|
-
var getOrThrowWith = /* @__PURE__ */ dual(2, (self, onLeft) => {
|
|
844
|
-
if (isRight2(self)) {
|
|
845
|
-
return self.right;
|
|
846
|
-
}
|
|
847
|
-
throw onLeft(self.left);
|
|
848
|
-
});
|
|
849
|
-
var getOrThrow = /* @__PURE__ */ getOrThrowWith(() => new Error("getOrThrow called on a Left"));
|
|
850
|
-
var orElse = /* @__PURE__ */ dual(2, (self, that) => isLeft2(self) ? that(self.left) : right2(self.right));
|
|
851
|
-
var flatMap = /* @__PURE__ */ dual(2, (self, f) => isLeft2(self) ? left2(self.left) : f(self.right));
|
|
852
|
-
var andThen = /* @__PURE__ */ dual(2, (self, f) => flatMap(self, (a) => {
|
|
853
|
-
const b = isFunction2(f) ? f(a) : f;
|
|
854
|
-
return isEither2(b) ? b : right2(b);
|
|
855
|
-
}));
|
|
856
|
-
var zipWith = /* @__PURE__ */ dual(3, (self, that, f) => flatMap(self, (r) => map(that, (r2) => f(r, r2))));
|
|
857
|
-
var ap = /* @__PURE__ */ dual(2, (self, that) => zipWith(self, that, (f, a) => f(a)));
|
|
858
|
-
var all = (input) => {
|
|
859
|
-
if (Symbol.iterator in input) {
|
|
860
|
-
const out2 = [];
|
|
861
|
-
for (const e of input) {
|
|
862
|
-
if (isLeft2(e)) {
|
|
863
|
-
return e;
|
|
864
|
-
}
|
|
865
|
-
out2.push(e.right);
|
|
866
|
-
}
|
|
867
|
-
return right2(out2);
|
|
868
|
-
}
|
|
869
|
-
const out = {};
|
|
870
|
-
for (const key of Object.keys(input)) {
|
|
871
|
-
const e = input[key];
|
|
872
|
-
if (isLeft2(e)) {
|
|
873
|
-
return e;
|
|
874
|
-
}
|
|
875
|
-
out[key] = e.right;
|
|
876
|
-
}
|
|
877
|
-
return right2(out);
|
|
878
|
-
};
|
|
879
|
-
var flip = (self) => isLeft2(self) ? right2(self.left) : left2(self.right);
|
|
880
|
-
var adapter2 = /* @__PURE__ */ adapter();
|
|
881
|
-
var gen = (...args) => {
|
|
882
|
-
const f = args.length === 1 ? args[0] : args[1].bind(args[0]);
|
|
883
|
-
const iterator = f(adapter2);
|
|
884
|
-
let state = iterator.next();
|
|
885
|
-
while (!state.done) {
|
|
886
|
-
const current = isGenKind(state.value) ? state.value.value : yieldWrapGet(state.value);
|
|
887
|
-
if (isLeft2(current)) {
|
|
888
|
-
return current;
|
|
889
|
-
}
|
|
890
|
-
state = iterator.next(current.right);
|
|
891
|
-
}
|
|
892
|
-
return right2(state.value);
|
|
893
|
-
};
|
|
894
|
-
var Do = /* @__PURE__ */ right2({});
|
|
895
|
-
var bind2 = /* @__PURE__ */ bind(map, flatMap);
|
|
896
|
-
var bindTo2 = /* @__PURE__ */ bindTo(map);
|
|
897
|
-
var let_2 = /* @__PURE__ */ let_(map);
|
|
898
|
-
var transposeOption = (self) => {
|
|
899
|
-
return isNone(self) ? right2(none) : map(self.value, some);
|
|
900
|
-
};
|
|
901
|
-
var transposeMapOption = /* @__PURE__ */ dual(2, (self, f) => isNone(self) ? right2(none) : map(f(self.value), some));
|
|
902
|
-
|
|
903
|
-
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/array.js
|
|
904
|
-
var isNonEmptyArray = (self) => self.length > 0;
|
|
905
729
|
|
|
906
730
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Order.js
|
|
907
731
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
@@ -911,16 +735,19 @@ var none2 = () => none;
|
|
|
911
735
|
var some2 = some;
|
|
912
736
|
var isNone2 = isNone;
|
|
913
737
|
var isSome2 = isSome;
|
|
914
|
-
var
|
|
738
|
+
var match = /* @__PURE__ */ dual(2, (self, {
|
|
915
739
|
onNone,
|
|
916
740
|
onSome
|
|
917
741
|
}) => isNone2(self) ? onNone() : onSome(self.value));
|
|
918
742
|
var getOrElse2 = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
|
|
919
|
-
var
|
|
920
|
-
var
|
|
921
|
-
var
|
|
743
|
+
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
|
|
744
|
+
var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
|
|
745
|
+
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
922
746
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
923
747
|
|
|
748
|
+
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/array.js
|
|
749
|
+
var isNonEmptyArray = (self) => self.length > 0;
|
|
750
|
+
|
|
924
751
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Array.js
|
|
925
752
|
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
926
753
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
@@ -965,7 +792,7 @@ var intersectionWith = (isEquivalent) => {
|
|
|
965
792
|
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
966
793
|
var empty = () => [];
|
|
967
794
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
|
|
968
|
-
var
|
|
795
|
+
var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
969
796
|
if (isEmptyReadonlyArray(self)) {
|
|
970
797
|
return [];
|
|
971
798
|
}
|
|
@@ -978,7 +805,7 @@ var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
978
805
|
}
|
|
979
806
|
return out;
|
|
980
807
|
});
|
|
981
|
-
var flatten = /* @__PURE__ */
|
|
808
|
+
var flatten = /* @__PURE__ */ flatMap(identity);
|
|
982
809
|
var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
983
810
|
const as = fromIterable(self);
|
|
984
811
|
const out = [];
|
|
@@ -1005,29 +832,11 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
|
1005
832
|
});
|
|
1006
833
|
|
|
1007
834
|
// src/core/Nano.ts
|
|
1008
|
-
var NanoInternalSuccessProto = {
|
|
1009
|
-
_tag: "Right"
|
|
1010
|
-
};
|
|
1011
835
|
function makeInternalSuccess(value) {
|
|
1012
|
-
|
|
1013
|
-
result.value = value;
|
|
1014
|
-
return result;
|
|
836
|
+
return { _tag: "Right", value };
|
|
1015
837
|
}
|
|
1016
|
-
var NanoInternalFailureProto = {
|
|
1017
|
-
_tag: "Left"
|
|
1018
|
-
};
|
|
1019
|
-
function makeInternalFailure(value) {
|
|
1020
|
-
const result = Object.create(NanoInternalFailureProto);
|
|
1021
|
-
result.value = value;
|
|
1022
|
-
return result;
|
|
1023
|
-
}
|
|
1024
|
-
var NanoInternalDefectProto = {
|
|
1025
|
-
_tag: "Defect"
|
|
1026
|
-
};
|
|
1027
838
|
function makeInternalDefect(value) {
|
|
1028
|
-
|
|
1029
|
-
result.value = value;
|
|
1030
|
-
return result;
|
|
839
|
+
return { _tag: "Defect", value };
|
|
1031
840
|
}
|
|
1032
841
|
var NanoDefectException = class {
|
|
1033
842
|
constructor(message) {
|
|
@@ -1042,17 +851,14 @@ var NanoTag = class {
|
|
|
1042
851
|
};
|
|
1043
852
|
var Tag = (identifier) => new NanoTag(identifier);
|
|
1044
853
|
var contextEmpty = { value: {} };
|
|
1045
|
-
var Proto = {
|
|
1046
|
-
run: () => {
|
|
1047
|
-
},
|
|
1048
|
-
[Symbol.iterator]() {
|
|
1049
|
-
return new SingleShotGen(new YieldWrap(this));
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
854
|
function make3(run2) {
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
855
|
+
const nano = {
|
|
856
|
+
run: run2,
|
|
857
|
+
[Symbol.iterator]() {
|
|
858
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
return nano;
|
|
1056
862
|
}
|
|
1057
863
|
var unsafeRun = (fa) => {
|
|
1058
864
|
const program = provideService(internalNanoCache, {})(fa);
|
|
@@ -1073,10 +879,34 @@ var run = (fa) => {
|
|
|
1073
879
|
return left2(new NanoDefectException(e));
|
|
1074
880
|
}
|
|
1075
881
|
};
|
|
1076
|
-
var succeed = (value) =>
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
882
|
+
var succeed = (value) => {
|
|
883
|
+
const nano = {
|
|
884
|
+
run: () => ({ _tag: "Right", value }),
|
|
885
|
+
[Symbol.iterator]() {
|
|
886
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
return nano;
|
|
890
|
+
};
|
|
891
|
+
var fail = (value) => {
|
|
892
|
+
const nano = {
|
|
893
|
+
run: () => ({ _tag: "Left", value }),
|
|
894
|
+
[Symbol.iterator]() {
|
|
895
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
return nano;
|
|
899
|
+
};
|
|
900
|
+
var sync = (value) => {
|
|
901
|
+
const nano = {
|
|
902
|
+
run: () => ({ _tag: "Right", value: value() }),
|
|
903
|
+
[Symbol.iterator]() {
|
|
904
|
+
return new SingleShotGen(new YieldWrap(this));
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
return nano;
|
|
908
|
+
};
|
|
909
|
+
var flatMap2 = dual(2, (fa, f) => make3((ctx) => {
|
|
1080
910
|
const result = fa.run(ctx);
|
|
1081
911
|
if (result._tag !== "Right") return result;
|
|
1082
912
|
return f(result.value).run(ctx);
|
|
@@ -1086,12 +916,12 @@ var map4 = dual(2, (fa, f) => make3((ctx) => {
|
|
|
1086
916
|
if (result._tag !== "Right") return result;
|
|
1087
917
|
return makeInternalSuccess(f(result.value));
|
|
1088
918
|
}));
|
|
1089
|
-
var
|
|
919
|
+
var orElse2 = (f) => (fa) => make3((ctx) => {
|
|
1090
920
|
const result = fa.run(ctx);
|
|
1091
921
|
if (result._tag === "Left") return f(result.value).run(ctx);
|
|
1092
922
|
return result;
|
|
1093
923
|
});
|
|
1094
|
-
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) =>
|
|
924
|
+
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
|
|
1095
925
|
var service = (tag) => make3(
|
|
1096
926
|
(ctx) => tag.key in ctx.value ? ctx.value[tag.key] : makeInternalDefect(`Cannot find service ${tag.key}`)
|
|
1097
927
|
);
|
|
@@ -1104,7 +934,7 @@ var provideService = (tag, value) => (fa) => make3((ctx) => {
|
|
|
1104
934
|
}
|
|
1105
935
|
});
|
|
1106
936
|
});
|
|
1107
|
-
var
|
|
937
|
+
var gen = (...args) => make3((ctx) => {
|
|
1108
938
|
const iterator = args[0]();
|
|
1109
939
|
let state = iterator.next();
|
|
1110
940
|
while (!state.done) {
|
|
@@ -1142,12 +972,12 @@ var option = (fa) => make3((ctx) => {
|
|
|
1142
972
|
}
|
|
1143
973
|
});
|
|
1144
974
|
var successUndefined = makeInternalSuccess(void 0);
|
|
1145
|
-
var
|
|
975
|
+
var void_ = make3(() => successUndefined);
|
|
1146
976
|
var ignore = (fa) => make3((ctx) => {
|
|
1147
977
|
fa.run(ctx);
|
|
1148
978
|
return successUndefined;
|
|
1149
979
|
});
|
|
1150
|
-
var
|
|
980
|
+
var all = (...args) => make3((ctx) => {
|
|
1151
981
|
const results = [];
|
|
1152
982
|
for (const arg of args) {
|
|
1153
983
|
const result = arg.run(ctx);
|
|
@@ -1168,8 +998,9 @@ function cachedBy(fa, key, lookupKey) {
|
|
|
1168
998
|
cacheObj[key] = cache;
|
|
1169
999
|
}
|
|
1170
1000
|
const lookup = lookupKey(...args);
|
|
1171
|
-
|
|
1172
|
-
|
|
1001
|
+
const cached2 = cache.get(lookup);
|
|
1002
|
+
if (cached2 !== void 0) {
|
|
1003
|
+
return cached2;
|
|
1173
1004
|
}
|
|
1174
1005
|
const result = fa(...args).run(ctx);
|
|
1175
1006
|
cache.set(lookup, result);
|
|
@@ -1205,6 +1036,20 @@ function parsePackageContentNameAndVersionFromScope(v) {
|
|
|
1205
1036
|
packageDirectory: packageJsonScope.packageDirectory
|
|
1206
1037
|
};
|
|
1207
1038
|
}
|
|
1039
|
+
function makeGetModuleSpecifier(ts) {
|
|
1040
|
+
if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction2(ts.moduleSpecifiers.getModuleSpecifier))) return;
|
|
1041
|
+
const _internal = ts.moduleSpecifiers.getModuleSpecifier;
|
|
1042
|
+
return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) => {
|
|
1043
|
+
return _internal(
|
|
1044
|
+
compilerOptions,
|
|
1045
|
+
importingSourceFile,
|
|
1046
|
+
importingSourceFileName,
|
|
1047
|
+
toFileName,
|
|
1048
|
+
host,
|
|
1049
|
+
options
|
|
1050
|
+
);
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1208
1053
|
|
|
1209
1054
|
// src/core/AST.ts
|
|
1210
1055
|
function collectSelfAndAncestorNodesInRange(node, textRange) {
|
|
@@ -1364,8 +1209,8 @@ var findImportedModuleIdentifier = fn("AST.findImportedModuleIdentifier")(
|
|
|
1364
1209
|
}
|
|
1365
1210
|
} else if (ts.isNamedImports(namedBindings)) {
|
|
1366
1211
|
for (const importSpecifier of namedBindings.elements) {
|
|
1367
|
-
const importProperty =
|
|
1368
|
-
|
|
1212
|
+
const importProperty = fromNullable(importSpecifier.propertyName).pipe(
|
|
1213
|
+
orElse(() => some2(importSpecifier.name))
|
|
1369
1214
|
);
|
|
1370
1215
|
if (yield* test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
|
|
1371
1216
|
return importSpecifier.name;
|
|
@@ -1576,7 +1421,8 @@ function parse(config) {
|
|
|
1576
1421
|
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : true,
|
|
1577
1422
|
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : true,
|
|
1578
1423
|
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : true,
|
|
1579
|
-
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : []
|
|
1424
|
+
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : [],
|
|
1425
|
+
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : []
|
|
1580
1426
|
};
|
|
1581
1427
|
}
|
|
1582
1428
|
|
|
@@ -1600,40 +1446,9 @@ var getSemanticDiagnosticsWithCodeFixes = fn(
|
|
|
1600
1446
|
let effectCodeFixes = [];
|
|
1601
1447
|
const executor = yield* createDiagnosticExecutor(sourceFile);
|
|
1602
1448
|
for (const rule of rules) {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
pipe(
|
|
1607
|
-
result.value,
|
|
1608
|
-
map3((_) => ({
|
|
1609
|
-
file: sourceFile,
|
|
1610
|
-
start: _.node.getStart(sourceFile),
|
|
1611
|
-
length: _.node.getEnd() - _.node.getStart(sourceFile),
|
|
1612
|
-
messageText: _.messageText,
|
|
1613
|
-
category: _.category,
|
|
1614
|
-
code: rule.code,
|
|
1615
|
-
source: "effect"
|
|
1616
|
-
}))
|
|
1617
|
-
)
|
|
1618
|
-
);
|
|
1619
|
-
effectCodeFixes = effectCodeFixes.concat(
|
|
1620
|
-
pipe(
|
|
1621
|
-
result.value,
|
|
1622
|
-
map3(
|
|
1623
|
-
(_) => map3(
|
|
1624
|
-
_.fixes,
|
|
1625
|
-
(fix) => ({
|
|
1626
|
-
...fix,
|
|
1627
|
-
code: rule.code,
|
|
1628
|
-
start: _.node.getStart(sourceFile),
|
|
1629
|
-
end: _.node.getEnd()
|
|
1630
|
-
})
|
|
1631
|
-
)
|
|
1632
|
-
),
|
|
1633
|
-
flatten
|
|
1634
|
-
)
|
|
1635
|
-
);
|
|
1636
|
-
}
|
|
1449
|
+
const { codeFixes, diagnostics: diagnostics2 } = yield* executor.execute(rule);
|
|
1450
|
+
effectDiagnostics = effectDiagnostics.concat(diagnostics2);
|
|
1451
|
+
effectCodeFixes = effectCodeFixes.concat(codeFixes);
|
|
1637
1452
|
}
|
|
1638
1453
|
return {
|
|
1639
1454
|
diagnostics: effectDiagnostics,
|
|
@@ -1721,10 +1536,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1721
1536
|
const sectionOverrides = {};
|
|
1722
1537
|
const skippedRules = [];
|
|
1723
1538
|
const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]+:(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
|
|
1724
|
-
let
|
|
1725
|
-
while ((
|
|
1726
|
-
const nextLineCaptureGroup =
|
|
1727
|
-
const rulesCaptureGroup =
|
|
1539
|
+
let match2;
|
|
1540
|
+
while ((match2 = regex.exec(sourceFile.text)) !== null) {
|
|
1541
|
+
const nextLineCaptureGroup = match2[1];
|
|
1542
|
+
const rulesCaptureGroup = match2[2];
|
|
1728
1543
|
if (rulesCaptureGroup) {
|
|
1729
1544
|
const trimmedRuleString = rulesCaptureGroup.trim();
|
|
1730
1545
|
if (trimmedRuleString) {
|
|
@@ -1736,7 +1551,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1736
1551
|
if (ruleLevel === "skip-file") skippedRules.push(ruleName);
|
|
1737
1552
|
const isOverrideNextLine = nextLineCaptureGroup && nextLineCaptureGroup.trim().toLowerCase() === "-next-line";
|
|
1738
1553
|
if (isOverrideNextLine) {
|
|
1739
|
-
const node = findNodeWithLeadingCommentAtPosition(
|
|
1554
|
+
const node = findNodeWithLeadingCommentAtPosition(match2.index);
|
|
1740
1555
|
if (node) {
|
|
1741
1556
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1742
1557
|
lineOverrides[ruleName].unshift({
|
|
@@ -1748,7 +1563,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1748
1563
|
} else {
|
|
1749
1564
|
sectionOverrides[ruleName] = sectionOverrides[ruleName] || [];
|
|
1750
1565
|
sectionOverrides[ruleName].unshift({
|
|
1751
|
-
pos:
|
|
1566
|
+
pos: match2.index,
|
|
1752
1567
|
level: ruleLevel
|
|
1753
1568
|
});
|
|
1754
1569
|
}
|
|
@@ -1764,12 +1579,14 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1764
1579
|
suggestion: ts.DiagnosticCategory.Suggestion
|
|
1765
1580
|
};
|
|
1766
1581
|
const execute = fn("LSP.ruleExecutor")(function* (rule) {
|
|
1582
|
+
const diagnostics2 = [];
|
|
1583
|
+
const codeFixes = [];
|
|
1767
1584
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
1768
|
-
if (skippedRules.indexOf(ruleNameLowered) > -1) return
|
|
1585
|
+
if (skippedRules.indexOf(ruleNameLowered) > -1) return { diagnostics: diagnostics2, codeFixes };
|
|
1769
1586
|
const fixByDisableNextLine = (_) => ({
|
|
1770
1587
|
fixName: rule.name + "_skipNextLine",
|
|
1771
1588
|
description: "Disable " + rule.name + " for this line",
|
|
1772
|
-
apply:
|
|
1589
|
+
apply: flatMap2(
|
|
1773
1590
|
service(ChangeTracker),
|
|
1774
1591
|
(changeTracker) => sync(() => {
|
|
1775
1592
|
const disableAtNode = findParentStatementForDisableNextLine(_.node);
|
|
@@ -1786,7 +1603,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1786
1603
|
const fixByDisableEntireFile = {
|
|
1787
1604
|
fixName: rule.name + "_skipFile",
|
|
1788
1605
|
description: "Disable " + rule.name + " for this entire file",
|
|
1789
|
-
apply:
|
|
1606
|
+
apply: flatMap2(
|
|
1790
1607
|
service(ChangeTracker),
|
|
1791
1608
|
(changeTracker) => sync(
|
|
1792
1609
|
() => changeTracker.insertText(
|
|
@@ -1798,16 +1615,15 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1798
1615
|
)
|
|
1799
1616
|
)
|
|
1800
1617
|
};
|
|
1801
|
-
|
|
1618
|
+
const applicableDiagnostics = [];
|
|
1802
1619
|
yield* rule.apply(sourceFile, (entry) => {
|
|
1803
|
-
|
|
1620
|
+
applicableDiagnostics.push({
|
|
1804
1621
|
...entry,
|
|
1805
1622
|
fixes: entry.fixes.concat([fixByDisableNextLine(entry), fixByDisableEntireFile])
|
|
1806
1623
|
});
|
|
1807
1624
|
});
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
let newLevel = pluginOptions.diagnosticSeverity[ruleNameLowered];
|
|
1625
|
+
for (const emitted of applicableDiagnostics.slice(0)) {
|
|
1626
|
+
let newLevel = pluginOptions.diagnosticSeverity[ruleNameLowered] || rule.severity;
|
|
1811
1627
|
const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
1812
1628
|
(_) => _.pos < emitted.node.getStart(sourceFile) && _.end >= emitted.node.getEnd()
|
|
1813
1629
|
);
|
|
@@ -1819,13 +1635,26 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1819
1635
|
);
|
|
1820
1636
|
if (sectionOverride) newLevel = sectionOverride.level;
|
|
1821
1637
|
}
|
|
1822
|
-
if (newLevel
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1638
|
+
if (!(newLevel in levelToDiagnosticCategory)) continue;
|
|
1639
|
+
diagnostics2.push({
|
|
1640
|
+
file: sourceFile,
|
|
1641
|
+
start: emitted.node.getStart(sourceFile),
|
|
1642
|
+
length: emitted.node.getEnd() - emitted.node.getStart(sourceFile),
|
|
1643
|
+
messageText: emitted.messageText,
|
|
1644
|
+
category: levelToDiagnosticCategory[newLevel],
|
|
1645
|
+
code: rule.code,
|
|
1646
|
+
source: "effect"
|
|
1647
|
+
});
|
|
1648
|
+
for (const fix of emitted.fixes) {
|
|
1649
|
+
codeFixes.push({
|
|
1650
|
+
...fix,
|
|
1651
|
+
code: rule.code,
|
|
1652
|
+
start: emitted.node.getStart(sourceFile),
|
|
1653
|
+
end: emitted.node.getEnd()
|
|
1654
|
+
});
|
|
1826
1655
|
}
|
|
1827
1656
|
}
|
|
1828
|
-
return
|
|
1657
|
+
return { diagnostics: diagnostics2, codeFixes };
|
|
1829
1658
|
});
|
|
1830
1659
|
return { execute };
|
|
1831
1660
|
}
|
|
@@ -1848,7 +1677,7 @@ var contextSelfInClasses = createCompletion({
|
|
|
1848
1677
|
"Context"
|
|
1849
1678
|
)
|
|
1850
1679
|
);
|
|
1851
|
-
const contextIdentifier =
|
|
1680
|
+
const contextIdentifier = match(contextName, {
|
|
1852
1681
|
onNone: () => "Context",
|
|
1853
1682
|
onSome: (_) => _.text
|
|
1854
1683
|
});
|
|
@@ -1881,7 +1710,7 @@ var effectDataClasses = createCompletion({
|
|
|
1881
1710
|
"Data"
|
|
1882
1711
|
)
|
|
1883
1712
|
);
|
|
1884
|
-
const effectDataIdentifier =
|
|
1713
|
+
const effectDataIdentifier = match(dataName, {
|
|
1885
1714
|
onNone: () => "Data",
|
|
1886
1715
|
onSome: (_) => _.text
|
|
1887
1716
|
});
|
|
@@ -1920,7 +1749,7 @@ var effectSchemaSelfInClasses = createCompletion({
|
|
|
1920
1749
|
"Schema"
|
|
1921
1750
|
)
|
|
1922
1751
|
);
|
|
1923
|
-
const schemaIdentifier =
|
|
1752
|
+
const schemaIdentifier = match(effectSchemaName, {
|
|
1924
1753
|
onNone: () => "Schema",
|
|
1925
1754
|
onSome: (_) => _.text
|
|
1926
1755
|
});
|
|
@@ -1971,7 +1800,7 @@ var effectSelfInClasses = createCompletion({
|
|
|
1971
1800
|
"Effect"
|
|
1972
1801
|
)
|
|
1973
1802
|
);
|
|
1974
|
-
const effectIdentifier =
|
|
1803
|
+
const effectIdentifier = match(effectName, {
|
|
1975
1804
|
onNone: () => "Effect",
|
|
1976
1805
|
onSome: (_) => _.text
|
|
1977
1806
|
});
|
|
@@ -2059,7 +1888,7 @@ function make4(ts, typeChecker) {
|
|
|
2059
1888
|
return invariantTypeArgument(propertyType);
|
|
2060
1889
|
};
|
|
2061
1890
|
const effectVarianceStruct = (type, atLocation) => map4(
|
|
2062
|
-
|
|
1891
|
+
all(
|
|
2063
1892
|
varianceStructCovariantType(type, atLocation, "_A"),
|
|
2064
1893
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
2065
1894
|
varianceStructCovariantType(type, atLocation, "_R")
|
|
@@ -2067,7 +1896,7 @@ function make4(ts, typeChecker) {
|
|
|
2067
1896
|
([A, E, R]) => ({ A, E, R })
|
|
2068
1897
|
);
|
|
2069
1898
|
const layerVarianceStruct = (type, atLocation) => map4(
|
|
2070
|
-
|
|
1899
|
+
all(
|
|
2071
1900
|
varianceStructContravariantType(type, atLocation, "_ROut"),
|
|
2072
1901
|
varianceStructCovariantType(type, atLocation, "_E"),
|
|
2073
1902
|
varianceStructCovariantType(type, atLocation, "_RIn")
|
|
@@ -2343,12 +2172,12 @@ function make4(ts, typeChecker) {
|
|
|
2343
2172
|
let replacementNode = succeed(yieldedExpression);
|
|
2344
2173
|
if (!explicitReturn && !(successType.flags & ts.TypeFlags.VoidLike)) {
|
|
2345
2174
|
replacementNode = pipe(
|
|
2346
|
-
|
|
2175
|
+
gen(function* () {
|
|
2347
2176
|
const effectIdentifier = pipe(
|
|
2348
2177
|
yield* option(
|
|
2349
2178
|
findImportedModuleIdentifierByPackageAndNameOrBarrel(node.getSourceFile(), "effect", "Effect")
|
|
2350
2179
|
),
|
|
2351
|
-
|
|
2180
|
+
match({
|
|
2352
2181
|
onNone: () => "Effect",
|
|
2353
2182
|
onSome: (_) => _.text
|
|
2354
2183
|
})
|
|
@@ -2381,7 +2210,7 @@ function make4(ts, typeChecker) {
|
|
|
2381
2210
|
(node) => node
|
|
2382
2211
|
);
|
|
2383
2212
|
const effectSchemaVarianceStruct = (type, atLocation) => map4(
|
|
2384
|
-
|
|
2213
|
+
all(
|
|
2385
2214
|
varianceStructInvariantType(type, atLocation, "_A"),
|
|
2386
2215
|
varianceStructInvariantType(type, atLocation, "_I"),
|
|
2387
2216
|
varianceStructCovariantType(type, atLocation, "_R")
|
|
@@ -2413,7 +2242,7 @@ function make4(ts, typeChecker) {
|
|
|
2413
2242
|
(type) => type
|
|
2414
2243
|
);
|
|
2415
2244
|
const contextTagVarianceStruct = (type, atLocation) => map4(
|
|
2416
|
-
|
|
2245
|
+
all(
|
|
2417
2246
|
varianceStructInvariantType(type, atLocation, "_Identifier"),
|
|
2418
2247
|
varianceStructInvariantType(type, atLocation, "_Service")
|
|
2419
2248
|
),
|
|
@@ -2530,7 +2359,7 @@ function makeTypeCheckerApiCache() {
|
|
|
2530
2359
|
expectedAndRealType: /* @__PURE__ */ new WeakMap()
|
|
2531
2360
|
};
|
|
2532
2361
|
}
|
|
2533
|
-
var deterministicTypeOrder =
|
|
2362
|
+
var deterministicTypeOrder = gen(function* () {
|
|
2534
2363
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2535
2364
|
return make2((a, b) => {
|
|
2536
2365
|
const aName = typeChecker.typeToString(a);
|
|
@@ -2773,6 +2602,15 @@ var appendToUniqueTypesMap = fn(
|
|
|
2773
2602
|
};
|
|
2774
2603
|
}
|
|
2775
2604
|
);
|
|
2605
|
+
function makeResolveExternalModuleName(typeChecker) {
|
|
2606
|
+
if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
const _internal = typeChecker.resolveExternalModuleName;
|
|
2610
|
+
return (moduleSpecifier) => {
|
|
2611
|
+
return _internal(moduleSpecifier);
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2776
2614
|
|
|
2777
2615
|
// src/completions/genFunctionStar.ts
|
|
2778
2616
|
var genFunctionStar = createCompletion({
|
|
@@ -2821,7 +2659,7 @@ var rpcMakeClasses = createCompletion({
|
|
|
2821
2659
|
"Rpc"
|
|
2822
2660
|
)
|
|
2823
2661
|
);
|
|
2824
|
-
const rpcIdentifier =
|
|
2662
|
+
const rpcIdentifier = match(rpcName, {
|
|
2825
2663
|
onNone: () => "Rpc",
|
|
2826
2664
|
onSome: (_) => _.text
|
|
2827
2665
|
});
|
|
@@ -2848,14 +2686,208 @@ var completions = [
|
|
|
2848
2686
|
effectDataClasses
|
|
2849
2687
|
];
|
|
2850
2688
|
|
|
2689
|
+
// src/completions/middlewareNamespaceImports.ts
|
|
2690
|
+
var importablePackagesMetadataCache = /* @__PURE__ */ new Map();
|
|
2691
|
+
var makeImportablePackagesMetadata = fn("makeImportablePackagesMetadata")(function* (sourceFile) {
|
|
2692
|
+
const ts = yield* service(TypeScriptApi);
|
|
2693
|
+
const program = yield* service(TypeScriptProgram);
|
|
2694
|
+
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
2695
|
+
const host = program;
|
|
2696
|
+
const namespaceByFileName = /* @__PURE__ */ new Map();
|
|
2697
|
+
const excludedByFileName = /* @__PURE__ */ new Map();
|
|
2698
|
+
const unbarreledModulePathByFileName = /* @__PURE__ */ new Map();
|
|
2699
|
+
for (const packageName of languageServicePluginOptions.namespaceImportPackages) {
|
|
2700
|
+
const barrelModule = ts.resolveModuleName(packageName, sourceFile.fileName, program.getCompilerOptions(), host);
|
|
2701
|
+
if (barrelModule.resolvedModule) {
|
|
2702
|
+
const barrelPath = barrelModule.resolvedModule.resolvedFileName;
|
|
2703
|
+
const barrelSource = program.getSourceFile(barrelPath) || ts.createSourceFile(barrelPath, host.readFile(barrelPath) || "", sourceFile.languageVersion, true);
|
|
2704
|
+
if (barrelSource) {
|
|
2705
|
+
for (const statement of barrelSource.statements) {
|
|
2706
|
+
if (ts.isExportDeclaration(statement)) {
|
|
2707
|
+
const exportClause = statement.exportClause;
|
|
2708
|
+
const moduleSpecifier = statement.moduleSpecifier;
|
|
2709
|
+
if (moduleSpecifier && ts.isStringLiteral(moduleSpecifier)) {
|
|
2710
|
+
const unbarreledModulePathResolved = ts.resolveModuleName(
|
|
2711
|
+
moduleSpecifier.text,
|
|
2712
|
+
barrelSource.fileName,
|
|
2713
|
+
program.getCompilerOptions(),
|
|
2714
|
+
host
|
|
2715
|
+
);
|
|
2716
|
+
if (unbarreledModulePathResolved.resolvedModule) {
|
|
2717
|
+
const unbarreledModulePath = unbarreledModulePathResolved.resolvedModule.resolvedFileName;
|
|
2718
|
+
if (exportClause && ts.isNamespaceExport(exportClause) && ts.isIdentifier(exportClause.name)) {
|
|
2719
|
+
namespaceByFileName.set(unbarreledModulePath, exportClause.name.text);
|
|
2720
|
+
const existingUnbarreledModulePath = unbarreledModulePathByFileName.get(barrelSource.fileName) || [];
|
|
2721
|
+
existingUnbarreledModulePath.push([exportClause.name.text, unbarreledModulePath]);
|
|
2722
|
+
unbarreledModulePathByFileName.set(barrelSource.fileName, existingUnbarreledModulePath);
|
|
2723
|
+
}
|
|
2724
|
+
if (exportClause && ts.isNamedExports(exportClause)) {
|
|
2725
|
+
for (const element of exportClause.elements) {
|
|
2726
|
+
if (!ts.isIdentifier(element.name)) continue;
|
|
2727
|
+
const methodName = element.name.text;
|
|
2728
|
+
const excludedMethods = excludedByFileName.get(methodName) || [];
|
|
2729
|
+
excludedMethods.push(unbarreledModulePath);
|
|
2730
|
+
excludedByFileName.set(methodName, excludedMethods);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
return {
|
|
2741
|
+
getImportNamespaceByFileName: (fileName) => namespaceByFileName.get(fileName),
|
|
2742
|
+
isExcludedFromNamespaceImport: (fileName, exportName) => (excludedByFileName.get(exportName) || []).includes(fileName),
|
|
2743
|
+
getUnbarreledModulePath: (fileName, exportName) => unbarreledModulePathByFileName.get(fileName)?.find(([name]) => name === exportName)?.[1]
|
|
2744
|
+
};
|
|
2745
|
+
});
|
|
2746
|
+
var appendEffectCompletionEntryData = fn("collectNamespaceImports")(
|
|
2747
|
+
function* (sourceFile, applicableCompletions) {
|
|
2748
|
+
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
2749
|
+
if (languageServicePluginOptions.namespaceImportPackages.length === 0) return applicableCompletions;
|
|
2750
|
+
const packagesMetadata = importablePackagesMetadataCache.get(sourceFile.fileName) || (yield* makeImportablePackagesMetadata(sourceFile));
|
|
2751
|
+
importablePackagesMetadataCache.set(sourceFile.fileName, packagesMetadata);
|
|
2752
|
+
if (applicableCompletions) {
|
|
2753
|
+
return {
|
|
2754
|
+
...applicableCompletions,
|
|
2755
|
+
entries: applicableCompletions.entries.map((entry) => {
|
|
2756
|
+
if (entry.data && entry.data.fileName && !entry.insertText && !entry.filterText && entry.data.exportName && entry.data.moduleSpecifier) {
|
|
2757
|
+
const isExcluded = packagesMetadata.isExcludedFromNamespaceImport(
|
|
2758
|
+
entry.data.fileName,
|
|
2759
|
+
entry.data.exportName
|
|
2760
|
+
);
|
|
2761
|
+
if (isExcluded) return entry;
|
|
2762
|
+
const unbarreledModulePath = packagesMetadata.getUnbarreledModulePath(
|
|
2763
|
+
entry.data.fileName,
|
|
2764
|
+
entry.data.exportName
|
|
2765
|
+
);
|
|
2766
|
+
const namespaceName = packagesMetadata.getImportNamespaceByFileName(
|
|
2767
|
+
unbarreledModulePath || entry.data.fileName
|
|
2768
|
+
);
|
|
2769
|
+
if (namespaceName) {
|
|
2770
|
+
return {
|
|
2771
|
+
...entry,
|
|
2772
|
+
// insertText: unbarreledModulePath ? namespaceName : namespaceName + "." + entry.name,
|
|
2773
|
+
// filterText: entry.name,
|
|
2774
|
+
data: {
|
|
2775
|
+
...entry.data,
|
|
2776
|
+
effectNamespaceName: namespaceName,
|
|
2777
|
+
effectUnbarreledModulePath: unbarreledModulePath || "",
|
|
2778
|
+
effectReplaceSpan: entry.replacementSpan || applicableCompletions.optionalReplacementSpan
|
|
2779
|
+
}
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
return entry;
|
|
2784
|
+
})
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
return applicableCompletions;
|
|
2788
|
+
}
|
|
2789
|
+
);
|
|
2790
|
+
var postprocessCompletionEntryDetails = fn("postprocessCompletionEntryDetails")(
|
|
2791
|
+
function* (sourceFile, data, applicableCompletionEntryDetails, formatOptions, preferences, languageServiceHost) {
|
|
2792
|
+
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
2793
|
+
if (languageServicePluginOptions.namespaceImportPackages.length === 0) return applicableCompletionEntryDetails;
|
|
2794
|
+
const ts = yield* service(TypeScriptApi);
|
|
2795
|
+
const program = yield* service(TypeScriptProgram);
|
|
2796
|
+
const getModuleSpecifier = makeGetModuleSpecifier(ts);
|
|
2797
|
+
if (!getModuleSpecifier) return applicableCompletionEntryDetails;
|
|
2798
|
+
if (!applicableCompletionEntryDetails) return applicableCompletionEntryDetails;
|
|
2799
|
+
if (!data) return applicableCompletionEntryDetails;
|
|
2800
|
+
if (!("effectNamespaceName" in data && "effectUnbarreledModulePath" in data && "effectReplaceSpan" in data)) {
|
|
2801
|
+
return applicableCompletionEntryDetails;
|
|
2802
|
+
}
|
|
2803
|
+
const effectReplaceSpan = data.effectReplaceSpan;
|
|
2804
|
+
const codeActions = applicableCompletionEntryDetails.codeActions;
|
|
2805
|
+
if (codeActions && codeActions.length === 1) {
|
|
2806
|
+
const action = codeActions[0];
|
|
2807
|
+
if (action.changes.length === 1) {
|
|
2808
|
+
const fileTextChanges = action.changes[0];
|
|
2809
|
+
if (fileTextChanges.fileName === sourceFile.fileName && fileTextChanges.textChanges.length === 1) {
|
|
2810
|
+
const change = fileTextChanges.textChanges[0];
|
|
2811
|
+
let hasImportActions = false;
|
|
2812
|
+
if (change.newText.trim().toLowerCase().startsWith("import") && change.newText.indexOf(data.exportName) > -1) {
|
|
2813
|
+
hasImportActions = true;
|
|
2814
|
+
}
|
|
2815
|
+
if (!hasImportActions && change.newText.indexOf(data.exportName) > -1) {
|
|
2816
|
+
const ancestorNodes = yield* getAncestorNodesInRange(sourceFile, {
|
|
2817
|
+
pos: change.span.start,
|
|
2818
|
+
end: change.span.start
|
|
2819
|
+
});
|
|
2820
|
+
const importNodes = ancestorNodes.filter((node) => ts.isImportDeclaration(node));
|
|
2821
|
+
hasImportActions = importNodes.length > 0;
|
|
2822
|
+
}
|
|
2823
|
+
if (!hasImportActions) return applicableCompletionEntryDetails;
|
|
2824
|
+
const formatContext = ts.formatting.getFormatContext(
|
|
2825
|
+
formatOptions || {},
|
|
2826
|
+
languageServiceHost
|
|
2827
|
+
);
|
|
2828
|
+
const changes = ts.textChanges.ChangeTracker.with(
|
|
2829
|
+
{
|
|
2830
|
+
formatContext,
|
|
2831
|
+
host: languageServiceHost,
|
|
2832
|
+
preferences: preferences || {}
|
|
2833
|
+
},
|
|
2834
|
+
(changeTracker) => {
|
|
2835
|
+
const isBarrelRedirect = String(data.effectUnbarreledModulePath).length > 0;
|
|
2836
|
+
const moduleSpecifier = isBarrelRedirect ? getModuleSpecifier(
|
|
2837
|
+
program.getCompilerOptions(),
|
|
2838
|
+
sourceFile,
|
|
2839
|
+
sourceFile.fileName,
|
|
2840
|
+
String(data.effectUnbarreledModulePath),
|
|
2841
|
+
program
|
|
2842
|
+
) : String(data.moduleSpecifier);
|
|
2843
|
+
ts.insertImports(
|
|
2844
|
+
changeTracker,
|
|
2845
|
+
sourceFile,
|
|
2846
|
+
ts.factory.createImportDeclaration(
|
|
2847
|
+
void 0,
|
|
2848
|
+
ts.factory.createImportClause(
|
|
2849
|
+
false,
|
|
2850
|
+
void 0,
|
|
2851
|
+
ts.factory.createNamespaceImport(ts.factory.createIdentifier(String(data.effectNamespaceName)))
|
|
2852
|
+
),
|
|
2853
|
+
ts.factory.createStringLiteral(moduleSpecifier)
|
|
2854
|
+
),
|
|
2855
|
+
true,
|
|
2856
|
+
preferences || {}
|
|
2857
|
+
);
|
|
2858
|
+
if (!isBarrelRedirect) {
|
|
2859
|
+
changeTracker.insertText(
|
|
2860
|
+
sourceFile,
|
|
2861
|
+
effectReplaceSpan.start,
|
|
2862
|
+
String(data.effectNamespaceName) + "."
|
|
2863
|
+
);
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
);
|
|
2867
|
+
return {
|
|
2868
|
+
...applicableCompletionEntryDetails,
|
|
2869
|
+
codeActions: [
|
|
2870
|
+
{
|
|
2871
|
+
description: "Import * as " + data.effectNamespaceName + " from " + data.effectUnbarreledModulePath,
|
|
2872
|
+
changes
|
|
2873
|
+
}
|
|
2874
|
+
]
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
return applicableCompletionEntryDetails;
|
|
2880
|
+
}
|
|
2881
|
+
);
|
|
2882
|
+
|
|
2851
2883
|
// src/diagnostics/duplicatePackage.ts
|
|
2852
2884
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
2853
2885
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
2854
2886
|
var duplicatePackage = createDiagnostic({
|
|
2855
2887
|
name: "duplicatePackage",
|
|
2856
2888
|
code: 6,
|
|
2889
|
+
severity: "warning",
|
|
2857
2890
|
apply: fn("duplicatePackage.apply")(function* (sourceFile, report) {
|
|
2858
|
-
const ts = yield* service(TypeScriptApi);
|
|
2859
2891
|
const program = yield* service(TypeScriptProgram);
|
|
2860
2892
|
const options = yield* service(LanguageServicePluginOptions);
|
|
2861
2893
|
if (sourceFile.statements.length < 1) return;
|
|
@@ -2884,7 +2916,6 @@ var duplicatePackage = createDiagnostic({
|
|
|
2884
2916
|
const versions = Object.keys(resolvedPackages[packageName]);
|
|
2885
2917
|
report({
|
|
2886
2918
|
node: sourceFile.statements[0],
|
|
2887
|
-
category: ts.DiagnosticCategory.Warning,
|
|
2888
2919
|
messageText: `Package ${packageName} is referenced multiple times with different versions (${versions.join(", ")}) and may cause unexpected type errors.
|
|
2889
2920
|
Cleanup your dependencies and your package lockfile to avoid multiple instances of this package and reload the project.
|
|
2890
2921
|
If this is intended set the LSP config "allowedDuplicatedPackages" to ${JSON.stringify(options.allowedDuplicatedPackages.concat([packageName]))}.
|
|
@@ -2901,6 +2932,7 @@ ${versions.map((version) => `- found ${version} at ${resolvedPackages[packageNam
|
|
|
2901
2932
|
var floatingEffect = createDiagnostic({
|
|
2902
2933
|
name: "floatingEffect",
|
|
2903
2934
|
code: 3,
|
|
2935
|
+
severity: "error",
|
|
2904
2936
|
apply: fn("floatingEffect.apply")(function* (sourceFile, report) {
|
|
2905
2937
|
const ts = yield* service(TypeScriptApi);
|
|
2906
2938
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -2927,13 +2959,12 @@ var floatingEffect = createDiagnostic({
|
|
|
2927
2959
|
if (isSome2(effect)) {
|
|
2928
2960
|
const allowedFloatingEffects = yield* pipe(
|
|
2929
2961
|
typeParser.fiberType(type, node.expression),
|
|
2930
|
-
|
|
2962
|
+
orElse2(() => typeParser.effectSubtype(type, node.expression)),
|
|
2931
2963
|
option
|
|
2932
2964
|
);
|
|
2933
2965
|
if (isNone2(allowedFloatingEffects)) {
|
|
2934
2966
|
report({
|
|
2935
2967
|
node,
|
|
2936
|
-
category: ts.DiagnosticCategory.Error,
|
|
2937
2968
|
messageText: `Effect must be yielded or assigned to a variable.`,
|
|
2938
2969
|
fixes: []
|
|
2939
2970
|
});
|
|
@@ -2947,6 +2978,7 @@ var floatingEffect = createDiagnostic({
|
|
|
2947
2978
|
var genericEffectServices = createDiagnostic({
|
|
2948
2979
|
name: "genericEffectServices",
|
|
2949
2980
|
code: 10,
|
|
2981
|
+
severity: "warning",
|
|
2950
2982
|
apply: fn("genericEffectServices.apply")(function* (sourceFile, report) {
|
|
2951
2983
|
const ts = yield* service(TypeScriptApi);
|
|
2952
2984
|
const typeParser = yield* service(TypeParser);
|
|
@@ -2976,12 +3008,11 @@ var genericEffectServices = createDiagnostic({
|
|
|
2976
3008
|
map4(() => {
|
|
2977
3009
|
report({
|
|
2978
3010
|
node: reportAt,
|
|
2979
|
-
category: ts.DiagnosticCategory.Warning,
|
|
2980
3011
|
messageText: `Effect Services with type parameters are not supported because they cannot be properly discriminated at runtime, which may cause unexpected behavior.`,
|
|
2981
3012
|
fixes: []
|
|
2982
3013
|
});
|
|
2983
3014
|
}),
|
|
2984
|
-
|
|
3015
|
+
orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
|
|
2985
3016
|
ignore
|
|
2986
3017
|
);
|
|
2987
3018
|
}
|
|
@@ -2989,10 +3020,124 @@ var genericEffectServices = createDiagnostic({
|
|
|
2989
3020
|
})
|
|
2990
3021
|
});
|
|
2991
3022
|
|
|
3023
|
+
// src/diagnostics/importFromBarrel.ts
|
|
3024
|
+
var importFromBarrel = createDiagnostic({
|
|
3025
|
+
name: "importFromBarrel",
|
|
3026
|
+
code: 12,
|
|
3027
|
+
severity: "off",
|
|
3028
|
+
apply: fn("importFromBarrel.apply")(function* (sourceFile, report) {
|
|
3029
|
+
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
3030
|
+
if (languageServicePluginOptions.namespaceImportPackages.length === 0) return;
|
|
3031
|
+
const ts = yield* service(TypeScriptApi);
|
|
3032
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
3033
|
+
const program = yield* service(TypeScriptProgram);
|
|
3034
|
+
const isImportedFromBarrelExport = (element, languageServicePluginOptions2) => {
|
|
3035
|
+
const getModuleSpecifier = makeGetModuleSpecifier(ts);
|
|
3036
|
+
const resolveExternalModuleName = makeResolveExternalModuleName(typeChecker);
|
|
3037
|
+
if (!(getModuleSpecifier && resolveExternalModuleName)) return;
|
|
3038
|
+
const importDeclaration = ts.findAncestor(element, (node) => ts.isImportDeclaration(node));
|
|
3039
|
+
if (!importDeclaration) return;
|
|
3040
|
+
if (!ts.isStringLiteral(importDeclaration.moduleSpecifier)) return;
|
|
3041
|
+
const importClause = importDeclaration.importClause;
|
|
3042
|
+
if (!importClause) return;
|
|
3043
|
+
const namedBindings = importClause.namedBindings;
|
|
3044
|
+
if (!namedBindings) return;
|
|
3045
|
+
if (!ts.isNamedImports(namedBindings)) return;
|
|
3046
|
+
const barrelModuleName = importDeclaration.moduleSpecifier.text;
|
|
3047
|
+
if (languageServicePluginOptions2.namespaceImportPackages.indexOf(barrelModuleName.toLowerCase()) === -1) return;
|
|
3048
|
+
const moduleSymbol = resolveExternalModuleName(importDeclaration.moduleSpecifier);
|
|
3049
|
+
if (!moduleSymbol) return;
|
|
3050
|
+
if (!moduleSymbol.exports) return;
|
|
3051
|
+
const sourceFile2 = importDeclaration.getSourceFile();
|
|
3052
|
+
const nodeForSymbol = element.propertyName || element.name;
|
|
3053
|
+
if (!ts.isIdentifier(nodeForSymbol)) return;
|
|
3054
|
+
const importedName = nodeForSymbol.text;
|
|
3055
|
+
const reexportedSymbol = moduleSymbol.exports.get(ts.escapeLeadingUnderscores(importedName));
|
|
3056
|
+
if (!reexportedSymbol) return;
|
|
3057
|
+
if (!(reexportedSymbol.declarations && reexportedSymbol.declarations.length === 1)) return;
|
|
3058
|
+
const namespaceExport = reexportedSymbol.declarations[0];
|
|
3059
|
+
if (!ts.isNamespaceExport(namespaceExport)) return;
|
|
3060
|
+
const exportDeclaration = namespaceExport.parent;
|
|
3061
|
+
if (!ts.isExportDeclaration(exportDeclaration)) return;
|
|
3062
|
+
if (!exportDeclaration.moduleSpecifier) return;
|
|
3063
|
+
const originalModuleSymbol = resolveExternalModuleName(exportDeclaration.moduleSpecifier);
|
|
3064
|
+
if (!originalModuleSymbol) return;
|
|
3065
|
+
if (!originalModuleSymbol.valueDeclaration) return;
|
|
3066
|
+
const originalSourceFile = originalModuleSymbol.valueDeclaration.getSourceFile();
|
|
3067
|
+
const unbarrelledFileName = getModuleSpecifier(
|
|
3068
|
+
program.getCompilerOptions(),
|
|
3069
|
+
sourceFile2,
|
|
3070
|
+
sourceFile2.fileName,
|
|
3071
|
+
originalSourceFile.fileName,
|
|
3072
|
+
program
|
|
3073
|
+
);
|
|
3074
|
+
if (unbarrelledFileName.toLowerCase().indexOf(barrelModuleName.toLowerCase() + "/") === -1) return;
|
|
3075
|
+
return { unbarrelledFileName, importedName, barrelModuleName, importClause, namedBindings, importDeclaration };
|
|
3076
|
+
};
|
|
3077
|
+
const nodeToVisit = [];
|
|
3078
|
+
const appendNodeToVisit = (node) => {
|
|
3079
|
+
nodeToVisit.push(node);
|
|
3080
|
+
return void 0;
|
|
3081
|
+
};
|
|
3082
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3083
|
+
while (nodeToVisit.length > 0) {
|
|
3084
|
+
const node = nodeToVisit.shift();
|
|
3085
|
+
const parent = node.parent;
|
|
3086
|
+
if (!(ts.isImportSpecifier(node) && ts.isNamedImports(parent))) {
|
|
3087
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3088
|
+
continue;
|
|
3089
|
+
}
|
|
3090
|
+
const result = isImportedFromBarrelExport(node, languageServicePluginOptions);
|
|
3091
|
+
if (!result) continue;
|
|
3092
|
+
const { barrelModuleName, importClause, importDeclaration, importedName, namedBindings, unbarrelledFileName } = result;
|
|
3093
|
+
report({
|
|
3094
|
+
node,
|
|
3095
|
+
messageText: `Importing from barrel module ${barrelModuleName} is not allowed.`,
|
|
3096
|
+
fixes: [
|
|
3097
|
+
{
|
|
3098
|
+
fixName: "replaceWithUnbarrelledImport",
|
|
3099
|
+
description: `Import * as ${importedName} from ${unbarrelledFileName}`,
|
|
3100
|
+
apply: gen(function* () {
|
|
3101
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
3102
|
+
const newImport = ts.factory.createImportDeclaration(
|
|
3103
|
+
void 0,
|
|
3104
|
+
ts.factory.createImportClause(
|
|
3105
|
+
importClause.isTypeOnly || node.isTypeOnly,
|
|
3106
|
+
void 0,
|
|
3107
|
+
ts.factory.createNamespaceImport(ts.factory.createIdentifier(importedName))
|
|
3108
|
+
),
|
|
3109
|
+
ts.factory.createStringLiteral(unbarrelledFileName)
|
|
3110
|
+
);
|
|
3111
|
+
if (namedBindings.elements.length === 1) {
|
|
3112
|
+
changeTracker.replaceNode(
|
|
3113
|
+
sourceFile,
|
|
3114
|
+
importDeclaration,
|
|
3115
|
+
newImport
|
|
3116
|
+
);
|
|
3117
|
+
} else {
|
|
3118
|
+
changeTracker.insertNodeAfter(sourceFile, importDeclaration, newImport);
|
|
3119
|
+
changeTracker.replaceNode(
|
|
3120
|
+
sourceFile,
|
|
3121
|
+
namedBindings,
|
|
3122
|
+
ts.factory.updateNamedImports(
|
|
3123
|
+
namedBindings,
|
|
3124
|
+
namedBindings.elements.filter((e) => e !== node)
|
|
3125
|
+
)
|
|
3126
|
+
);
|
|
3127
|
+
}
|
|
3128
|
+
})
|
|
3129
|
+
}
|
|
3130
|
+
]
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
})
|
|
3134
|
+
});
|
|
3135
|
+
|
|
2992
3136
|
// src/diagnostics/leakingRequirements.ts
|
|
2993
3137
|
var leakingRequirements = createDiagnostic({
|
|
2994
3138
|
name: "leakingRequirements",
|
|
2995
3139
|
code: 8,
|
|
3140
|
+
severity: "suggestion",
|
|
2996
3141
|
apply: fn("leakingRequirements.apply")(function* (sourceFile, report) {
|
|
2997
3142
|
const ts = yield* service(TypeScriptApi);
|
|
2998
3143
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -3012,7 +3157,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
3012
3157
|
yield* pipe(
|
|
3013
3158
|
typeParser.effectType(servicePropertyType, atLocation),
|
|
3014
3159
|
map4((_) => effectContextType = _.R),
|
|
3015
|
-
|
|
3160
|
+
orElse2(() => {
|
|
3016
3161
|
const servicePropertyCallSignatures = servicePropertyType.getCallSignatures();
|
|
3017
3162
|
if (servicePropertyCallSignatures.length === 1) {
|
|
3018
3163
|
return pipe(
|
|
@@ -3022,7 +3167,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
3022
3167
|
})
|
|
3023
3168
|
);
|
|
3024
3169
|
}
|
|
3025
|
-
return
|
|
3170
|
+
return void_;
|
|
3026
3171
|
}),
|
|
3027
3172
|
ignore
|
|
3028
3173
|
);
|
|
@@ -3050,7 +3195,6 @@ var leakingRequirements = createDiagnostic({
|
|
|
3050
3195
|
if (requirements.length === 0) return;
|
|
3051
3196
|
report({
|
|
3052
3197
|
node,
|
|
3053
|
-
category: ts.DiagnosticCategory.Warning,
|
|
3054
3198
|
messageText: `This Service is leaking the ${requirements.map((_) => typeChecker.typeToString(_)).join(" | ")} requirement.
|
|
3055
3199
|
If these requirements cannot be cached and are expected to be provided per method invocation (e.g. HttpServerRequest), you can safely disable this diagnostic for this line through quickfixes.
|
|
3056
3200
|
More info at https://effect.website/docs/requirements-management/layers/#avoiding-requirement-leakage`,
|
|
@@ -3081,13 +3225,13 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
3081
3225
|
for (const [type, reportAt] of typesToCheck) {
|
|
3082
3226
|
yield* pipe(
|
|
3083
3227
|
typeParser.contextTag(type, node),
|
|
3084
|
-
|
|
3228
|
+
flatMap2(
|
|
3085
3229
|
({ Service }) => pipe(
|
|
3086
3230
|
parseLeakedRequirements(Service, node),
|
|
3087
3231
|
map4((requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeOrder)))
|
|
3088
3232
|
)
|
|
3089
3233
|
),
|
|
3090
|
-
|
|
3234
|
+
orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
|
|
3091
3235
|
ignore
|
|
3092
3236
|
);
|
|
3093
3237
|
}
|
|
@@ -3099,17 +3243,17 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
3099
3243
|
var missingEffectContext = createDiagnostic({
|
|
3100
3244
|
name: "missingEffectContext",
|
|
3101
3245
|
code: 1,
|
|
3246
|
+
severity: "error",
|
|
3102
3247
|
apply: fn("missingEffectContext.apply")(function* (sourceFile, report) {
|
|
3103
|
-
const ts = yield* service(TypeScriptApi);
|
|
3104
3248
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3105
3249
|
const typeParser = yield* service(TypeParser);
|
|
3106
3250
|
const typeOrder = yield* deterministicTypeOrder;
|
|
3107
3251
|
const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
|
|
3108
|
-
|
|
3252
|
+
all(
|
|
3109
3253
|
typeParser.effectType(expectedType, node),
|
|
3110
3254
|
typeParser.effectType(realType, valueNode)
|
|
3111
3255
|
),
|
|
3112
|
-
|
|
3256
|
+
flatMap2(
|
|
3113
3257
|
([expectedEffect, realEffect]) => getMissingTypeEntriesInTargetType(
|
|
3114
3258
|
realEffect.R,
|
|
3115
3259
|
expectedEffect.R
|
|
@@ -3119,23 +3263,24 @@ var missingEffectContext = createDiagnostic({
|
|
|
3119
3263
|
const sortTypes = sort(typeOrder);
|
|
3120
3264
|
const entries = yield* expectedAndRealType(sourceFile);
|
|
3121
3265
|
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
expectedType,
|
|
3126
|
-
valueNode,
|
|
3127
|
-
realType
|
|
3128
|
-
),
|
|
3129
|
-
orElse3(() => succeed([]))
|
|
3130
|
-
);
|
|
3131
|
-
if (missingContext.length > 0) {
|
|
3132
|
-
report(
|
|
3133
|
-
{
|
|
3266
|
+
if (expectedType !== realType) {
|
|
3267
|
+
yield* pipe(
|
|
3268
|
+
checkForMissingContextTypes(
|
|
3134
3269
|
node,
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3270
|
+
expectedType,
|
|
3271
|
+
valueNode,
|
|
3272
|
+
realType
|
|
3273
|
+
),
|
|
3274
|
+
map4(
|
|
3275
|
+
(missingTypes) => missingTypes.length > 0 ? report(
|
|
3276
|
+
{
|
|
3277
|
+
node,
|
|
3278
|
+
messageText: `Missing '${sortTypes(missingTypes).map((_) => typeChecker.typeToString(_)).join(" | ")}' in the expected Effect context.`,
|
|
3279
|
+
fixes: []
|
|
3280
|
+
}
|
|
3281
|
+
) : void 0
|
|
3282
|
+
),
|
|
3283
|
+
ignore
|
|
3139
3284
|
);
|
|
3140
3285
|
}
|
|
3141
3286
|
}
|
|
@@ -3146,17 +3291,17 @@ var missingEffectContext = createDiagnostic({
|
|
|
3146
3291
|
var missingEffectError = createDiagnostic({
|
|
3147
3292
|
name: "missingEffectError",
|
|
3148
3293
|
code: 1,
|
|
3294
|
+
severity: "error",
|
|
3149
3295
|
apply: fn("missingEffectError.apply")(function* (sourceFile, report) {
|
|
3150
|
-
const ts = yield* service(TypeScriptApi);
|
|
3151
3296
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3152
3297
|
const typeParser = yield* service(TypeParser);
|
|
3153
3298
|
const typeOrder = yield* deterministicTypeOrder;
|
|
3154
3299
|
const checkForMissingErrorTypes = (node, expectedType, valueNode, realType) => pipe(
|
|
3155
|
-
|
|
3300
|
+
all(
|
|
3156
3301
|
typeParser.effectType(expectedType, node),
|
|
3157
3302
|
typeParser.effectType(realType, valueNode)
|
|
3158
3303
|
),
|
|
3159
|
-
|
|
3304
|
+
flatMap2(
|
|
3160
3305
|
([expectedEffect, realEffect]) => getMissingTypeEntriesInTargetType(
|
|
3161
3306
|
realEffect.E,
|
|
3162
3307
|
expectedEffect.E
|
|
@@ -3166,23 +3311,24 @@ var missingEffectError = createDiagnostic({
|
|
|
3166
3311
|
const sortTypes = sort(typeOrder);
|
|
3167
3312
|
const entries = yield* expectedAndRealType(sourceFile);
|
|
3168
3313
|
for (const [node, expectedType, valueNode, realType] of entries) {
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
expectedType,
|
|
3173
|
-
valueNode,
|
|
3174
|
-
realType
|
|
3175
|
-
),
|
|
3176
|
-
orElse3(() => succeed([]))
|
|
3177
|
-
);
|
|
3178
|
-
if (missingContext.length > 0) {
|
|
3179
|
-
report(
|
|
3180
|
-
{
|
|
3314
|
+
if (expectedType !== realType) {
|
|
3315
|
+
yield* pipe(
|
|
3316
|
+
checkForMissingErrorTypes(
|
|
3181
3317
|
node,
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3318
|
+
expectedType,
|
|
3319
|
+
valueNode,
|
|
3320
|
+
realType
|
|
3321
|
+
),
|
|
3322
|
+
map4(
|
|
3323
|
+
(missingTypes) => missingTypes.length > 0 ? report(
|
|
3324
|
+
{
|
|
3325
|
+
node,
|
|
3326
|
+
messageText: `Missing '${sortTypes(missingTypes).map((_) => typeChecker.typeToString(_)).join(" | ")}' in the expected Effect errors.`,
|
|
3327
|
+
fixes: []
|
|
3328
|
+
}
|
|
3329
|
+
) : void 0
|
|
3330
|
+
),
|
|
3331
|
+
ignore
|
|
3186
3332
|
);
|
|
3187
3333
|
}
|
|
3188
3334
|
}
|
|
@@ -3193,6 +3339,7 @@ var missingEffectError = createDiagnostic({
|
|
|
3193
3339
|
var missingReturnYieldStar = createDiagnostic({
|
|
3194
3340
|
name: "missingReturnYieldStar",
|
|
3195
3341
|
code: 7,
|
|
3342
|
+
severity: "error",
|
|
3196
3343
|
apply: fn("missingReturnYieldStar.apply")(function* (sourceFile, report) {
|
|
3197
3344
|
const ts = yield* service(TypeScriptApi);
|
|
3198
3345
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -3219,15 +3366,15 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
3219
3366
|
const effectGenNode = generatorFunctionOrReturnStatement.parent;
|
|
3220
3367
|
const effectGenLike = yield* pipe(
|
|
3221
3368
|
typeParser.effectGen(effectGenNode),
|
|
3222
|
-
|
|
3223
|
-
|
|
3369
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3370
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3224
3371
|
option
|
|
3225
3372
|
);
|
|
3226
3373
|
if (isSome2(effectGenLike)) {
|
|
3227
3374
|
const fix = node.expression ? [{
|
|
3228
3375
|
fixName: "missingReturnYieldStar_fix",
|
|
3229
3376
|
description: "Add return statement",
|
|
3230
|
-
apply:
|
|
3377
|
+
apply: gen(function* () {
|
|
3231
3378
|
const changeTracker = yield* service(ChangeTracker);
|
|
3232
3379
|
changeTracker.replaceNode(
|
|
3233
3380
|
sourceFile,
|
|
@@ -3240,7 +3387,6 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
3240
3387
|
}] : [];
|
|
3241
3388
|
report({
|
|
3242
3389
|
node,
|
|
3243
|
-
category: ts.DiagnosticCategory.Error,
|
|
3244
3390
|
messageText: `Yielded Effect never succeeds, so it is best to use a 'return yield*' instead.`,
|
|
3245
3391
|
fixes: fix
|
|
3246
3392
|
});
|
|
@@ -3257,6 +3403,7 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
3257
3403
|
var missingStarInYieldEffectGen = createDiagnostic({
|
|
3258
3404
|
name: "missingStarInYieldEffectGen",
|
|
3259
3405
|
code: 4,
|
|
3406
|
+
severity: "error",
|
|
3260
3407
|
apply: fn("missingStarInYieldEffectGen.apply")(function* (sourceFile, report) {
|
|
3261
3408
|
const ts = yield* service(TypeScriptApi);
|
|
3262
3409
|
const typeParser = yield* service(TypeParser);
|
|
@@ -3280,8 +3427,8 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
3280
3427
|
const effectGenNode = functionStarNode.parent;
|
|
3281
3428
|
yield* pipe(
|
|
3282
3429
|
typeParser.effectGen(effectGenNode),
|
|
3283
|
-
|
|
3284
|
-
|
|
3430
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3431
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3285
3432
|
map4(({ functionStar }) => {
|
|
3286
3433
|
if (functionStar) {
|
|
3287
3434
|
brokenGenerators.add(functionStar);
|
|
@@ -3296,7 +3443,6 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
3296
3443
|
brokenGenerators.forEach(
|
|
3297
3444
|
(node) => report({
|
|
3298
3445
|
node,
|
|
3299
|
-
category: ts.DiagnosticCategory.Error,
|
|
3300
3446
|
messageText: `Seems like you used yield instead of yield* inside this Effect.gen.`,
|
|
3301
3447
|
fixes: []
|
|
3302
3448
|
})
|
|
@@ -3305,7 +3451,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
3305
3451
|
const fix = node.expression ? [{
|
|
3306
3452
|
fixName: "missingStarInYieldEffectGen_fix",
|
|
3307
3453
|
description: "Replace yield with yield*",
|
|
3308
|
-
apply:
|
|
3454
|
+
apply: gen(function* () {
|
|
3309
3455
|
const changeTracker = yield* service(ChangeTracker);
|
|
3310
3456
|
changeTracker.replaceNode(
|
|
3311
3457
|
sourceFile,
|
|
@@ -3319,7 +3465,6 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
3319
3465
|
}] : [];
|
|
3320
3466
|
report({
|
|
3321
3467
|
node,
|
|
3322
|
-
category: ts.DiagnosticCategory.Error,
|
|
3323
3468
|
messageText: `When yielding Effects inside Effect.gen, you should use yield* instead of yield.`,
|
|
3324
3469
|
fixes: fix
|
|
3325
3470
|
});
|
|
@@ -3331,6 +3476,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
3331
3476
|
var returnEffectInGen = createDiagnostic({
|
|
3332
3477
|
name: "returnEffectInGen",
|
|
3333
3478
|
code: 11,
|
|
3479
|
+
severity: "suggestion",
|
|
3334
3480
|
apply: fn("returnEffectInGen.apply")(function* (sourceFile, report) {
|
|
3335
3481
|
const ts = yield* service(TypeScriptApi);
|
|
3336
3482
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -3358,13 +3504,13 @@ var returnEffectInGen = createDiagnostic({
|
|
|
3358
3504
|
const effectGenNode = generatorOrRegularFunction.parent;
|
|
3359
3505
|
yield* pipe(
|
|
3360
3506
|
typeParser.effectGen(effectGenNode),
|
|
3361
|
-
|
|
3362
|
-
|
|
3507
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
3508
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
3363
3509
|
map4(() => {
|
|
3364
3510
|
const fix = node.expression ? [{
|
|
3365
3511
|
fixName: "returnEffectInGen_fix",
|
|
3366
3512
|
description: "Add yield* statement",
|
|
3367
|
-
apply:
|
|
3513
|
+
apply: gen(function* () {
|
|
3368
3514
|
const changeTracker = yield* service(ChangeTracker);
|
|
3369
3515
|
changeTracker.replaceNode(
|
|
3370
3516
|
sourceFile,
|
|
@@ -3378,7 +3524,6 @@ var returnEffectInGen = createDiagnostic({
|
|
|
3378
3524
|
}] : [];
|
|
3379
3525
|
report({
|
|
3380
3526
|
node,
|
|
3381
|
-
category: ts.DiagnosticCategory.Suggestion,
|
|
3382
3527
|
messageText: `You are returning an Effect-able type inside a generator function, and will result in nested Effect<Effect<...>>.
|
|
3383
3528
|
Maybe you wanted to return yield* instead?
|
|
3384
3529
|
Nested Effect-able types may be intended if you plan to later manually flatten or unwrap this Effect, if so you can safely disable this diagnostic for this line through quickfixes.`,
|
|
@@ -3398,6 +3543,7 @@ Nested Effect-able types may be intended if you plan to later manually flatten o
|
|
|
3398
3543
|
var unnecessaryEffectGen = createDiagnostic({
|
|
3399
3544
|
name: "unnecessaryEffectGen",
|
|
3400
3545
|
code: 5,
|
|
3546
|
+
severity: "suggestion",
|
|
3401
3547
|
apply: fn("unnecessaryEffectGen.apply")(function* (sourceFile, report) {
|
|
3402
3548
|
const ts = yield* service(TypeScriptApi);
|
|
3403
3549
|
const typeParser = yield* service(TypeParser);
|
|
@@ -3416,12 +3562,11 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
3416
3562
|
map4(
|
|
3417
3563
|
({ replacementNode }) => report({
|
|
3418
3564
|
node,
|
|
3419
|
-
category: ts.DiagnosticCategory.Suggestion,
|
|
3420
3565
|
messageText: `This Effect.gen contains a single return statement.`,
|
|
3421
3566
|
fixes: [{
|
|
3422
3567
|
fixName: "unnecessaryEffectGen_fix",
|
|
3423
3568
|
description: "Remove the Effect.gen, and keep the body",
|
|
3424
|
-
apply:
|
|
3569
|
+
apply: gen(function* () {
|
|
3425
3570
|
const textChanges = yield* service(
|
|
3426
3571
|
ChangeTracker
|
|
3427
3572
|
);
|
|
@@ -3441,6 +3586,7 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
3441
3586
|
var unnecessaryPipe = createDiagnostic({
|
|
3442
3587
|
name: "unnecessaryPipe",
|
|
3443
3588
|
code: 9,
|
|
3589
|
+
severity: "suggestion",
|
|
3444
3590
|
apply: fn("unnecessaryPipe.apply")(function* (sourceFile, report) {
|
|
3445
3591
|
const ts = yield* service(TypeScriptApi);
|
|
3446
3592
|
const typeParser = yield* service(TypeParser);
|
|
@@ -3460,12 +3606,11 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
3460
3606
|
if (args.length === 0) {
|
|
3461
3607
|
report({
|
|
3462
3608
|
node,
|
|
3463
|
-
category: ts.DiagnosticCategory.Suggestion,
|
|
3464
3609
|
messageText: `This pipe call contains no arguments.`,
|
|
3465
3610
|
fixes: [{
|
|
3466
3611
|
fixName: "unnecessaryPipe_fix",
|
|
3467
3612
|
description: "Remove the pipe call",
|
|
3468
|
-
apply:
|
|
3613
|
+
apply: gen(function* () {
|
|
3469
3614
|
const textChanges = yield* service(
|
|
3470
3615
|
ChangeTracker
|
|
3471
3616
|
);
|
|
@@ -3494,12 +3639,13 @@ var diagnostics = [
|
|
|
3494
3639
|
leakingRequirements,
|
|
3495
3640
|
unnecessaryPipe,
|
|
3496
3641
|
genericEffectServices,
|
|
3497
|
-
returnEffectInGen
|
|
3642
|
+
returnEffectInGen,
|
|
3643
|
+
importFromBarrel
|
|
3498
3644
|
];
|
|
3499
3645
|
|
|
3500
3646
|
// src/goto/effectRpcDefinition.ts
|
|
3501
3647
|
function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
3502
|
-
return
|
|
3648
|
+
return gen(function* () {
|
|
3503
3649
|
const program = yield* service(TypeScriptProgram);
|
|
3504
3650
|
const ts = yield* service(TypeScriptApi);
|
|
3505
3651
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -3621,7 +3767,7 @@ function dedupeJsDocs(quickInfo2) {
|
|
|
3621
3767
|
// src/quickinfo/effectTypeArgs.ts
|
|
3622
3768
|
function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
3623
3769
|
return pipe(
|
|
3624
|
-
|
|
3770
|
+
gen(function* () {
|
|
3625
3771
|
const ts = yield* service(TypeScriptApi);
|
|
3626
3772
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3627
3773
|
const typeParser = yield* service(TypeParser);
|
|
@@ -3682,7 +3828,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
3682
3828
|
atLocation
|
|
3683
3829
|
),
|
|
3684
3830
|
map4((_) => makeSymbolDisplayParts("Effect Type Parameters", _.A, _.E, _.R)),
|
|
3685
|
-
|
|
3831
|
+
orElse2(() => {
|
|
3686
3832
|
const callSignatues = type.getCallSignatures();
|
|
3687
3833
|
if (callSignatues.length !== 1) return succeed([]);
|
|
3688
3834
|
const returnType = callSignatues[0].getReturnType();
|
|
@@ -3716,7 +3862,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
3716
3862
|
documentation: effectTypeArgsDocumentation
|
|
3717
3863
|
};
|
|
3718
3864
|
}),
|
|
3719
|
-
|
|
3865
|
+
orElse2(() => succeed(quickInfo2))
|
|
3720
3866
|
);
|
|
3721
3867
|
}
|
|
3722
3868
|
|
|
@@ -3748,7 +3894,7 @@ var GraphNodeCompoundTransform = class {
|
|
|
3748
3894
|
_tag = "GraphNodeCompoundTransform";
|
|
3749
3895
|
};
|
|
3750
3896
|
function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
3751
|
-
return
|
|
3897
|
+
return gen(function* () {
|
|
3752
3898
|
const ts = yield* service(TypeScriptApi);
|
|
3753
3899
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3754
3900
|
const typeParser = yield* service(TypeParser);
|
|
@@ -3765,7 +3911,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
3765
3911
|
const maybeLayer = yield* option(typeParser.layerType(type, node));
|
|
3766
3912
|
if (isSome2(maybeLayer)) {
|
|
3767
3913
|
const argNodes = yield* option(
|
|
3768
|
-
|
|
3914
|
+
all(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
|
|
3769
3915
|
);
|
|
3770
3916
|
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
3771
3917
|
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
@@ -3809,7 +3955,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
3809
3955
|
);
|
|
3810
3956
|
if (ts.isCallExpression(node)) {
|
|
3811
3957
|
const argNodes = yield* option(
|
|
3812
|
-
|
|
3958
|
+
all(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
|
|
3813
3959
|
);
|
|
3814
3960
|
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
3815
3961
|
return new GraphNodeCompoundTransform(
|
|
@@ -3884,7 +4030,7 @@ function escapeMermaid(text) {
|
|
|
3884
4030
|
return text.replace(/"/mg, "#quot;").replace(/\n/mg, " ");
|
|
3885
4031
|
}
|
|
3886
4032
|
function processNodeMermaid(graph, ctx, ctxL) {
|
|
3887
|
-
return
|
|
4033
|
+
return gen(function* () {
|
|
3888
4034
|
const ts = yield* service(TypeScriptApi);
|
|
3889
4035
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3890
4036
|
let subgraphDefs = [];
|
|
@@ -3937,7 +4083,7 @@ function processNodeMermaid(graph, ctx, ctxL) {
|
|
|
3937
4083
|
return subgraphDefs;
|
|
3938
4084
|
}
|
|
3939
4085
|
case "GraphNodeCompoundTransform": {
|
|
3940
|
-
const childs = flatten(yield*
|
|
4086
|
+
const childs = flatten(yield* all(...graph.args.map((_) => processNodeMermaid(_, ctx, ctxL))));
|
|
3941
4087
|
let currentEdges = [];
|
|
3942
4088
|
const connectedNodes = /* @__PURE__ */ new Set();
|
|
3943
4089
|
for (const requiredServiceKey of graph.rin) {
|
|
@@ -3969,7 +4115,7 @@ function processNodeMermaid(graph, ctx, ctxL) {
|
|
|
3969
4115
|
});
|
|
3970
4116
|
}
|
|
3971
4117
|
function generateMarmaidUri(graph, ctxL) {
|
|
3972
|
-
return
|
|
4118
|
+
return gen(function* () {
|
|
3973
4119
|
const ctx = {
|
|
3974
4120
|
seenIds: /* @__PURE__ */ new Set()
|
|
3975
4121
|
};
|
|
@@ -3981,7 +4127,7 @@ function generateMarmaidUri(graph, ctxL) {
|
|
|
3981
4127
|
}
|
|
3982
4128
|
function layerInfo(sourceFile, position, quickInfo2) {
|
|
3983
4129
|
return pipe(
|
|
3984
|
-
|
|
4130
|
+
gen(function* () {
|
|
3985
4131
|
const ts = yield* service(TypeScriptApi);
|
|
3986
4132
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3987
4133
|
const typeParser = yield* service(TypeParser);
|
|
@@ -4006,8 +4152,8 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
4006
4152
|
};
|
|
4007
4153
|
const layerInfoDisplayParts = yield* pipe(
|
|
4008
4154
|
processLayerGraphNode(graphCtx, layerNode, void 0),
|
|
4009
|
-
|
|
4010
|
-
(rootNode) =>
|
|
4155
|
+
flatMap2(
|
|
4156
|
+
(rootNode) => gen(function* () {
|
|
4011
4157
|
yield* succeed(void 0);
|
|
4012
4158
|
const lines = [];
|
|
4013
4159
|
const appendInfo = (providesNode, type, kindText) => {
|
|
@@ -4051,7 +4197,7 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
4051
4197
|
];
|
|
4052
4198
|
})
|
|
4053
4199
|
),
|
|
4054
|
-
|
|
4200
|
+
orElse2(
|
|
4055
4201
|
(e) => succeed([{
|
|
4056
4202
|
kind: "text",
|
|
4057
4203
|
text: "```\n/** layer graph not created: " + e.message + " */\n```\n"
|
|
@@ -4079,13 +4225,13 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
4079
4225
|
documentation: layerInfoDisplayParts
|
|
4080
4226
|
};
|
|
4081
4227
|
}),
|
|
4082
|
-
|
|
4228
|
+
orElse2(() => succeed(quickInfo2))
|
|
4083
4229
|
);
|
|
4084
4230
|
}
|
|
4085
4231
|
|
|
4086
4232
|
// src/quickinfo.ts
|
|
4087
4233
|
function quickInfo(sourceFile, position, quickInfo2) {
|
|
4088
|
-
return
|
|
4234
|
+
return gen(function* () {
|
|
4089
4235
|
const deduped = yield* dedupeJsDocs(quickInfo2);
|
|
4090
4236
|
const withEffectTypeArgs = yield* effectTypeArgs(sourceFile, position, deduped);
|
|
4091
4237
|
const withLayerInfo = yield* layerInfo(sourceFile, position, withEffectTypeArgs);
|
|
@@ -4116,9 +4262,9 @@ var asyncAwaitToGen = createRefactor({
|
|
|
4116
4262
|
kind: "refactor.rewrite.effect.asyncAwaitToGen",
|
|
4117
4263
|
description: "Rewrite to Effect.gen",
|
|
4118
4264
|
apply: pipe(
|
|
4119
|
-
|
|
4265
|
+
gen(function* () {
|
|
4120
4266
|
const changeTracker = yield* service(ChangeTracker);
|
|
4121
|
-
const effectModuleIdentifierName =
|
|
4267
|
+
const effectModuleIdentifierName = match(
|
|
4122
4268
|
yield* option(
|
|
4123
4269
|
findImportedModuleIdentifier(
|
|
4124
4270
|
sourceFile,
|
|
@@ -4187,9 +4333,9 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
4187
4333
|
kind: "refactor.rewrite.effect.asyncAwaitToGenTryPromise",
|
|
4188
4334
|
description: "Rewrite to Effect.gen with failures",
|
|
4189
4335
|
apply: pipe(
|
|
4190
|
-
|
|
4336
|
+
gen(function* () {
|
|
4191
4337
|
const changeTracker = yield* service(ChangeTracker);
|
|
4192
|
-
const effectModuleIdentifierName =
|
|
4338
|
+
const effectModuleIdentifierName = match(
|
|
4193
4339
|
yield* option(
|
|
4194
4340
|
findImportedModuleIdentifier(
|
|
4195
4341
|
sourceFile,
|
|
@@ -4294,7 +4440,7 @@ var effectGenToFn = createRefactor({
|
|
|
4294
4440
|
}
|
|
4295
4441
|
const maybePipe = yield* pipe(
|
|
4296
4442
|
typeParser.pipeCall(parent),
|
|
4297
|
-
|
|
4443
|
+
orElse2((e) => parent.parent ? typeParser.pipeCall(parent.parent) : fail(e)),
|
|
4298
4444
|
option
|
|
4299
4445
|
);
|
|
4300
4446
|
if (isSome2(maybePipe) && maybePipe.value.subject === nodeToReplace2) {
|
|
@@ -4318,7 +4464,7 @@ var effectGenToFn = createRefactor({
|
|
|
4318
4464
|
kind: "refactor.rewrite.effect.effectGenToFn",
|
|
4319
4465
|
description: "Convert to Effect.fn",
|
|
4320
4466
|
apply: pipe(
|
|
4321
|
-
|
|
4467
|
+
gen(function* () {
|
|
4322
4468
|
const changeTracker = yield* service(ChangeTracker);
|
|
4323
4469
|
const effectFn = nodeToReplace.name && ts.isIdentifier(nodeToReplace.name) ? ts.factory.createCallExpression(
|
|
4324
4470
|
ts.factory.createPropertyAccessExpression(
|
|
@@ -4375,7 +4521,7 @@ var functionToArrow = createRefactor({
|
|
|
4375
4521
|
kind: "refactor.rewrite.effect.functionToArrow",
|
|
4376
4522
|
description: "Convert to arrow",
|
|
4377
4523
|
apply: pipe(
|
|
4378
|
-
|
|
4524
|
+
gen(function* () {
|
|
4379
4525
|
const changeTracker = yield* service(ChangeTracker);
|
|
4380
4526
|
const body = node.body;
|
|
4381
4527
|
let newBody = ts.factory.createBlock(body.statements);
|
|
@@ -4538,9 +4684,9 @@ var makeSchemaOpaque = createRefactor({
|
|
|
4538
4684
|
kind: "refactor.rewrite.effect.makeSchemaOpaque",
|
|
4539
4685
|
description: `Make Schema opaque`,
|
|
4540
4686
|
apply: pipe(
|
|
4541
|
-
|
|
4687
|
+
gen(function* () {
|
|
4542
4688
|
const changeTracker = yield* service(ChangeTracker);
|
|
4543
|
-
const effectSchemaName =
|
|
4689
|
+
const effectSchemaName = match(
|
|
4544
4690
|
yield* option(
|
|
4545
4691
|
findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
4546
4692
|
sourceFile,
|
|
@@ -4616,9 +4762,9 @@ var makeSchemaOpaqueWithNs = createRefactor({
|
|
|
4616
4762
|
kind: "refactor.rewrite.effect.makeSchemaOpaqueWithNs",
|
|
4617
4763
|
description: `Make Schema opaque with namespace`,
|
|
4618
4764
|
apply: pipe(
|
|
4619
|
-
|
|
4765
|
+
gen(function* () {
|
|
4620
4766
|
const changeTracker = yield* service(ChangeTracker);
|
|
4621
|
-
const effectSchemaName =
|
|
4767
|
+
const effectSchemaName = match(
|
|
4622
4768
|
yield* option(
|
|
4623
4769
|
findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
4624
4770
|
sourceFile,
|
|
@@ -4772,7 +4918,7 @@ var pipeableToDatafirst = createRefactor({
|
|
|
4772
4918
|
return {
|
|
4773
4919
|
kind: "refactor.rewrite.effect.pipeableToDatafirst",
|
|
4774
4920
|
description: "Rewrite to datafirst",
|
|
4775
|
-
apply:
|
|
4921
|
+
apply: gen(function* () {
|
|
4776
4922
|
const changeTracker = yield* service(ChangeTracker);
|
|
4777
4923
|
changeTracker.replaceNode(sourceFile, node, newNode);
|
|
4778
4924
|
})
|
|
@@ -4793,7 +4939,7 @@ var removeUnnecessaryEffectGen = createRefactor({
|
|
|
4793
4939
|
return {
|
|
4794
4940
|
kind: "refactor.rewrite.effect.removeUnnecessaryEffectGen",
|
|
4795
4941
|
description: "Remove unnecessary Effect.gen",
|
|
4796
|
-
apply:
|
|
4942
|
+
apply: gen(function* () {
|
|
4797
4943
|
const changeTracker = yield* service(ChangeTracker);
|
|
4798
4944
|
changeTracker.replaceNode(sourceFile, nodeToReplace, yield* replacementNode);
|
|
4799
4945
|
})
|
|
@@ -4823,7 +4969,7 @@ var toggleLazyConst = createRefactor({
|
|
|
4823
4969
|
return {
|
|
4824
4970
|
kind: "refactor.rewrite.effect.toggleLazyConst",
|
|
4825
4971
|
description: "Toggle lazy const",
|
|
4826
|
-
apply:
|
|
4972
|
+
apply: gen(function* () {
|
|
4827
4973
|
const changeTracker = yield* service(ChangeTracker);
|
|
4828
4974
|
const initializer = node.initializer;
|
|
4829
4975
|
if (ts.isArrowFunction(initializer) && initializer.parameters.length === 0) {
|
|
@@ -4913,7 +5059,7 @@ var toggleTypeAnnotation = createRefactor({
|
|
|
4913
5059
|
kind: "refactor.rewrite.effect.toggleTypeAnnotation",
|
|
4914
5060
|
description: "Toggle type annotation",
|
|
4915
5061
|
apply: pipe(
|
|
4916
|
-
|
|
5062
|
+
gen(function* () {
|
|
4917
5063
|
const changeTracker = yield* service(ChangeTracker);
|
|
4918
5064
|
if (node.type) {
|
|
4919
5065
|
changeTracker.deleteRange(sourceFile, { pos: node.name.end, end: node.type.end });
|
|
@@ -4921,19 +5067,19 @@ var toggleTypeAnnotation = createRefactor({
|
|
|
4921
5067
|
}
|
|
4922
5068
|
const initializer = node.initializer;
|
|
4923
5069
|
const initializerType = typeChecker.getTypeAtLocation(initializer);
|
|
4924
|
-
const initializerTypeNode =
|
|
5070
|
+
const initializerTypeNode = fromNullable(typeChecker.typeToTypeNode(
|
|
4925
5071
|
initializerType,
|
|
4926
5072
|
node,
|
|
4927
5073
|
ts.NodeBuilderFlags.NoTruncation
|
|
4928
5074
|
)).pipe(
|
|
4929
|
-
|
|
4930
|
-
() =>
|
|
5075
|
+
orElse(
|
|
5076
|
+
() => fromNullable(typeChecker.typeToTypeNode(
|
|
4931
5077
|
initializerType,
|
|
4932
5078
|
void 0,
|
|
4933
5079
|
ts.NodeBuilderFlags.NoTruncation
|
|
4934
5080
|
))
|
|
4935
5081
|
),
|
|
4936
|
-
|
|
5082
|
+
getOrUndefined
|
|
4937
5083
|
);
|
|
4938
5084
|
if (initializerTypeNode) {
|
|
4939
5085
|
changeTracker.insertNodeAt(
|
|
@@ -4995,7 +5141,7 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
|
|
|
4995
5141
|
yield* option(
|
|
4996
5142
|
findImportedModuleIdentifierByPackageAndNameOrBarrel(sourceFile, "effect", "Schema")
|
|
4997
5143
|
),
|
|
4998
|
-
|
|
5144
|
+
match({
|
|
4999
5145
|
onNone: () => "Schema",
|
|
5000
5146
|
onSome: (_) => _.text
|
|
5001
5147
|
})
|
|
@@ -5078,7 +5224,7 @@ var parseAllLiterals = fn(
|
|
|
5078
5224
|
}
|
|
5079
5225
|
}
|
|
5080
5226
|
if (ts.isUnionTypeNode(node)) {
|
|
5081
|
-
return flatten(yield*
|
|
5227
|
+
return flatten(yield* all(...node.types.map((_) => parseAllLiterals(_))));
|
|
5082
5228
|
}
|
|
5083
5229
|
if (ts.isParenthesizedTypeNode(node)) {
|
|
5084
5230
|
return yield* parseAllLiterals(node.type);
|
|
@@ -5091,7 +5237,7 @@ var createUnsupportedNodeComment = (ts, sourceFile, node) => ts.addSyntheticTrai
|
|
|
5091
5237
|
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
5092
5238
|
" Not supported conversion: " + node.getText(sourceFile) + " "
|
|
5093
5239
|
);
|
|
5094
|
-
var processNode = (node, isVirtualTypeNode) =>
|
|
5240
|
+
var processNode = (node, isVirtualTypeNode) => gen(function* () {
|
|
5095
5241
|
const { createApiCall, createApiPropertyAccess, entityNameToDataTypeName, sourceFile, ts } = yield* service(
|
|
5096
5242
|
SchemaGenContext
|
|
5097
5243
|
);
|
|
@@ -5125,11 +5271,11 @@ var processNode = (node, isVirtualTypeNode) => gen2(function* () {
|
|
|
5125
5271
|
if (ts.isUnionTypeNode(node)) {
|
|
5126
5272
|
const allLiterals = yield* option(parseAllLiterals(node));
|
|
5127
5273
|
if (isSome2(allLiterals)) return createApiCall("Literal", allLiterals.value);
|
|
5128
|
-
const members = yield*
|
|
5274
|
+
const members = yield* all(...node.types.map((_) => processNode(_, isVirtualTypeNode)));
|
|
5129
5275
|
return createApiCall("Union", members);
|
|
5130
5276
|
}
|
|
5131
5277
|
if (ts.isIntersectionTypeNode(node)) {
|
|
5132
|
-
const [firstSchema, ...otherSchemas] = yield*
|
|
5278
|
+
const [firstSchema, ...otherSchemas] = yield* all(
|
|
5133
5279
|
...node.types.map((_) => processNode(_, isVirtualTypeNode))
|
|
5134
5280
|
);
|
|
5135
5281
|
if (otherSchemas.length === 0) return firstSchema;
|
|
@@ -5185,13 +5331,13 @@ var processNode = (node, isVirtualTypeNode) => gen2(function* () {
|
|
|
5185
5331
|
case "Option":
|
|
5186
5332
|
case "Chunk":
|
|
5187
5333
|
case "Array": {
|
|
5188
|
-
const elements = yield*
|
|
5334
|
+
const elements = yield* all(
|
|
5189
5335
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
5190
5336
|
);
|
|
5191
5337
|
return createApiCall(parsedName.value, elements);
|
|
5192
5338
|
}
|
|
5193
5339
|
case "Record": {
|
|
5194
|
-
const elements = yield*
|
|
5340
|
+
const elements = yield* all(
|
|
5195
5341
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
5196
5342
|
);
|
|
5197
5343
|
if (elements.length >= 2) {
|
|
@@ -5205,7 +5351,7 @@ var processNode = (node, isVirtualTypeNode) => gen2(function* () {
|
|
|
5205
5351
|
return createUnsupportedNodeComment(ts, sourceFile, node);
|
|
5206
5352
|
}
|
|
5207
5353
|
case "Either": {
|
|
5208
|
-
const elements = yield*
|
|
5354
|
+
const elements = yield* all(
|
|
5209
5355
|
...node.typeArguments ? node.typeArguments.map((_) => processNode(_, isVirtualTypeNode)) : []
|
|
5210
5356
|
);
|
|
5211
5357
|
if (elements.length >= 2) {
|
|
@@ -5404,7 +5550,7 @@ var applyAtNode = fn("SchemaGen.applyAtNode")(
|
|
|
5404
5550
|
const changeTracker = yield* service(ChangeTracker);
|
|
5405
5551
|
const newNode = yield* pipe(
|
|
5406
5552
|
process(sourceFile, node, preferClass),
|
|
5407
|
-
|
|
5553
|
+
orElse2(
|
|
5408
5554
|
(error) => succeed(ts.addSyntheticLeadingComment(
|
|
5409
5555
|
ts.factory.createIdentifier(""),
|
|
5410
5556
|
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
@@ -5488,7 +5634,7 @@ var wrapWithEffectGen = createRefactor({
|
|
|
5488
5634
|
option
|
|
5489
5635
|
);
|
|
5490
5636
|
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
5491
|
-
const effectModuleIdentifier =
|
|
5637
|
+
const effectModuleIdentifier = match(
|
|
5492
5638
|
yield* option(
|
|
5493
5639
|
findImportedModuleIdentifier(
|
|
5494
5640
|
sourceFile,
|
|
@@ -5508,7 +5654,7 @@ var wrapWithEffectGen = createRefactor({
|
|
|
5508
5654
|
kind: "refactor.rewrite.effect.wrapWithEffectGen",
|
|
5509
5655
|
description: `Wrap with Effect.gen`,
|
|
5510
5656
|
apply: pipe(
|
|
5511
|
-
|
|
5657
|
+
gen(function* () {
|
|
5512
5658
|
const changeTracker = yield* service(ChangeTracker);
|
|
5513
5659
|
const effectGen = yield* pipe(
|
|
5514
5660
|
createEffectGenCallExpressionWithBlock(
|
|
@@ -5536,7 +5682,7 @@ var wrapWithPipe = createRefactor({
|
|
|
5536
5682
|
return {
|
|
5537
5683
|
kind: "refactor.rewrite.effect.wrapWithPipe",
|
|
5538
5684
|
description: `Wrap with pipe(...)`,
|
|
5539
|
-
apply:
|
|
5685
|
+
apply: gen(function* () {
|
|
5540
5686
|
const changeTracker = yield* service(ChangeTracker);
|
|
5541
5687
|
changeTracker.insertText(sourceFile, textRange.pos, "pipe(");
|
|
5542
5688
|
changeTracker.insertText(sourceFile, textRange.end, ")");
|
|
@@ -5619,11 +5765,11 @@ var init = (modules) => {
|
|
|
5619
5765
|
return pipe(
|
|
5620
5766
|
getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
|
|
5621
5767
|
runNano(program),
|
|
5622
|
-
|
|
5768
|
+
map(({ codeFixes, diagnostics: diagnostics2 }) => {
|
|
5623
5769
|
effectCodeFixesForFile.set(fileName, codeFixes);
|
|
5624
5770
|
return diagnostics2.concat(applicableDiagnostics);
|
|
5625
5771
|
}),
|
|
5626
|
-
|
|
5772
|
+
getOrElse(() => applicableDiagnostics)
|
|
5627
5773
|
);
|
|
5628
5774
|
}
|
|
5629
5775
|
}
|
|
@@ -5674,8 +5820,8 @@ var init = (modules) => {
|
|
|
5674
5820
|
return effectCodeFixes;
|
|
5675
5821
|
}),
|
|
5676
5822
|
run,
|
|
5677
|
-
|
|
5678
|
-
|
|
5823
|
+
map((effectCodeFixes) => applicableCodeFixes.concat(effectCodeFixes)),
|
|
5824
|
+
getOrElse(() => applicableCodeFixes)
|
|
5679
5825
|
);
|
|
5680
5826
|
};
|
|
5681
5827
|
proxy.getApplicableRefactors = (...args) => {
|
|
@@ -5688,8 +5834,8 @@ var init = (modules) => {
|
|
|
5688
5834
|
return pipe(
|
|
5689
5835
|
getApplicableRefactors(refactors, sourceFile, positionOrRange),
|
|
5690
5836
|
runNano(program),
|
|
5691
|
-
|
|
5692
|
-
|
|
5837
|
+
map((effectRefactors) => applicableRefactors.concat(effectRefactors)),
|
|
5838
|
+
getOrElse(() => applicableRefactors)
|
|
5693
5839
|
);
|
|
5694
5840
|
}
|
|
5695
5841
|
}
|
|
@@ -5701,7 +5847,7 @@ var init = (modules) => {
|
|
|
5701
5847
|
const sourceFile = program.getSourceFile(fileName);
|
|
5702
5848
|
if (sourceFile) {
|
|
5703
5849
|
const result = pipe(
|
|
5704
|
-
|
|
5850
|
+
gen(function* () {
|
|
5705
5851
|
const applicableRefactor = yield* getEditsForRefactor(
|
|
5706
5852
|
refactors,
|
|
5707
5853
|
sourceFile,
|
|
@@ -5728,7 +5874,7 @@ var init = (modules) => {
|
|
|
5728
5874
|
}),
|
|
5729
5875
|
runNano(program)
|
|
5730
5876
|
);
|
|
5731
|
-
if (
|
|
5877
|
+
if (isRight2(result)) return result.right;
|
|
5732
5878
|
}
|
|
5733
5879
|
}
|
|
5734
5880
|
return languageService.getEditsForRefactor(
|
|
@@ -5755,7 +5901,7 @@ var init = (modules) => {
|
|
|
5755
5901
|
applicableQuickInfo
|
|
5756
5902
|
),
|
|
5757
5903
|
runNano(program),
|
|
5758
|
-
|
|
5904
|
+
getOrElse(() => applicableQuickInfo)
|
|
5759
5905
|
);
|
|
5760
5906
|
}
|
|
5761
5907
|
}
|
|
@@ -5776,32 +5922,70 @@ var init = (modules) => {
|
|
|
5776
5922
|
const sourceFile = program.getSourceFile(fileName);
|
|
5777
5923
|
if (sourceFile) {
|
|
5778
5924
|
return pipe(
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5925
|
+
appendEffectCompletionEntryData(sourceFile, applicableCompletions),
|
|
5926
|
+
flatMap2(
|
|
5927
|
+
(augmentedCompletions) => pipe(
|
|
5928
|
+
getCompletionsAtPosition(
|
|
5929
|
+
completions,
|
|
5930
|
+
sourceFile,
|
|
5931
|
+
position,
|
|
5932
|
+
options,
|
|
5933
|
+
formattingSettings
|
|
5934
|
+
),
|
|
5935
|
+
map4(
|
|
5936
|
+
(effectCompletions) => augmentedCompletions ? {
|
|
5937
|
+
...augmentedCompletions,
|
|
5938
|
+
entries: effectCompletions.concat(augmentedCompletions.entries)
|
|
5939
|
+
} : effectCompletions.length > 0 ? {
|
|
5940
|
+
entries: effectCompletions,
|
|
5941
|
+
isGlobalCompletion: false,
|
|
5942
|
+
isMemberCompletion: false,
|
|
5943
|
+
isNewIdentifierLocation: false
|
|
5944
|
+
} : void 0
|
|
5945
|
+
)
|
|
5946
|
+
)
|
|
5785
5947
|
),
|
|
5786
5948
|
runNano(program),
|
|
5787
|
-
|
|
5788
|
-
(effectCompletions) => applicableCompletions ? {
|
|
5789
|
-
...applicableCompletions,
|
|
5790
|
-
entries: effectCompletions.concat(applicableCompletions.entries)
|
|
5791
|
-
} : effectCompletions.length > 0 ? {
|
|
5792
|
-
entries: effectCompletions,
|
|
5793
|
-
isGlobalCompletion: false,
|
|
5794
|
-
isMemberCompletion: false,
|
|
5795
|
-
isNewIdentifierLocation: false
|
|
5796
|
-
} : void 0
|
|
5797
|
-
),
|
|
5798
|
-
Either_exports.getOrElse(() => applicableCompletions)
|
|
5949
|
+
getOrElse(() => applicableCompletions)
|
|
5799
5950
|
);
|
|
5800
5951
|
}
|
|
5801
5952
|
}
|
|
5802
5953
|
}
|
|
5803
5954
|
return applicableCompletions;
|
|
5804
5955
|
};
|
|
5956
|
+
proxy.getCompletionEntryDetails = (fileName, position, entryName, formatOptions, source, preferences, _data, ...args) => {
|
|
5957
|
+
const applicableCompletionEntryDetails = languageService.getCompletionEntryDetails(
|
|
5958
|
+
fileName,
|
|
5959
|
+
position,
|
|
5960
|
+
entryName,
|
|
5961
|
+
formatOptions,
|
|
5962
|
+
source,
|
|
5963
|
+
preferences,
|
|
5964
|
+
_data,
|
|
5965
|
+
...args
|
|
5966
|
+
);
|
|
5967
|
+
if (languageServicePluginOptions.completions) {
|
|
5968
|
+
const program = languageService.getProgram();
|
|
5969
|
+
if (program) {
|
|
5970
|
+
const sourceFile = program.getSourceFile(fileName);
|
|
5971
|
+
if (sourceFile) {
|
|
5972
|
+
return pipe(
|
|
5973
|
+
postprocessCompletionEntryDetails(
|
|
5974
|
+
sourceFile,
|
|
5975
|
+
_data,
|
|
5976
|
+
applicableCompletionEntryDetails,
|
|
5977
|
+
formatOptions,
|
|
5978
|
+
preferences,
|
|
5979
|
+
info.languageServiceHost
|
|
5980
|
+
),
|
|
5981
|
+
runNano(program),
|
|
5982
|
+
getOrElse(() => applicableCompletionEntryDetails)
|
|
5983
|
+
);
|
|
5984
|
+
}
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
return applicableCompletionEntryDetails;
|
|
5988
|
+
};
|
|
5805
5989
|
proxy.getDefinitionAndBoundSpan = (fileName, position, ...args) => {
|
|
5806
5990
|
const applicableDefinition = languageService.getDefinitionAndBoundSpan(fileName, position, ...args);
|
|
5807
5991
|
if (languageServicePluginOptions.goto) {
|
|
@@ -5812,7 +5996,7 @@ var init = (modules) => {
|
|
|
5812
5996
|
return pipe(
|
|
5813
5997
|
goto(applicableDefinition, sourceFile, position),
|
|
5814
5998
|
runNano(program),
|
|
5815
|
-
|
|
5999
|
+
getOrElse(() => applicableDefinition)
|
|
5816
6000
|
);
|
|
5817
6001
|
}
|
|
5818
6002
|
}
|