@prisma/orm-toolchain 8.0.0-rc.14-dev.19 → 8.0.0-rc.14-dev.21

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/dist/cli.mjs CHANGED
@@ -6727,7 +6727,7 @@ const lspCommand = defineServerCommand({
6727
6727
  } },
6728
6728
  handler: async (args, io) => {
6729
6729
  const exitCode = await withoutClientProcessIdInArgv(async () => {
6730
- const { startServer } = await import("./exports-uCZMBtq-.mjs");
6730
+ const { startServer } = await import("./exports-C4Peu_9F.mjs");
6731
6731
  return startServer({
6732
6732
  stdin: io.stdin,
6733
6733
  stdout: io.stdout,
@@ -1598,6 +1598,364 @@ function addFoldingRange(declaration, sources, ranges) {
1598
1598
  kind: FoldingRangeKind.Region
1599
1599
  });
1600
1600
  }
1601
+ function classifyPslSignatureContext(input) {
1602
+ const syntax = locateAttributeSyntax(input);
1603
+ if (syntax === void 0) return blockValueSignatureContext(input);
1604
+ const attributeName = syntax.attribute.name()?.identifier()?.name();
1605
+ const args = syntax.attribute.argList();
1606
+ const position = args === void 0 ? void 0 : signatureArguments(syntax, args, []);
1607
+ const owner = signatureOwner(syntax.attribute);
1608
+ return attributeName === void 0 || position === void 0 || owner === void 0 ? void 0 : {
1609
+ ...owner,
1610
+ ...position,
1611
+ attributeName
1612
+ };
1613
+ }
1614
+ function blockValueSignatureContext(input) {
1615
+ const offset = input.sourceFile.offsetAt(input.position);
1616
+ const anchor = input.document.syntax.tokenAtOffset(offset).leftBiased();
1617
+ if (anchor === void 0 || anchor.kind === "Comment") return void 0;
1618
+ const preceding = skipTriviaToken(anchor, "prev");
1619
+ const pair = preceding?.parent.findAncestor(KeyValuePairAst.cast);
1620
+ const equals = pair?.equals();
1621
+ if (pair === void 0 || equals === void 0 || offset <= equals.offset) return void 0;
1622
+ const block = pair.syntax.findAncestor(GenericBlockDeclarationAst.cast);
1623
+ const blockKeyword = block?.keyword()?.text;
1624
+ const key = pair.key()?.name();
1625
+ if (block === void 0 || blockKeyword === void 0 || key === void 0) return void 0;
1626
+ const position = signatureExpression({
1627
+ offset,
1628
+ preceding
1629
+ }, pair.value(), []);
1630
+ return position === void 0 ? void 0 : {
1631
+ ownerKind: "blockValue",
1632
+ block,
1633
+ blockKeyword,
1634
+ key,
1635
+ ...position
1636
+ };
1637
+ }
1638
+ function signatureOwner(attribute) {
1639
+ if (attribute instanceof FieldAttributeAst) {
1640
+ const field = attribute.syntax.findAncestor(FieldDeclarationAst.cast);
1641
+ const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
1642
+ return field === void 0 || model === void 0 ? void 0 : {
1643
+ ownerKind: "field",
1644
+ field,
1645
+ model
1646
+ };
1647
+ }
1648
+ const block = attribute.syntax.findAncestor(GenericBlockDeclarationAst.cast);
1649
+ if (block !== void 0) {
1650
+ const blockKeyword = block.keyword()?.text;
1651
+ return blockKeyword === void 0 || blockKeyword.length === 0 ? void 0 : {
1652
+ ownerKind: "block",
1653
+ block,
1654
+ blockKeyword
1655
+ };
1656
+ }
1657
+ const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
1658
+ return model === void 0 ? void 0 : {
1659
+ ownerKind: "model",
1660
+ model
1661
+ };
1662
+ }
1663
+ function signatureArguments(context, args, path) {
1664
+ if (!betweenDelimiters(context.offset, args.lparen(), args.rparen())) return void 0;
1665
+ const containing = argumentAtCursor(context, args);
1666
+ const next = context.preceding?.kind === "Comma" ? nonTriviaSibling(context.preceding, "next") : void 0;
1667
+ const following = next instanceof SyntaxNode && next.parent?.offset === args.syntax.offset ? AttributeArgAst.cast(next) : void 0;
1668
+ const active = containing ?? following;
1669
+ const { precedingPositionalCount: positionalIndex, otherNamedKeys: existingNamedKeys } = argumentSiblings(args, active, context.offset);
1670
+ if (active === void 0) return ["LParen", "Comma"].includes(context.preceding?.kind ?? "") ? {
1671
+ path,
1672
+ argumentSlot: {
1673
+ positionalIndex,
1674
+ existingNamedKeys
1675
+ }
1676
+ } : void 0;
1677
+ if (active.colon() !== void 0) {
1678
+ const name = active.name()?.name();
1679
+ if (name === void 0) return void 0;
1680
+ const valuePath = [...path, {
1681
+ kind: "namedArgument",
1682
+ name
1683
+ }];
1684
+ return active === containing ? signatureExpression(context, active.value(), valuePath) : {
1685
+ path: valuePath,
1686
+ argumentSlot: void 0
1687
+ };
1688
+ }
1689
+ const value = active.value();
1690
+ if (value === void 0 || value instanceof IdentifierAst && value.syntax.isInside(context.offset)) return {
1691
+ path,
1692
+ argumentSlot: {
1693
+ positionalIndex,
1694
+ existingNamedKeys
1695
+ }
1696
+ };
1697
+ const valuePath = [...path, {
1698
+ kind: "positionalArgument",
1699
+ index: positionalIndex
1700
+ }];
1701
+ return active === containing ? signatureExpression(context, value, valuePath) : {
1702
+ path: valuePath,
1703
+ argumentSlot: void 0
1704
+ };
1705
+ }
1706
+ function signatureExpression(context, expression, path) {
1707
+ const position = {
1708
+ path,
1709
+ argumentSlot: void 0
1710
+ };
1711
+ if (expression === void 0 || context.offset <= expression.syntax.offset || context.offset >= expression.syntax.endOffset && !recoveredContainerContainsCursor(expression, context.offset)) return position;
1712
+ if (expression instanceof ArrayLiteralAst) return betweenDelimiters(context.offset, expression.lbracket(), expression.rbracket()) ? signatureExpression(context, listElementAtCursor(context, expression), [...path, { kind: "listElement" }]) : void 0;
1713
+ if (expression instanceof ObjectLiteralExprAst) {
1714
+ const closing = expression.rbrace();
1715
+ if (closing !== void 0 && context.offset >= closing.endOffset) return void 0;
1716
+ const field = recordFieldAtCursor(context, expression);
1717
+ return field !== void 0 ? signatureExpression(context, field.value(), [...path, { kind: "recordValue" }]) : position;
1718
+ }
1719
+ if (expression instanceof FunctionCallAst) {
1720
+ const opening = expression.lparen();
1721
+ if (opening !== void 0 && context.offset > opening.offset) {
1722
+ const name = expression.name();
1723
+ const identifier = name?.identifier()?.name();
1724
+ return identifier !== void 0 && name?.isSimpleName(identifier) === true ? signatureArguments(context, expression, [...path, {
1725
+ kind: "functionCall",
1726
+ name: identifier
1727
+ }]) : void 0;
1728
+ }
1729
+ return expression.name()?.syntax.isInside(context.offset) === true ? position : void 0;
1730
+ }
1731
+ return position;
1732
+ }
1733
+ function providePslSignatureHelp(input) {
1734
+ const context = classifyPslSignatureContext(input);
1735
+ if (context === void 0) return null;
1736
+ const root = argumentRootGrammar(context, input.candidates);
1737
+ if (root === void 0) return null;
1738
+ return signatureHelp(context, root, input.clientSupportsLabelOffsets === true);
1739
+ }
1740
+ function rootSignatureName(owner) {
1741
+ switch (owner.ownerKind) {
1742
+ case "field": return `@${owner.attributeName}`;
1743
+ case "model":
1744
+ case "block": return `@@${owner.attributeName}`;
1745
+ case "blockValue": return;
1746
+ }
1747
+ }
1748
+ function signatureHelp(context, root, labelOffsets) {
1749
+ const callIndex = context.path.reduce((last, step, index) => step.kind === "functionCall" ? index : last, -1);
1750
+ const call = context.path[callIndex];
1751
+ const signaturePath = context.path.slice(0, callIndex + 1);
1752
+ const name = call?.kind === "functionCall" ? call.name : rootSignatureName(context);
1753
+ if (name === void 0) return null;
1754
+ const signatures = resolveGrammar(root, signaturePath).flatMap((grammar) => {
1755
+ if ("kind" in grammar) return [];
1756
+ const active = context.path[callIndex + 1];
1757
+ const params = resolveSignatureParameters(grammar, active?.kind === "namedArgument" ? active.name : void 0);
1758
+ const index = parameterIndex(context, active, params);
1759
+ return [{
1760
+ signature: renderSignature(name, grammar, params, labelOffsets),
1761
+ index
1762
+ }];
1763
+ });
1764
+ if (signatures.length === 0) return null;
1765
+ const matched = signatures.findIndex(({ signature, index }) => index >= 0 && index < (signature.parameters?.length ?? 0));
1766
+ const activeSignature = matched < 0 ? 0 : matched;
1767
+ const activeParameter = signatures[activeSignature]?.index;
1768
+ return {
1769
+ signatures: signatures.map(({ signature }) => signature),
1770
+ activeSignature,
1771
+ ...matched >= 0 && activeParameter !== void 0 ? { activeParameter } : {}
1772
+ };
1773
+ }
1774
+ function parameterIndex(context, active, params) {
1775
+ if (active?.kind === "namedArgument") return params.findIndex((param) => param.key === active.name);
1776
+ if (active?.kind === "positionalArgument") return active.index;
1777
+ const slot = context.argumentSlot;
1778
+ if (slot !== void 0) return params.findIndex((param, index) => index >= slot.positionalIndex && !slot.existingNamedKeys.includes(param.key));
1779
+ return -1;
1780
+ }
1781
+ function resolveSignatureParameters(signature, activeName) {
1782
+ const positional = signature.positional ?? [];
1783
+ const keys = new Set(positional.map((param) => param.key));
1784
+ const namedAlias = activeName === void 0 ? void 0 : signature.named?.[activeName];
1785
+ return [...positional.map((param) => param.key === activeName && namedAlias !== void 0 ? {
1786
+ key: param.key,
1787
+ ...namedAlias
1788
+ } : param), ...Object.entries(signature.named ?? {}).flatMap(([key, param]) => keys.has(key) ? [] : [{
1789
+ key,
1790
+ ...param
1791
+ }])];
1792
+ }
1793
+ function renderSignatureLabel(name, signature, params) {
1794
+ let label = `${name}(`;
1795
+ const parts = params.map((param, index) => {
1796
+ if (index > 0) label += ", ";
1797
+ const positional = index < (signature.positional?.length ?? 0);
1798
+ const optional = "optional" in param.type && param.type.optional === true;
1799
+ const typeLabel = optional && param.type.label.includes(" | ") ? `(${param.type.label})` : param.type.label;
1800
+ const text = positional ? `${typeLabel}${optional ? "?" : ""}` : `${param.key}${optional ? "?" : ""}: ${param.type.label}`;
1801
+ const start = label.length;
1802
+ label += text;
1803
+ return {
1804
+ param,
1805
+ text,
1806
+ start,
1807
+ end: label.length,
1808
+ positional
1809
+ };
1810
+ });
1811
+ return {
1812
+ label: `${label})`,
1813
+ parts
1814
+ };
1815
+ }
1816
+ function renderSignature(name, signature, params, labelOffsets) {
1817
+ const { label, parts } = renderSignatureLabel(name, signature, params);
1818
+ const rendered = parts.map(({ param, text, start, end, positional }) => {
1819
+ const documentation = positional ? `**${param.key}**\n\n${param.documentation}${signature.named?.[param.key] === void 0 ? "" : `\n\nAccepted positionally or by \`${param.key}:\`.`}` : param.documentation;
1820
+ return {
1821
+ label: positional && labelOffsets ? [start, end] : text,
1822
+ documentation: {
1823
+ kind: MarkupKind.Markdown,
1824
+ value: documentation
1825
+ }
1826
+ };
1827
+ });
1828
+ return {
1829
+ label,
1830
+ documentation: {
1831
+ kind: MarkupKind.Markdown,
1832
+ value: signature.documentation
1833
+ },
1834
+ parameters: rendered
1835
+ };
1836
+ }
1837
+ function providePslHover(input) {
1838
+ const offset = input.sourceFile.offsetAt(input.position);
1839
+ const token = identTokenAt(input.document.syntax, offset);
1840
+ if (token === void 0) return null;
1841
+ const value = hoverValueAt(input.binder, token, input.pslBlockDescriptors);
1842
+ if (value === void 0) return null;
1843
+ return {
1844
+ contents: {
1845
+ kind: MarkupKind.Markdown,
1846
+ value
1847
+ },
1848
+ range: {
1849
+ start: input.sourceFile.positionAt(token.offset),
1850
+ end: input.sourceFile.positionAt(token.endOffset)
1851
+ }
1852
+ };
1853
+ }
1854
+ function hoverValueAt(binder, token, pslBlockDescriptors) {
1855
+ const result = resolveHoverResult(binder, token);
1856
+ if (result !== void 0) return renderHoverResult(result);
1857
+ return blockKeywordDocumentationAt(token, pslBlockDescriptors);
1858
+ }
1859
+ function identTokenAt(root, offset) {
1860
+ const at = root.tokenAtOffset(offset);
1861
+ const left = at.leftBiased();
1862
+ if (left?.kind === "Ident") return left;
1863
+ const right = at.rightBiased();
1864
+ return right?.kind === "Ident" ? right : void 0;
1865
+ }
1866
+ function resolveHoverResult(binder, token) {
1867
+ return token.parent.findAncestor((node) => narrowHoverResult(binder.symbolForNode(node)));
1868
+ }
1869
+ function narrowHoverResult(resolution) {
1870
+ switch (resolution?.kind) {
1871
+ case "model":
1872
+ case "compositeType":
1873
+ case "namedType":
1874
+ case "block":
1875
+ case "field": return {
1876
+ kind: "entity",
1877
+ symbol: resolution.symbol
1878
+ };
1879
+ case "attribute": return {
1880
+ kind: "attribute",
1881
+ symbol: resolution.symbol
1882
+ };
1883
+ case "contributedType": return {
1884
+ kind: "contributedType",
1885
+ symbol: resolution.symbol
1886
+ };
1887
+ default: return;
1888
+ }
1889
+ }
1890
+ function renderHoverResult(result) {
1891
+ if (result.kind === "entity") return renderEntityContent(result.symbol);
1892
+ if (result.kind === "attribute") return renderAttributeContent(result.symbol);
1893
+ return renderContributedTypeContent(result.symbol);
1894
+ }
1895
+ function renderEntityContent(entity) {
1896
+ return withDocumentation([
1897
+ "```prisma",
1898
+ renderDeclarationLine(entity),
1899
+ "```"
1900
+ ].join("\n"), entity.node.docComment());
1901
+ }
1902
+ function renderAttributeContent(symbol) {
1903
+ const name = `${symbol.level === "field" ? "@" : "@@"}${symbol.name}`;
1904
+ const params = resolveSignatureParameters(symbol.spec, void 0);
1905
+ const { label } = renderSignatureLabel(name, symbol.spec, params);
1906
+ return withDocumentation([
1907
+ "```prisma",
1908
+ label,
1909
+ "```"
1910
+ ].join("\n"), symbol.spec.documentation);
1911
+ }
1912
+ function renderContributedTypeContent(symbol) {
1913
+ return withDocumentation([
1914
+ "```prisma",
1915
+ renderContributedTypeLabel(symbol),
1916
+ "```"
1917
+ ].join("\n"), symbol.descriptor.kind === "typeConstructor" ? symbol.descriptor.documentation : void 0);
1918
+ }
1919
+ function withDocumentation(fence, documentation) {
1920
+ return documentation === void 0 || documentation === "" ? fence : `${fence}\n\n${documentation}`;
1921
+ }
1922
+ function renderContributedTypeLabel(symbol) {
1923
+ const path = symbol.path.join(".");
1924
+ const args = symbol.descriptor.args ?? [];
1925
+ if (args.length === 0) return path;
1926
+ return `${path}(${args.map((arg, index) => {
1927
+ return `${arg.name ?? `arg${index + 1}`}${arg.optional === true ? "?" : ""}: ${argumentTypeLabel(arg)}`;
1928
+ }).join(", ")})`;
1929
+ }
1930
+ function argumentTypeLabel(arg) {
1931
+ if (arg.kind === "string") return "string";
1932
+ if (arg.kind === "boolean") return "boolean";
1933
+ if (arg.kind === "number") return "number";
1934
+ if (arg.kind === "stringArray") return "string[]";
1935
+ if (arg.kind === "object") return "object";
1936
+ return arg.values.map((value) => `'${value}'`).join(" | ");
1937
+ }
1938
+ function blockKeywordDocumentationAt(token, pslBlockDescriptors) {
1939
+ const declaration = GenericBlockDeclarationAst.cast(token.parent);
1940
+ if (declaration === void 0 || declaration.keyword()?.offset !== token.offset) return void 0;
1941
+ return findBlockDescriptor(pslBlockDescriptors, token.text)?.documentation;
1942
+ }
1943
+ function renderDeclarationLine(entity) {
1944
+ if (entity.kind === "block") return `${entity.keyword} ${entity.name}`;
1945
+ if (entity.kind === "field" || entity.kind === "namedType") return collapseWhitespace(printSyntaxWithoutComments(entity.node.syntax));
1946
+ return `${entity.node.keyword()?.text ?? ""} ${entity.name}`;
1947
+ }
1948
+ function printSyntaxWithoutComments(node) {
1949
+ let text = "";
1950
+ for (const token of node.tokens()) {
1951
+ if (token.kind === "Comment") continue;
1952
+ text += token.text;
1953
+ }
1954
+ return text;
1955
+ }
1956
+ function collapseWhitespace(text) {
1957
+ return text.replace(/\s+/g, " ").trim();
1958
+ }
1601
1959
  function binderContextFromStack(stack) {
1602
1960
  return {
1603
1961
  authoringContributions: stack.authoringContributions ?? {
@@ -2127,226 +2485,6 @@ function createPendingSemanticToken(startOffset, endOffset, tokenType, modifierB
2127
2485
  function tokenTypeIndex(tokenType) {
2128
2486
  return semanticTokenTypes.indexOf(tokenType);
2129
2487
  }
2130
- function classifyPslSignatureContext(input) {
2131
- const syntax = locateAttributeSyntax(input);
2132
- if (syntax === void 0) return blockValueSignatureContext(input);
2133
- const attributeName = syntax.attribute.name()?.identifier()?.name();
2134
- const args = syntax.attribute.argList();
2135
- const position = args === void 0 ? void 0 : signatureArguments(syntax, args, []);
2136
- const owner = signatureOwner(syntax.attribute);
2137
- return attributeName === void 0 || position === void 0 || owner === void 0 ? void 0 : {
2138
- ...owner,
2139
- ...position,
2140
- attributeName
2141
- };
2142
- }
2143
- function blockValueSignatureContext(input) {
2144
- const offset = input.sourceFile.offsetAt(input.position);
2145
- const anchor = input.document.syntax.tokenAtOffset(offset).leftBiased();
2146
- if (anchor === void 0 || anchor.kind === "Comment") return void 0;
2147
- const preceding = skipTriviaToken(anchor, "prev");
2148
- const pair = preceding?.parent.findAncestor(KeyValuePairAst.cast);
2149
- const equals = pair?.equals();
2150
- if (pair === void 0 || equals === void 0 || offset <= equals.offset) return void 0;
2151
- const block = pair.syntax.findAncestor(GenericBlockDeclarationAst.cast);
2152
- const blockKeyword = block?.keyword()?.text;
2153
- const key = pair.key()?.name();
2154
- if (block === void 0 || blockKeyword === void 0 || key === void 0) return void 0;
2155
- const position = signatureExpression({
2156
- offset,
2157
- preceding
2158
- }, pair.value(), []);
2159
- return position === void 0 ? void 0 : {
2160
- ownerKind: "blockValue",
2161
- block,
2162
- blockKeyword,
2163
- key,
2164
- ...position
2165
- };
2166
- }
2167
- function signatureOwner(attribute) {
2168
- if (attribute instanceof FieldAttributeAst) {
2169
- const field = attribute.syntax.findAncestor(FieldDeclarationAst.cast);
2170
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
2171
- return field === void 0 || model === void 0 ? void 0 : {
2172
- ownerKind: "field",
2173
- field,
2174
- model
2175
- };
2176
- }
2177
- const block = attribute.syntax.findAncestor(GenericBlockDeclarationAst.cast);
2178
- if (block !== void 0) {
2179
- const blockKeyword = block.keyword()?.text;
2180
- return blockKeyword === void 0 || blockKeyword.length === 0 ? void 0 : {
2181
- ownerKind: "block",
2182
- block,
2183
- blockKeyword
2184
- };
2185
- }
2186
- const model = attribute.syntax.findAncestor(ModelDeclarationAst.cast);
2187
- return model === void 0 ? void 0 : {
2188
- ownerKind: "model",
2189
- model
2190
- };
2191
- }
2192
- function signatureArguments(context, args, path) {
2193
- if (!betweenDelimiters(context.offset, args.lparen(), args.rparen())) return void 0;
2194
- const containing = argumentAtCursor(context, args);
2195
- const next = context.preceding?.kind === "Comma" ? nonTriviaSibling(context.preceding, "next") : void 0;
2196
- const following = next instanceof SyntaxNode && next.parent?.offset === args.syntax.offset ? AttributeArgAst.cast(next) : void 0;
2197
- const active = containing ?? following;
2198
- const { precedingPositionalCount: positionalIndex, otherNamedKeys: existingNamedKeys } = argumentSiblings(args, active, context.offset);
2199
- if (active === void 0) return ["LParen", "Comma"].includes(context.preceding?.kind ?? "") ? {
2200
- path,
2201
- argumentSlot: {
2202
- positionalIndex,
2203
- existingNamedKeys
2204
- }
2205
- } : void 0;
2206
- if (active.colon() !== void 0) {
2207
- const name = active.name()?.name();
2208
- if (name === void 0) return void 0;
2209
- const valuePath = [...path, {
2210
- kind: "namedArgument",
2211
- name
2212
- }];
2213
- return active === containing ? signatureExpression(context, active.value(), valuePath) : {
2214
- path: valuePath,
2215
- argumentSlot: void 0
2216
- };
2217
- }
2218
- const value = active.value();
2219
- if (value === void 0 || value instanceof IdentifierAst && value.syntax.isInside(context.offset)) return {
2220
- path,
2221
- argumentSlot: {
2222
- positionalIndex,
2223
- existingNamedKeys
2224
- }
2225
- };
2226
- const valuePath = [...path, {
2227
- kind: "positionalArgument",
2228
- index: positionalIndex
2229
- }];
2230
- return active === containing ? signatureExpression(context, value, valuePath) : {
2231
- path: valuePath,
2232
- argumentSlot: void 0
2233
- };
2234
- }
2235
- function signatureExpression(context, expression, path) {
2236
- const position = {
2237
- path,
2238
- argumentSlot: void 0
2239
- };
2240
- if (expression === void 0 || context.offset <= expression.syntax.offset || context.offset >= expression.syntax.endOffset && !recoveredContainerContainsCursor(expression, context.offset)) return position;
2241
- if (expression instanceof ArrayLiteralAst) return betweenDelimiters(context.offset, expression.lbracket(), expression.rbracket()) ? signatureExpression(context, listElementAtCursor(context, expression), [...path, { kind: "listElement" }]) : void 0;
2242
- if (expression instanceof ObjectLiteralExprAst) {
2243
- const closing = expression.rbrace();
2244
- if (closing !== void 0 && context.offset >= closing.endOffset) return void 0;
2245
- const field = recordFieldAtCursor(context, expression);
2246
- return field !== void 0 ? signatureExpression(context, field.value(), [...path, { kind: "recordValue" }]) : position;
2247
- }
2248
- if (expression instanceof FunctionCallAst) {
2249
- const opening = expression.lparen();
2250
- if (opening !== void 0 && context.offset > opening.offset) {
2251
- const name = expression.name();
2252
- const identifier = name?.identifier()?.name();
2253
- return identifier !== void 0 && name?.isSimpleName(identifier) === true ? signatureArguments(context, expression, [...path, {
2254
- kind: "functionCall",
2255
- name: identifier
2256
- }]) : void 0;
2257
- }
2258
- return expression.name()?.syntax.isInside(context.offset) === true ? position : void 0;
2259
- }
2260
- return position;
2261
- }
2262
- function providePslSignatureHelp(input) {
2263
- const context = classifyPslSignatureContext(input);
2264
- if (context === void 0) return null;
2265
- const root = argumentRootGrammar(context, input.candidates);
2266
- if (root === void 0) return null;
2267
- return signatureHelp(context, root, input.clientSupportsLabelOffsets === true);
2268
- }
2269
- function rootSignatureName(owner) {
2270
- switch (owner.ownerKind) {
2271
- case "field": return `@${owner.attributeName}`;
2272
- case "model":
2273
- case "block": return `@@${owner.attributeName}`;
2274
- case "blockValue": return;
2275
- }
2276
- }
2277
- function signatureHelp(context, root, labelOffsets) {
2278
- const callIndex = context.path.reduce((last, step, index) => step.kind === "functionCall" ? index : last, -1);
2279
- const call = context.path[callIndex];
2280
- const signaturePath = context.path.slice(0, callIndex + 1);
2281
- const name = call?.kind === "functionCall" ? call.name : rootSignatureName(context);
2282
- if (name === void 0) return null;
2283
- const signatures = resolveGrammar(root, signaturePath).flatMap((grammar) => {
2284
- if ("kind" in grammar) return [];
2285
- const active = context.path[callIndex + 1];
2286
- const params = parameters(grammar, active?.kind === "namedArgument" ? active.name : void 0);
2287
- const index = parameterIndex(context, active, params);
2288
- return [{
2289
- signature: renderSignature(name, grammar, params, labelOffsets),
2290
- index
2291
- }];
2292
- });
2293
- if (signatures.length === 0) return null;
2294
- const matched = signatures.findIndex(({ signature, index }) => index >= 0 && index < (signature.parameters?.length ?? 0));
2295
- const activeSignature = matched < 0 ? 0 : matched;
2296
- const activeParameter = signatures[activeSignature]?.index;
2297
- return {
2298
- signatures: signatures.map(({ signature }) => signature),
2299
- activeSignature,
2300
- ...matched >= 0 && activeParameter !== void 0 ? { activeParameter } : {}
2301
- };
2302
- }
2303
- function parameterIndex(context, active, params) {
2304
- if (active?.kind === "namedArgument") return params.findIndex((param) => param.key === active.name);
2305
- if (active?.kind === "positionalArgument") return active.index;
2306
- const slot = context.argumentSlot;
2307
- if (slot !== void 0) return params.findIndex((param, index) => index >= slot.positionalIndex && !slot.existingNamedKeys.includes(param.key));
2308
- return -1;
2309
- }
2310
- function parameters(signature, activeName) {
2311
- const positional = signature.positional ?? [];
2312
- const keys = new Set(positional.map((param) => param.key));
2313
- const namedAlias = activeName === void 0 ? void 0 : signature.named?.[activeName];
2314
- return [...positional.map((param) => param.key === activeName && namedAlias !== void 0 ? {
2315
- key: param.key,
2316
- ...namedAlias
2317
- } : param), ...Object.entries(signature.named ?? {}).flatMap(([key, param]) => keys.has(key) ? [] : [{
2318
- key,
2319
- ...param
2320
- }])];
2321
- }
2322
- function renderSignature(name, signature, params, labelOffsets) {
2323
- let label = `${name}(`;
2324
- const rendered = params.map((param, index) => {
2325
- if (index > 0) label += ", ";
2326
- const positional = index < (signature.positional?.length ?? 0);
2327
- const optional = "optional" in param.type && param.type.optional === true;
2328
- const typeLabel = optional && param.type.label.includes(" | ") ? `(${param.type.label})` : param.type.label;
2329
- const text = positional ? `${typeLabel}${optional ? "?" : ""}` : `${param.key}${optional ? "?" : ""}: ${param.type.label}`;
2330
- const start = label.length;
2331
- label += text;
2332
- const documentation = positional ? `**${param.key}**\n\n${param.documentation}${signature.named?.[param.key] === void 0 ? "" : `\n\nAccepted positionally or by \`${param.key}:\`.`}` : param.documentation;
2333
- return {
2334
- label: positional && labelOffsets ? [start, label.length] : text,
2335
- documentation: {
2336
- kind: MarkupKind.Markdown,
2337
- value: documentation
2338
- }
2339
- };
2340
- });
2341
- return {
2342
- label: `${label})`,
2343
- documentation: {
2344
- kind: MarkupKind.Markdown,
2345
- value: signature.documentation
2346
- },
2347
- parameters: rendered
2348
- };
2349
- }
2350
2488
  const CONFIG_LOAD_FAILED_CODE = "PRISMA_CONFIG_LOAD_FAILED";
2351
2489
  var Project = class {
2352
2490
  configPath;
@@ -2434,6 +2572,22 @@ var Project = class {
2434
2572
  return null;
2435
2573
  }
2436
2574
  }
2575
+ async hover(uri, position) {
2576
+ const data = await this.#resolveMember(uri);
2577
+ const document = data?.artifacts.document(uri);
2578
+ if (data === void 0 || document === void 0) return null;
2579
+ try {
2580
+ return providePslHover({
2581
+ document: document.parse().document,
2582
+ sourceFile: document.sourceFile,
2583
+ position,
2584
+ binder: data.artifacts.binder(),
2585
+ pslBlockDescriptors: data.controlStack.pslBlockDescriptors
2586
+ });
2587
+ } catch {
2588
+ return null;
2589
+ }
2590
+ }
2437
2591
  async foldingRanges(uri) {
2438
2592
  const data = await this.#resolveMember(uri);
2439
2593
  const document = data?.artifacts.document(uri);
@@ -2850,6 +3004,10 @@ function createServerOn(connection) {
2850
3004
  if (getOpenDocument(uri) === void 0) return null;
2851
3005
  return (await projects.nearestProject(uri))?.signatureHelp(uri, position, clientCapabilities.signatureLabelOffsets) ?? null;
2852
3006
  }
3007
+ async function hoverForDocument(uri, position) {
3008
+ if (getOpenDocument(uri) === void 0) return null;
3009
+ return (await projects.nearestProject(uri))?.hover(uri, position) ?? null;
3010
+ }
2853
3011
  connection.onInitialize(async (params) => {
2854
3012
  rootPath = resolveRootPath(params);
2855
3013
  clientCapabilities = resolveClientCapabilities(params);
@@ -2876,6 +3034,7 @@ function createServerOn(connection) {
2876
3034
  ","
2877
3035
  ] },
2878
3036
  signatureHelpProvider: { triggerCharacters: ["(", ","] },
3037
+ hoverProvider: true,
2879
3038
  ...clientCapabilities.pullDiagnostics ? { diagnosticProvider: {
2880
3039
  interFileDependencies: true,
2881
3040
  workspaceDiagnostics: false
@@ -2887,6 +3046,7 @@ function createServerOn(connection) {
2887
3046
  connection.onDocumentFormatting((params) => formatDocument(params.textDocument.uri));
2888
3047
  connection.onCompletion((params) => completeDocument(params.textDocument.uri, params.position));
2889
3048
  connection.onSignatureHelp((params) => signatureHelpForDocument(params.textDocument.uri, params.position));
3049
+ connection.onHover((params) => hoverForDocument(params.textDocument.uri, params.position));
2890
3050
  connection.languages.semanticTokens.on((params) => semanticTokensForDocument(params.textDocument.uri));
2891
3051
  connection.languages.semanticTokens.onRange((params) => semanticTokensForDocument(params.textDocument.uri, params.range));
2892
3052
  connection.languages.diagnostics.on(async (params) => {
@@ -3212,4 +3372,4 @@ function startServer(streams) {
3212
3372
  //#endregion
3213
3373
  export { startServer };
3214
3374
 
3215
- //# sourceMappingURL=exports-uCZMBtq-.mjs.map
3375
+ //# sourceMappingURL=exports-C4Peu_9F.mjs.map