@effect/language-service 0.53.0 → 0.53.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/index.js CHANGED
@@ -1220,6 +1220,7 @@ var defaults = {
1220
1220
  diagnosticSeverity: {},
1221
1221
  diagnosticsName: true,
1222
1222
  missingDiagnosticNextLine: "warning",
1223
+ reportSuggestionsAsWarningsInTsc: false,
1223
1224
  quickinfo: true,
1224
1225
  quickinfoEffectParameters: "whentruncated",
1225
1226
  quickinfoMaximumLength: -1,
@@ -1265,6 +1266,7 @@ function parse(config) {
1265
1266
  diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
1266
1267
  diagnosticsName: isObject(config) && hasProperty(config, "diagnosticsName") && isBoolean(config.diagnosticsName) ? config.diagnosticsName : defaults.diagnosticsName,
1267
1268
  missingDiagnosticNextLine: isObject(config) && hasProperty(config, "missingDiagnosticNextLine") && isString(config.missingDiagnosticNextLine) && isValidSeverityLevel(config.missingDiagnosticNextLine) ? config.missingDiagnosticNextLine : defaults.missingDiagnosticNextLine,
1269
+ reportSuggestionsAsWarningsInTsc: isObject(config) && hasProperty(config, "reportSuggestionsAsWarningsInTsc") && isBoolean(config.reportSuggestionsAsWarningsInTsc) ? config.reportSuggestionsAsWarningsInTsc : defaults.reportSuggestionsAsWarningsInTsc,
1268
1270
  quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
1269
1271
  quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
1270
1272
  quickinfoMaximumLength: isObject(config) && hasProperty(config, "quickinfoMaximumLength") && isNumber(config.quickinfoMaximumLength) ? config.quickinfoMaximumLength : defaults.quickinfoMaximumLength,
@@ -13903,6 +13905,20 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
13903
13905
  var deflate_1 = deflate;
13904
13906
 
13905
13907
  // src/core/LayerGraph.ts
13908
+ var formatSourceFileName = (sourceFile) => {
13909
+ let fileName = sourceFile.fileName;
13910
+ if (fileName.indexOf("/") > -1) {
13911
+ fileName = fileName.split("/").pop();
13912
+ }
13913
+ return fileName;
13914
+ };
13915
+ var formatSourceFileNameLineAndColumn = (ts, tsUtils, node, fromSourceFile) => {
13916
+ const nodeSourceFile = tsUtils.getSourceFileOfNode(node);
13917
+ const nodePosition = ts.getTokenPosOfNode(node, nodeSourceFile);
13918
+ const { character, line } = ts.getLineAndCharacterOfPosition(nodeSourceFile, nodePosition);
13919
+ if (!fromSourceFile || nodeSourceFile === fromSourceFile) return `ln ${line + 1} col ${character}`;
13920
+ return `in ${formatSourceFileName(nodeSourceFile)} at ln ${line + 1} col ${character}`;
13921
+ };
13906
13922
  var UnableToProduceLayerGraphError = class {
13907
13923
  constructor(message, node) {
13908
13924
  this.message = message;
@@ -13956,7 +13972,11 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
13956
13972
  provides = typeCheckerUtils.unrollUnionMembers(layerTypes.ROut).filter((_) => !(_.flags & ts.TypeFlags.Never));
13957
13973
  requires = typeCheckerUtils.unrollUnionMembers(layerTypes.RIn).filter((_) => !(_.flags & ts.TypeFlags.Never));
13958
13974
  }
13959
- return { node: node2, layerType, layerTypes, provides, requires };
13975
+ let displayNode = node2;
13976
+ if (node2.parent && ts.isVariableDeclaration(node2.parent) && node2.parent.initializer === node2) {
13977
+ displayNode = node2.parent.name;
13978
+ }
13979
+ return { node: node2, displayNode, layerType, layerTypes, provides, requires };
13960
13980
  });
13961
13981
  const addNode2 = fn("addNode")(function* (node2, nodeInfo) {
13962
13982
  const graphNode = addNode(mutableGraph, nodeInfo ? nodeInfo : yield* extractNodeInfo(node2));
@@ -14085,20 +14105,6 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
14085
14105
  }
14086
14106
  return endMutation2(mutableGraph);
14087
14107
  });
14088
- var formatSourceFileName = (sourceFile) => {
14089
- let fileName = sourceFile.fileName;
14090
- if (fileName.indexOf("/") > -1) {
14091
- fileName = fileName.split("/").pop();
14092
- }
14093
- return fileName;
14094
- };
14095
- var formatSourceFileNameLineAndColumn = (ts, tsUtils, node, fromSourceFile) => {
14096
- const nodeSourceFile = tsUtils.getSourceFileOfNode(node);
14097
- const nodePosition = ts.getTokenPosOfNode(node, nodeSourceFile);
14098
- const { character, line } = ts.getLineAndCharacterOfPosition(nodeSourceFile, nodePosition);
14099
- if (!fromSourceFile || nodeSourceFile === fromSourceFile) return `ln ${line + 1} col ${character}`;
14100
- return `in ${formatSourceFileName(nodeSourceFile)} at ln ${line + 1} col ${character}`;
14101
- };
14102
14108
  var formatLayerGraph = fn("formatLayerGraph")(
14103
14109
  function* (layerGraph, _fromSourceFile) {
14104
14110
  const tsUtils = yield* service(TypeScriptUtils);
@@ -14161,12 +14167,12 @@ var formatNestedLayerGraph = fn("formatNestedLayerGraph")(
14161
14167
  `style ${graphNodeIndex}_wrap fill:transparent`,
14162
14168
  `style ${graphNodeIndex}_wrap stroke:none`
14163
14169
  ];
14164
- const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
14165
- const nodeText = sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
14170
+ const tsNode = graphNode.displayNode;
14171
+ const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
14172
+ const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
14166
14173
  result = [
14167
14174
  ...result,
14168
- `subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}
14169
- <small>_${mermaidSafe(formatSourceFileNameLineAndColumn(ts, tsUtils, graphNode.node, fromSourceFile))}_</small>\`"]`,
14175
+ `subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}<br/><small>_${mermaidSafe(formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile))}_</small>\`"]`,
14170
14176
  ...subgraphDefs.map((_) => ` ${_}`),
14171
14177
  `end`,
14172
14178
  `style ${graphNodeIndex} fill:transparent`
@@ -14215,6 +14221,7 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
14215
14221
  for (const leafNode of dedupedLeafNodes) {
14216
14222
  const nodeIndex = addNode(mutableGraph, {
14217
14223
  node: leafNode.node,
14224
+ displayNode: leafNode.displayNode,
14218
14225
  requires: leafNode.requires,
14219
14226
  provides: leafNode.provides
14220
14227
  });
@@ -14240,13 +14247,16 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
14240
14247
  var formatLayerOutlineGraph = fn("formatLayerOutlineGraph")(
14241
14248
  function* (layerOutlineGraph, fromSourceFile) {
14242
14249
  const tsUtils = yield* service(TypeScriptUtils);
14250
+ const ts = yield* service(TypeScriptApi);
14243
14251
  return toMermaid(layerOutlineGraph, {
14244
14252
  edgeLabel: () => "",
14245
14253
  nodeLabel: (graphNode) => {
14246
- const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
14247
- const nodeText = sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
14254
+ const tsNode = graphNode.displayNode;
14255
+ const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
14256
+ const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
14248
14257
  if (sourceFile === fromSourceFile) return nodeText;
14249
- return nodeText + "\n_in " + formatSourceFileName(sourceFile) + "_";
14258
+ return `${nodeText}
14259
+ _${formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile)}_`;
14250
14260
  }
14251
14261
  });
14252
14262
  }
@@ -14329,6 +14339,7 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
14329
14339
  const sortedTypes = pipe(fromIterable(rootTypes), sort(typeCheckerUtils.deterministicTypeOrder));
14330
14340
  for (const layerType of sortedTypes) {
14331
14341
  const tsNodes = [];
14342
+ const tsDisplayNodes = [];
14332
14343
  for (const layerNode of values2(
14333
14344
  walkLeavesMatching(
14334
14345
  layerGraph,
@@ -14339,11 +14350,13 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
14339
14350
  )
14340
14351
  )) {
14341
14352
  tsNodes.push(layerNode.node);
14353
+ tsDisplayNodes.push(layerNode.displayNode);
14342
14354
  }
14343
14355
  result.push({
14344
14356
  kind,
14345
14357
  type: layerType,
14346
- nodes: tsNodes
14358
+ nodes: tsNodes,
14359
+ displayNodes: tsDisplayNodes
14347
14360
  });
14348
14361
  }
14349
14362
  };
@@ -14365,7 +14378,7 @@ var formatLayerProvidersAndRequirersInfo = fn("formatLayerProvidersAndRequirersI
14365
14378
  void 0,
14366
14379
  ts.TypeFormatFlags.NoTruncation
14367
14380
  );
14368
- const positions = infoNode.nodes.map((_) => {
14381
+ const positions = infoNode.displayNodes.map((_) => {
14369
14382
  const sourceFile = tsUtils.getSourceFileOfNode(_);
14370
14383
  const nodeText = sourceFile.text.substring(_.pos, _.end).trim().replace(/\n/g, " ").substr(0, 50);
14371
14384
  return `${formatSourceFileNameLineAndColumn(ts, tsUtils, _, fromSourceFile)} by \`${nodeText}\``;