@effect/language-service 0.52.1 → 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/README.md +2 -1
- package/cli.js +4 -2
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +4 -2
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +187 -116
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +4 -2
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1243,7 +1243,8 @@ var defaults = {
|
|
|
1243
1243
|
skipLeadingPath: ["src/"]
|
|
1244
1244
|
}],
|
|
1245
1245
|
extendedKeyDetection: false,
|
|
1246
|
-
pipeableMinArgCount: 1
|
|
1246
|
+
pipeableMinArgCount: 1,
|
|
1247
|
+
layerGraphFollowDepth: 0
|
|
1247
1248
|
};
|
|
1248
1249
|
function parseKeyPatterns(patterns) {
|
|
1249
1250
|
const result = [];
|
|
@@ -1279,7 +1280,8 @@ function parse(config) {
|
|
|
1279
1280
|
noExternal: isObject(config) && hasProperty(config, "noExternal") && isBoolean(config.noExternal) ? config.noExternal : defaults.noExternal,
|
|
1280
1281
|
keyPatterns: isObject(config) && hasProperty(config, "keyPatterns") && isArray(config.keyPatterns) ? parseKeyPatterns(config.keyPatterns) : defaults.keyPatterns,
|
|
1281
1282
|
extendedKeyDetection: isObject(config) && hasProperty(config, "extendedKeyDetection") && isBoolean(config.extendedKeyDetection) ? config.extendedKeyDetection : defaults.extendedKeyDetection,
|
|
1282
|
-
pipeableMinArgCount: isObject(config) && hasProperty(config, "pipeableMinArgCount") && isNumber(config.pipeableMinArgCount) ? config.pipeableMinArgCount : defaults.pipeableMinArgCount
|
|
1283
|
+
pipeableMinArgCount: isObject(config) && hasProperty(config, "pipeableMinArgCount") && isNumber(config.pipeableMinArgCount) ? config.pipeableMinArgCount : defaults.pipeableMinArgCount,
|
|
1284
|
+
layerGraphFollowDepth: isObject(config) && hasProperty(config, "layerGraphFollowDepth") && isNumber(config.layerGraphFollowDepth) ? config.layerGraphFollowDepth : defaults.layerGraphFollowDepth
|
|
1283
1285
|
};
|
|
1284
1286
|
}
|
|
1285
1287
|
|
|
@@ -13901,6 +13903,20 @@ var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
|
13901
13903
|
var deflate_1 = deflate;
|
|
13902
13904
|
|
|
13903
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
|
+
};
|
|
13904
13920
|
var UnableToProduceLayerGraphError = class {
|
|
13905
13921
|
constructor(message, node) {
|
|
13906
13922
|
this.message = message;
|
|
@@ -13919,11 +13935,14 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
13919
13935
|
const visitedNodes = /* @__PURE__ */ new WeakSet();
|
|
13920
13936
|
const nodeInPipeContext = /* @__PURE__ */ new WeakSet();
|
|
13921
13937
|
const nodeToGraph = /* @__PURE__ */ new WeakMap();
|
|
13922
|
-
const
|
|
13923
|
-
const
|
|
13938
|
+
const depthBudget = /* @__PURE__ */ new WeakMap();
|
|
13939
|
+
const nodeToVisit = [];
|
|
13940
|
+
const appendNodeToVisit = (node2, nodeDepthBudget) => {
|
|
13941
|
+
depthBudget.set(node2, nodeDepthBudget);
|
|
13924
13942
|
nodeToVisit.push(node2);
|
|
13925
13943
|
return void 0;
|
|
13926
13944
|
};
|
|
13945
|
+
appendNodeToVisit(node, opts.followSymbolsDepth);
|
|
13927
13946
|
const mutableGraph = beginMutation3(directed());
|
|
13928
13947
|
const extractNodeInfo = fn("extractNodeInfo")(function* (node2) {
|
|
13929
13948
|
let provides = [];
|
|
@@ -13951,21 +13970,30 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
13951
13970
|
provides = typeCheckerUtils.unrollUnionMembers(layerTypes.ROut).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13952
13971
|
requires = typeCheckerUtils.unrollUnionMembers(layerTypes.RIn).filter((_) => !(_.flags & ts.TypeFlags.Never));
|
|
13953
13972
|
}
|
|
13954
|
-
|
|
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 };
|
|
13955
13978
|
});
|
|
13956
13979
|
const addNode2 = fn("addNode")(function* (node2, nodeInfo) {
|
|
13957
13980
|
const graphNode = addNode(mutableGraph, nodeInfo ? nodeInfo : yield* extractNodeInfo(node2));
|
|
13958
13981
|
nodeToGraph.set(node2, graphNode);
|
|
13959
13982
|
return graphNode;
|
|
13960
13983
|
});
|
|
13984
|
+
const isSimpleIdentifier = (node2) => {
|
|
13985
|
+
return ts.isIdentifier(node2) || ts.isPropertyAccessExpression(node2) && ts.isIdentifier(node2.name) && isSimpleIdentifier(node2.expression);
|
|
13986
|
+
};
|
|
13987
|
+
const getAdjustedNode2 = (node2) => ts.isPropertyDeclaration(node2) || ts.isVariableDeclaration(node2) ? node2.initializer : ts.isExpression(node2) ? node2 : void 0;
|
|
13961
13988
|
while (nodeToVisit.length > 0) {
|
|
13962
13989
|
const node2 = nodeToVisit.pop();
|
|
13990
|
+
const currentDepthBudget = depthBudget.get(node2);
|
|
13963
13991
|
const pipeArgs = yield* pipe(typeParser.pipeCall(node2), orElse2(() => void_));
|
|
13964
13992
|
if (pipeArgs) {
|
|
13965
13993
|
if (!visitedNodes.has(node2)) {
|
|
13966
|
-
appendNodeToVisit(node2);
|
|
13967
|
-
appendNodeToVisit(pipeArgs.subject);
|
|
13968
|
-
pipeArgs.args.forEach(appendNodeToVisit);
|
|
13994
|
+
appendNodeToVisit(node2, currentDepthBudget);
|
|
13995
|
+
appendNodeToVisit(pipeArgs.subject, currentDepthBudget);
|
|
13996
|
+
pipeArgs.args.forEach((_) => appendNodeToVisit(_, currentDepthBudget));
|
|
13969
13997
|
pipeArgs.args.forEach((_) => nodeInPipeContext.add(_));
|
|
13970
13998
|
visitedNodes.add(node2);
|
|
13971
13999
|
} else {
|
|
@@ -14000,8 +14028,8 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
14000
14028
|
}
|
|
14001
14029
|
if (shouldExplode) {
|
|
14002
14030
|
if (!visitedNodes.has(node2)) {
|
|
14003
|
-
appendNodeToVisit(node2);
|
|
14004
|
-
node2.arguments.forEach(appendNodeToVisit);
|
|
14031
|
+
appendNodeToVisit(node2, currentDepthBudget);
|
|
14032
|
+
node2.arguments.forEach((_) => appendNodeToVisit(_, currentDepthBudget));
|
|
14005
14033
|
visitedNodes.add(node2);
|
|
14006
14034
|
} else {
|
|
14007
14035
|
const childNodes = node2.arguments.map((_) => nodeToGraph.get(_)).filter(isNumber).filter(
|
|
@@ -14023,8 +14051,8 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
14023
14051
|
}
|
|
14024
14052
|
if (opts.arrayLiteralAsMerge && ts.isArrayLiteralExpression(node2)) {
|
|
14025
14053
|
if (!visitedNodes.has(node2)) {
|
|
14026
|
-
appendNodeToVisit(node2);
|
|
14027
|
-
node2.elements.forEach(appendNodeToVisit);
|
|
14054
|
+
appendNodeToVisit(node2, currentDepthBudget);
|
|
14055
|
+
node2.elements.forEach((_) => appendNodeToVisit(_, currentDepthBudget));
|
|
14028
14056
|
visitedNodes.add(node2);
|
|
14029
14057
|
} else {
|
|
14030
14058
|
const childNodes = node2.elements.map((_) => nodeToGraph.get(_)).filter(isNumber).filter(
|
|
@@ -14039,110 +14067,139 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
14039
14067
|
}
|
|
14040
14068
|
continue;
|
|
14041
14069
|
}
|
|
14070
|
+
if (currentDepthBudget > 0 && isSimpleIdentifier(node2)) {
|
|
14071
|
+
let symbol3 = typeChecker.getSymbolAtLocation(node2);
|
|
14072
|
+
if (symbol3) {
|
|
14073
|
+
if (symbol3.flags & ts.SymbolFlags.Alias) {
|
|
14074
|
+
symbol3 = typeChecker.getAliasedSymbol(symbol3);
|
|
14075
|
+
}
|
|
14076
|
+
if (symbol3.declarations && symbol3.declarations.length === 1) {
|
|
14077
|
+
const declarationNode = getAdjustedNode2(symbol3.declarations[0]);
|
|
14078
|
+
if (declarationNode) {
|
|
14079
|
+
if (!visitedNodes.has(declarationNode)) {
|
|
14080
|
+
appendNodeToVisit(node2, currentDepthBudget);
|
|
14081
|
+
appendNodeToVisit(declarationNode, currentDepthBudget - 1);
|
|
14082
|
+
visitedNodes.add(node2);
|
|
14083
|
+
continue;
|
|
14084
|
+
}
|
|
14085
|
+
const childNode = nodeToGraph.get(declarationNode);
|
|
14086
|
+
if (isNumber(childNode)) {
|
|
14087
|
+
const graphNode = yield* addNode2(node2);
|
|
14088
|
+
addEdge(mutableGraph, graphNode, childNode, { relationship: "symbol" });
|
|
14089
|
+
continue;
|
|
14090
|
+
}
|
|
14091
|
+
}
|
|
14092
|
+
}
|
|
14093
|
+
}
|
|
14094
|
+
}
|
|
14042
14095
|
if (ts.isExpression(node2)) {
|
|
14043
14096
|
const nodeInfo = yield* extractNodeInfo(node2);
|
|
14044
14097
|
if (nodeInfo.layerTypes) {
|
|
14045
14098
|
yield* addNode2(node2, nodeInfo);
|
|
14046
|
-
continue;
|
|
14047
14099
|
}
|
|
14100
|
+
continue;
|
|
14048
14101
|
}
|
|
14049
14102
|
return yield* fail(new UnableToProduceLayerGraphError("Unable to produce layer graph for node", node2));
|
|
14050
14103
|
}
|
|
14051
14104
|
return endMutation2(mutableGraph);
|
|
14052
14105
|
});
|
|
14053
|
-
var formatLayerGraph = fn("formatLayerGraph")(
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
",
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
",
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
});
|
|
14072
|
-
var formatNestedLayerGraph = fn("formatNestedLayerGraph")(function* (layerGraph) {
|
|
14073
|
-
const tsUtils = yield* service(TypeScriptUtils);
|
|
14074
|
-
const typeChecker = yield* service(TypeCheckerApi);
|
|
14075
|
-
const ts = yield* service(TypeScriptApi);
|
|
14076
|
-
const mermaidSafe = (value) => value.replace(/\n/g, " ").replace(
|
|
14077
|
-
/\s+/g,
|
|
14078
|
-
" "
|
|
14079
|
-
).substring(0, 50).replace(/"/g, "#quot;").replace(/</mg, "#lt;").replace(/>/mg, "#gt;").trim();
|
|
14080
|
-
const typeNameCache = /* @__PURE__ */ new Map();
|
|
14081
|
-
const typeName = (type) => {
|
|
14082
|
-
if (typeNameCache.has(type)) return typeNameCache.get(type);
|
|
14083
|
-
const name = typeChecker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
14084
|
-
typeNameCache.set(type, name);
|
|
14085
|
-
return name;
|
|
14086
|
-
};
|
|
14087
|
-
let result = [];
|
|
14088
|
-
for (const [graphNodeIndex, graphNode] of entries(nodes(layerGraph))) {
|
|
14089
|
-
let subgraphDefs = [];
|
|
14090
|
-
for (const kind of ["requires", "provides"]) {
|
|
14091
|
-
const typesMermaidNodes = [];
|
|
14092
|
-
for (let i = 0; i < graphNode[kind].length; i++) {
|
|
14093
|
-
typesMermaidNodes.push(`${graphNodeIndex}_${kind}_${i}["${mermaidSafe(typeName(graphNode[kind][i]))}"]`);
|
|
14094
|
-
}
|
|
14095
|
-
if (typesMermaidNodes.length > 0) {
|
|
14096
|
-
subgraphDefs = [
|
|
14097
|
-
...subgraphDefs,
|
|
14098
|
-
`subgraph ${graphNodeIndex}_${kind} [${kind === "provides" ? "Provides" : "Requires"}]`,
|
|
14099
|
-
...typesMermaidNodes.map((_) => ` ${_}`),
|
|
14100
|
-
`end`,
|
|
14101
|
-
`style ${graphNodeIndex}_${kind} stroke:none`
|
|
14102
|
-
];
|
|
14103
|
-
}
|
|
14104
|
-
}
|
|
14105
|
-
subgraphDefs = [
|
|
14106
|
-
`subgraph ${graphNodeIndex}_wrap[" "]`,
|
|
14107
|
-
...subgraphDefs.map((_) => ` ${_}`),
|
|
14108
|
-
`end`,
|
|
14109
|
-
`style ${graphNodeIndex}_wrap fill:transparent`,
|
|
14110
|
-
`style ${graphNodeIndex}_wrap stroke:none`
|
|
14111
|
-
];
|
|
14112
|
-
const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
|
|
14113
|
-
const nodePosition = graphNode.node.getStart(sourceFile, false);
|
|
14114
|
-
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
14115
|
-
const nodeText = sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
|
|
14116
|
-
result = [
|
|
14117
|
-
...result,
|
|
14118
|
-
`subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}<br/>_at ln ${line + 1} col ${character}_\`"]`,
|
|
14119
|
-
...subgraphDefs.map((_) => ` ${_}`),
|
|
14120
|
-
`end`,
|
|
14121
|
-
`style ${graphNodeIndex} fill:transparent`
|
|
14122
|
-
];
|
|
14106
|
+
var formatLayerGraph = fn("formatLayerGraph")(
|
|
14107
|
+
function* (layerGraph, _fromSourceFile) {
|
|
14108
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
14109
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
14110
|
+
const ts = yield* service(TypeScriptApi);
|
|
14111
|
+
return toMermaid(layerGraph, {
|
|
14112
|
+
edgeLabel: (edge) => JSON.stringify(edge),
|
|
14113
|
+
nodeLabel: (graphNode) => {
|
|
14114
|
+
const sourceFile = tsUtils.getSourceFileOfNode(graphNode.node);
|
|
14115
|
+
let text = sourceFile.text.substring(graphNode.node.pos, graphNode.node.end).trim();
|
|
14116
|
+
text += "\nprovides: " + graphNode.provides.map((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)).join(
|
|
14117
|
+
", "
|
|
14118
|
+
);
|
|
14119
|
+
text += "\nrequires: " + graphNode.requires.map((_) => typeChecker.typeToString(_, void 0, ts.TypeFormatFlags.NoTruncation)).join(
|
|
14120
|
+
", "
|
|
14121
|
+
);
|
|
14122
|
+
return text;
|
|
14123
|
+
}
|
|
14124
|
+
});
|
|
14123
14125
|
}
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14126
|
+
);
|
|
14127
|
+
var formatNestedLayerGraph = fn("formatNestedLayerGraph")(
|
|
14128
|
+
function* (layerGraph, fromSourceFile) {
|
|
14129
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
14130
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
14131
|
+
const ts = yield* service(TypeScriptApi);
|
|
14132
|
+
const mermaidSafe = (value) => value.replace(/\n/g, " ").replace(
|
|
14133
|
+
/\s+/g,
|
|
14134
|
+
" "
|
|
14135
|
+
).substring(0, 50).replace(/"/g, "#quot;").replace(/</mg, "#lt;").replace(/>/mg, "#gt;").trim();
|
|
14136
|
+
const typeNameCache = /* @__PURE__ */ new Map();
|
|
14137
|
+
const typeName = (type) => {
|
|
14138
|
+
if (typeNameCache.has(type)) return typeNameCache.get(type);
|
|
14139
|
+
const name = typeChecker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
|
|
14140
|
+
typeNameCache.set(type, name);
|
|
14141
|
+
return name;
|
|
14142
|
+
};
|
|
14143
|
+
let result = [];
|
|
14144
|
+
for (const [graphNodeIndex, graphNode] of entries(nodes(layerGraph))) {
|
|
14145
|
+
let subgraphDefs = [];
|
|
14146
|
+
for (const kind of ["requires", "provides"]) {
|
|
14147
|
+
const typesMermaidNodes = [];
|
|
14148
|
+
for (let i = 0; i < graphNode[kind].length; i++) {
|
|
14149
|
+
typesMermaidNodes.push(`${graphNodeIndex}_${kind}_${i}["${mermaidSafe(typeName(graphNode[kind][i]))}"]`);
|
|
14150
|
+
}
|
|
14151
|
+
if (typesMermaidNodes.length > 0) {
|
|
14152
|
+
subgraphDefs = [
|
|
14153
|
+
...subgraphDefs,
|
|
14154
|
+
`subgraph ${graphNodeIndex}_${kind} [${kind === "provides" ? "Provides" : "Requires"}]`,
|
|
14155
|
+
...typesMermaidNodes.map((_) => ` ${_}`),
|
|
14156
|
+
`end`,
|
|
14157
|
+
`style ${graphNodeIndex}_${kind} stroke:none`
|
|
14158
|
+
];
|
|
14134
14159
|
}
|
|
14135
14160
|
}
|
|
14161
|
+
subgraphDefs = [
|
|
14162
|
+
`subgraph ${graphNodeIndex}_wrap[" "]`,
|
|
14163
|
+
...subgraphDefs.map((_) => ` ${_}`),
|
|
14164
|
+
`end`,
|
|
14165
|
+
`style ${graphNodeIndex}_wrap fill:transparent`,
|
|
14166
|
+
`style ${graphNodeIndex}_wrap stroke:none`
|
|
14167
|
+
];
|
|
14168
|
+
const tsNode = graphNode.displayNode;
|
|
14169
|
+
const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
|
|
14170
|
+
const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
|
|
14171
|
+
result = [
|
|
14172
|
+
...result,
|
|
14173
|
+
`subgraph ${graphNodeIndex} ["\`${mermaidSafe(nodeText)}<br/><small>_${mermaidSafe(formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile))}_</small>\`"]`,
|
|
14174
|
+
...subgraphDefs.map((_) => ` ${_}`),
|
|
14175
|
+
`end`,
|
|
14176
|
+
`style ${graphNodeIndex} fill:transparent`
|
|
14177
|
+
];
|
|
14178
|
+
}
|
|
14179
|
+
for (const edgeInfo of values2(edges(layerGraph))) {
|
|
14180
|
+
const sourceData = layerGraph.nodes.get(edgeInfo.source);
|
|
14181
|
+
const targetData = layerGraph.nodes.get(edgeInfo.target);
|
|
14182
|
+
let connected = false;
|
|
14183
|
+
for (const kind of ["requires", "provides"]) {
|
|
14184
|
+
for (let i = 0; i < sourceData[kind].length; i++) {
|
|
14185
|
+
const targetIdx = targetData[kind].indexOf(sourceData[kind][i]);
|
|
14186
|
+
if (targetIdx > -1) {
|
|
14187
|
+
result.push(`${edgeInfo.source}_${kind}_${i} -.-> ${edgeInfo.target}_${kind}_${targetIdx}`);
|
|
14188
|
+
connected = true;
|
|
14189
|
+
}
|
|
14190
|
+
}
|
|
14191
|
+
}
|
|
14192
|
+
if (!connected) {
|
|
14193
|
+
result.push(`${edgeInfo.source} -.-x ${edgeInfo.target}`);
|
|
14194
|
+
}
|
|
14136
14195
|
}
|
|
14137
|
-
if (
|
|
14138
|
-
|
|
14139
|
-
|
|
14196
|
+
if (result.length === 0) return "";
|
|
14197
|
+
return [
|
|
14198
|
+
`flowchart TB`,
|
|
14199
|
+
...result.map((_) => ` ${_}`)
|
|
14200
|
+
].join("\n");
|
|
14140
14201
|
}
|
|
14141
|
-
|
|
14142
|
-
`flowchart TB`,
|
|
14143
|
-
...result.map((_) => ` ${_}`)
|
|
14144
|
-
].join("\n");
|
|
14145
|
-
});
|
|
14202
|
+
);
|
|
14146
14203
|
var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
14147
14204
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
14148
14205
|
const mutableGraph = beginMutation3(directed());
|
|
@@ -14162,6 +14219,7 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
|
14162
14219
|
for (const leafNode of dedupedLeafNodes) {
|
|
14163
14220
|
const nodeIndex = addNode(mutableGraph, {
|
|
14164
14221
|
node: leafNode.node,
|
|
14222
|
+
displayNode: leafNode.displayNode,
|
|
14165
14223
|
requires: leafNode.requires,
|
|
14166
14224
|
provides: leafNode.provides
|
|
14167
14225
|
});
|
|
@@ -14185,13 +14243,18 @@ var extractOutlineGraph = fn("extractOutlineGraph")(function* (layerGraph) {
|
|
|
14185
14243
|
return endMutation2(mutableGraph);
|
|
14186
14244
|
});
|
|
14187
14245
|
var formatLayerOutlineGraph = fn("formatLayerOutlineGraph")(
|
|
14188
|
-
function* (layerOutlineGraph) {
|
|
14246
|
+
function* (layerOutlineGraph, fromSourceFile) {
|
|
14189
14247
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
14248
|
+
const ts = yield* service(TypeScriptApi);
|
|
14190
14249
|
return toMermaid(layerOutlineGraph, {
|
|
14191
14250
|
edgeLabel: () => "",
|
|
14192
14251
|
nodeLabel: (graphNode) => {
|
|
14193
|
-
const
|
|
14194
|
-
|
|
14252
|
+
const tsNode = graphNode.displayNode;
|
|
14253
|
+
const sourceFile = tsUtils.getSourceFileOfNode(tsNode);
|
|
14254
|
+
const nodeText = sourceFile.text.substring(tsNode.pos, tsNode.end).trim();
|
|
14255
|
+
if (sourceFile === fromSourceFile) return nodeText;
|
|
14256
|
+
return `${nodeText}
|
|
14257
|
+
_${formatSourceFileNameLineAndColumn(ts, tsUtils, tsNode, fromSourceFile)}_`;
|
|
14195
14258
|
}
|
|
14196
14259
|
});
|
|
14197
14260
|
}
|
|
@@ -14274,6 +14337,7 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
|
14274
14337
|
const sortedTypes = pipe(fromIterable(rootTypes), sort(typeCheckerUtils.deterministicTypeOrder));
|
|
14275
14338
|
for (const layerType of sortedTypes) {
|
|
14276
14339
|
const tsNodes = [];
|
|
14340
|
+
const tsDisplayNodes = [];
|
|
14277
14341
|
for (const layerNode of values2(
|
|
14278
14342
|
walkLeavesMatching(
|
|
14279
14343
|
layerGraph,
|
|
@@ -14284,11 +14348,13 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
|
14284
14348
|
)
|
|
14285
14349
|
)) {
|
|
14286
14350
|
tsNodes.push(layerNode.node);
|
|
14351
|
+
tsDisplayNodes.push(layerNode.displayNode);
|
|
14287
14352
|
}
|
|
14288
14353
|
result.push({
|
|
14289
14354
|
kind,
|
|
14290
14355
|
type: layerType,
|
|
14291
|
-
nodes: tsNodes
|
|
14356
|
+
nodes: tsNodes,
|
|
14357
|
+
displayNodes: tsDisplayNodes
|
|
14292
14358
|
});
|
|
14293
14359
|
}
|
|
14294
14360
|
};
|
|
@@ -14298,7 +14364,7 @@ var extractProvidersAndRequirers = fn("extractProvidersAndRequirers")(
|
|
|
14298
14364
|
}
|
|
14299
14365
|
);
|
|
14300
14366
|
var formatLayerProvidersAndRequirersInfo = fn("formatLayerProvidersAndRequirersInfo")(
|
|
14301
|
-
function* (info) {
|
|
14367
|
+
function* (info, fromSourceFile) {
|
|
14302
14368
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
14303
14369
|
const ts = yield* service(TypeScriptApi);
|
|
14304
14370
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
@@ -14310,12 +14376,10 @@ var formatLayerProvidersAndRequirersInfo = fn("formatLayerProvidersAndRequirersI
|
|
|
14310
14376
|
void 0,
|
|
14311
14377
|
ts.TypeFormatFlags.NoTruncation
|
|
14312
14378
|
);
|
|
14313
|
-
const positions = infoNode.
|
|
14379
|
+
const positions = infoNode.displayNodes.map((_) => {
|
|
14314
14380
|
const sourceFile = tsUtils.getSourceFileOfNode(_);
|
|
14315
|
-
const nodePosition = ts.getTokenPosOfNode(_, sourceFile);
|
|
14316
|
-
const { character, line } = ts.getLineAndCharacterOfPosition(sourceFile, nodePosition);
|
|
14317
14381
|
const nodeText = sourceFile.text.substring(_.pos, _.end).trim().replace(/\n/g, " ").substr(0, 50);
|
|
14318
|
-
return
|
|
14382
|
+
return `${formatSourceFileNameLineAndColumn(ts, tsUtils, _, fromSourceFile)} by \`${nodeText}\``;
|
|
14319
14383
|
});
|
|
14320
14384
|
textualExplanation.push(`- ${typeString} ${infoNode.kind} at ${positions.join(", ")}`);
|
|
14321
14385
|
};
|
|
@@ -14370,16 +14434,21 @@ function getAdjustedNode(sourceFile, position) {
|
|
|
14370
14434
|
}
|
|
14371
14435
|
function parseLayerGraph(layerNode) {
|
|
14372
14436
|
return gen(function* () {
|
|
14437
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
14438
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
14373
14439
|
const layerGraph = yield* extractLayerGraph(layerNode, {
|
|
14374
14440
|
arrayLiteralAsMerge: false,
|
|
14375
|
-
explodeOnlyLayerCalls: false
|
|
14441
|
+
explodeOnlyLayerCalls: false,
|
|
14442
|
+
followSymbolsDepth: options.layerGraphFollowDepth
|
|
14376
14443
|
});
|
|
14377
|
-
const
|
|
14444
|
+
const sourceFile = tsUtils.getSourceFileOfNode(layerNode);
|
|
14445
|
+
const nestedGraphMermaid = yield* formatNestedLayerGraph(layerGraph, sourceFile);
|
|
14378
14446
|
const outlineGraph = yield* extractOutlineGraph(layerGraph);
|
|
14379
|
-
const outlineGraphMermaid = yield* formatLayerOutlineGraph(outlineGraph);
|
|
14447
|
+
const outlineGraphMermaid = yield* formatLayerOutlineGraph(outlineGraph, sourceFile);
|
|
14380
14448
|
const providersAndRequirers = yield* extractProvidersAndRequirers(layerGraph);
|
|
14381
14449
|
const providersAndRequirersTextualExplanation = yield* formatLayerProvidersAndRequirersInfo(
|
|
14382
|
-
providersAndRequirers
|
|
14450
|
+
providersAndRequirers,
|
|
14451
|
+
sourceFile
|
|
14383
14452
|
);
|
|
14384
14453
|
return { nestedGraphMermaid, outlineGraphMermaid, providersAndRequirersTextualExplanation };
|
|
14385
14454
|
});
|
|
@@ -14974,7 +15043,8 @@ var layerMagic = createRefactor({
|
|
|
14974
15043
|
return pipe(
|
|
14975
15044
|
extractLayerGraph(atLocation, {
|
|
14976
15045
|
arrayLiteralAsMerge: true,
|
|
14977
|
-
explodeOnlyLayerCalls: true
|
|
15046
|
+
explodeOnlyLayerCalls: true,
|
|
15047
|
+
followSymbolsDepth: 0
|
|
14978
15048
|
}),
|
|
14979
15049
|
flatMap2(extractOutlineGraph),
|
|
14980
15050
|
flatMap2(
|
|
@@ -15070,7 +15140,8 @@ var layerMagic = createRefactor({
|
|
|
15070
15140
|
(_targetLayer) => pipe(
|
|
15071
15141
|
extractLayerGraph(_targetLayer.castedStructure, {
|
|
15072
15142
|
arrayLiteralAsMerge: true,
|
|
15073
|
-
explodeOnlyLayerCalls: true
|
|
15143
|
+
explodeOnlyLayerCalls: true,
|
|
15144
|
+
followSymbolsDepth: 0
|
|
15074
15145
|
}),
|
|
15075
15146
|
flatMap2(extractOutlineGraph),
|
|
15076
15147
|
flatMap2(
|