@prisma/orm-toolchain 8.0.0-rc.14-dev.41 → 8.0.0-rc.14-dev.42
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
|
@@ -6866,7 +6866,7 @@ const lspCommand = defineServerCommand({
|
|
|
6866
6866
|
} },
|
|
6867
6867
|
handler: async (args, io) => {
|
|
6868
6868
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
6869
|
-
const { startServer } = await import("./exports-
|
|
6869
|
+
const { startServer } = await import("./exports-B9Yxhu3o.mjs");
|
|
6870
6870
|
return startServer({
|
|
6871
6871
|
stdin: io.stdin,
|
|
6872
6872
|
stdout: io.stdout,
|
|
@@ -1561,6 +1561,13 @@ function compareNames(left, right) {
|
|
|
1561
1561
|
if (left > right) return 1;
|
|
1562
1562
|
return 0;
|
|
1563
1563
|
}
|
|
1564
|
+
function identTokenAt(root, offset) {
|
|
1565
|
+
const at = root.tokenAtOffset(offset);
|
|
1566
|
+
const left = at.leftBiased();
|
|
1567
|
+
if (left?.kind === "Ident") return left;
|
|
1568
|
+
const right = at.rightBiased();
|
|
1569
|
+
return right?.kind === "Ident" ? right : void 0;
|
|
1570
|
+
}
|
|
1564
1571
|
function resolvedNodeAt(token, binder) {
|
|
1565
1572
|
const found = token.parent.findAncestor((node) => {
|
|
1566
1573
|
const resolution = binder.symbolForNode(node);
|
|
@@ -1572,47 +1579,14 @@ function resolvedNodeAt(token, binder) {
|
|
|
1572
1579
|
});
|
|
1573
1580
|
return found === "declaration" ? void 0 : found;
|
|
1574
1581
|
}
|
|
1575
|
-
function
|
|
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) {
|
|
1582
|
+
function pslSymbolOf(resolution) {
|
|
1606
1583
|
switch (resolution.kind) {
|
|
1607
1584
|
case "model":
|
|
1608
1585
|
case "compositeType":
|
|
1609
1586
|
case "namedType":
|
|
1610
1587
|
case "block":
|
|
1611
|
-
case "field":
|
|
1612
|
-
case "namespace": return resolution.symbol
|
|
1613
|
-
node: node.syntax,
|
|
1614
|
-
name: node.name()
|
|
1615
|
-
}));
|
|
1588
|
+
case "field":
|
|
1589
|
+
case "namespace": return resolution.symbol;
|
|
1616
1590
|
case "contributedType":
|
|
1617
1591
|
case "contributedNamespace":
|
|
1618
1592
|
case "crossSpace":
|
|
@@ -1620,14 +1594,42 @@ function declarationsOf(resolution) {
|
|
|
1620
1594
|
case "parameter":
|
|
1621
1595
|
case "function":
|
|
1622
1596
|
case "constant":
|
|
1623
|
-
case "unresolved": return
|
|
1597
|
+
case "unresolved": return;
|
|
1624
1598
|
}
|
|
1625
1599
|
}
|
|
1626
|
-
function
|
|
1627
|
-
|
|
1600
|
+
function provideDefinition(input) {
|
|
1601
|
+
const token = identTokenAt(input.document.syntax, input.sourceFile.offsetAt(input.position));
|
|
1602
|
+
const reference = token === void 0 ? void 0 : resolvedNodeAt(token, input.binder);
|
|
1603
|
+
const symbol = reference === void 0 ? void 0 : pslSymbolOf(reference.resolution);
|
|
1604
|
+
if (reference === void 0 || symbol === void 0) return null;
|
|
1605
|
+
const declarations = declarationsOf(symbol);
|
|
1606
|
+
if (!input.linkSupport) return declarations.map((declaration) => {
|
|
1607
|
+
const target = input.sources.sourceFileFor(declaration.node);
|
|
1608
|
+
return {
|
|
1609
|
+
uri: target.filename,
|
|
1610
|
+
range: rangeOf(target, nameNode(declaration))
|
|
1611
|
+
};
|
|
1612
|
+
});
|
|
1613
|
+
const originSelectionRange = rangeOf(input.sourceFile, reference.node);
|
|
1614
|
+
return declarations.map((declaration) => {
|
|
1615
|
+
const target = input.sources.sourceFileFor(declaration.node);
|
|
1616
|
+
return {
|
|
1617
|
+
originSelectionRange,
|
|
1618
|
+
targetUri: target.filename,
|
|
1619
|
+
targetRange: rangeOf(target, declaration.node),
|
|
1620
|
+
targetSelectionRange: rangeOf(target, nameNode(declaration))
|
|
1621
|
+
};
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
function declarationsOf(symbol) {
|
|
1625
|
+
if (symbol.kind === "namespace") return symbol.declarations.map(({ node }) => ({
|
|
1626
|
+
node: node.syntax,
|
|
1627
|
+
name: node.name()
|
|
1628
|
+
}));
|
|
1629
|
+
return [{
|
|
1628
1630
|
node: symbol.node.syntax,
|
|
1629
1631
|
name: symbol.node.name()
|
|
1630
|
-
};
|
|
1632
|
+
}];
|
|
1631
1633
|
}
|
|
1632
1634
|
function nameNode(declaration) {
|
|
1633
1635
|
return declaration.name?.syntax ?? declaration.node;
|
|
@@ -1936,13 +1938,6 @@ function hoverValueAt(binder, token, pslBlockDescriptors) {
|
|
|
1936
1938
|
if (result !== void 0) return renderHoverResult(result);
|
|
1937
1939
|
return blockKeywordDocumentationAt(token, pslBlockDescriptors);
|
|
1938
1940
|
}
|
|
1939
|
-
function identTokenAt(root, offset) {
|
|
1940
|
-
const at = root.tokenAtOffset(offset);
|
|
1941
|
-
const left = at.leftBiased();
|
|
1942
|
-
if (left?.kind === "Ident") return left;
|
|
1943
|
-
const right = at.rightBiased();
|
|
1944
|
-
return right?.kind === "Ident" ? right : void 0;
|
|
1945
|
-
}
|
|
1946
1941
|
function resolveHoverResult(binder, token) {
|
|
1947
1942
|
const resolution = resolvedNodeAt(token, binder)?.resolution;
|
|
1948
1943
|
switch (resolution?.kind) {
|
|
@@ -2129,6 +2124,14 @@ var ProjectArtifacts = class {
|
|
|
2129
2124
|
return this.#sources;
|
|
2130
2125
|
}
|
|
2131
2126
|
document = (uri) => this.#readDocument(uri);
|
|
2127
|
+
documents = () => {
|
|
2128
|
+
const snapshots = [];
|
|
2129
|
+
for (const uri of this.#inputs.uris()) {
|
|
2130
|
+
const snapshot = this.#readDocument(uri);
|
|
2131
|
+
if (snapshot !== void 0) snapshots.push(snapshot);
|
|
2132
|
+
}
|
|
2133
|
+
return snapshots;
|
|
2134
|
+
};
|
|
2132
2135
|
diagnostics = (uri, projectSymbolDiagnostics) => {
|
|
2133
2136
|
const snapshot = this.#readDocument(uri);
|
|
2134
2137
|
if (snapshot === void 0) return [];
|
|
@@ -2263,11 +2266,7 @@ var ProjectArtifacts = class {
|
|
|
2263
2266
|
return snapshot;
|
|
2264
2267
|
}
|
|
2265
2268
|
#readSymbolTableResult() {
|
|
2266
|
-
const currentDocuments =
|
|
2267
|
-
for (const uri of this.#inputs.uris()) {
|
|
2268
|
-
const snapshot = this.#readDocument(uri);
|
|
2269
|
-
if (snapshot !== void 0) currentDocuments.push(snapshot.parse().document);
|
|
2270
|
-
}
|
|
2269
|
+
const currentDocuments = this.documents().map((snapshot) => snapshot.parse().document);
|
|
2271
2270
|
this.#symbolTableResult ??= buildSymbolTable({
|
|
2272
2271
|
documents: currentDocuments,
|
|
2273
2272
|
sources: this.sources
|
|
@@ -2281,6 +2280,33 @@ var ProjectArtifacts = class {
|
|
|
2281
2280
|
return this.#readBinderResult().diagnostics;
|
|
2282
2281
|
}
|
|
2283
2282
|
};
|
|
2283
|
+
function provideReferences(input) {
|
|
2284
|
+
const token = identTokenAt(input.document.syntax, input.sourceFile.offsetAt(input.position));
|
|
2285
|
+
const resolved = token === void 0 ? void 0 : resolvedNodeAt(token, input.binder);
|
|
2286
|
+
const symbol = resolved === void 0 ? void 0 : pslSymbolOf(resolved.resolution);
|
|
2287
|
+
if (symbol === void 0) return [];
|
|
2288
|
+
const declarationName = symbol.kind === "namespace" ? void 0 : symbol.node.name()?.syntax;
|
|
2289
|
+
const locations = [];
|
|
2290
|
+
for (const { document, sourceFile } of input.documents) for (const offset of occurrencesOf(symbol.name, sourceFile.text)) {
|
|
2291
|
+
const candidate = document.syntax.tokenAtOffset(offset).rightBiased();
|
|
2292
|
+
if (candidate === void 0) continue;
|
|
2293
|
+
const usage = resolvedNodeAt(candidate, input.binder);
|
|
2294
|
+
if (usage === void 0 || pslSymbolOf(usage.resolution) !== symbol) continue;
|
|
2295
|
+
if (!input.includeDeclaration && usage.node === declarationName) continue;
|
|
2296
|
+
locations.push({
|
|
2297
|
+
uri: sourceFile.filename,
|
|
2298
|
+
range: {
|
|
2299
|
+
start: sourceFile.positionAt(candidate.offset),
|
|
2300
|
+
end: sourceFile.positionAt(candidate.endOffset)
|
|
2301
|
+
}
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
2304
|
+
return locations;
|
|
2305
|
+
}
|
|
2306
|
+
function* occurrencesOf(name, text) {
|
|
2307
|
+
if (name.length === 0) return;
|
|
2308
|
+
for (let offset = text.indexOf(name); offset >= 0; offset = text.indexOf(name, offset + name.length)) yield offset;
|
|
2309
|
+
}
|
|
2284
2310
|
const semanticTokenTypes = [
|
|
2285
2311
|
SemanticTokenTypes.keyword,
|
|
2286
2312
|
SemanticTokenTypes.namespace,
|
|
@@ -2727,13 +2753,36 @@ var Project = class {
|
|
|
2727
2753
|
return provideDefinition({
|
|
2728
2754
|
document: document.parse().document,
|
|
2729
2755
|
sourceFile: document.sourceFile,
|
|
2756
|
+
position,
|
|
2730
2757
|
sources: data.artifacts.sources,
|
|
2731
|
-
binder: data.artifacts.binder()
|
|
2732
|
-
|
|
2758
|
+
binder: data.artifacts.binder(),
|
|
2759
|
+
linkSupport
|
|
2760
|
+
});
|
|
2733
2761
|
} catch {
|
|
2734
2762
|
return null;
|
|
2735
2763
|
}
|
|
2736
2764
|
}
|
|
2765
|
+
async references(uri, position, includeDeclaration) {
|
|
2766
|
+
const data = await this.#resolveMember(uri);
|
|
2767
|
+
const document = data?.artifacts.document(uri);
|
|
2768
|
+
if (data === void 0 || document === void 0) return [];
|
|
2769
|
+
try {
|
|
2770
|
+
const documents = data.artifacts.documents().map((snapshot) => ({
|
|
2771
|
+
document: snapshot.parse().document,
|
|
2772
|
+
sourceFile: snapshot.sourceFile
|
|
2773
|
+
}));
|
|
2774
|
+
return provideReferences({
|
|
2775
|
+
document: document.parse().document,
|
|
2776
|
+
sourceFile: document.sourceFile,
|
|
2777
|
+
position,
|
|
2778
|
+
documents,
|
|
2779
|
+
binder: data.artifacts.binder(),
|
|
2780
|
+
includeDeclaration
|
|
2781
|
+
});
|
|
2782
|
+
} catch {
|
|
2783
|
+
return [];
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2737
2786
|
async foldingRanges(uri) {
|
|
2738
2787
|
const data = await this.#resolveMember(uri);
|
|
2739
2788
|
const document = data?.artifacts.document(uri);
|
|
@@ -3158,6 +3207,10 @@ function createServerOn(connection) {
|
|
|
3158
3207
|
if (getOpenDocument(uri) === void 0) return null;
|
|
3159
3208
|
return (await projects.nearestProject(uri))?.definition(uri, position, clientCapabilities.definitionLinks) ?? null;
|
|
3160
3209
|
}
|
|
3210
|
+
async function referencesForDocument(uri, position, includeDeclaration) {
|
|
3211
|
+
if (getOpenDocument(uri) === void 0) return [];
|
|
3212
|
+
return (await projects.nearestProject(uri))?.references(uri, position, includeDeclaration) ?? [];
|
|
3213
|
+
}
|
|
3161
3214
|
connection.onInitialize(async (params) => {
|
|
3162
3215
|
rootPath = resolveRootPath(params);
|
|
3163
3216
|
clientCapabilities = resolveClientCapabilities(params);
|
|
@@ -3186,6 +3239,7 @@ function createServerOn(connection) {
|
|
|
3186
3239
|
signatureHelpProvider: { triggerCharacters: ["(", ","] },
|
|
3187
3240
|
hoverProvider: true,
|
|
3188
3241
|
definitionProvider: true,
|
|
3242
|
+
referencesProvider: true,
|
|
3189
3243
|
...clientCapabilities.pullDiagnostics ? { diagnosticProvider: {
|
|
3190
3244
|
interFileDependencies: true,
|
|
3191
3245
|
workspaceDiagnostics: false
|
|
@@ -3198,6 +3252,7 @@ function createServerOn(connection) {
|
|
|
3198
3252
|
connection.onCompletion((params) => completeDocument(params.textDocument.uri, params.position));
|
|
3199
3253
|
connection.onSignatureHelp((params) => signatureHelpForDocument(params.textDocument.uri, params.position));
|
|
3200
3254
|
connection.onDefinition((params) => definitionForDocument(params.textDocument.uri, params.position));
|
|
3255
|
+
connection.onReferences((params) => referencesForDocument(params.textDocument.uri, params.position, params.context.includeDeclaration));
|
|
3201
3256
|
connection.onHover((params) => hoverForDocument(params.textDocument.uri, params.position));
|
|
3202
3257
|
connection.languages.semanticTokens.on((params) => semanticTokensForDocument(params.textDocument.uri));
|
|
3203
3258
|
connection.languages.semanticTokens.onRange((params) => semanticTokensForDocument(params.textDocument.uri, params.range));
|
|
@@ -3526,4 +3581,4 @@ function startServer(streams) {
|
|
|
3526
3581
|
//#endregion
|
|
3527
3582
|
export { startServer };
|
|
3528
3583
|
|
|
3529
|
-
//# sourceMappingURL=exports-
|
|
3584
|
+
//# sourceMappingURL=exports-B9Yxhu3o.mjs.map
|