@effect/language-service 0.47.0 → 0.47.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 +97 -53
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +4 -0
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +12 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +4 -0
- package/transform.js.map +1 -1
package/cli.js
CHANGED
|
@@ -2274,6 +2274,21 @@ var containsWith2 = (isEquivalent) => dual(2, (self, a) => {
|
|
|
2274
2274
|
});
|
|
2275
2275
|
var _equivalence2 = /* @__PURE__ */ equivalence();
|
|
2276
2276
|
var contains2 = /* @__PURE__ */ containsWith2(_equivalence2);
|
|
2277
|
+
var chop = /* @__PURE__ */ dual(2, (self, f) => {
|
|
2278
|
+
const input = fromIterable(self);
|
|
2279
|
+
if (isNonEmptyReadonlyArray(input)) {
|
|
2280
|
+
const [b, rest] = f(input);
|
|
2281
|
+
const out = [b];
|
|
2282
|
+
let next = rest;
|
|
2283
|
+
while (isNonEmptyArray(next)) {
|
|
2284
|
+
const [b2, rest2] = f(next);
|
|
2285
|
+
out.push(b2);
|
|
2286
|
+
next = rest2;
|
|
2287
|
+
}
|
|
2288
|
+
return out;
|
|
2289
|
+
}
|
|
2290
|
+
return [];
|
|
2291
|
+
});
|
|
2277
2292
|
var splitAt = /* @__PURE__ */ dual(2, (self, n) => {
|
|
2278
2293
|
const input = Array.from(self);
|
|
2279
2294
|
const _n = Math.floor(n);
|
|
@@ -2290,6 +2305,13 @@ var splitNonEmptyAt = /* @__PURE__ */ dual(2, (self, n) => {
|
|
|
2290
2305
|
return _n >= self.length ? [copy(self), []] : [prepend(self.slice(1, _n), headNonEmpty(self)), self.slice(_n)];
|
|
2291
2306
|
});
|
|
2292
2307
|
var copy = (self) => self.slice();
|
|
2308
|
+
var chunksOf = /* @__PURE__ */ dual(2, (self, n) => {
|
|
2309
|
+
const input = fromIterable(self);
|
|
2310
|
+
if (isNonEmptyReadonlyArray(input)) {
|
|
2311
|
+
return chop(input, splitNonEmptyAt(n));
|
|
2312
|
+
}
|
|
2313
|
+
return [];
|
|
2314
|
+
});
|
|
2293
2315
|
var unionWith = /* @__PURE__ */ dual(3, (self, that, isEquivalent) => {
|
|
2294
2316
|
const a = fromIterable(self);
|
|
2295
2317
|
const b = fromIterable(that);
|
|
@@ -14492,6 +14514,7 @@ var succeed7 = succeed;
|
|
|
14492
14514
|
var suspend4 = suspend;
|
|
14493
14515
|
var sync4 = sync;
|
|
14494
14516
|
var _void = void_;
|
|
14517
|
+
var yieldNow4 = yieldNow;
|
|
14495
14518
|
var catchAll2 = catchAll;
|
|
14496
14519
|
var catchAllCause2 = catchAllCause;
|
|
14497
14520
|
var catchIf2 = catchIf;
|
|
@@ -32987,6 +33010,10 @@ var makeKeyBuilder = fn2("KeyBuilder")(
|
|
|
32987
33010
|
);
|
|
32988
33011
|
var keyBuilderCache = /* @__PURE__ */ new Map();
|
|
32989
33012
|
var getOrMakeKeyBuilder = fn2("getOrMakeKeyBuilder")(function* (sourceFile) {
|
|
33013
|
+
while (keyBuilderCache.size > 5) {
|
|
33014
|
+
const oldest = keyBuilderCache.keys().next().value;
|
|
33015
|
+
if (oldest) keyBuilderCache.delete(oldest);
|
|
33016
|
+
}
|
|
32990
33017
|
const keyBuilder = keyBuilderCache.get(sourceFile.fileName) || (yield* makeKeyBuilder(sourceFile));
|
|
32991
33018
|
keyBuilderCache.set(sourceFile.fileName, keyBuilder);
|
|
32992
33019
|
return keyBuilder;
|
|
@@ -35211,86 +35238,103 @@ var project2 = file3("project").pipe(
|
|
|
35211
35238
|
var extractEffectLspOptions = (compilerOptions) => {
|
|
35212
35239
|
return (hasProperty(compilerOptions, "plugins") && isArray(compilerOptions.plugins) ? compilerOptions.plugins : []).find((_) => hasProperty(_, "name") && _.name === "@effect/language-service");
|
|
35213
35240
|
};
|
|
35241
|
+
var BATCH_SIZE = 50;
|
|
35214
35242
|
var diagnostics2 = make58(
|
|
35215
35243
|
"diagnostics",
|
|
35216
35244
|
{ file: file4, project: project2 },
|
|
35217
35245
|
fn("diagnostics")(function* ({ file: file5, project: project3 }) {
|
|
35218
35246
|
const path2 = yield* Path2;
|
|
35219
35247
|
const tsInstance = yield* getTypeScript;
|
|
35220
|
-
|
|
35248
|
+
const filesToCheck = /* @__PURE__ */ new Set();
|
|
35221
35249
|
let checkedFilesCount = 0;
|
|
35222
35250
|
let errorsCount = 0;
|
|
35223
35251
|
let warningsCount = 0;
|
|
35224
35252
|
let messagesCount = 0;
|
|
35225
|
-
const { service: service3 } = (0, import_project_service.createProjectService)();
|
|
35226
35253
|
if (isSome2(file5)) {
|
|
35227
|
-
filesToCheck
|
|
35254
|
+
filesToCheck.add(path2.resolve(file5.value));
|
|
35228
35255
|
}
|
|
35229
35256
|
if (isSome2(project3)) {
|
|
35230
35257
|
let tsconfigToHandle = [project3.value ?? ""];
|
|
35231
35258
|
while (tsconfigToHandle.length > 0) {
|
|
35232
35259
|
const tsconfigPath = tsconfigToHandle.shift();
|
|
35233
|
-
const
|
|
35234
|
-
|
|
35260
|
+
const tsconfigAbsolutePath = path2.resolve(tsconfigPath);
|
|
35261
|
+
const configFile = tsInstance.readConfigFile(tsconfigAbsolutePath, tsInstance.sys.readFile);
|
|
35262
|
+
if (configFile.error) {
|
|
35263
|
+
if (!tsconfigAbsolutePath.endsWith("tsconfig.json")) {
|
|
35264
|
+
tsconfigToHandle = [...tsconfigToHandle, path2.resolve(tsconfigPath, "tsconfig.json")];
|
|
35265
|
+
}
|
|
35266
|
+
continue;
|
|
35267
|
+
}
|
|
35235
35268
|
const parsedConfig = tsInstance.parseJsonConfigFileContent(
|
|
35236
35269
|
configFile.config,
|
|
35237
35270
|
tsInstance.sys,
|
|
35238
|
-
|
|
35271
|
+
path2.dirname(tsconfigAbsolutePath)
|
|
35239
35272
|
);
|
|
35240
35273
|
tsconfigToHandle = [...tsconfigToHandle, ...parsedConfig.projectReferences?.map((_) => _.path) ?? []];
|
|
35241
|
-
|
|
35274
|
+
parsedConfig.fileNames.forEach((_) => filesToCheck.add(_));
|
|
35242
35275
|
}
|
|
35243
35276
|
}
|
|
35244
|
-
if (filesToCheck.
|
|
35277
|
+
if (filesToCheck.size === 0) {
|
|
35245
35278
|
return yield* new NoFilesToCheckError();
|
|
35246
35279
|
}
|
|
35247
|
-
|
|
35248
|
-
|
|
35249
|
-
|
|
35250
|
-
|
|
35251
|
-
const
|
|
35252
|
-
|
|
35253
|
-
|
|
35254
|
-
|
|
35255
|
-
|
|
35256
|
-
|
|
35257
|
-
|
|
35258
|
-
|
|
35259
|
-
|
|
35260
|
-
|
|
35261
|
-
|
|
35262
|
-
|
|
35263
|
-
|
|
35264
|
-
|
|
35265
|
-
|
|
35266
|
-
|
|
35267
|
-
|
|
35268
|
-
|
|
35269
|
-
|
|
35270
|
-
|
|
35271
|
-
|
|
35272
|
-
|
|
35273
|
-
|
|
35274
|
-
|
|
35275
|
-
|
|
35276
|
-
|
|
35277
|
-
|
|
35278
|
-
|
|
35279
|
-
|
|
35280
|
-
|
|
35281
|
-
|
|
35282
|
-
|
|
35283
|
-
|
|
35284
|
-
|
|
35285
|
-
|
|
35286
|
-
|
|
35287
|
-
|
|
35288
|
-
|
|
35289
|
-
|
|
35290
|
-
|
|
35280
|
+
const filesToCheckArray = fromIterable(filesToCheck);
|
|
35281
|
+
const batches = chunksOf(filesToCheckArray, BATCH_SIZE);
|
|
35282
|
+
for (const batch of batches) {
|
|
35283
|
+
const { service: service3 } = (0, import_project_service.createProjectService)({ options: { loadTypeScriptPlugins: false } });
|
|
35284
|
+
for (const filePath of batch) {
|
|
35285
|
+
service3.openClientFile(filePath);
|
|
35286
|
+
try {
|
|
35287
|
+
const scriptInfo = service3.getScriptInfo(filePath);
|
|
35288
|
+
if (!scriptInfo) continue;
|
|
35289
|
+
const project4 = scriptInfo.getDefaultProject();
|
|
35290
|
+
const languageService = project4.getLanguageService(true);
|
|
35291
|
+
const program = languageService.getProgram();
|
|
35292
|
+
if (!program) continue;
|
|
35293
|
+
const sourceFile = program.getSourceFile(filePath);
|
|
35294
|
+
if (!sourceFile) continue;
|
|
35295
|
+
const pluginConfig = extractEffectLspOptions(program.getCompilerOptions());
|
|
35296
|
+
if (!pluginConfig) continue;
|
|
35297
|
+
const results = pipe(
|
|
35298
|
+
getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
|
|
35299
|
+
nanoLayer3,
|
|
35300
|
+
nanoLayer2,
|
|
35301
|
+
nanoLayer,
|
|
35302
|
+
provideService7(TypeCheckerApi, program.getTypeChecker()),
|
|
35303
|
+
provideService7(TypeScriptProgram, program),
|
|
35304
|
+
provideService7(TypeScriptApi, tsInstance),
|
|
35305
|
+
provideService7(
|
|
35306
|
+
LanguageServicePluginOptions,
|
|
35307
|
+
parse4(pluginConfig)
|
|
35308
|
+
),
|
|
35309
|
+
run9,
|
|
35310
|
+
map((_) => _.diagnostics),
|
|
35311
|
+
map(
|
|
35312
|
+
map4(
|
|
35313
|
+
(_) => _.category === tsInstance.DiagnosticCategory.Suggestion ? { ..._, category: tsInstance.DiagnosticCategory.Message } : _
|
|
35314
|
+
)
|
|
35315
|
+
),
|
|
35316
|
+
getOrElse(() => [])
|
|
35317
|
+
);
|
|
35318
|
+
checkedFilesCount++;
|
|
35319
|
+
errorsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Error).length;
|
|
35320
|
+
warningsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Warning).length;
|
|
35321
|
+
messagesCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Message).length;
|
|
35322
|
+
if (results.length > 0) {
|
|
35323
|
+
const formattedResults = tsInstance.formatDiagnosticsWithColorAndContext(results, {
|
|
35324
|
+
getCanonicalFileName: (fileName) => path2.resolve(fileName),
|
|
35325
|
+
getCurrentDirectory: () => path2.resolve("."),
|
|
35326
|
+
getNewLine: () => "\n"
|
|
35327
|
+
});
|
|
35328
|
+
console.log(formattedResults);
|
|
35329
|
+
}
|
|
35330
|
+
} finally {
|
|
35331
|
+
service3.closeClientFile(filePath);
|
|
35332
|
+
}
|
|
35333
|
+
}
|
|
35334
|
+
yield* yieldNow4();
|
|
35291
35335
|
}
|
|
35292
35336
|
console.log(
|
|
35293
|
-
`Checked ${checkedFilesCount} files out of ${filesToCheck.
|
|
35337
|
+
`Checked ${checkedFilesCount} files out of ${filesToCheck.size} files.
|
|
35294
35338
|
${errorsCount} errors, ${warningsCount} warnings and ${messagesCount} messages.`
|
|
35295
35339
|
);
|
|
35296
35340
|
})
|