@effect/language-service 0.41.0 → 0.42.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 +1 -0
- package/cli.js +51 -21
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +69 -23
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +109 -31
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +69 -23
- package/transform.js.map +1 -1
package/package.json
CHANGED
package/transform.js
CHANGED
|
@@ -1179,6 +1179,7 @@ var defaults = {
|
|
|
1179
1179
|
diagnosticSeverity: {},
|
|
1180
1180
|
quickinfo: true,
|
|
1181
1181
|
quickinfoEffectParameters: "whentruncated",
|
|
1182
|
+
quickinfoMaximumLength: -1,
|
|
1182
1183
|
completions: true,
|
|
1183
1184
|
goto: true,
|
|
1184
1185
|
inlays: true,
|
|
@@ -1197,6 +1198,7 @@ function parse(config) {
|
|
|
1197
1198
|
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1198
1199
|
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1199
1200
|
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1201
|
+
quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
|
|
1200
1202
|
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1201
1203
|
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1202
1204
|
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
@@ -1214,6 +1216,56 @@ function parse(config) {
|
|
|
1214
1216
|
var TypeScriptApi = Tag("TypeScriptApi");
|
|
1215
1217
|
var TypeScriptProgram = Tag("TypeScriptProgram");
|
|
1216
1218
|
var ChangeTracker = Tag("ChangeTracker");
|
|
1219
|
+
function getPackageJsonInfoCache(program) {
|
|
1220
|
+
try {
|
|
1221
|
+
if (hasProperty(program, "getModuleResolutionCache") && isFunction2(program.getModuleResolutionCache)) {
|
|
1222
|
+
const moduleResolutionCache = program.getModuleResolutionCache();
|
|
1223
|
+
if (hasProperty(moduleResolutionCache, "getPackageJsonInfoCache") && isFunction2(moduleResolutionCache.getPackageJsonInfoCache)) {
|
|
1224
|
+
return moduleResolutionCache.getPackageJsonInfoCache();
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
} catch (_) {
|
|
1228
|
+
return void 0;
|
|
1229
|
+
}
|
|
1230
|
+
return void 0;
|
|
1231
|
+
}
|
|
1232
|
+
function getDirectoryPath(ts, path) {
|
|
1233
|
+
try {
|
|
1234
|
+
if (hasProperty(ts, "getDirectoryPath") && isFunction2(ts.getDirectoryPath)) {
|
|
1235
|
+
return ts.getDirectoryPath(path);
|
|
1236
|
+
}
|
|
1237
|
+
return path;
|
|
1238
|
+
} catch (_) {
|
|
1239
|
+
return path;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
function makeGetModuleSpecifier(ts) {
|
|
1243
|
+
if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction2(ts.moduleSpecifiers.getModuleSpecifier))) return;
|
|
1244
|
+
const _internal = ts.moduleSpecifiers.getModuleSpecifier;
|
|
1245
|
+
return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) => {
|
|
1246
|
+
return _internal(
|
|
1247
|
+
compilerOptions,
|
|
1248
|
+
importingSourceFile,
|
|
1249
|
+
importingSourceFileName,
|
|
1250
|
+
toFileName,
|
|
1251
|
+
host,
|
|
1252
|
+
options
|
|
1253
|
+
);
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
function makeGetTemporaryModuleResolutionState(ts) {
|
|
1257
|
+
if (hasProperty(ts, "getTemporaryModuleResolutionState") && isFunction2(ts.getTemporaryModuleResolutionState)) {
|
|
1258
|
+
const _internal = ts.getTemporaryModuleResolutionState;
|
|
1259
|
+
return (cache, program, compilerOptions) => _internal(cache, program, compilerOptions);
|
|
1260
|
+
}
|
|
1261
|
+
return void 0;
|
|
1262
|
+
}
|
|
1263
|
+
function makeGetPackageScopeForPath(ts) {
|
|
1264
|
+
if (hasProperty(ts, "getPackageScopeForPath") && isFunction2(ts.getPackageScopeForPath)) {
|
|
1265
|
+
const _internal = ts.getPackageScopeForPath;
|
|
1266
|
+
return (path, state) => _internal(path, state);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1217
1269
|
|
|
1218
1270
|
// src/core/TypeScriptUtils.ts
|
|
1219
1271
|
var TypeScriptUtils = Tag("TypeScriptUtils");
|
|
@@ -1222,6 +1274,8 @@ var nanoLayer = (fa) => pipe(
|
|
|
1222
1274
|
flatMap2((ts) => pipe(fa, provideService(TypeScriptUtils, makeTypeScriptUtils(ts))))
|
|
1223
1275
|
);
|
|
1224
1276
|
function makeTypeScriptUtils(ts) {
|
|
1277
|
+
const getTemporaryModuleResolutionState = makeGetTemporaryModuleResolutionState(ts);
|
|
1278
|
+
const getPackageScopeForPath = makeGetPackageScopeForPath(ts);
|
|
1225
1279
|
function parsePackageContentNameAndVersionFromScope(v) {
|
|
1226
1280
|
if (!isObject(v)) return;
|
|
1227
1281
|
if (!hasProperty(v, "packageJsonScope")) return;
|
|
@@ -1256,20 +1310,26 @@ function makeTypeScriptUtils(ts) {
|
|
|
1256
1310
|
exportsKeys
|
|
1257
1311
|
};
|
|
1258
1312
|
}
|
|
1259
|
-
function
|
|
1260
|
-
if (pattern.indexOf("*") === -1) return [pattern.toLowerCase()];
|
|
1313
|
+
function resolveModuleWithPackageInfoFromSourceFile(program, sourceFile) {
|
|
1261
1314
|
let packageJsonScope = parsePackageContentNameAndVersionFromScope(sourceFile);
|
|
1262
|
-
if (!packageJsonScope &&
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1315
|
+
if (!packageJsonScope && getPackageScopeForPath && getTemporaryModuleResolutionState) {
|
|
1316
|
+
const packageJsonInfoCache = getPackageJsonInfoCache(program);
|
|
1317
|
+
const temporaryModuleResolutionState = getTemporaryModuleResolutionState(
|
|
1318
|
+
packageJsonInfoCache,
|
|
1265
1319
|
program,
|
|
1266
1320
|
program.getCompilerOptions()
|
|
1267
1321
|
);
|
|
1322
|
+
const directoryPath = getDirectoryPath(ts, sourceFile.fileName);
|
|
1268
1323
|
packageJsonScope = parsePackageContentNameAndVersionFromScope({
|
|
1269
1324
|
...sourceFile,
|
|
1270
|
-
packageJsonScope:
|
|
1325
|
+
packageJsonScope: getPackageScopeForPath(directoryPath, temporaryModuleResolutionState)
|
|
1271
1326
|
});
|
|
1272
1327
|
}
|
|
1328
|
+
return packageJsonScope;
|
|
1329
|
+
}
|
|
1330
|
+
function resolveModulePattern(program, sourceFile, pattern) {
|
|
1331
|
+
if (pattern.indexOf("*") === -1) return [pattern.toLowerCase()];
|
|
1332
|
+
const packageJsonScope = resolveModuleWithPackageInfoFromSourceFile(program, sourceFile);
|
|
1273
1333
|
const referencedPackages = [];
|
|
1274
1334
|
for (const statement of sourceFile.statements) {
|
|
1275
1335
|
if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
@@ -1287,20 +1347,6 @@ function makeTypeScriptUtils(ts) {
|
|
|
1287
1347
|
)
|
|
1288
1348
|
);
|
|
1289
1349
|
}
|
|
1290
|
-
function makeGetModuleSpecifier() {
|
|
1291
|
-
if (!(hasProperty(ts, "moduleSpecifiers") && hasProperty(ts.moduleSpecifiers, "getModuleSpecifier") && isFunction2(ts.moduleSpecifiers.getModuleSpecifier))) return;
|
|
1292
|
-
const _internal = ts.moduleSpecifiers.getModuleSpecifier;
|
|
1293
|
-
return (compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, options) => {
|
|
1294
|
-
return _internal(
|
|
1295
|
-
compilerOptions,
|
|
1296
|
-
importingSourceFile,
|
|
1297
|
-
importingSourceFileName,
|
|
1298
|
-
toFileName,
|
|
1299
|
-
host,
|
|
1300
|
-
options
|
|
1301
|
-
);
|
|
1302
|
-
};
|
|
1303
|
-
}
|
|
1304
1350
|
function findNodeWithLeadingCommentAtPosition(sourceFile, position) {
|
|
1305
1351
|
const sourceText = sourceFile.text;
|
|
1306
1352
|
let result;
|
|
@@ -1689,6 +1735,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1689
1735
|
findNodeAtPositionIncludingTrivia,
|
|
1690
1736
|
parsePackageContentNameAndVersionFromScope,
|
|
1691
1737
|
resolveModulePattern,
|
|
1738
|
+
resolveModuleWithPackageInfoFromSourceFile,
|
|
1692
1739
|
findNodeWithLeadingCommentAtPosition,
|
|
1693
1740
|
getCommentAtPosition,
|
|
1694
1741
|
getAncestorNodesInRange,
|
|
@@ -1703,7 +1750,6 @@ function makeTypeScriptUtils(ts) {
|
|
|
1703
1750
|
parseDataForExtendsClassCompletion,
|
|
1704
1751
|
createEffectGenCallExpressionWithBlock,
|
|
1705
1752
|
createReturnYieldStarStatement,
|
|
1706
|
-
makeGetModuleSpecifier,
|
|
1707
1753
|
parseAccessedExpressionForCompletion,
|
|
1708
1754
|
getSourceFileOfNode
|
|
1709
1755
|
};
|
|
@@ -3656,14 +3702,14 @@ var importFromBarrel = createDiagnostic({
|
|
|
3656
3702
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
3657
3703
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3658
3704
|
const program = yield* service(TypeScriptProgram);
|
|
3705
|
+
const getModuleSpecifier = makeGetModuleSpecifier(ts);
|
|
3706
|
+
const resolveExternalModuleName = makeResolveExternalModuleName(typeChecker);
|
|
3659
3707
|
const packageNamesToCheck = flatten(
|
|
3660
3708
|
languageServicePluginOptions.namespaceImportPackages.map(
|
|
3661
3709
|
(packageName) => tsUtils.resolveModulePattern(program, sourceFile, packageName)
|
|
3662
3710
|
)
|
|
3663
3711
|
);
|
|
3664
3712
|
const isImportedFromBarrelExport = (element) => {
|
|
3665
|
-
const getModuleSpecifier = tsUtils.makeGetModuleSpecifier();
|
|
3666
|
-
const resolveExternalModuleName = makeResolveExternalModuleName(typeChecker);
|
|
3667
3713
|
if (!(getModuleSpecifier && resolveExternalModuleName)) return;
|
|
3668
3714
|
const importDeclaration = ts.findAncestor(element, (node) => ts.isImportDeclaration(node));
|
|
3669
3715
|
if (!importDeclaration) return;
|