@effect/language-service 0.36.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/cli.js +108 -25
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +407 -288
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +831 -308
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +377 -262
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -86,8 +86,10 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
86
86
|
- Remove unnecessary `Effect.gen` definitions that contains a single `yield` statement.
|
|
87
87
|
- Wrap an `Effect` expression with `Effect.gen`
|
|
88
88
|
- Toggle between pipe styles `X.pipe(Y)` and `pipe(X, Y)`
|
|
89
|
+
- Layer Magic: Automatically compose and build layers based on service dependencies
|
|
89
90
|
|
|
90
91
|
### Miscellaneous
|
|
92
|
+
- Renaming a class name, will rename the identifier as well for TaggedError, TaggedClass, etc...
|
|
91
93
|
- "Go to definition" for RpcClient will resolve to the Rpc definition
|
|
92
94
|
|
|
93
95
|
## Options
|
|
@@ -113,7 +115,8 @@ Few options can be provided alongside the initialization of the Language Service
|
|
|
113
115
|
"allowedDuplicatedPackages": [], // list of package names that have effect in peer dependencies and are allowed to be duplicated (default: [])
|
|
114
116
|
"barrelImportPackages": [], // package names that should be preferred as imported from the top level barrel file (default: [])
|
|
115
117
|
"namespaceImportPackages": [], // package names that should be preferred as imported with namespace imports e.g. ["effect", "@effect/*"] (default: [])
|
|
116
|
-
"topLevelNamedReexports": "ignore" // for namespaceImportPackages, how should top level named re-exports (e.g. {pipe} from "effect") be treated? "ignore" will leave them as is, "follow" will rewrite them to the re-exported module (e.g. {pipe} from "effect/Function")
|
|
118
|
+
"topLevelNamedReexports": "ignore", // for namespaceImportPackages, how should top level named re-exports (e.g. {pipe} from "effect") be treated? "ignore" will leave them as is, "follow" will rewrite them to the re-exported module (e.g. {pipe} from "effect/Function")
|
|
119
|
+
"importAliases": { "Array": "Arr" } // allows to chose some different names for import name aliases (only when not chosing to import the whole module) (default: {})
|
|
117
120
|
}
|
|
118
121
|
]
|
|
119
122
|
}
|
package/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -28972,6 +28973,34 @@ var suspend11 = (fn3) => {
|
|
|
28972
28973
|
nano[args2] = fn3;
|
|
28973
28974
|
return nano;
|
|
28974
28975
|
};
|
|
28976
|
+
var timings = {};
|
|
28977
|
+
var timingsCount = {};
|
|
28978
|
+
var WithSpanProto = {
|
|
28979
|
+
...PrimitiveProto,
|
|
28980
|
+
[evaluate2](fiber) {
|
|
28981
|
+
const [fa, name] = this[args2];
|
|
28982
|
+
if (!fiber._perf) return fa;
|
|
28983
|
+
const start4 = performance.now();
|
|
28984
|
+
timingsCount[name] = (timingsCount[name] || 0) + 1;
|
|
28985
|
+
return match17(fa, {
|
|
28986
|
+
onSuccess: (_) => {
|
|
28987
|
+
const end5 = performance.now();
|
|
28988
|
+
timings[name] = (timings[name] || 0) + (end5 - start4);
|
|
28989
|
+
return succeed17(_);
|
|
28990
|
+
},
|
|
28991
|
+
onFailure: (_) => {
|
|
28992
|
+
const end5 = performance.now();
|
|
28993
|
+
timings[name] = (timings[name] || 0) + (end5 - start4);
|
|
28994
|
+
return fail18(_);
|
|
28995
|
+
}
|
|
28996
|
+
});
|
|
28997
|
+
}
|
|
28998
|
+
};
|
|
28999
|
+
var withSpan6 = (name) => (fa) => {
|
|
29000
|
+
const nano = Object.create(WithSpanProto);
|
|
29001
|
+
nano[args2] = [fa, name];
|
|
29002
|
+
return nano;
|
|
29003
|
+
};
|
|
28975
29004
|
var OnSuccessProto2 = {
|
|
28976
29005
|
...PrimitiveProto,
|
|
28977
29006
|
[evaluate2](fiber) {
|
|
@@ -29012,7 +29041,7 @@ var unsafeFromIterator = (iterator, initial) => {
|
|
|
29012
29041
|
nano[args2] = [iterator, initial];
|
|
29013
29042
|
return nano;
|
|
29014
29043
|
};
|
|
29015
|
-
var fn2 = (_) => (body) => (...args3) => suspend11(() => unsafeFromIterator(body(...args3)));
|
|
29044
|
+
var fn2 = (_) => (body) => (...args3) => withSpan6(_)(suspend11(() => unsafeFromIterator(body(...args3))));
|
|
29016
29045
|
var MatchProto = {
|
|
29017
29046
|
...PrimitiveProto,
|
|
29018
29047
|
[evaluate2](fiber) {
|
|
@@ -29264,7 +29293,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29264
29293
|
fnCall = ts4.factory.createCallExpression(
|
|
29265
29294
|
fnCall,
|
|
29266
29295
|
void 0,
|
|
29267
|
-
[ts4.factory.createStringLiteral(fnName
|
|
29296
|
+
[ts4.factory.createStringLiteral(ts4.idText(fnName))]
|
|
29268
29297
|
);
|
|
29269
29298
|
}
|
|
29270
29299
|
return tryPreserveDeclarationSemantics(
|
|
@@ -29336,7 +29365,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29336
29365
|
if (!namedBindings) continue;
|
|
29337
29366
|
if (ts4.isNamespaceImport(namedBindings)) {
|
|
29338
29367
|
if (test(namedBindings.name, statement.moduleSpecifier, none2())) {
|
|
29339
|
-
return namedBindings.name
|
|
29368
|
+
return ts4.idText(namedBindings.name);
|
|
29340
29369
|
}
|
|
29341
29370
|
} else if (ts4.isNamedImports(namedBindings)) {
|
|
29342
29371
|
for (const importSpecifier of namedBindings.elements) {
|
|
@@ -29344,7 +29373,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29344
29373
|
orElse(() => some2(importSpecifier.name))
|
|
29345
29374
|
);
|
|
29346
29375
|
if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
|
|
29347
|
-
return importSpecifier.name
|
|
29376
|
+
return ts4.idText(importSpecifier.name);
|
|
29348
29377
|
}
|
|
29349
29378
|
}
|
|
29350
29379
|
}
|
|
@@ -29357,7 +29386,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29357
29386
|
if (isNone2(importProperty) && ts4.isStringLiteral(fromModule) && fromModule.text === packageName + "/" + moduleName) {
|
|
29358
29387
|
return true;
|
|
29359
29388
|
}
|
|
29360
|
-
if (isSome2(importProperty) && ts4.isIdentifier(importProperty.value) && importProperty.value
|
|
29389
|
+
if (isSome2(importProperty) && ts4.isIdentifier(importProperty.value) && ts4.idText(importProperty.value) === moduleName && ts4.isStringLiteral(fromModule) && fromModule.text === packageName) {
|
|
29361
29390
|
return true;
|
|
29362
29391
|
}
|
|
29363
29392
|
return false;
|
|
@@ -29791,9 +29820,11 @@ var moduleNames = choice3("module", [
|
|
|
29791
29820
|
var getPatchesForModule = fn("getPatchesForModule")(
|
|
29792
29821
|
function* (moduleName, dirPath4, version, sourceFile) {
|
|
29793
29822
|
const patches = [];
|
|
29794
|
-
|
|
29795
|
-
let
|
|
29796
|
-
let
|
|
29823
|
+
const insertUtilsPosition = some2({ position: 0 });
|
|
29824
|
+
let insertClearSourceFileEffectMetadataPosition = none2();
|
|
29825
|
+
let insertCheckSourceFilePosition = none2();
|
|
29826
|
+
let insertSkipPrecedingCommentDirectivePosition = none2();
|
|
29827
|
+
let insertAppendMetadataRelationErrorPosition = none2();
|
|
29797
29828
|
const nodesToCheck = [];
|
|
29798
29829
|
function findNodeAtPositionIncludingTrivia(sourceFile2, position) {
|
|
29799
29830
|
function find3(node) {
|
|
@@ -29818,8 +29849,11 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29818
29849
|
}
|
|
29819
29850
|
return pushed;
|
|
29820
29851
|
}
|
|
29821
|
-
|
|
29822
|
-
if (!pushFunctionDeclarationNode("
|
|
29852
|
+
let requiresFullScan = false;
|
|
29853
|
+
if (!pushFunctionDeclarationNode("checkSourceFileWorker")) requiresFullScan = true;
|
|
29854
|
+
if (!pushFunctionDeclarationNode("markPrecedingCommentDirectiveLine")) requiresFullScan = true;
|
|
29855
|
+
if (!pushFunctionDeclarationNode("reportRelationError")) requiresFullScan = true;
|
|
29856
|
+
if (requiresFullScan) nodesToCheck.push(sourceFile);
|
|
29823
29857
|
while (nodesToCheck.length > 0) {
|
|
29824
29858
|
const node = nodesToCheck.shift();
|
|
29825
29859
|
if (!node) continue;
|
|
@@ -29829,12 +29863,29 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29829
29863
|
const identifier2 = expression.expression;
|
|
29830
29864
|
if (ts3.isIdentifier(identifier2) && ts3.idText(identifier2) === "checkGrammarSourceFile" && ts3.isBlock(node.parent) && node.parent.statements.length > 0) {
|
|
29831
29865
|
const block = node.parent;
|
|
29832
|
-
|
|
29866
|
+
const parentFunctionDeclaration = ts3.findAncestor(node, ts3.isFunctionDeclaration);
|
|
29867
|
+
if (parentFunctionDeclaration && parentFunctionDeclaration.name && ts3.isIdentifier(parentFunctionDeclaration.name) && ts3.idText(parentFunctionDeclaration.name) === "checkSourceFileWorker") {
|
|
29868
|
+
insertClearSourceFileEffectMetadataPosition = some2({ position: node.pos });
|
|
29869
|
+
insertCheckSourceFilePosition = some2({
|
|
29870
|
+
position: block.statements[block.statements.length - 1].end
|
|
29871
|
+
});
|
|
29872
|
+
}
|
|
29833
29873
|
}
|
|
29834
29874
|
}
|
|
29835
29875
|
} else if (ts3.isFunctionDeclaration(node)) {
|
|
29836
29876
|
if (node.name && ts3.isIdentifier(node.name) && ts3.idText(node.name) === "markPrecedingCommentDirectiveLine" && node.body && node.body.statements.length > 0) {
|
|
29837
|
-
insertSkipPrecedingCommentDirectivePosition = node.body.statements[0].pos;
|
|
29877
|
+
insertSkipPrecedingCommentDirectivePosition = some2({ position: node.body.statements[0].pos });
|
|
29878
|
+
}
|
|
29879
|
+
if (node.name && ts3.isIdentifier(node.name) && ts3.idText(node.name) === "reportRelationError" && node.body && node.body.statements.length > 0 && node.parameters.length >= 3) {
|
|
29880
|
+
const sourceIdentifier2 = node.parameters[1] && ts3.isParameter(node.parameters[1]) && ts3.isIdentifier(node.parameters[1].name) ? ts3.idText(node.parameters[1].name) : void 0;
|
|
29881
|
+
const targetIdentifier2 = node.parameters[2] && ts3.isParameter(node.parameters[2]) && ts3.isIdentifier(node.parameters[2].name) ? ts3.idText(node.parameters[2].name) : void 0;
|
|
29882
|
+
if (sourceIdentifier2 && targetIdentifier2) {
|
|
29883
|
+
insertAppendMetadataRelationErrorPosition = some2({
|
|
29884
|
+
position: node.body.statements[0].pos,
|
|
29885
|
+
sourceIdentifier: sourceIdentifier2,
|
|
29886
|
+
targetIdentifier: targetIdentifier2
|
|
29887
|
+
});
|
|
29888
|
+
}
|
|
29838
29889
|
}
|
|
29839
29890
|
}
|
|
29840
29891
|
ts3.forEachChild(node, (child) => {
|
|
@@ -29842,16 +29893,15 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29842
29893
|
return void 0;
|
|
29843
29894
|
});
|
|
29844
29895
|
}
|
|
29845
|
-
insertUtilsPosition
|
|
29846
|
-
if (insertUtilsPosition === -1) {
|
|
29896
|
+
if (isNone2(insertUtilsPosition)) {
|
|
29847
29897
|
return yield* fail7(new UnableToFindPositionToPatchError({ positionToFind: "effect lsp utils insertion" }));
|
|
29848
29898
|
}
|
|
29849
29899
|
if (moduleName !== "typescript") {
|
|
29850
29900
|
patches.push(
|
|
29851
29901
|
yield* makeEffectLspPatchChange(
|
|
29852
29902
|
sourceFile.text,
|
|
29853
|
-
insertUtilsPosition,
|
|
29854
|
-
insertUtilsPosition,
|
|
29903
|
+
insertUtilsPosition.value.position,
|
|
29904
|
+
insertUtilsPosition.value.position,
|
|
29855
29905
|
"\n" + (yield* getTypeScriptApisUtils(dirPath4)) + "\n",
|
|
29856
29906
|
"",
|
|
29857
29907
|
version
|
|
@@ -29861,28 +29911,61 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29861
29911
|
patches.push(
|
|
29862
29912
|
yield* makeEffectLspPatchChange(
|
|
29863
29913
|
sourceFile.text,
|
|
29864
|
-
insertUtilsPosition,
|
|
29865
|
-
insertUtilsPosition,
|
|
29914
|
+
insertUtilsPosition.value.position,
|
|
29915
|
+
insertUtilsPosition.value.position,
|
|
29866
29916
|
"\n" + (yield* getEffectLspPatchUtils()) + "\n",
|
|
29867
29917
|
"",
|
|
29868
29918
|
version
|
|
29869
29919
|
)
|
|
29870
29920
|
);
|
|
29871
|
-
if (
|
|
29921
|
+
if (isNone2(insertClearSourceFileEffectMetadataPosition)) {
|
|
29922
|
+
return yield* fail7(
|
|
29923
|
+
new UnableToFindPositionToPatchError({ positionToFind: "clearSourceFileEffectMetadata" })
|
|
29924
|
+
);
|
|
29925
|
+
}
|
|
29926
|
+
patches.push(
|
|
29927
|
+
yield* makeEffectLspPatchChange(
|
|
29928
|
+
sourceFile.text,
|
|
29929
|
+
insertClearSourceFileEffectMetadataPosition.value.position,
|
|
29930
|
+
insertClearSourceFileEffectMetadataPosition.value.position,
|
|
29931
|
+
`effectLspPatchUtils.exports.clearSourceFileEffectMetadata(node)
|
|
29932
|
+
`,
|
|
29933
|
+
"\n",
|
|
29934
|
+
version
|
|
29935
|
+
)
|
|
29936
|
+
);
|
|
29937
|
+
if (isNone2(insertCheckSourceFilePosition)) {
|
|
29872
29938
|
return yield* fail7(new UnableToFindPositionToPatchError({ positionToFind: "checkSourceFileWorker" }));
|
|
29873
29939
|
}
|
|
29874
29940
|
patches.push(
|
|
29875
29941
|
yield* makeEffectLspPatchChange(
|
|
29876
29942
|
sourceFile.text,
|
|
29877
|
-
insertCheckSourceFilePosition,
|
|
29878
|
-
insertCheckSourceFilePosition,
|
|
29943
|
+
insertCheckSourceFilePosition.value.position,
|
|
29944
|
+
insertCheckSourceFilePosition.value.position,
|
|
29879
29945
|
`effectLspPatchUtils.exports.checkSourceFileWorker(${moduleName === "typescript" ? "module.exports" : "effectLspTypeScriptApis"}, host, node, compilerOptions, diagnostics.add)
|
|
29880
29946
|
`,
|
|
29881
29947
|
"\n",
|
|
29882
29948
|
version
|
|
29883
29949
|
)
|
|
29884
29950
|
);
|
|
29885
|
-
if (
|
|
29951
|
+
if (isNone2(insertAppendMetadataRelationErrorPosition)) {
|
|
29952
|
+
return yield* fail7(
|
|
29953
|
+
new UnableToFindPositionToPatchError({ positionToFind: "appendMetadataRelationError" })
|
|
29954
|
+
);
|
|
29955
|
+
}
|
|
29956
|
+
const { sourceIdentifier, targetIdentifier } = insertAppendMetadataRelationErrorPosition.value;
|
|
29957
|
+
patches.push(
|
|
29958
|
+
yield* makeEffectLspPatchChange(
|
|
29959
|
+
sourceFile.text,
|
|
29960
|
+
insertAppendMetadataRelationErrorPosition.value.position,
|
|
29961
|
+
insertAppendMetadataRelationErrorPosition.value.position,
|
|
29962
|
+
`effectLspPatchUtils.exports.appendMetadataRelationError(${moduleName === "typescript" ? "module.exports" : "effectLspTypeScriptApis"}, errorNode, ${sourceIdentifier}, ${targetIdentifier})
|
|
29963
|
+
`,
|
|
29964
|
+
"\n",
|
|
29965
|
+
version
|
|
29966
|
+
)
|
|
29967
|
+
);
|
|
29968
|
+
if (isNone2(insertSkipPrecedingCommentDirectivePosition)) {
|
|
29886
29969
|
return yield* fail7(
|
|
29887
29970
|
new UnableToFindPositionToPatchError({ positionToFind: "skip preceding comment directive" })
|
|
29888
29971
|
);
|
|
@@ -29890,8 +29973,8 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29890
29973
|
patches.push(
|
|
29891
29974
|
yield* makeEffectLspPatchChange(
|
|
29892
29975
|
sourceFile.text,
|
|
29893
|
-
insertSkipPrecedingCommentDirectivePosition,
|
|
29894
|
-
insertSkipPrecedingCommentDirectivePosition,
|
|
29976
|
+
insertSkipPrecedingCommentDirectivePosition.value.position,
|
|
29977
|
+
insertSkipPrecedingCommentDirectivePosition.value.position,
|
|
29895
29978
|
'if(diagnostic && diagnostic.source === "effect"){ return -1; }\n',
|
|
29896
29979
|
"\n",
|
|
29897
29980
|
version
|
|
@@ -29983,7 +30066,7 @@ var cliCommand = make58(
|
|
|
29983
30066
|
).pipe(withSubcommands3([patch9, unpatch, check2]));
|
|
29984
30067
|
var main = run8(cliCommand, {
|
|
29985
30068
|
name: "effect-language-service",
|
|
29986
|
-
version: "0.0.
|
|
30069
|
+
version: "0.0.2"
|
|
29987
30070
|
});
|
|
29988
30071
|
main(process.argv).pipe(
|
|
29989
30072
|
provide2(layer11),
|