@prisma/orm-toolchain 8.0.0-rc.14-dev.32 → 8.0.0-rc.14-dev.33
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
|
@@ -6730,7 +6730,7 @@ const lspCommand = defineServerCommand({
|
|
|
6730
6730
|
} },
|
|
6731
6731
|
handler: async (args, io) => {
|
|
6732
6732
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
6733
|
-
const { startServer } = await import("./exports-
|
|
6733
|
+
const { startServer } = await import("./exports-BufoY0DR.mjs");
|
|
6734
6734
|
return startServer({
|
|
6735
6735
|
stdin: io.stdin,
|
|
6736
6736
|
stdout: io.stdout,
|
|
@@ -1561,6 +1561,83 @@ function compareNames(left, right) {
|
|
|
1561
1561
|
if (left > right) return 1;
|
|
1562
1562
|
return 0;
|
|
1563
1563
|
}
|
|
1564
|
+
function resolvedNodeAt(token, binder) {
|
|
1565
|
+
const found = token.parent.findAncestor((node) => {
|
|
1566
|
+
const resolution = binder.symbolForNode(node);
|
|
1567
|
+
if (resolution !== void 0) return {
|
|
1568
|
+
node,
|
|
1569
|
+
resolution
|
|
1570
|
+
};
|
|
1571
|
+
return binder.declaredSymbol(node) === void 0 ? void 0 : "declaration";
|
|
1572
|
+
});
|
|
1573
|
+
return found === "declaration" ? void 0 : found;
|
|
1574
|
+
}
|
|
1575
|
+
function provideDefinition(source, position, linkSupport) {
|
|
1576
|
+
const token = tokenAt(source, source.sourceFile.offsetAt(position));
|
|
1577
|
+
const reference = token === void 0 ? void 0 : resolvedNodeAt(token, source.binder);
|
|
1578
|
+
if (reference === void 0) return null;
|
|
1579
|
+
const declarations = declarationsOf(reference.resolution);
|
|
1580
|
+
if (declarations.length === 0) return null;
|
|
1581
|
+
if (declarations.some((declaration) => declaration.name?.syntax === reference.node)) return null;
|
|
1582
|
+
if (!linkSupport) return declarations.map((declaration) => {
|
|
1583
|
+
const target = source.sources.sourceFileFor(declaration.node);
|
|
1584
|
+
return {
|
|
1585
|
+
uri: target.filename,
|
|
1586
|
+
range: rangeOf(target, nameNode(declaration))
|
|
1587
|
+
};
|
|
1588
|
+
});
|
|
1589
|
+
const originSelectionRange = rangeOf(source.sourceFile, reference.node);
|
|
1590
|
+
return declarations.map((declaration) => {
|
|
1591
|
+
const target = source.sources.sourceFileFor(declaration.node);
|
|
1592
|
+
return {
|
|
1593
|
+
originSelectionRange,
|
|
1594
|
+
targetUri: target.filename,
|
|
1595
|
+
targetRange: rangeOf(target, declaration.node),
|
|
1596
|
+
targetSelectionRange: rangeOf(target, nameNode(declaration))
|
|
1597
|
+
};
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
function tokenAt(source, offset) {
|
|
1601
|
+
const at = source.document.syntax.tokenAtOffset(offset);
|
|
1602
|
+
const right = at.rightBiased();
|
|
1603
|
+
return right?.kind === "Ident" ? right : at.leftBiased();
|
|
1604
|
+
}
|
|
1605
|
+
function declarationsOf(resolution) {
|
|
1606
|
+
switch (resolution.kind) {
|
|
1607
|
+
case "model":
|
|
1608
|
+
case "compositeType":
|
|
1609
|
+
case "namedType":
|
|
1610
|
+
case "block":
|
|
1611
|
+
case "field": return [declarationOf(resolution.symbol)];
|
|
1612
|
+
case "namespace": return resolution.symbol.declarations.map(({ node }) => ({
|
|
1613
|
+
node: node.syntax,
|
|
1614
|
+
name: node.name()
|
|
1615
|
+
}));
|
|
1616
|
+
case "contributedType":
|
|
1617
|
+
case "contributedNamespace":
|
|
1618
|
+
case "crossSpace":
|
|
1619
|
+
case "attribute":
|
|
1620
|
+
case "parameter":
|
|
1621
|
+
case "function":
|
|
1622
|
+
case "constant":
|
|
1623
|
+
case "unresolved": return [];
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
function declarationOf(symbol) {
|
|
1627
|
+
return {
|
|
1628
|
+
node: symbol.node.syntax,
|
|
1629
|
+
name: symbol.node.name()
|
|
1630
|
+
};
|
|
1631
|
+
}
|
|
1632
|
+
function nameNode(declaration) {
|
|
1633
|
+
return declaration.name?.syntax ?? declaration.node;
|
|
1634
|
+
}
|
|
1635
|
+
function rangeOf(sourceFile, node) {
|
|
1636
|
+
return {
|
|
1637
|
+
start: sourceFile.positionAt(node.offset),
|
|
1638
|
+
end: sourceFile.positionAt(node.endOffset)
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1564
1641
|
/**
|
|
1565
1642
|
* Computes folding ranges for block declarations in a PSL document.
|
|
1566
1643
|
*
|
|
@@ -1867,9 +1944,7 @@ function identTokenAt(root, offset) {
|
|
|
1867
1944
|
return right?.kind === "Ident" ? right : void 0;
|
|
1868
1945
|
}
|
|
1869
1946
|
function resolveHoverResult(binder, token) {
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1872
|
-
function narrowHoverResult(resolution) {
|
|
1947
|
+
const resolution = resolvedNodeAt(token, binder)?.resolution;
|
|
1873
1948
|
switch (resolution?.kind) {
|
|
1874
1949
|
case "model":
|
|
1875
1950
|
case "compositeType":
|
|
@@ -1879,6 +1954,10 @@ function narrowHoverResult(resolution) {
|
|
|
1879
1954
|
kind: "entity",
|
|
1880
1955
|
symbol: resolution.symbol
|
|
1881
1956
|
};
|
|
1957
|
+
case "namespace": return {
|
|
1958
|
+
kind: "namespace",
|
|
1959
|
+
symbol: resolution.symbol
|
|
1960
|
+
};
|
|
1882
1961
|
case "attribute": return {
|
|
1883
1962
|
kind: "attribute",
|
|
1884
1963
|
symbol: resolution.symbol
|
|
@@ -1904,6 +1983,7 @@ function narrowHoverResult(resolution) {
|
|
|
1904
1983
|
}
|
|
1905
1984
|
function renderHoverResult(result) {
|
|
1906
1985
|
if (result.kind === "entity") return renderEntityContent(result.symbol);
|
|
1986
|
+
if (result.kind === "namespace") return renderNamespaceContent(result.symbol);
|
|
1907
1987
|
if (result.kind === "attribute") return renderAttributeContent(result.symbol);
|
|
1908
1988
|
if (result.kind === "contributedType") return renderContributedTypeContent(result.symbol);
|
|
1909
1989
|
if (result.kind === "parameter") return renderParameterContent(result.symbol);
|
|
@@ -1917,6 +1997,13 @@ function renderEntityContent(entity) {
|
|
|
1917
1997
|
"```"
|
|
1918
1998
|
].join("\n"), entity.node.docComment());
|
|
1919
1999
|
}
|
|
2000
|
+
function renderNamespaceContent(namespace) {
|
|
2001
|
+
return [
|
|
2002
|
+
"```prisma",
|
|
2003
|
+
`namespace ${namespace.name}`,
|
|
2004
|
+
"```"
|
|
2005
|
+
].join("\n");
|
|
2006
|
+
}
|
|
1920
2007
|
function renderAttributeContent(symbol) {
|
|
1921
2008
|
const name = `${symbol.level === "field" ? "@" : "@@"}${symbol.name}`;
|
|
1922
2009
|
const params = resolveSignatureParameters(symbol.spec, void 0);
|
|
@@ -2395,7 +2482,7 @@ function collectExpression(expression, source, tokens, context = {}) {
|
|
|
2395
2482
|
if (expression instanceof FunctionCallAst) {
|
|
2396
2483
|
const memberPath = expression.memberPath();
|
|
2397
2484
|
if (memberPath === void 0) collectTypeReference(expression.name(), source, tokens);
|
|
2398
|
-
else collectMemberPath(memberPath, tokens);
|
|
2485
|
+
else collectMemberPath(memberPath, source, tokens);
|
|
2399
2486
|
for (const arg of expression.args()) collectAttributeArg(arg, source, tokens);
|
|
2400
2487
|
return;
|
|
2401
2488
|
}
|
|
@@ -2412,14 +2499,17 @@ function collectExpression(expression, source, tokens, context = {}) {
|
|
|
2412
2499
|
}
|
|
2413
2500
|
if (expression instanceof TaggedLiteralExprAst) return;
|
|
2414
2501
|
if (expression instanceof PathExprAst) {
|
|
2415
|
-
collectMemberPath(expression, tokens);
|
|
2502
|
+
collectMemberPath(expression, source, tokens);
|
|
2416
2503
|
return;
|
|
2417
2504
|
}
|
|
2418
2505
|
collectIdentifierExpression(expression, source, tokens, context);
|
|
2419
2506
|
}
|
|
2420
2507
|
/** A member path such as `address.city` names fields, one per segment. */
|
|
2421
|
-
function collectMemberPath(path, tokens) {
|
|
2422
|
-
for (const segment of path.segments())
|
|
2508
|
+
function collectMemberPath(path, source, tokens) {
|
|
2509
|
+
for (const segment of path.segments()) {
|
|
2510
|
+
const resolution = source.binder.symbolForNode(segment.syntax);
|
|
2511
|
+
addIdentifier(segment, resolution?.kind === "namespace" || resolution?.kind === "contributedNamespace" ? "namespace" : "property", tokens);
|
|
2512
|
+
}
|
|
2423
2513
|
}
|
|
2424
2514
|
function collectIdentifierExpression(identifier, source, tokens, context) {
|
|
2425
2515
|
if (identifier.name() === void 0) return;
|
|
@@ -2441,8 +2531,8 @@ function collectTypeReference(name, source, tokens) {
|
|
|
2441
2531
|
const segments = identifierSegments(name);
|
|
2442
2532
|
if (segments.length === 0) return;
|
|
2443
2533
|
for (const segment of segments.slice(0, -1)) {
|
|
2444
|
-
const qualifier = source.binder.
|
|
2445
|
-
if (qualifier
|
|
2534
|
+
const qualifier = source.binder.symbolForNode(segment.identifier.syntax);
|
|
2535
|
+
if (qualifier?.kind === "namespace" || qualifier?.kind === "contributedNamespace") tokens.push(rangeForIdentifier(segment.identifier, "namespace"));
|
|
2446
2536
|
}
|
|
2447
2537
|
const finalSegment = segments[segments.length - 1];
|
|
2448
2538
|
if (finalSegment === void 0) return;
|
|
@@ -2629,6 +2719,21 @@ var Project = class {
|
|
|
2629
2719
|
return null;
|
|
2630
2720
|
}
|
|
2631
2721
|
}
|
|
2722
|
+
async definition(uri, position, linkSupport) {
|
|
2723
|
+
const data = await this.#resolveMember(uri);
|
|
2724
|
+
const document = data?.artifacts.document(uri);
|
|
2725
|
+
if (data === void 0 || document === void 0) return null;
|
|
2726
|
+
try {
|
|
2727
|
+
return provideDefinition({
|
|
2728
|
+
document: document.parse().document,
|
|
2729
|
+
sourceFile: document.sourceFile,
|
|
2730
|
+
sources: data.artifacts.sources,
|
|
2731
|
+
binder: data.artifacts.binder()
|
|
2732
|
+
}, position, linkSupport);
|
|
2733
|
+
} catch {
|
|
2734
|
+
return null;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2632
2737
|
async foldingRanges(uri) {
|
|
2633
2738
|
const data = await this.#resolveMember(uri);
|
|
2634
2739
|
const document = data?.artifacts.document(uri);
|
|
@@ -3049,6 +3154,10 @@ function createServerOn(connection) {
|
|
|
3049
3154
|
if (getOpenDocument(uri) === void 0) return null;
|
|
3050
3155
|
return (await projects.nearestProject(uri))?.hover(uri, position) ?? null;
|
|
3051
3156
|
}
|
|
3157
|
+
async function definitionForDocument(uri, position) {
|
|
3158
|
+
if (getOpenDocument(uri) === void 0) return null;
|
|
3159
|
+
return (await projects.nearestProject(uri))?.definition(uri, position, clientCapabilities.definitionLinks) ?? null;
|
|
3160
|
+
}
|
|
3052
3161
|
connection.onInitialize(async (params) => {
|
|
3053
3162
|
rootPath = resolveRootPath(params);
|
|
3054
3163
|
clientCapabilities = resolveClientCapabilities(params);
|
|
@@ -3076,6 +3185,7 @@ function createServerOn(connection) {
|
|
|
3076
3185
|
] },
|
|
3077
3186
|
signatureHelpProvider: { triggerCharacters: ["(", ","] },
|
|
3078
3187
|
hoverProvider: true,
|
|
3188
|
+
definitionProvider: true,
|
|
3079
3189
|
...clientCapabilities.pullDiagnostics ? { diagnosticProvider: {
|
|
3080
3190
|
interFileDependencies: true,
|
|
3081
3191
|
workspaceDiagnostics: false
|
|
@@ -3087,6 +3197,7 @@ function createServerOn(connection) {
|
|
|
3087
3197
|
connection.onDocumentFormatting((params) => formatDocument(params.textDocument.uri));
|
|
3088
3198
|
connection.onCompletion((params) => completeDocument(params.textDocument.uri, params.position));
|
|
3089
3199
|
connection.onSignatureHelp((params) => signatureHelpForDocument(params.textDocument.uri, params.position));
|
|
3200
|
+
connection.onDefinition((params) => definitionForDocument(params.textDocument.uri, params.position));
|
|
3090
3201
|
connection.onHover((params) => hoverForDocument(params.textDocument.uri, params.position));
|
|
3091
3202
|
connection.languages.semanticTokens.on((params) => semanticTokensForDocument(params.textDocument.uri));
|
|
3092
3203
|
connection.languages.semanticTokens.onRange((params) => semanticTokensForDocument(params.textDocument.uri, params.range));
|
|
@@ -3140,6 +3251,7 @@ const noClientCapabilities = {
|
|
|
3140
3251
|
watchedFilesRegistration: false,
|
|
3141
3252
|
completionSnippets: false,
|
|
3142
3253
|
signatureLabelOffsets: false,
|
|
3254
|
+
definitionLinks: false,
|
|
3143
3255
|
completionTriggerSuggestCommand: false,
|
|
3144
3256
|
completionTriggerParameterHintsCommand: false,
|
|
3145
3257
|
pullDiagnostics: false,
|
|
@@ -3150,6 +3262,7 @@ function resolveClientCapabilities(params) {
|
|
|
3150
3262
|
watchedFilesRegistration: params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true,
|
|
3151
3263
|
completionSnippets: params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true,
|
|
3152
3264
|
signatureLabelOffsets: params.capabilities.textDocument?.signatureHelp?.signatureInformation?.parameterInformation?.labelOffsetSupport === true,
|
|
3265
|
+
definitionLinks: params.capabilities.textDocument?.definition?.linkSupport === true,
|
|
3153
3266
|
completionTriggerSuggestCommand: supportsCompletionCommand(params.initializationOptions, "supportsTriggerSuggestCommand"),
|
|
3154
3267
|
completionTriggerParameterHintsCommand: supportsCompletionCommand(params.initializationOptions, "supportsTriggerParameterHintsCommand"),
|
|
3155
3268
|
pullDiagnostics: params.capabilities.textDocument?.diagnostic?.relatedDocumentSupport === true,
|
|
@@ -3413,4 +3526,4 @@ function startServer(streams) {
|
|
|
3413
3526
|
//#endregion
|
|
3414
3527
|
export { startServer };
|
|
3415
3528
|
|
|
3416
|
-
//# sourceMappingURL=exports-
|
|
3529
|
+
//# sourceMappingURL=exports-BufoY0DR.mjs.map
|