@effect/language-service 0.47.0 → 0.47.1

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.
Files changed (3) hide show
  1. package/cli.js +93 -53
  2. package/cli.js.map +1 -1
  3. package/package.json +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;
@@ -35211,86 +35234,103 @@ var project2 = file3("project").pipe(
35211
35234
  var extractEffectLspOptions = (compilerOptions) => {
35212
35235
  return (hasProperty(compilerOptions, "plugins") && isArray(compilerOptions.plugins) ? compilerOptions.plugins : []).find((_) => hasProperty(_, "name") && _.name === "@effect/language-service");
35213
35236
  };
35237
+ var BATCH_SIZE = 50;
35214
35238
  var diagnostics2 = make58(
35215
35239
  "diagnostics",
35216
35240
  { file: file4, project: project2 },
35217
35241
  fn("diagnostics")(function* ({ file: file5, project: project3 }) {
35218
35242
  const path2 = yield* Path2;
35219
35243
  const tsInstance = yield* getTypeScript;
35220
- let filesToCheck = [];
35244
+ const filesToCheck = /* @__PURE__ */ new Set();
35221
35245
  let checkedFilesCount = 0;
35222
35246
  let errorsCount = 0;
35223
35247
  let warningsCount = 0;
35224
35248
  let messagesCount = 0;
35225
- const { service: service3 } = (0, import_project_service.createProjectService)();
35226
35249
  if (isSome2(file5)) {
35227
- filesToCheck = [...filesToCheck, ...path2.resolve(file5.value ?? "")];
35250
+ filesToCheck.add(path2.resolve(file5.value));
35228
35251
  }
35229
35252
  if (isSome2(project3)) {
35230
35253
  let tsconfigToHandle = [project3.value ?? ""];
35231
35254
  while (tsconfigToHandle.length > 0) {
35232
35255
  const tsconfigPath = tsconfigToHandle.shift();
35233
- const configFile = tsInstance.readConfigFile(tsconfigPath, tsInstance.sys.readFile);
35234
- if (configFile.error) continue;
35256
+ const tsconfigAbsolutePath = path2.resolve(tsconfigPath);
35257
+ const configFile = tsInstance.readConfigFile(tsconfigAbsolutePath, tsInstance.sys.readFile);
35258
+ if (configFile.error) {
35259
+ if (!tsconfigAbsolutePath.endsWith("tsconfig.json")) {
35260
+ tsconfigToHandle = [...tsconfigToHandle, path2.resolve(tsconfigPath, "tsconfig.json")];
35261
+ }
35262
+ continue;
35263
+ }
35235
35264
  const parsedConfig = tsInstance.parseJsonConfigFileContent(
35236
35265
  configFile.config,
35237
35266
  tsInstance.sys,
35238
- tsInstance.sys.getCurrentDirectory()
35267
+ path2.dirname(tsconfigAbsolutePath)
35239
35268
  );
35240
35269
  tsconfigToHandle = [...tsconfigToHandle, ...parsedConfig.projectReferences?.map((_) => _.path) ?? []];
35241
- filesToCheck = [...filesToCheck, ...parsedConfig.fileNames];
35270
+ parsedConfig.fileNames.forEach((_) => filesToCheck.add(_));
35242
35271
  }
35243
35272
  }
35244
- if (filesToCheck.length === 0) {
35273
+ if (filesToCheck.size === 0) {
35245
35274
  return yield* new NoFilesToCheckError();
35246
35275
  }
35247
- for (const filePath of filesToCheck) {
35248
- service3.openClientFile(filePath);
35249
- const scriptInfo = service3.getScriptInfo(filePath);
35250
- if (!scriptInfo) continue;
35251
- const project4 = scriptInfo.getDefaultProject();
35252
- const languageService = project4.getLanguageService(true);
35253
- const program = languageService.getProgram();
35254
- if (!program) continue;
35255
- const sourceFile = program.getSourceFile(filePath);
35256
- if (!sourceFile) continue;
35257
- const pluginConfig = extractEffectLspOptions(program.getCompilerOptions());
35258
- if (!pluginConfig) continue;
35259
- const results = pipe(
35260
- getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
35261
- nanoLayer3,
35262
- nanoLayer2,
35263
- nanoLayer,
35264
- provideService7(TypeCheckerApi, program.getTypeChecker()),
35265
- provideService7(TypeScriptProgram, program),
35266
- provideService7(TypeScriptApi, tsInstance),
35267
- provideService7(
35268
- LanguageServicePluginOptions,
35269
- parse4(pluginConfig)
35270
- ),
35271
- run9,
35272
- map((_) => _.diagnostics),
35273
- map(
35274
- map4(
35275
- (_) => _.category === tsInstance.DiagnosticCategory.Suggestion ? { ..._, category: tsInstance.DiagnosticCategory.Message } : _
35276
- )
35277
- ),
35278
- getOrElse(() => [])
35279
- );
35280
- checkedFilesCount++;
35281
- errorsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Error).length;
35282
- warningsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Warning).length;
35283
- messagesCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Message).length;
35284
- if (results.length === 0) continue;
35285
- const formattedResults = tsInstance.formatDiagnosticsWithColorAndContext(results, {
35286
- getCanonicalFileName: (fileName) => path2.resolve(fileName),
35287
- getCurrentDirectory: () => path2.resolve("."),
35288
- getNewLine: () => "\n"
35289
- });
35290
- console.log(formattedResults);
35276
+ const filesToCheckArray = fromIterable(filesToCheck);
35277
+ const batches = chunksOf(filesToCheckArray, BATCH_SIZE);
35278
+ for (const batch of batches) {
35279
+ const { service: service3 } = (0, import_project_service.createProjectService)({ options: { loadTypeScriptPlugins: false } });
35280
+ for (const filePath of batch) {
35281
+ service3.openClientFile(filePath);
35282
+ try {
35283
+ const scriptInfo = service3.getScriptInfo(filePath);
35284
+ if (!scriptInfo) continue;
35285
+ const project4 = scriptInfo.getDefaultProject();
35286
+ const languageService = project4.getLanguageService(true);
35287
+ const program = languageService.getProgram();
35288
+ if (!program) continue;
35289
+ const sourceFile = program.getSourceFile(filePath);
35290
+ if (!sourceFile) continue;
35291
+ const pluginConfig = extractEffectLspOptions(program.getCompilerOptions());
35292
+ if (!pluginConfig) continue;
35293
+ const results = pipe(
35294
+ getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
35295
+ nanoLayer3,
35296
+ nanoLayer2,
35297
+ nanoLayer,
35298
+ provideService7(TypeCheckerApi, program.getTypeChecker()),
35299
+ provideService7(TypeScriptProgram, program),
35300
+ provideService7(TypeScriptApi, tsInstance),
35301
+ provideService7(
35302
+ LanguageServicePluginOptions,
35303
+ parse4(pluginConfig)
35304
+ ),
35305
+ run9,
35306
+ map((_) => _.diagnostics),
35307
+ map(
35308
+ map4(
35309
+ (_) => _.category === tsInstance.DiagnosticCategory.Suggestion ? { ..._, category: tsInstance.DiagnosticCategory.Message } : _
35310
+ )
35311
+ ),
35312
+ getOrElse(() => [])
35313
+ );
35314
+ checkedFilesCount++;
35315
+ errorsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Error).length;
35316
+ warningsCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Warning).length;
35317
+ messagesCount += results.filter((_) => _.category === tsInstance.DiagnosticCategory.Message).length;
35318
+ if (results.length > 0) {
35319
+ const formattedResults = tsInstance.formatDiagnosticsWithColorAndContext(results, {
35320
+ getCanonicalFileName: (fileName) => path2.resolve(fileName),
35321
+ getCurrentDirectory: () => path2.resolve("."),
35322
+ getNewLine: () => "\n"
35323
+ });
35324
+ console.log(formattedResults);
35325
+ }
35326
+ } finally {
35327
+ service3.closeClientFile(filePath);
35328
+ }
35329
+ }
35330
+ yield* yieldNow4();
35291
35331
  }
35292
35332
  console.log(
35293
- `Checked ${checkedFilesCount} files out of ${filesToCheck.length} files.
35333
+ `Checked ${checkedFilesCount} files out of ${filesToCheck.size} files.
35294
35334
  ${errorsCount} errors, ${warningsCount} warnings and ${messagesCount} messages.`
35295
35335
  );
35296
35336
  })