@effect/language-service 0.38.1 → 0.38.2
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/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +66 -12
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +106 -17
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +66 -12
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -960,7 +960,7 @@ var match = (fa, opts) => {
|
|
|
960
960
|
var orElse2 = (f) => (fa) => {
|
|
961
961
|
const nano = Object.create(MatchProto);
|
|
962
962
|
nano[args] = fa;
|
|
963
|
-
nano[contE] = f;
|
|
963
|
+
nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : f(_);
|
|
964
964
|
return nano;
|
|
965
965
|
};
|
|
966
966
|
var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
|
|
@@ -1148,6 +1148,19 @@ var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
return out;
|
|
1150
1150
|
});
|
|
1151
|
+
var partition = /* @__PURE__ */ dual(2, (self, predicate) => {
|
|
1152
|
+
const left3 = [];
|
|
1153
|
+
const right3 = [];
|
|
1154
|
+
const as = fromIterable(self);
|
|
1155
|
+
for (let i = 0; i < as.length; i++) {
|
|
1156
|
+
if (predicate(as[i], i)) {
|
|
1157
|
+
right3.push(as[i]);
|
|
1158
|
+
} else {
|
|
1159
|
+
left3.push(as[i]);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return [left3, right3];
|
|
1163
|
+
});
|
|
1151
1164
|
var every = /* @__PURE__ */ dual(2, (self, refinement) => self.every(refinement));
|
|
1152
1165
|
var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
1153
1166
|
const input = fromIterable(self);
|
|
@@ -1746,18 +1759,21 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
1746
1759
|
const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
1747
1760
|
const effectRefactors = [];
|
|
1748
1761
|
for (const refactor of refactors2) {
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
description: refactor.description,
|
|
1754
|
-
actions: [{
|
|
1762
|
+
yield* pipe(
|
|
1763
|
+
refactor.apply(sourceFile, textRange),
|
|
1764
|
+
map3(
|
|
1765
|
+
(result) => effectRefactors.push({
|
|
1755
1766
|
name: refactorNameToFullyQualifiedName(refactor.name),
|
|
1756
|
-
description:
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1767
|
+
description: refactor.description,
|
|
1768
|
+
actions: [{
|
|
1769
|
+
name: refactorNameToFullyQualifiedName(refactor.name),
|
|
1770
|
+
description: result.description,
|
|
1771
|
+
kind: result.kind
|
|
1772
|
+
}]
|
|
1773
|
+
})
|
|
1774
|
+
),
|
|
1775
|
+
ignore
|
|
1776
|
+
);
|
|
1761
1777
|
}
|
|
1762
1778
|
return effectRefactors;
|
|
1763
1779
|
});
|
|
@@ -3226,6 +3242,55 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3226
3242
|
"TypeParser.extendsContextTag",
|
|
3227
3243
|
(atLocation) => atLocation
|
|
3228
3244
|
);
|
|
3245
|
+
const extendsEffectTag = cachedBy(
|
|
3246
|
+
fn("TypeParser.extendsEffectTag")(function* (atLocation) {
|
|
3247
|
+
if (!atLocation.name) {
|
|
3248
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
3249
|
+
}
|
|
3250
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
3251
|
+
if (!heritageClauses) {
|
|
3252
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
3253
|
+
}
|
|
3254
|
+
for (const heritageClause of heritageClauses) {
|
|
3255
|
+
for (const typeX of heritageClause.types) {
|
|
3256
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
3257
|
+
const wholeCall = typeX.expression;
|
|
3258
|
+
if (ts.isCallExpression(wholeCall)) {
|
|
3259
|
+
const effectTagCall = wholeCall.expression;
|
|
3260
|
+
if (ts.isCallExpression(effectTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
|
|
3261
|
+
const effectTagIdentifier = effectTagCall.expression;
|
|
3262
|
+
const selfTypeNode = wholeCall.typeArguments[0];
|
|
3263
|
+
if (ts.isPropertyAccessExpression(effectTagIdentifier) && ts.isIdentifier(effectTagIdentifier.name) && ts.idText(effectTagIdentifier.name) === "Tag") {
|
|
3264
|
+
const parsedEffectModule = yield* pipe(
|
|
3265
|
+
importedEffectModule(effectTagIdentifier.expression),
|
|
3266
|
+
option
|
|
3267
|
+
);
|
|
3268
|
+
if (isSome2(parsedEffectModule)) {
|
|
3269
|
+
const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
|
|
3270
|
+
if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
|
|
3271
|
+
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
3272
|
+
const tagType = yield* contextTag(type, atLocation);
|
|
3273
|
+
return {
|
|
3274
|
+
className: atLocation.name,
|
|
3275
|
+
selfTypeNode,
|
|
3276
|
+
keyStringLiteral: ts.isStringLiteral(effectTagCall.arguments[0]) ? effectTagCall.arguments[0] : void 0,
|
|
3277
|
+
args: effectTagCall.arguments,
|
|
3278
|
+
Identifier: tagType.Identifier,
|
|
3279
|
+
Service: tagType.Service,
|
|
3280
|
+
Tag: parsedEffectModule.value
|
|
3281
|
+
};
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
return yield* typeParserIssue("Class does not extend Effect.Tag", void 0, atLocation);
|
|
3290
|
+
}),
|
|
3291
|
+
"TypeParser.extendsEffectTag",
|
|
3292
|
+
(atLocation) => atLocation
|
|
3293
|
+
);
|
|
3229
3294
|
const extendsEffectService = cachedBy(
|
|
3230
3295
|
fn("TypeParser.extendsEffectService")(function* (atLocation) {
|
|
3231
3296
|
if (!atLocation.name) {
|
|
@@ -3308,6 +3373,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
|
3308
3373
|
pipeCall,
|
|
3309
3374
|
scopeType,
|
|
3310
3375
|
promiseLike,
|
|
3376
|
+
extendsEffectTag,
|
|
3311
3377
|
extendsEffectService,
|
|
3312
3378
|
extendsContextTag,
|
|
3313
3379
|
extendsSchemaClass,
|
|
@@ -3520,6 +3586,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
3520
3586
|
if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
|
|
3521
3587
|
const { Service, accessors: accessors2, className } = yield* pipe(
|
|
3522
3588
|
typeParser.extendsEffectService(node),
|
|
3589
|
+
orElse2(() => map3(typeParser.extendsEffectTag(node), (_) => ({ accessors: true, ..._ }))),
|
|
3523
3590
|
orElse2(() => fail("not a class extending Effect.Service call"))
|
|
3524
3591
|
);
|
|
3525
3592
|
if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
|
|
@@ -10821,7 +10888,7 @@ function findInnermostGraphEdge(graph, kind, key) {
|
|
|
10821
10888
|
}
|
|
10822
10889
|
}
|
|
10823
10890
|
function escapeMermaid(text) {
|
|
10824
|
-
return text.replace(/"/mg, "#quot;").replace(/\n/mg, " ");
|
|
10891
|
+
return text.replace(/"/mg, "#quot;").replace(/\n/mg, " ").replace(/</mg, "#lt;").replace(/>/mg, "#gt;");
|
|
10825
10892
|
}
|
|
10826
10893
|
function processNodeMermaid(graph, ctx, ctxL) {
|
|
10827
10894
|
return gen(function* () {
|
|
@@ -11678,12 +11745,35 @@ var layerMagic = createRefactor({
|
|
|
11678
11745
|
(_) => succeed((_.flags & ts.TypeFlags.Never) !== 0)
|
|
11679
11746
|
);
|
|
11680
11747
|
}
|
|
11681
|
-
const
|
|
11748
|
+
const previouslyProvided = yield* pipe(
|
|
11749
|
+
typeParser.layerType(typeChecker.getTypeAtLocation(atLocation), atLocation),
|
|
11750
|
+
map3((_) => _.ROut),
|
|
11751
|
+
option
|
|
11752
|
+
);
|
|
11753
|
+
const [existingBefore, newlyIntroduced] = pipe(
|
|
11682
11754
|
fromIterable(memory.values()),
|
|
11683
11755
|
sort(typeCheckerUtils.deterministicTypeOrder),
|
|
11756
|
+
partition(
|
|
11757
|
+
(_) => isNone2(previouslyProvided) || typeChecker.isTypeAssignableTo(_, previouslyProvided.value)
|
|
11758
|
+
)
|
|
11759
|
+
);
|
|
11760
|
+
const typeReferences = pipe(
|
|
11761
|
+
newlyIntroduced,
|
|
11684
11762
|
map5((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
|
|
11685
11763
|
filter((_) => !!_)
|
|
11686
11764
|
);
|
|
11765
|
+
const providesUnion = typeReferences.length === 0 ? ts.factory.createTypeReferenceNode("never") : ts.factory.createUnionTypeNode(typeReferences);
|
|
11766
|
+
const typeStrings = pipe(
|
|
11767
|
+
existingBefore,
|
|
11768
|
+
map5((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)),
|
|
11769
|
+
filter((_) => !!_)
|
|
11770
|
+
);
|
|
11771
|
+
const unionWithComment = typeStrings.length === 0 ? providesUnion : ts.addSyntheticTrailingComment(
|
|
11772
|
+
providesUnion,
|
|
11773
|
+
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
11774
|
+
" " + typeStrings.join(" | ") + " ",
|
|
11775
|
+
false
|
|
11776
|
+
);
|
|
11687
11777
|
const newDeclaration = ts.factory.createAsExpression(
|
|
11688
11778
|
ts.factory.createAsExpression(
|
|
11689
11779
|
ts.factory.createArrayLiteralExpression(extractedLayers.map((_) => _.node)),
|
|
@@ -11691,9 +11781,7 @@ var layerMagic = createRefactor({
|
|
|
11691
11781
|
),
|
|
11692
11782
|
ts.factory.createTypeReferenceNode(
|
|
11693
11783
|
ts.factory.createQualifiedName(ts.factory.createIdentifier(layerIdentifier), "Layer"),
|
|
11694
|
-
|
|
11695
|
-
ts.factory.createTypeReferenceNode("never")
|
|
11696
|
-
] : [ts.factory.createUnionTypeNode(typeReferences)]
|
|
11784
|
+
[unionWithComment]
|
|
11697
11785
|
)
|
|
11698
11786
|
);
|
|
11699
11787
|
changeTracker.replaceNode(sourceFile, atLocation, newDeclaration, {
|
|
@@ -13061,6 +13149,7 @@ var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _
|
|
|
13061
13149
|
const baseIdentifier = yield* pipe(
|
|
13062
13150
|
map3(typeParser.extendsContextTag(parentClass), (_) => [_.keyStringLiteral]),
|
|
13063
13151
|
orElse2(() => map3(typeParser.extendsEffectService(parentClass), (_) => [_.keyStringLiteral])),
|
|
13152
|
+
orElse2(() => map3(typeParser.extendsEffectTag(parentClass), (_) => [_.keyStringLiteral])),
|
|
13064
13153
|
orElse2(
|
|
13065
13154
|
() => map3(typeParser.extendsSchemaTaggedClass(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
|
|
13066
13155
|
),
|