@effect/language-service 0.53.0 → 0.53.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 +35 -24
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -13903,6 +13903,20 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
13903
13903
|
var deflate_1 = deflate;
|
|
13904
13904
|
|
|
13905
13905
|
// src/core/LayerGraph.ts
|
|
13906
|
+
var formatSourceFileName = (sourceFile) => {
|
|
13907
|
+
let fileName = sourceFile.fileName;
|
|
13908
|
+
if (fileName.indexOf("/") > -1) {
|
|
13909
|
+
fileName = fileName.split("/").pop();
|
|
13910
|
+
}
|
|
13911
|
+
return fileName;
|
|
13912
|
+
};
|
|
13913
|
+
var formatSourceFileNameLineAndColumn = (ts, tsUtils, node, fromSourceFile) => {
|
|
13914
|
+
const nodeSourceFile = tsUtils.getSourceFileOfNode(node);
|
|
13915
|
+
const nodePosition = ts.getTokenPosOfNode(node, nodeSourceFile);
|
|
13916
|
+
const { character, line } = ts.getLineAndCharacterOfPosition(nodeSourceFile, nodePosition);
|
|
13917
|
+
if (!fromSourceFile || nodeSourceFile === fromSourceFile) return `ln ${line + 1} col ${character}`;
|
|
13918
|
+
return `in ${formatSourceFileName(nodeSourceFile)} at ln ${line + 1} col ${character}`;
|
|
13919
|
+
};
|
|
13906
13920
|
var UnableToProduceLayerGraphError = class {
|
|
13907
13921
|
constructor(message, node) {
|
|
13908
13922
|
this.message = message;
|
|
@@ -13956,7 +13970,11 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
13956
13970
|
provides = typeCheckerUtils.unrollUnionMembers(layerTypes.ROut).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13957
13971
|
requires = typeCheckerUtils.unrollUnionMembers(layerTypes.RIn).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13958
13972
|
}
|
|
13959
|
-
|
|
13973
|
+
let displayNode = node2;
|
|
13974
|
+
if (node2.parent && ts.isVariableDeclaration(node2.parent) && node2.parent.initializer === node2) {
|
|
13975
|
+
displayNode = node2.parent.name;
|
|
13976
|
+
}
|
|
13977
|
+
return { node: node2, displayNode, layerType, layerTypes, provides, requires };
|
|
13960
13978
|
});
|
|
13961
13979
|
const addNode2 = fn("addNode")(function* (node2, nodeInfo) {
|
|
13962
13980
|
const graphNode = addNode(mutableGraph, nodeInfo ? nodeInfo : yield* extractNodeInfo(node2));
|
|
@@ -14085,20 +14103,6 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
14085
14103
|
}
|
|
14086
14104
|
return endMutation2(mutableGraph);
|
|
14087
14105
|
});
|
|
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
14106
|
var formatLayerGraph = fn("formatLayerGraph")(
|
|
14103
14107
|
function* (layerGraph, _fromSourceFile) {
|
|
14104
14108
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
@@ -14161,12 +14165,12 @@ var formatNestedLayerGraph = fn("formatNestedLayerGraph")(
|
|
|
14161
14165
|
`style ${graphNodeIndex}_wrap fill:transparent`,
|
|
14162
14166
|
`style ${graphNodeIndex}_wrap stroke:none`
|
|
14163
14167
|
];
|
|
14164
|
-
const
|
|
14165
|
-
const
|
|
14168
|
+
const tsNode = graphNode.displayNode;
|
|
14169
|
+
const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
|
|
14170
|
+
const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
|
|
14166
14171
|
result = [
|
|
14167
14172
|
...result,
|
|
14168
|
-
`subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}
|
|
14169
|
-
<small>_${mermaidSafe(formatSourceFileNameLineAndColumn(ts, tsUtils, graphNode.node, fromSourceFile))}_</small>\`"]`,
|
|
14173
|
+
`subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}<br/><small>_${mermaidSafe(formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile))}_</small>\`"]`,
|
|
14170
14174
|
...subgraphDefs.map((_) => ` ${_}`),
|
|
14171
14175
|
`end`,
|
|
14172
14176
|
`style ${graphNodeIndex} fill:transparent`
|
|
@@ -14215,6 +14219,7 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
|
14215
14219
|
for (const leafNode of dedupedLeafNodes) {
|
|
14216
14220
|
const nodeIndex = addNode(mutableGraph, {
|
|
14217
14221
|
node: leafNode.node,
|
|
14222
|
+
displayNode: leafNode.displayNode,
|
|
14218
14223
|
requires: leafNode.requires,
|
|
14219
14224
|
provides: leafNode.provides
|
|
14220
14225
|
});
|
|
@@ -14240,13 +14245,16 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
|
14240
14245
|
var formatLayerOutlineGraph = fn("formatLayerOutlineGraph")(
|
|
14241
14246
|
function* (layerOutlineGraph, fromSourceFile) {
|
|
14242
14247
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
14248
|
+
const ts = yield* service(TypeScriptApi);
|
|
14243
14249
|
return toMermaid(layerOutlineGraph, {
|
|
14244
14250
|
edgeLabel: () => "",
|
|
14245
14251
|
nodeLabel: (graphNode) => {
|
|
14246
|
-
const
|
|
14247
|
-
const
|
|
14252
|
+
const tsNode = graphNode.displayNode;
|
|
14253
|
+
const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
|
|
14254
|
+
const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
|
|
14248
14255
|
if (sourceFile === fromSourceFile) return nodeText;
|
|
14249
|
-
return nodeText
|
|
14256
|
+
return `${nodeText}
|
|
14257
|
+
_${formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile)}_`;
|
|
14250
14258
|
}
|
|
14251
14259
|
});
|
|
14252
14260
|
}
|
|
@@ -14329,6 +14337,7 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
|
14329
14337
|
const sortedTypes = pipe(fromIterable(rootTypes), sort(typeCheckerUtils.deterministicTypeOrder));
|
|
14330
14338
|
for (const layerType of sortedTypes) {
|
|
14331
14339
|
const tsNodes = [];
|
|
14340
|
+
const tsDisplayNodes = [];
|
|
14332
14341
|
for (const layerNode of values2(
|
|
14333
14342
|
walkLeavesMatching(
|
|
14334
14343
|
layerGraph,
|
|
@@ -14339,11 +14348,13 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
|
14339
14348
|
)
|
|
14340
14349
|
)) {
|
|
14341
14350
|
tsNodes.push(layerNode.node);
|
|
14351
|
+
tsDisplayNodes.push(layerNode.displayNode);
|
|
14342
14352
|
}
|
|
14343
14353
|
result.push({
|
|
14344
14354
|
kind,
|
|
14345
14355
|
type: layerType,
|
|
14346
|
-
nodes: tsNodes
|
|
14356
|
+
nodes: tsNodes,
|
|
14357
|
+
displayNodes: tsDisplayNodes
|
|
14347
14358
|
});
|
|
14348
14359
|
}
|
|
14349
14360
|
};
|
|
@@ -14365,7 +14376,7 @@ var formatLayerProvidersAndRequirersInfo = fn("formatLayerProvidersAndRequirersI
|
|
|
14365
14376
|
void 0,
|
|
14366
14377
|
ts.TypeFormatFlags.NoTruncation
|
|
14367
14378
|
);
|
|
14368
|
-
const positions = infoNode.
|
|
14379
|
+
const positions = infoNode.displayNodes.map((_) => {
|
|
14369
14380
|
const sourceFile = tsUtils.getSourceFileOfNode(_);
|
|
14370
14381
|
const nodeText = sourceFile.text.substring(_.pos, _.end).trim().replace(/\n/g, " ").substr(0, 50);
|
|
14371
14382
|
return `${formatSourceFileNameLineAndColumn(ts, tsUtils, _, fromSourceFile)} by \`${nodeText}\``;
|