@effect/language-service 0.32.0 → 0.33.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.
package/index.js CHANGED
@@ -1519,17 +1519,34 @@ function parseDiagnosticSeverity(config) {
1519
1519
  )
1520
1520
  );
1521
1521
  }
1522
+ var defaults = {
1523
+ refactors: true,
1524
+ diagnostics: true,
1525
+ diagnosticSeverity: {},
1526
+ quickinfo: true,
1527
+ quickinfoEffectParameters: "whentruncated",
1528
+ completions: true,
1529
+ goto: true,
1530
+ inlays: true,
1531
+ allowedDuplicatedPackages: [],
1532
+ namespaceImportPackages: [],
1533
+ barrelImportPackages: [],
1534
+ topLevelNamedReexports: "ignore"
1535
+ };
1522
1536
  function parse(config) {
1523
1537
  return {
1524
- diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : true,
1525
- diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : {},
1526
- quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : true,
1527
- completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : true,
1528
- goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : true,
1529
- allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : [],
1530
- namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : [],
1531
- barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : [],
1532
- topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && (config.topLevelNamedReexports.toLowerCase() === "ignore" || config.topLevelNamedReexports.toLowerCase() === "follow") ? config.topLevelNamedReexports.toLowerCase() : "ignore"
1538
+ refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
1539
+ diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
1540
+ diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
1541
+ quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
1542
+ quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
1543
+ completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
1544
+ goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
1545
+ inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
1546
+ allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
1547
+ namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
1548
+ barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
1549
+ topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports
1533
1550
  };
1534
1551
  }
1535
1552
 
@@ -5929,6 +5946,44 @@ function goto(applicableGotoDefinition, sourceFile, position) {
5929
5946
  return effectRpcDefinition(applicableGotoDefinition, sourceFile, position);
5930
5947
  }
5931
5948
 
5949
+ // src/inlays/middlewareGenLike.ts
5950
+ var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, preferences, inlayHints) {
5951
+ if (!preferences) return inlayHints;
5952
+ if (preferences.includeInlayFunctionLikeReturnTypeHints !== true) return inlayHints;
5953
+ if (!inlayHints) return inlayHints;
5954
+ const tsUtils = yield* service(TypeScriptUtils);
5955
+ const ts = yield* service(TypeScriptApi);
5956
+ const typeParser = yield* service(TypeParser);
5957
+ const result = [];
5958
+ const parseType = (node) => {
5959
+ return pipe(
5960
+ typeParser.effectGen(node),
5961
+ orElse2(() => pipe(typeParser.effectFnGen(node), orElse2(() => typeParser.effectFnUntracedGen(node))))
5962
+ );
5963
+ };
5964
+ for (const inlayHint of inlayHints) {
5965
+ let shouldOmit = false;
5966
+ if (inlayHint.kind === ts.InlayHintKind.Type) {
5967
+ const node = tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, inlayHint.position - 1);
5968
+ if (node && node.parent) {
5969
+ const possiblyGen = node.parent;
5970
+ yield* pipe(
5971
+ parseType(possiblyGen),
5972
+ map3((_) => {
5973
+ const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
5974
+ if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.getEnd() && inlayHint.position <= _.body.getStart(sourceFile)) {
5975
+ shouldOmit = true;
5976
+ }
5977
+ }),
5978
+ ignore
5979
+ );
5980
+ }
5981
+ }
5982
+ if (!shouldOmit) result.push(inlayHint);
5983
+ }
5984
+ return result;
5985
+ });
5986
+
5932
5987
  // src/quickinfo/dedupeJsDocs.ts
5933
5988
  var SymbolDisplayPartEq = make((fa, fb) => fa.kind === fb.kind && fa.text === fb.text);
5934
5989
  var JSDocTagInfoEq = make(
@@ -5952,6 +6007,8 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
5952
6007
  const ts = yield* service(TypeScriptApi);
5953
6008
  const typeChecker = yield* service(TypeCheckerApi);
5954
6009
  const typeParser = yield* service(TypeParser);
6010
+ const options = yield* service(LanguageServicePluginOptions);
6011
+ if (options.quickinfoEffectParameters === "never") return quickInfo2;
5955
6012
  function formatTypeForQuickInfo(channelType, channelName) {
5956
6013
  const stringRepresentation = typeChecker.typeToString(
5957
6014
  channelType,
@@ -5997,7 +6054,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
5997
6054
  type: typeChecker.getTypeAtLocation(adjustedNode),
5998
6055
  atLocation: adjustedNode,
5999
6056
  node: adjustedNode,
6000
- shouldTry: quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
6057
+ shouldTry: options.quickinfoEffectParameters === "always" && quickInfo2 ? true : quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
6001
6058
  };
6002
6059
  }
6003
6060
  const data = getDataForQuickInfo();
@@ -12435,6 +12492,23 @@ var init = (modules) => {
12435
12492
  }
12436
12493
  return applicableDefinition;
12437
12494
  };
12495
+ proxy.provideInlayHints = (fileName, span, preferences, ...args2) => {
12496
+ const applicableInlayHints = languageService.provideInlayHints(fileName, span, preferences, ...args2);
12497
+ if (languageServicePluginOptions.inlays) {
12498
+ const program = languageService.getProgram();
12499
+ if (program) {
12500
+ const sourceFile = program.getSourceFile(fileName);
12501
+ if (sourceFile) {
12502
+ return pipe(
12503
+ middlewareGenLike(sourceFile, span, preferences, applicableInlayHints),
12504
+ runNano(program),
12505
+ getOrElse(() => applicableInlayHints)
12506
+ );
12507
+ }
12508
+ }
12509
+ }
12510
+ return applicableInlayHints;
12511
+ };
12438
12512
  return proxy;
12439
12513
  }
12440
12514
  return { create, onConfigurationChanged };