@effect/language-service 0.43.1 → 0.43.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 +138 -130
- package/cli.js.map +1 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -28875,12 +28875,6 @@ var runMain2 = runMain;
|
|
|
28875
28875
|
// node_modules/.pnpm/@effect+platform-node@0.96.0_@effect+cluster@0.48.2_@effect+platform@0.90.6_@effect+rpc@0.69._5eaod7sdztwbb2cfcwufk3knjm/node_modules/@effect/platform-node/dist/esm/NodeRuntime.js
|
|
28876
28876
|
var runMain3 = runMain2;
|
|
28877
28877
|
|
|
28878
|
-
// src/cli/check.ts
|
|
28879
|
-
var ts2 = __toESM(require("typescript"));
|
|
28880
|
-
|
|
28881
|
-
// src/cli/utils.ts
|
|
28882
|
-
var ts = __toESM(require("typescript"));
|
|
28883
|
-
|
|
28884
28878
|
// src/core/Nano.ts
|
|
28885
28879
|
var NanoTag = class {
|
|
28886
28880
|
constructor(key) {
|
|
@@ -29138,35 +29132,35 @@ function getPackageJsonInfoCache(program) {
|
|
|
29138
29132
|
}
|
|
29139
29133
|
return void 0;
|
|
29140
29134
|
}
|
|
29141
|
-
function getDirectoryPath(
|
|
29135
|
+
function getDirectoryPath(ts, path2) {
|
|
29142
29136
|
try {
|
|
29143
|
-
if (hasProperty(
|
|
29144
|
-
return
|
|
29137
|
+
if (hasProperty(ts, "getDirectoryPath") && isFunction2(ts.getDirectoryPath)) {
|
|
29138
|
+
return ts.getDirectoryPath(path2);
|
|
29145
29139
|
}
|
|
29146
29140
|
return path2;
|
|
29147
29141
|
} catch (_) {
|
|
29148
29142
|
return path2;
|
|
29149
29143
|
}
|
|
29150
29144
|
}
|
|
29151
|
-
function makeGetTemporaryModuleResolutionState(
|
|
29152
|
-
if (hasProperty(
|
|
29153
|
-
const _internal =
|
|
29145
|
+
function makeGetTemporaryModuleResolutionState(ts) {
|
|
29146
|
+
if (hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction2(ts.getTemporaryModuleResolutionState)) {
|
|
29147
|
+
const _internal = ts.getTemporaryModuleResolutionState;
|
|
29154
29148
|
return (cache, program, compilerOptions) => _internal(cache, program, compilerOptions);
|
|
29155
29149
|
}
|
|
29156
29150
|
return void 0;
|
|
29157
29151
|
}
|
|
29158
|
-
function makeGetPackageScopeForPath(
|
|
29159
|
-
if (hasProperty(
|
|
29160
|
-
const _internal =
|
|
29152
|
+
function makeGetPackageScopeForPath(ts) {
|
|
29153
|
+
if (hasProperty(ts, "getPackageScopeForPath") && isFunction2(ts.getPackageScopeForPath)) {
|
|
29154
|
+
const _internal = ts.getPackageScopeForPath;
|
|
29161
29155
|
return (path2, state) => _internal(path2, state);
|
|
29162
29156
|
}
|
|
29163
29157
|
}
|
|
29164
29158
|
|
|
29165
29159
|
// src/core/TypeScriptUtils.ts
|
|
29166
29160
|
var TypeScriptUtils = Tag4("TypeScriptUtils");
|
|
29167
|
-
function makeTypeScriptUtils(
|
|
29168
|
-
const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(
|
|
29169
|
-
const getPackageScopeForPath = makeGetPackageScopeForPath(
|
|
29161
|
+
function makeTypeScriptUtils(ts) {
|
|
29162
|
+
const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(ts);
|
|
29163
|
+
const getPackageScopeForPath = makeGetPackageScopeForPath(ts);
|
|
29170
29164
|
function parsePackageContentNameAndVersionFromScope(v) {
|
|
29171
29165
|
if (!isObject(v)) return;
|
|
29172
29166
|
if (!hasProperty(v, "packageJsonScope")) return;
|
|
@@ -29210,7 +29204,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29210
29204
|
program,
|
|
29211
29205
|
program.getCompilerOptions()
|
|
29212
29206
|
);
|
|
29213
|
-
const directoryPath = getDirectoryPath(
|
|
29207
|
+
const directoryPath = getDirectoryPath(ts, sourceFile.fileName);
|
|
29214
29208
|
packageJsonScope = parsePackageContentNameAndVersionFromScope({
|
|
29215
29209
|
...sourceFile,
|
|
29216
29210
|
packageJsonScope: getPackageScopeForPath(directoryPath, temporaryModuleResolutionState)
|
|
@@ -29223,7 +29217,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29223
29217
|
const packageJsonScope = resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
|
|
29224
29218
|
const referencedPackages = [];
|
|
29225
29219
|
for (const statement of sourceFile.statements) {
|
|
29226
|
-
if (
|
|
29220
|
+
if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
29227
29221
|
const moduleSpecifier = statement.moduleSpecifier.text.toLowerCase();
|
|
29228
29222
|
const packageName = moduleSpecifier.startsWith("@") ? moduleSpecifier.split("/", 2).join("/") : moduleSpecifier.split("/", 1).join("/");
|
|
29229
29223
|
referencedPackages.push(packageName);
|
|
@@ -29242,7 +29236,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29242
29236
|
const sourceText = sourceFile.text;
|
|
29243
29237
|
let result;
|
|
29244
29238
|
function find3(node) {
|
|
29245
|
-
const leading =
|
|
29239
|
+
const leading = ts.getLeadingCommentRanges(sourceText, node.pos);
|
|
29246
29240
|
if (leading) {
|
|
29247
29241
|
for (const commentRange of leading) {
|
|
29248
29242
|
if (commentRange.pos <= position && position < commentRange.end) {
|
|
@@ -29252,7 +29246,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29252
29246
|
}
|
|
29253
29247
|
}
|
|
29254
29248
|
if (node.pos <= position && position < node.end) {
|
|
29255
|
-
|
|
29249
|
+
ts.forEachChild(node, find3);
|
|
29256
29250
|
}
|
|
29257
29251
|
}
|
|
29258
29252
|
find3(sourceFile);
|
|
@@ -29271,8 +29265,8 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29271
29265
|
}
|
|
29272
29266
|
function findNodeAtPosition(sourceFile, position) {
|
|
29273
29267
|
function find3(node) {
|
|
29274
|
-
if (position >=
|
|
29275
|
-
return
|
|
29268
|
+
if (position >= ts.getTokenPosOfNode(node, sourceFile) && position < node.end) {
|
|
29269
|
+
return ts.forEachChild(node, find3) || node;
|
|
29276
29270
|
}
|
|
29277
29271
|
return void 0;
|
|
29278
29272
|
}
|
|
@@ -29281,7 +29275,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29281
29275
|
function findNodeAtPositionIncludingTrivia(sourceFile, position) {
|
|
29282
29276
|
function find3(node) {
|
|
29283
29277
|
if (position >= node.pos && position < node.end) {
|
|
29284
|
-
return
|
|
29278
|
+
return ts.forEachChild(node, find3) || node;
|
|
29285
29279
|
}
|
|
29286
29280
|
return void 0;
|
|
29287
29281
|
}
|
|
@@ -29294,11 +29288,11 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29294
29288
|
}
|
|
29295
29289
|
function getCommentAtPosition(sourceFile, pos) {
|
|
29296
29290
|
const token = findNodeAtPositionIncludingTrivia(sourceFile, pos);
|
|
29297
|
-
if (token === void 0 || token.kind ===
|
|
29291
|
+
if (token === void 0 || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || "").length) {
|
|
29298
29292
|
return;
|
|
29299
29293
|
}
|
|
29300
|
-
const startPos = token.pos === 0 ? (
|
|
29301
|
-
const result =
|
|
29294
|
+
const startPos = token.pos === 0 ? (ts.getShebang(sourceFile.text) || "").length : token.pos;
|
|
29295
|
+
const result = ts.forEachTrailingCommentRange(sourceFile.text, startPos, isCommentInRange, pos) || ts.forEachLeadingCommentRange(sourceFile.text, startPos, isCommentInRange, pos);
|
|
29302
29296
|
return result;
|
|
29303
29297
|
}
|
|
29304
29298
|
function isCommentInRange(pos, end5, kind, _nl, at) {
|
|
@@ -29312,45 +29306,45 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29312
29306
|
}
|
|
29313
29307
|
function transformAsyncAwaitToEffectGeneratorBody(body, onAwait) {
|
|
29314
29308
|
function visitor(_) {
|
|
29315
|
-
if (
|
|
29316
|
-
const expression =
|
|
29317
|
-
return
|
|
29318
|
-
|
|
29309
|
+
if (ts.isAwaitExpression(_)) {
|
|
29310
|
+
const expression = ts.visitEachChild(_.expression, visitor, ts.nullTransformationContext);
|
|
29311
|
+
return ts.factory.createYieldExpression(
|
|
29312
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
29319
29313
|
onAwait(expression)
|
|
29320
29314
|
);
|
|
29321
29315
|
}
|
|
29322
|
-
return
|
|
29316
|
+
return ts.visitEachChild(_, visitor, ts.nullTransformationContext);
|
|
29323
29317
|
}
|
|
29324
29318
|
return visitor(body);
|
|
29325
29319
|
}
|
|
29326
29320
|
function transformAsyncAwaitToEffectFn(node, effectModuleName, onAwait) {
|
|
29327
29321
|
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
29328
|
-
const fnName = node.name &&
|
|
29329
|
-
let fnCall =
|
|
29330
|
-
|
|
29322
|
+
const fnName = node.name && ts.isIdentifier(node.name) ? node.name : ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && node.parent.initializer === node ? node.parent.name : void 0;
|
|
29323
|
+
let fnCall = ts.factory.createPropertyAccessExpression(
|
|
29324
|
+
ts.factory.createIdentifier(effectModuleName),
|
|
29331
29325
|
"fn"
|
|
29332
29326
|
);
|
|
29333
29327
|
if (fnName) {
|
|
29334
|
-
fnCall =
|
|
29328
|
+
fnCall = ts.factory.createCallExpression(
|
|
29335
29329
|
fnCall,
|
|
29336
29330
|
void 0,
|
|
29337
|
-
[
|
|
29331
|
+
[ts.factory.createStringLiteral(ts.idText(fnName))]
|
|
29338
29332
|
);
|
|
29339
29333
|
}
|
|
29340
29334
|
return tryPreserveDeclarationSemantics(
|
|
29341
29335
|
node,
|
|
29342
|
-
|
|
29336
|
+
ts.factory.createCallExpression(
|
|
29343
29337
|
fnCall,
|
|
29344
29338
|
void 0,
|
|
29345
29339
|
[
|
|
29346
|
-
|
|
29340
|
+
ts.factory.createFunctionExpression(
|
|
29347
29341
|
void 0,
|
|
29348
|
-
|
|
29342
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
29349
29343
|
void 0,
|
|
29350
29344
|
node.typeParameters,
|
|
29351
29345
|
node.parameters,
|
|
29352
29346
|
void 0,
|
|
29353
|
-
|
|
29347
|
+
ts.isBlock(generatorBody) ? generatorBody : ts.factory.createBlock([ts.factory.createReturnStatement(generatorBody)])
|
|
29354
29348
|
)
|
|
29355
29349
|
]
|
|
29356
29350
|
),
|
|
@@ -29360,11 +29354,11 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29360
29354
|
function transformAsyncAwaitToEffectGen(node, effectModuleName, onAwait) {
|
|
29361
29355
|
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
29362
29356
|
const effectGenCallExp = createEffectGenCallExpression(effectModuleName, generatorBody);
|
|
29363
|
-
let currentFlags =
|
|
29364
|
-
currentFlags &= ~
|
|
29365
|
-
const newModifiers =
|
|
29366
|
-
if (
|
|
29367
|
-
return
|
|
29357
|
+
let currentFlags = ts.getCombinedModifierFlags(node);
|
|
29358
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
29359
|
+
const newModifiers = ts.factory.createModifiersFromModifierFlags(currentFlags);
|
|
29360
|
+
if (ts.isArrowFunction(node)) {
|
|
29361
|
+
return ts.factory.createArrowFunction(
|
|
29368
29362
|
newModifiers,
|
|
29369
29363
|
node.typeParameters,
|
|
29370
29364
|
node.parameters,
|
|
@@ -29373,11 +29367,11 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29373
29367
|
effectGenCallExp
|
|
29374
29368
|
);
|
|
29375
29369
|
}
|
|
29376
|
-
const newBody =
|
|
29377
|
-
|
|
29370
|
+
const newBody = ts.factory.createBlock([
|
|
29371
|
+
ts.factory.createReturnStatement(effectGenCallExp)
|
|
29378
29372
|
]);
|
|
29379
|
-
if (
|
|
29380
|
-
return
|
|
29373
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
29374
|
+
return ts.factory.createFunctionDeclaration(
|
|
29381
29375
|
newModifiers,
|
|
29382
29376
|
node.asteriskToken,
|
|
29383
29377
|
node.name,
|
|
@@ -29387,7 +29381,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29387
29381
|
newBody
|
|
29388
29382
|
);
|
|
29389
29383
|
}
|
|
29390
|
-
return
|
|
29384
|
+
return ts.factory.createFunctionExpression(
|
|
29391
29385
|
newModifiers,
|
|
29392
29386
|
node.asteriskToken,
|
|
29393
29387
|
node.name,
|
|
@@ -29399,22 +29393,22 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29399
29393
|
}
|
|
29400
29394
|
function findImportedModuleIdentifier(sourceFile, test) {
|
|
29401
29395
|
for (const statement of sourceFile.statements) {
|
|
29402
|
-
if (!
|
|
29396
|
+
if (!ts.isImportDeclaration(statement)) continue;
|
|
29403
29397
|
const importClause = statement.importClause;
|
|
29404
29398
|
if (!importClause) continue;
|
|
29405
29399
|
const namedBindings = importClause.namedBindings;
|
|
29406
29400
|
if (!namedBindings) continue;
|
|
29407
|
-
if (
|
|
29401
|
+
if (ts.isNamespaceImport(namedBindings)) {
|
|
29408
29402
|
if (test(namedBindings.name, statement.moduleSpecifier, none2())) {
|
|
29409
|
-
return
|
|
29403
|
+
return ts.idText(namedBindings.name);
|
|
29410
29404
|
}
|
|
29411
|
-
} else if (
|
|
29405
|
+
} else if (ts.isNamedImports(namedBindings)) {
|
|
29412
29406
|
for (const importSpecifier of namedBindings.elements) {
|
|
29413
29407
|
const importProperty = fromNullable(importSpecifier.propertyName).pipe(
|
|
29414
29408
|
orElse(() => some2(importSpecifier.name))
|
|
29415
29409
|
);
|
|
29416
29410
|
if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
|
|
29417
|
-
return
|
|
29411
|
+
return ts.idText(importSpecifier.name);
|
|
29418
29412
|
}
|
|
29419
29413
|
}
|
|
29420
29414
|
}
|
|
@@ -29424,10 +29418,10 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29424
29418
|
return findImportedModuleIdentifier(
|
|
29425
29419
|
sourceFile,
|
|
29426
29420
|
(_, fromModule, importProperty) => {
|
|
29427
|
-
if (isNone2(importProperty) &&
|
|
29421
|
+
if (isNone2(importProperty) && ts.isStringLiteral(fromModule) && fromModule.text === packageName + "/" + moduleName) {
|
|
29428
29422
|
return true;
|
|
29429
29423
|
}
|
|
29430
|
-
if (isSome2(importProperty) &&
|
|
29424
|
+
if (isSome2(importProperty) && ts.isIdentifier(importProperty.value) && ts.idText(importProperty.value) === moduleName && ts.isStringLiteral(fromModule) && fromModule.text === packageName) {
|
|
29431
29425
|
return true;
|
|
29432
29426
|
}
|
|
29433
29427
|
return false;
|
|
@@ -29436,19 +29430,19 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29436
29430
|
}
|
|
29437
29431
|
function simplifyTypeNode(typeNode) {
|
|
29438
29432
|
function collectCallable(typeNode2) {
|
|
29439
|
-
if (
|
|
29440
|
-
if (
|
|
29433
|
+
if (ts.isParenthesizedTypeNode(typeNode2)) return collectCallable(typeNode2.type);
|
|
29434
|
+
if (ts.isFunctionTypeNode(typeNode2)) {
|
|
29441
29435
|
return some2([
|
|
29442
|
-
|
|
29436
|
+
ts.factory.createCallSignature(typeNode2.typeParameters, typeNode2.parameters, typeNode2.type)
|
|
29443
29437
|
]);
|
|
29444
29438
|
}
|
|
29445
|
-
if (
|
|
29446
|
-
const allCallSignatures = typeNode2.members.every(
|
|
29439
|
+
if (ts.isTypeLiteralNode(typeNode2)) {
|
|
29440
|
+
const allCallSignatures = typeNode2.members.every(ts.isCallSignatureDeclaration);
|
|
29447
29441
|
if (allCallSignatures) {
|
|
29448
29442
|
return some2(typeNode2.members);
|
|
29449
29443
|
}
|
|
29450
29444
|
}
|
|
29451
|
-
if (
|
|
29445
|
+
if (ts.isIntersectionTypeNode(typeNode2)) {
|
|
29452
29446
|
const members = typeNode2.types.map((node) => collectCallable(node));
|
|
29453
29447
|
if (members.every(isSome2)) {
|
|
29454
29448
|
return some2(members.map((_) => isSome2(_) ? _.value : []).flat());
|
|
@@ -29458,34 +29452,34 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29458
29452
|
}
|
|
29459
29453
|
const callSignatures = collectCallable(typeNode);
|
|
29460
29454
|
if (isSome2(callSignatures) && callSignatures.value.length > 1) {
|
|
29461
|
-
return
|
|
29455
|
+
return ts.factory.createTypeLiteralNode(callSignatures.value);
|
|
29462
29456
|
}
|
|
29463
29457
|
return typeNode;
|
|
29464
29458
|
}
|
|
29465
29459
|
function tryPreserveDeclarationSemantics(nodeToReplace, node, dropAsync) {
|
|
29466
|
-
if (!
|
|
29467
|
-
if (
|
|
29460
|
+
if (!ts.isExpression(node)) return node;
|
|
29461
|
+
if (ts.isFunctionDeclaration(nodeToReplace)) {
|
|
29468
29462
|
if (!nodeToReplace.name) return node;
|
|
29469
|
-
let currentFlags =
|
|
29470
|
-
currentFlags &= ~
|
|
29471
|
-
const newModifiers = dropAsync ?
|
|
29472
|
-
return
|
|
29463
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
29464
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
29465
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
29466
|
+
return ts.factory.createVariableStatement(
|
|
29473
29467
|
newModifiers,
|
|
29474
|
-
|
|
29475
|
-
[
|
|
29468
|
+
ts.factory.createVariableDeclarationList(
|
|
29469
|
+
[ts.factory.createVariableDeclaration(
|
|
29476
29470
|
nodeToReplace.name,
|
|
29477
29471
|
void 0,
|
|
29478
29472
|
void 0,
|
|
29479
29473
|
node
|
|
29480
29474
|
)],
|
|
29481
|
-
|
|
29475
|
+
ts.NodeFlags.Const
|
|
29482
29476
|
)
|
|
29483
29477
|
);
|
|
29484
|
-
} else if (
|
|
29485
|
-
let currentFlags =
|
|
29486
|
-
currentFlags &= ~
|
|
29487
|
-
const newModifiers = dropAsync ?
|
|
29488
|
-
return
|
|
29478
|
+
} else if (ts.isMethodDeclaration(nodeToReplace)) {
|
|
29479
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
29480
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
29481
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
29482
|
+
return ts.factory.createPropertyDeclaration(
|
|
29489
29483
|
newModifiers,
|
|
29490
29484
|
nodeToReplace.name,
|
|
29491
29485
|
void 0,
|
|
@@ -29496,30 +29490,30 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29496
29490
|
return node;
|
|
29497
29491
|
}
|
|
29498
29492
|
function parseAccessedExpressionForCompletion(sourceFile, position) {
|
|
29499
|
-
const precedingToken =
|
|
29493
|
+
const precedingToken = ts.findPrecedingToken(position, sourceFile, void 0, true);
|
|
29500
29494
|
if (!precedingToken) return;
|
|
29501
29495
|
let accessedObject = precedingToken;
|
|
29502
|
-
let replacementSpan =
|
|
29496
|
+
let replacementSpan = ts.createTextSpan(position, 0);
|
|
29503
29497
|
let outerNode = precedingToken;
|
|
29504
|
-
if (
|
|
29505
|
-
const spanStart =
|
|
29506
|
-
replacementSpan =
|
|
29498
|
+
if (ts.isIdentifier(precedingToken) && precedingToken.parent && ts.isPropertyAccessExpression(precedingToken.parent)) {
|
|
29499
|
+
const spanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
|
|
29500
|
+
replacementSpan = ts.createTextSpan(
|
|
29507
29501
|
spanStart,
|
|
29508
29502
|
precedingToken.end - spanStart
|
|
29509
29503
|
);
|
|
29510
29504
|
accessedObject = precedingToken.parent.expression;
|
|
29511
29505
|
outerNode = precedingToken.parent;
|
|
29512
|
-
} else if (
|
|
29513
|
-
const precedingTokenSpanStart =
|
|
29514
|
-
replacementSpan =
|
|
29506
|
+
} else if (ts.isToken(precedingToken) && precedingToken.kind === ts.SyntaxKind.DotToken && ts.isPropertyAccessExpression(precedingToken.parent)) {
|
|
29507
|
+
const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
|
|
29508
|
+
replacementSpan = ts.createTextSpan(
|
|
29515
29509
|
precedingTokenSpanStart,
|
|
29516
29510
|
precedingToken.end - precedingTokenSpanStart
|
|
29517
29511
|
);
|
|
29518
29512
|
accessedObject = precedingToken.parent.expression;
|
|
29519
29513
|
outerNode = precedingToken.parent;
|
|
29520
|
-
} else if (
|
|
29521
|
-
const precedingTokenSpanStart =
|
|
29522
|
-
replacementSpan =
|
|
29514
|
+
} else if (ts.isIdentifier(precedingToken) && precedingToken.parent) {
|
|
29515
|
+
const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken, sourceFile);
|
|
29516
|
+
replacementSpan = ts.createTextSpan(
|
|
29523
29517
|
precedingTokenSpanStart,
|
|
29524
29518
|
precedingToken.end - precedingTokenSpanStart
|
|
29525
29519
|
);
|
|
@@ -29534,13 +29528,13 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29534
29528
|
const maybeInfos = parseAccessedExpressionForCompletion(sourceFile, position);
|
|
29535
29529
|
if (!maybeInfos) return;
|
|
29536
29530
|
const { accessedObject, outerNode, replacementSpan } = maybeInfos;
|
|
29537
|
-
if (!
|
|
29531
|
+
if (!ts.isIdentifier(accessedObject)) return;
|
|
29538
29532
|
let classDeclaration = outerNode.parent;
|
|
29539
|
-
while (
|
|
29533
|
+
while (ts.isExpressionWithTypeArguments(classDeclaration) || ts.isHeritageClause(classDeclaration)) {
|
|
29540
29534
|
if (!classDeclaration.parent) break;
|
|
29541
29535
|
classDeclaration = classDeclaration.parent;
|
|
29542
29536
|
}
|
|
29543
|
-
if (!
|
|
29537
|
+
if (!ts.isClassDeclaration(classDeclaration)) return;
|
|
29544
29538
|
if (!classDeclaration.name) return;
|
|
29545
29539
|
return {
|
|
29546
29540
|
accessedObject,
|
|
@@ -29550,9 +29544,9 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29550
29544
|
};
|
|
29551
29545
|
}
|
|
29552
29546
|
function createEffectGenCallExpression(effectModuleIdentifierName, node) {
|
|
29553
|
-
const generator =
|
|
29547
|
+
const generator = ts.factory.createFunctionExpression(
|
|
29554
29548
|
void 0,
|
|
29555
|
-
|
|
29549
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
29556
29550
|
void 0,
|
|
29557
29551
|
[],
|
|
29558
29552
|
[],
|
|
@@ -29560,9 +29554,9 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29560
29554
|
node
|
|
29561
29555
|
// NOTE(mattia): intended, to use same routine for both ConciseBody and Body
|
|
29562
29556
|
);
|
|
29563
|
-
return
|
|
29564
|
-
|
|
29565
|
-
|
|
29557
|
+
return ts.factory.createCallExpression(
|
|
29558
|
+
ts.factory.createPropertyAccessExpression(
|
|
29559
|
+
ts.factory.createIdentifier(effectModuleIdentifierName),
|
|
29566
29560
|
"gen"
|
|
29567
29561
|
),
|
|
29568
29562
|
void 0,
|
|
@@ -29572,41 +29566,41 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29572
29566
|
function createEffectGenCallExpressionWithBlock(effectModuleIdentifierName, statement) {
|
|
29573
29567
|
return createEffectGenCallExpression(
|
|
29574
29568
|
effectModuleIdentifierName,
|
|
29575
|
-
|
|
29569
|
+
ts.factory.createBlock(isArray(statement) ? statement : [statement], false)
|
|
29576
29570
|
);
|
|
29577
29571
|
}
|
|
29578
29572
|
function createReturnYieldStarStatement(expr) {
|
|
29579
|
-
return
|
|
29580
|
-
|
|
29581
|
-
|
|
29573
|
+
return ts.factory.createReturnStatement(
|
|
29574
|
+
ts.factory.createYieldExpression(
|
|
29575
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
29582
29576
|
expr
|
|
29583
29577
|
)
|
|
29584
29578
|
);
|
|
29585
29579
|
}
|
|
29586
29580
|
function createDataTaggedErrorDeclaration(dataModuleIdentifier, name, fields) {
|
|
29587
|
-
const invokeTaggedError =
|
|
29588
|
-
|
|
29589
|
-
|
|
29581
|
+
const invokeTaggedError = ts.factory.createCallExpression(
|
|
29582
|
+
ts.factory.createPropertyAccessExpression(
|
|
29583
|
+
ts.factory.createIdentifier(dataModuleIdentifier),
|
|
29590
29584
|
"TaggedError"
|
|
29591
29585
|
),
|
|
29592
29586
|
void 0,
|
|
29593
29587
|
[
|
|
29594
|
-
|
|
29588
|
+
ts.factory.createStringLiteral(name)
|
|
29595
29589
|
]
|
|
29596
29590
|
);
|
|
29597
|
-
const withTypeFields =
|
|
29591
|
+
const withTypeFields = ts.factory.createExpressionWithTypeArguments(
|
|
29598
29592
|
invokeTaggedError,
|
|
29599
29593
|
[
|
|
29600
|
-
|
|
29594
|
+
ts.factory.createTypeLiteralNode(fields)
|
|
29601
29595
|
]
|
|
29602
29596
|
);
|
|
29603
|
-
return
|
|
29604
|
-
[
|
|
29597
|
+
return ts.factory.createClassDeclaration(
|
|
29598
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
29605
29599
|
name,
|
|
29606
29600
|
void 0,
|
|
29607
29601
|
[
|
|
29608
|
-
|
|
29609
|
-
|
|
29602
|
+
ts.factory.createHeritageClause(
|
|
29603
|
+
ts.SyntaxKind.ExtendsKeyword,
|
|
29610
29604
|
[
|
|
29611
29605
|
withTypeFields
|
|
29612
29606
|
]
|
|
@@ -29617,7 +29611,7 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29617
29611
|
}
|
|
29618
29612
|
function getSourceFileOfNode(current) {
|
|
29619
29613
|
let node = current;
|
|
29620
|
-
while (node && node.kind !==
|
|
29614
|
+
while (node && node.kind !== ts.SyntaxKind.SourceFile) {
|
|
29621
29615
|
node = node.parent;
|
|
29622
29616
|
}
|
|
29623
29617
|
return node;
|
|
@@ -29647,7 +29641,6 @@ function makeTypeScriptUtils(ts4) {
|
|
|
29647
29641
|
}
|
|
29648
29642
|
|
|
29649
29643
|
// src/cli/utils.ts
|
|
29650
|
-
var tsUtils = makeTypeScriptUtils(ts);
|
|
29651
29644
|
var PackageJsonSchema = Struct({
|
|
29652
29645
|
name: String$,
|
|
29653
29646
|
version: String$,
|
|
@@ -29671,6 +29664,16 @@ var CorruptedPatchedSourceFileError = class extends TaggedError("CorruptedPatche
|
|
|
29671
29664
|
return `Patched source file ${this.filePath} has corrupted patches`;
|
|
29672
29665
|
}
|
|
29673
29666
|
};
|
|
29667
|
+
var UnableToFindInstalledTypeScriptPackage = class extends TaggedError("UnableToFindInstalledTypeScriptPackage") {
|
|
29668
|
+
get message() {
|
|
29669
|
+
return `Unable to find an installed typescript package`;
|
|
29670
|
+
}
|
|
29671
|
+
};
|
|
29672
|
+
var getTypeScript = try_3({
|
|
29673
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29674
|
+
try: () => require("typescript"),
|
|
29675
|
+
catch: (cause2) => new UnableToFindInstalledTypeScriptPackage({ cause: cause2 })
|
|
29676
|
+
});
|
|
29674
29677
|
var getPackageJsonData = fn("getPackageJsonData")(function* (packageDir) {
|
|
29675
29678
|
const path2 = yield* Path2;
|
|
29676
29679
|
const fs = yield* FileSystem;
|
|
@@ -29760,6 +29763,8 @@ var makeEffectLspPatchChange = fn("makeEffectLspPatchChange")(
|
|
|
29760
29763
|
);
|
|
29761
29764
|
var extractAppliedEffectLspPatches = fn("extractAppliedEffectLspPatches")(
|
|
29762
29765
|
function* (sourceFile) {
|
|
29766
|
+
const ts = yield* getTypeScript;
|
|
29767
|
+
const tsUtils = makeTypeScriptUtils(ts);
|
|
29763
29768
|
const regex = /@effect-lsp-patch(?:\s+)([a-zA-Z0-9+=/]+)/gm;
|
|
29764
29769
|
let match18;
|
|
29765
29770
|
const patches = [];
|
|
@@ -29806,6 +29811,7 @@ var applyTextChanges = fn("applyTextChanges")(
|
|
|
29806
29811
|
);
|
|
29807
29812
|
var getUnpatchedSourceFile = fn("getUnpatchedSourceFile")(function* (filePath) {
|
|
29808
29813
|
const fs = yield* FileSystem;
|
|
29814
|
+
const ts = yield* getTypeScript;
|
|
29809
29815
|
const sourceText = yield* fs.readFileString(filePath);
|
|
29810
29816
|
const sourceFile = ts.createSourceFile(
|
|
29811
29817
|
filePath,
|
|
@@ -29826,6 +29832,7 @@ var getUnpatchedSourceFile = fn("getUnpatchedSourceFile")(function* (filePath) {
|
|
|
29826
29832
|
});
|
|
29827
29833
|
var omitBundlerSourceFileComment = fn("omitBundlerSourceFileComment")(
|
|
29828
29834
|
function* (originalSourceText) {
|
|
29835
|
+
const ts = yield* getTypeScript;
|
|
29829
29836
|
const deleteChanges = [];
|
|
29830
29837
|
const sourceFile = ts.createSourceFile(
|
|
29831
29838
|
"file.ts",
|
|
@@ -29860,6 +29867,7 @@ var check2 = make58(
|
|
|
29860
29867
|
{ dirPath },
|
|
29861
29868
|
fn("check")(function* ({ dirPath: dirPath4 }) {
|
|
29862
29869
|
const fs = yield* FileSystem;
|
|
29870
|
+
const ts = yield* getTypeScript;
|
|
29863
29871
|
const { version: effectLspVersion } = yield* getPackageJsonData(__dirname);
|
|
29864
29872
|
yield* logDebug2(`Found @effect/language-service version ${effectLspVersion}!`);
|
|
29865
29873
|
yield* logDebug2(`Searching for typescript in ${dirPath4}...`);
|
|
@@ -29870,7 +29878,7 @@ var check2 = make58(
|
|
|
29870
29878
|
const filePath = yield* getModuleFilePath(dirPath4, moduleName);
|
|
29871
29879
|
yield* logDebug2(`Reading ${moduleName} from ${filePath}...`);
|
|
29872
29880
|
const sourceText = yield* fs.readFileString(filePath);
|
|
29873
|
-
const sourceFile =
|
|
29881
|
+
const sourceFile = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.ES2022, true);
|
|
29874
29882
|
yield* logDebug2(`Collecting patches for ${moduleName}...`);
|
|
29875
29883
|
const { patches } = yield* extractAppliedEffectLspPatches(sourceFile);
|
|
29876
29884
|
const patchesVersion = pipe(patches, map3((patch10) => patch10.version), dedupe);
|
|
@@ -29884,7 +29892,6 @@ var check2 = make58(
|
|
|
29884
29892
|
);
|
|
29885
29893
|
|
|
29886
29894
|
// src/cli/patch.ts
|
|
29887
|
-
var ts3 = __toESM(require("typescript"));
|
|
29888
29895
|
var UnableToFindPositionToPatchError = class extends TaggedError("UnableToFindPositionToPatchError") {
|
|
29889
29896
|
get message() {
|
|
29890
29897
|
return `Unable to find position to patch ${this.positionToFind}`;
|
|
@@ -29904,6 +29911,7 @@ var moduleNames = choice3("module", [
|
|
|
29904
29911
|
);
|
|
29905
29912
|
var getPatchesForModule = fn("getPatchesForModule")(
|
|
29906
29913
|
function* (moduleName, dirPath4, version, sourceFile) {
|
|
29914
|
+
const ts = yield* getTypeScript;
|
|
29907
29915
|
const patches = [];
|
|
29908
29916
|
let insertClearSourceFileEffectMetadataPosition = none2();
|
|
29909
29917
|
let insertCheckSourceFilePosition = none2();
|
|
@@ -29913,7 +29921,7 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29913
29921
|
function findNodeAtPositionIncludingTrivia(sourceFile2, position) {
|
|
29914
29922
|
function find3(node) {
|
|
29915
29923
|
if (position >= node.pos && position < node.end) {
|
|
29916
|
-
return
|
|
29924
|
+
return ts.forEachChild(node, find3) || node;
|
|
29917
29925
|
}
|
|
29918
29926
|
return void 0;
|
|
29919
29927
|
}
|
|
@@ -29926,7 +29934,7 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29926
29934
|
while ((match18 = regex.exec(sourceFile.text)) !== null) {
|
|
29927
29935
|
const node = findNodeAtPositionIncludingTrivia(sourceFile, match18.index);
|
|
29928
29936
|
if (node) {
|
|
29929
|
-
const functionDeclaration =
|
|
29937
|
+
const functionDeclaration = ts.findAncestor(node, ts.isFunctionDeclaration);
|
|
29930
29938
|
nodesToCheck.push(functionDeclaration || node);
|
|
29931
29939
|
pushed = true;
|
|
29932
29940
|
}
|
|
@@ -29941,14 +29949,14 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29941
29949
|
while (nodesToCheck.length > 0) {
|
|
29942
29950
|
const node = nodesToCheck.shift();
|
|
29943
29951
|
if (!node) continue;
|
|
29944
|
-
if (
|
|
29952
|
+
if (ts.isExpressionStatement(node)) {
|
|
29945
29953
|
const expression = node.expression;
|
|
29946
|
-
if (
|
|
29954
|
+
if (ts.isCallExpression(expression)) {
|
|
29947
29955
|
const identifier2 = expression.expression;
|
|
29948
|
-
if (
|
|
29956
|
+
if (ts.isIdentifier(identifier2) && ts.idText(identifier2) === "checkGrammarSourceFile" && ts.isBlock(node.parent) && node.parent.statements.length > 0) {
|
|
29949
29957
|
const block = node.parent;
|
|
29950
|
-
const parentFunctionDeclaration =
|
|
29951
|
-
if (parentFunctionDeclaration && parentFunctionDeclaration.name &&
|
|
29958
|
+
const parentFunctionDeclaration = ts.findAncestor(node, ts.isFunctionDeclaration);
|
|
29959
|
+
if (parentFunctionDeclaration && parentFunctionDeclaration.name && ts.isIdentifier(parentFunctionDeclaration.name) && ts.idText(parentFunctionDeclaration.name) === "checkSourceFileWorker") {
|
|
29952
29960
|
insertClearSourceFileEffectMetadataPosition = some2({ position: node.pos });
|
|
29953
29961
|
insertCheckSourceFilePosition = some2({
|
|
29954
29962
|
position: block.statements[block.statements.length - 1].end
|
|
@@ -29956,13 +29964,13 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29956
29964
|
}
|
|
29957
29965
|
}
|
|
29958
29966
|
}
|
|
29959
|
-
} else if (
|
|
29960
|
-
if (node.name &&
|
|
29967
|
+
} else if (ts.isFunctionDeclaration(node)) {
|
|
29968
|
+
if (node.name && ts.isIdentifier(node.name) && ts.idText(node.name) === "markPrecedingCommentDirectiveLine" && node.body && node.body.statements.length > 0) {
|
|
29961
29969
|
insertSkipPrecedingCommentDirectivePosition = some2({ position: node.body.statements[0].pos });
|
|
29962
29970
|
}
|
|
29963
|
-
if (node.name &&
|
|
29964
|
-
const sourceIdentifier2 = node.parameters[1] &&
|
|
29965
|
-
const targetIdentifier2 = node.parameters[2] &&
|
|
29971
|
+
if (node.name && ts.isIdentifier(node.name) && ts.idText(node.name) === "reportRelationError" && node.body && node.body.statements.length > 0 && node.parameters.length >= 3) {
|
|
29972
|
+
const sourceIdentifier2 = node.parameters[1] && ts.isParameter(node.parameters[1]) && ts.isIdentifier(node.parameters[1].name) ? ts.idText(node.parameters[1].name) : void 0;
|
|
29973
|
+
const targetIdentifier2 = node.parameters[2] && ts.isParameter(node.parameters[2]) && ts.isIdentifier(node.parameters[2].name) ? ts.idText(node.parameters[2].name) : void 0;
|
|
29966
29974
|
if (sourceIdentifier2 && targetIdentifier2) {
|
|
29967
29975
|
insertAppendMetadataRelationErrorPosition = some2({
|
|
29968
29976
|
position: node.body.statements[0].pos,
|
|
@@ -29972,7 +29980,7 @@ var getPatchesForModule = fn("getPatchesForModule")(
|
|
|
29972
29980
|
}
|
|
29973
29981
|
}
|
|
29974
29982
|
}
|
|
29975
|
-
|
|
29983
|
+
ts.forEachChild(node, (child) => {
|
|
29976
29984
|
nodesToCheck.push(child);
|
|
29977
29985
|
return void 0;
|
|
29978
29986
|
});
|