@prisma/orm-toolchain 8.0.0-rc.17-dev.3 → 8.0.0-rc.17-dev.5
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 +3 -3
- package/dist/cli__control-api.mjs +1 -1
- package/dist/{exports-Bd3uWDtm.mjs → exports-8j3KNNBj.mjs} +191 -4
- package/dist/exports-8j3KNNBj.mjs.map +1 -0
- package/dist/{import-roots-BeAYfehL.mjs → import-roots-B6vrm5bT.mjs} +2 -2
- package/dist/{import-roots-BeAYfehL.mjs.map → import-roots-B6vrm5bT.mjs.map} +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/{ref-Cc_CTagE-C070Ym7p.mjs → ref-Cc_CTagE-D_HDIWdx.mjs} +2 -2
- package/dist/{ref-Cc_CTagE-C070Ym7p.mjs.map → ref-Cc_CTagE-D_HDIWdx.mjs.map} +1 -1
- package/dist/{shells-D8mbojP8.mjs → shells-DVHHju1S.mjs} +2 -1
- package/dist/{shells-D8mbojP8.mjs.map → shells-DVHHju1S.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/exports-Bd3uWDtm.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -8,9 +8,9 @@ import { r as getEmittedArtifactPaths } from "./exports-DaDckULH-JNQeM6Nn.mjs";
|
|
|
8
8
|
import { r as isInSpaceHistory } from "./graph-membership-C_ZO26nT-B7C4CJsh.mjs";
|
|
9
9
|
import { d as writeRef, r as readRef } from "./refs-qwvw4_dV-DNg_7WTD.mjs";
|
|
10
10
|
import { a as contractHashAtMarker } from "./aggregate-DlfOyErc.mjs";
|
|
11
|
-
import { i as createScaffoldSpecifierResolver } from "./import-roots-
|
|
11
|
+
import { i as createScaffoldSpecifierResolver } from "./import-roots-B6vrm5bT.mjs";
|
|
12
12
|
import { o as isLiveMarkerRef } from "./ref-resolution-Be_zewf7.mjs";
|
|
13
|
-
import { $ as refuseUnknownInvariants, A as executeRefListCommand, B as loadContractSourceWithStack, D as executeMigrationPlanCommand, E as executeMigrationNewCommand, F as listRefsByContractHash, G as migrationSpaceListEntriesFromAggregate, H as looksLikePath, I as liveMarkerUse, J as refuseContractSpaceIntegrity, K as preflightRefAdvancement, L as loadAggregateIntegrityViolations, M as findPackageByDirPath, N as formatSourceDiagnostic, P as hasMigrationPath, Q as refusePackageCorruptionOnAggregate, R as loadContractRawSafely, T as executeMigrateShowPlan, U as mapContractAtError, V as loadContractSpaceAggregateForCli, X as refuseMarkerOutsideGraph, Z as refuseMissingInvariantPath, _t as toDeclaredExtensionsFromRaw, a as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, at as resolveMigrationRef, b as executeContractEmit, c as appliedHashesFromLedger, ct as retryCommandFor, d as buildReadAggregate, dt as runMigrationList, et as requireDatabaseForLiveMarkerUse, f as buildRefAdvancementFields, ft as shellQuoted, g as deriveStatusEdgeAnnotations, gt as statusForMigrationHash, h as createControlClient, ht as statementFlag, i as RECORDED_CONTRACT_REF_FORMS, j as executeRefSetCommand, k as executeRefDeleteCommand, m as computeRefAdvancementName, mt as sourceWarningDiagnostic, n as DB_UPDATE_POLICY, nt as resolveContractRef$1, o as advanceRefSafely, p as checkSingleTarget, pt as snapshotVerifierFor, q as readMigrationRefs, r as NO_REF_ADVANCEMENT, rt as resolveContractRefToSnapshot, t as ALL_CONTRACT_REF_FORMS, tt as resolveAppTargetPath, u as buildMigrationSpaceGraphEntries, ut as runMigrationCheck, vt as validateLoadedContract, y as enumerateCheckSpaces, z as loadContractSource } from "./ref-Cc_CTagE-
|
|
13
|
+
import { $ as refuseUnknownInvariants, A as executeRefListCommand, B as loadContractSourceWithStack, D as executeMigrationPlanCommand, E as executeMigrationNewCommand, F as listRefsByContractHash, G as migrationSpaceListEntriesFromAggregate, H as looksLikePath, I as liveMarkerUse, J as refuseContractSpaceIntegrity, K as preflightRefAdvancement, L as loadAggregateIntegrityViolations, M as findPackageByDirPath, N as formatSourceDiagnostic, P as hasMigrationPath, Q as refusePackageCorruptionOnAggregate, R as loadContractRawSafely, T as executeMigrateShowPlan, U as mapContractAtError, V as loadContractSpaceAggregateForCli, X as refuseMarkerOutsideGraph, Z as refuseMissingInvariantPath, _t as toDeclaredExtensionsFromRaw, a as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, at as resolveMigrationRef, b as executeContractEmit, c as appliedHashesFromLedger, ct as retryCommandFor, d as buildReadAggregate, dt as runMigrationList, et as requireDatabaseForLiveMarkerUse, f as buildRefAdvancementFields, ft as shellQuoted, g as deriveStatusEdgeAnnotations, gt as statusForMigrationHash, h as createControlClient, ht as statementFlag, i as RECORDED_CONTRACT_REF_FORMS, j as executeRefSetCommand, k as executeRefDeleteCommand, m as computeRefAdvancementName, mt as sourceWarningDiagnostic, n as DB_UPDATE_POLICY, nt as resolveContractRef$1, o as advanceRefSafely, p as checkSingleTarget, pt as snapshotVerifierFor, q as readMigrationRefs, r as NO_REF_ADVANCEMENT, rt as resolveContractRefToSnapshot, t as ALL_CONTRACT_REF_FORMS, tt as resolveAppTargetPath, u as buildMigrationSpaceGraphEntries, ut as runMigrationCheck, vt as validateLoadedContract, y as enumerateCheckSpaces, z as loadContractSource } from "./ref-Cc_CTagE-D_HDIWdx.mjs";
|
|
14
14
|
import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
|
|
15
15
|
import { createRequire } from "node:module";
|
|
16
16
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -6944,7 +6944,7 @@ const lspCommand = defineServerCommand({
|
|
|
6944
6944
|
} },
|
|
6945
6945
|
handler: async (args, io) => {
|
|
6946
6946
|
const exitCode = await withoutClientProcessIdInArgv(async () => {
|
|
6947
|
-
const { startServer } = await import("./exports-
|
|
6947
|
+
const { startServer } = await import("./exports-8j3KNNBj.mjs");
|
|
6948
6948
|
return startServer({
|
|
6949
6949
|
stdin: io.stdin,
|
|
6950
6950
|
stdout: io.stdout,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { g as errorFromCaught } from "./caught-errors-HFQjjQVE-b_GDV-6J.mjs";
|
|
2
|
-
import { $ as refuseUnknownInvariants, A as executeRefListCommand, C as executeDbUpdate, D as executeMigrationPlanCommand, E as executeMigrationNewCommand, F as listRefsByContractHash, G as migrationSpaceListEntriesFromAggregate, J as refuseContractSpaceIntegrity, K as preflightRefAdvancement, L as loadAggregateIntegrityViolations, O as executeRefAdvancement, P as hasMigrationPath, Q as refusePackageCorruptionOnAggregate, R as loadContractRawSafely, S as executeDbSign, T as executeMigrateShowPlan, U as mapContractAtError, V as loadContractSpaceAggregateForCli, W as mapIntegrityViolations, X as refuseMarkerOutsideGraph, Y as refuseDeclaredExtensionTargetMismatch, Z as refuseMissingInvariantPath, _ as disposeEmitQueue, at as resolveMigrationRef, b as executeContractEmit, c as appliedHashesFromLedger, d as buildReadAggregate, dt as runMigrationList, f as buildRefAdvancementFields, g as deriveStatusEdgeAnnotations, gt as statusForMigrationHash, h as createControlClient, it as resolveFromForPlan, j as executeRefSetCommand, k as executeRefDeleteCommand, l as buildContractSpaceAggregate, lt as runContractSpaceSeedPhase, m as computeRefAdvancementName, nt as resolveContractRef$1, o as advanceRefSafely, ot as resolveStatements, p as checkSingleTarget, q as readMigrationRefs, r as NO_REF_ADVANCEMENT, rt as resolveContractRefToSnapshot, s as appContractStandInFromIdentity, st as resolveToForPlan, u as buildMigrationSpaceGraphEntries, ut as runMigrationCheck, v as enrichContract, w as executeDbVerify, x as executeDbInit, y as enumerateCheckSpaces, z as loadContractSource } from "./ref-Cc_CTagE-
|
|
2
|
+
import { $ as refuseUnknownInvariants, A as executeRefListCommand, C as executeDbUpdate, D as executeMigrationPlanCommand, E as executeMigrationNewCommand, F as listRefsByContractHash, G as migrationSpaceListEntriesFromAggregate, J as refuseContractSpaceIntegrity, K as preflightRefAdvancement, L as loadAggregateIntegrityViolations, O as executeRefAdvancement, P as hasMigrationPath, Q as refusePackageCorruptionOnAggregate, R as loadContractRawSafely, S as executeDbSign, T as executeMigrateShowPlan, U as mapContractAtError, V as loadContractSpaceAggregateForCli, W as mapIntegrityViolations, X as refuseMarkerOutsideGraph, Y as refuseDeclaredExtensionTargetMismatch, Z as refuseMissingInvariantPath, _ as disposeEmitQueue, at as resolveMigrationRef, b as executeContractEmit, c as appliedHashesFromLedger, d as buildReadAggregate, dt as runMigrationList, f as buildRefAdvancementFields, g as deriveStatusEdgeAnnotations, gt as statusForMigrationHash, h as createControlClient, it as resolveFromForPlan, j as executeRefSetCommand, k as executeRefDeleteCommand, l as buildContractSpaceAggregate, lt as runContractSpaceSeedPhase, m as computeRefAdvancementName, nt as resolveContractRef$1, o as advanceRefSafely, ot as resolveStatements, p as checkSingleTarget, q as readMigrationRefs, r as NO_REF_ADVANCEMENT, rt as resolveContractRefToSnapshot, s as appContractStandInFromIdentity, st as resolveToForPlan, u as buildMigrationSpaceGraphEntries, ut as runMigrationCheck, v as enrichContract, w as executeDbVerify, x as executeDbInit, y as enumerateCheckSpaces, z as loadContractSource } from "./ref-Cc_CTagE-D_HDIWdx.mjs";
|
|
3
3
|
export { NO_REF_ADVANCEMENT, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, errorFromCaught, executeContractEmit, executeDbInit, executeDbSign, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMarkerOutsideGraph, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef$1 as resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveStatements, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
|
|
@@ -8,11 +8,11 @@ import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
|
8
8
|
import { readFileSync, statSync } from "node:fs";
|
|
9
9
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
10
|
import { normalize as normalize$1 } from "node:path";
|
|
11
|
-
import { format } from "@prisma/orm-framework/psl-parser/format";
|
|
12
|
-
import { EMPTY_DATA_TYPES, assembleAttributeSpecs, blockSpecFactoryOf, buildSymbolTable, createBinder, entityReference, findBlockDescriptor, isNamespaceLike, isPrismaNextSchema, matchesSelector, memberEntries, renameLegacyDirective, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
|
|
11
|
+
import { format, resolveFormatOptions } from "@prisma/orm-framework/psl-parser/format";
|
|
12
|
+
import { EMPTY_DATA_TYPES, assembleAttributeSpecs, blockSpecFactoryOf, buildSymbolTable, createBinder, entityReference, findBlockDescriptor, isNamespaceLike, isPrismaNextSchema, isPslIdentifier, matchesSelector, memberEntries, renameLegacyDirective, typeReferenceNode } from "@prisma/orm-framework/psl-parser";
|
|
13
13
|
import { CompletionItemKind, CompletionItemTag, ConnectionError, ConnectionErrors, DiagnosticSeverity, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FoldingRangeKind, InsertTextFormat, LSPErrorCodes, MarkupKind, ProposedFeatures, RegistrationRequest, ResponseError, SemanticTokenModifiers, SemanticTokenTypes, TextDocumentSyncKind, createConnection } from "vscode-languageserver";
|
|
14
14
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
15
|
-
import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, PathExprAst, PslSources, StringLiteralExprAst, SyntaxNode, TaggedLiteralExprAst, TypesBlockAst, any, isTrivia, nonTriviaSibling, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
|
|
15
|
+
import { ArrayLiteralAst, AttributeArgAst, AttributeArgListAst, BooleanLiteralExprAst, CompositeTypeDeclarationAst, FieldAttributeAst, FieldDeclarationAst, FunctionCallAst, GenericBlockDeclarationAst, IdentifierAst, KeyValuePairAst, ModelAttributeAst, ModelDeclarationAst, NamespaceDeclarationAst, NumberLiteralExprAst, ObjectLiteralExprAst, PathExprAst, PslSources, StringLiteralExprAst, SyntaxNode, SyntaxToken, TaggedLiteralExprAst, TypesBlockAst, any, isTrivia, nonTriviaSibling, parse, skipTriviaToken } from "@prisma/orm-framework/psl-parser/syntax";
|
|
16
16
|
import { hasPslInterpreter } from "@prisma/orm-framework/psl-parser/interpret";
|
|
17
17
|
import { isAuthoringPslBlockDescriptor } from "@prisma/orm-framework/components/authoring";
|
|
18
18
|
import { ProposedFeatures as ProposedFeatures$1, StreamMessageReader, StreamMessageWriter, createConnection as createConnection$1, createProtocolConnection } from "vscode-languageserver/node";
|
|
@@ -2306,6 +2306,135 @@ function* occurrencesOf(name, text) {
|
|
|
2306
2306
|
if (name.length === 0) return;
|
|
2307
2307
|
for (let offset = text.indexOf(name); offset >= 0; offset = text.indexOf(name, offset + name.length)) yield offset;
|
|
2308
2308
|
}
|
|
2309
|
+
function providePrepareRename(input) {
|
|
2310
|
+
const { sourceFile } = input;
|
|
2311
|
+
const token = identTokenAt(input.document.syntax, sourceFile.offsetAt(input.position));
|
|
2312
|
+
if (token === void 0) return null;
|
|
2313
|
+
if (provideReferences({
|
|
2314
|
+
...input,
|
|
2315
|
+
includeDeclaration: true
|
|
2316
|
+
}).length === 0) return null;
|
|
2317
|
+
return {
|
|
2318
|
+
range: {
|
|
2319
|
+
start: sourceFile.positionAt(token.offset),
|
|
2320
|
+
end: sourceFile.positionAt(token.endOffset)
|
|
2321
|
+
},
|
|
2322
|
+
placeholder: token.text
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
function provideRename(input) {
|
|
2326
|
+
const { newName } = input;
|
|
2327
|
+
if (!isPslIdentifier(newName)) throw new ResponseError(LSPErrorCodes.RequestFailed, `"${newName}" is not a valid PSL identifier`);
|
|
2328
|
+
const locations = provideReferences({
|
|
2329
|
+
...input,
|
|
2330
|
+
includeDeclaration: true
|
|
2331
|
+
});
|
|
2332
|
+
if (locations.length === 0) return null;
|
|
2333
|
+
const changes = {};
|
|
2334
|
+
const editsOf = (uri) => {
|
|
2335
|
+
const edits = changes[uri] ?? [];
|
|
2336
|
+
changes[uri] = edits;
|
|
2337
|
+
return edits;
|
|
2338
|
+
};
|
|
2339
|
+
for (const { uri, range } of locations) editsOf(uri).push({
|
|
2340
|
+
range,
|
|
2341
|
+
newText: newName
|
|
2342
|
+
});
|
|
2343
|
+
const insertion = mapAttributeEdit(input);
|
|
2344
|
+
if (insertion !== void 0) editsOf(insertion.uri).push(insertion.edit);
|
|
2345
|
+
return { changes };
|
|
2346
|
+
}
|
|
2347
|
+
function mapAttributeEdit(input) {
|
|
2348
|
+
const symbol = renamedSymbol(input);
|
|
2349
|
+
if (symbol === void 0 || symbol.name === input.newName) return void 0;
|
|
2350
|
+
switch (symbol.kind) {
|
|
2351
|
+
case "model": return modelTakesMap(symbol, input) ? blockMapEdit(symbol, input) : void 0;
|
|
2352
|
+
case "field": return fieldTakesMap(symbol, input) ? fieldMapEdit(symbol, input) : void 0;
|
|
2353
|
+
case "block": return blockTakesMap(symbol, input) ? blockMapEdit(symbol, input) : void 0;
|
|
2354
|
+
case "compositeType":
|
|
2355
|
+
case "namedType":
|
|
2356
|
+
case "namespace": return;
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
function renamedSymbol(input) {
|
|
2360
|
+
const token = identTokenAt(input.document.syntax, input.sourceFile.offsetAt(input.position));
|
|
2361
|
+
const resolved = token === void 0 ? void 0 : resolvedNodeAt(token, input.binder);
|
|
2362
|
+
return resolved === void 0 ? void 0 : pslSymbolOf(resolved.resolution);
|
|
2363
|
+
}
|
|
2364
|
+
function modelTakesMap(model, source) {
|
|
2365
|
+
if (hasAttribute(model.node.attributes(), "map")) return false;
|
|
2366
|
+
if (hasAttribute(model.node.attributes(), "base")) return false;
|
|
2367
|
+
return attributeSpecResolver({
|
|
2368
|
+
ownerKind: "model",
|
|
2369
|
+
model: model.node
|
|
2370
|
+
}, source)("map") !== void 0;
|
|
2371
|
+
}
|
|
2372
|
+
function fieldTakesMap(field, source) {
|
|
2373
|
+
const owner = field.node.syntax.parent;
|
|
2374
|
+
const model = owner === void 0 ? void 0 : ModelDeclarationAst.cast(owner);
|
|
2375
|
+
if (model === void 0) return false;
|
|
2376
|
+
if (hasAttribute(field.node.attributes(), "map")) return false;
|
|
2377
|
+
const type = typeReferenceNode(field);
|
|
2378
|
+
const typeKind = type === void 0 ? void 0 : source.binder.symbolForNode(type)?.kind;
|
|
2379
|
+
if (typeKind === "model" || typeKind === "crossSpace") return false;
|
|
2380
|
+
return attributeSpecResolver({
|
|
2381
|
+
ownerKind: "field",
|
|
2382
|
+
field: field.node,
|
|
2383
|
+
model
|
|
2384
|
+
}, source)("map") !== void 0;
|
|
2385
|
+
}
|
|
2386
|
+
function blockTakesMap(block, source) {
|
|
2387
|
+
if (hasAttribute(block.node.attributes(), "map")) return false;
|
|
2388
|
+
return findBlockDescriptor(source.pslBlockDescriptors, block.keyword)?.nameIsStorageName === true;
|
|
2389
|
+
}
|
|
2390
|
+
function hasAttribute(attributes, name) {
|
|
2391
|
+
for (const attribute of attributes) if (attribute.name()?.isSimpleName(name) === true) return true;
|
|
2392
|
+
return false;
|
|
2393
|
+
}
|
|
2394
|
+
function fieldMapEdit(field, input) {
|
|
2395
|
+
const sourceFile = sourceFileOf(field.node, input);
|
|
2396
|
+
if (sourceFile === void 0) return void 0;
|
|
2397
|
+
const end = sourceFile.positionAt(field.node.syntax.endOffset);
|
|
2398
|
+
return {
|
|
2399
|
+
uri: sourceFile.filename,
|
|
2400
|
+
edit: {
|
|
2401
|
+
range: {
|
|
2402
|
+
start: end,
|
|
2403
|
+
end
|
|
2404
|
+
},
|
|
2405
|
+
newText: ` @map("${field.name}")`
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
function blockMapEdit(symbol, input) {
|
|
2410
|
+
const sourceFile = sourceFileOf(symbol.node, input);
|
|
2411
|
+
const rbrace = symbol.node.rbrace();
|
|
2412
|
+
if (sourceFile === void 0 || rbrace === void 0) return void 0;
|
|
2413
|
+
const { indentUnit, newline } = input.formatOptions;
|
|
2414
|
+
const indent = indentUnit.repeat(enclosingBlockCount(symbol.node.syntax) + 1);
|
|
2415
|
+
const before = rbrace.prevSiblingOrToken;
|
|
2416
|
+
const anchor = before instanceof SyntaxToken && before.kind === "Whitespace" ? before : rbrace;
|
|
2417
|
+
const at = sourceFile.positionAt(anchor.offset);
|
|
2418
|
+
return {
|
|
2419
|
+
uri: sourceFile.filename,
|
|
2420
|
+
edit: {
|
|
2421
|
+
range: {
|
|
2422
|
+
start: at,
|
|
2423
|
+
end: at
|
|
2424
|
+
},
|
|
2425
|
+
newText: `${newline}${indent}@@map("${symbol.name}")${newline}`
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function enclosingBlockCount(node) {
|
|
2430
|
+
let count = 0;
|
|
2431
|
+
for (let parent = node.parent; parent?.parent !== void 0; parent = parent.parent) count++;
|
|
2432
|
+
return count;
|
|
2433
|
+
}
|
|
2434
|
+
function sourceFileOf(node, input) {
|
|
2435
|
+
const root = node.syntax.root();
|
|
2436
|
+
return input.documents.find(({ document }) => document.syntax === root)?.sourceFile;
|
|
2437
|
+
}
|
|
2309
2438
|
const semanticTokenTypes = [
|
|
2310
2439
|
SemanticTokenTypes.keyword,
|
|
2311
2440
|
SemanticTokenTypes.namespace,
|
|
@@ -2782,6 +2911,51 @@ var Project = class {
|
|
|
2782
2911
|
return [];
|
|
2783
2912
|
}
|
|
2784
2913
|
}
|
|
2914
|
+
async prepareRename(uri, position) {
|
|
2915
|
+
const data = await this.#resolveMember(uri);
|
|
2916
|
+
const document = data?.artifacts.document(uri);
|
|
2917
|
+
if (data === void 0 || document === void 0) return null;
|
|
2918
|
+
try {
|
|
2919
|
+
const documents = data.artifacts.documents().map((snapshot) => ({
|
|
2920
|
+
document: snapshot.parse().document,
|
|
2921
|
+
sourceFile: snapshot.sourceFile
|
|
2922
|
+
}));
|
|
2923
|
+
return providePrepareRename({
|
|
2924
|
+
document: document.parse().document,
|
|
2925
|
+
sourceFile: document.sourceFile,
|
|
2926
|
+
position,
|
|
2927
|
+
documents,
|
|
2928
|
+
binder: data.artifacts.binder()
|
|
2929
|
+
});
|
|
2930
|
+
} catch {
|
|
2931
|
+
return null;
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
async rename(uri, position, newName) {
|
|
2935
|
+
const data = await this.#resolveMember(uri);
|
|
2936
|
+
const document = data?.artifacts.document(uri);
|
|
2937
|
+
if (data === void 0 || document === void 0) return null;
|
|
2938
|
+
try {
|
|
2939
|
+
const documents = data.artifacts.documents().map((snapshot) => ({
|
|
2940
|
+
document: snapshot.parse().document,
|
|
2941
|
+
sourceFile: snapshot.sourceFile
|
|
2942
|
+
}));
|
|
2943
|
+
return provideRename({
|
|
2944
|
+
document: document.parse().document,
|
|
2945
|
+
sourceFile: document.sourceFile,
|
|
2946
|
+
position,
|
|
2947
|
+
documents,
|
|
2948
|
+
binder: data.artifacts.binder(),
|
|
2949
|
+
...data.controlStack,
|
|
2950
|
+
symbolTable: data.artifacts.symbolTable(),
|
|
2951
|
+
formatOptions: resolveFormatOptions(data.formatter),
|
|
2952
|
+
newName
|
|
2953
|
+
});
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
if (error instanceof ResponseError && error.code === LSPErrorCodes.RequestFailed) throw error;
|
|
2956
|
+
return null;
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2785
2959
|
async foldingRanges(uri) {
|
|
2786
2960
|
const data = await this.#resolveMember(uri);
|
|
2787
2961
|
const document = data?.artifacts.document(uri);
|
|
@@ -3210,6 +3384,14 @@ function createServerOn(connection) {
|
|
|
3210
3384
|
if (getOpenDocument(uri) === void 0) return [];
|
|
3211
3385
|
return (await projects.nearestProject(uri))?.references(uri, position, includeDeclaration) ?? [];
|
|
3212
3386
|
}
|
|
3387
|
+
async function prepareRenameForDocument(uri, position) {
|
|
3388
|
+
if (getOpenDocument(uri) === void 0) return null;
|
|
3389
|
+
return (await projects.nearestProject(uri))?.prepareRename(uri, position) ?? null;
|
|
3390
|
+
}
|
|
3391
|
+
async function renameForDocument(uri, position, newName) {
|
|
3392
|
+
if (getOpenDocument(uri) === void 0) return null;
|
|
3393
|
+
return (await projects.nearestProject(uri))?.rename(uri, position, newName) ?? null;
|
|
3394
|
+
}
|
|
3213
3395
|
connection.onInitialize(async (params) => {
|
|
3214
3396
|
rootPath = resolveRootPath(params);
|
|
3215
3397
|
clientCapabilities = resolveClientCapabilities(params);
|
|
@@ -3239,6 +3421,7 @@ function createServerOn(connection) {
|
|
|
3239
3421
|
hoverProvider: true,
|
|
3240
3422
|
definitionProvider: true,
|
|
3241
3423
|
referencesProvider: true,
|
|
3424
|
+
renameProvider: clientCapabilities.renamePrepareSupport ? { prepareProvider: true } : true,
|
|
3242
3425
|
...clientCapabilities.pullDiagnostics ? { diagnosticProvider: {
|
|
3243
3426
|
interFileDependencies: true,
|
|
3244
3427
|
workspaceDiagnostics: false
|
|
@@ -3252,6 +3435,8 @@ function createServerOn(connection) {
|
|
|
3252
3435
|
connection.onSignatureHelp((params) => signatureHelpForDocument(params.textDocument.uri, params.position));
|
|
3253
3436
|
connection.onDefinition((params) => definitionForDocument(params.textDocument.uri, params.position));
|
|
3254
3437
|
connection.onReferences((params) => referencesForDocument(params.textDocument.uri, params.position, params.context.includeDeclaration));
|
|
3438
|
+
connection.onPrepareRename((params) => prepareRenameForDocument(params.textDocument.uri, params.position));
|
|
3439
|
+
connection.onRenameRequest((params) => renameForDocument(params.textDocument.uri, params.position, params.newName));
|
|
3255
3440
|
connection.onHover((params) => hoverForDocument(params.textDocument.uri, params.position));
|
|
3256
3441
|
connection.languages.semanticTokens.on((params) => semanticTokensForDocument(params.textDocument.uri));
|
|
3257
3442
|
connection.languages.semanticTokens.onRange((params) => semanticTokensForDocument(params.textDocument.uri, params.range));
|
|
@@ -3306,6 +3491,7 @@ const noClientCapabilities = {
|
|
|
3306
3491
|
completionSnippets: false,
|
|
3307
3492
|
signatureLabelOffsets: false,
|
|
3308
3493
|
definitionLinks: false,
|
|
3494
|
+
renamePrepareSupport: false,
|
|
3309
3495
|
completionTriggerSuggestCommand: false,
|
|
3310
3496
|
completionTriggerParameterHintsCommand: false,
|
|
3311
3497
|
pullDiagnostics: false,
|
|
@@ -3317,6 +3503,7 @@ function resolveClientCapabilities(params) {
|
|
|
3317
3503
|
completionSnippets: params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true,
|
|
3318
3504
|
signatureLabelOffsets: params.capabilities.textDocument?.signatureHelp?.signatureInformation?.parameterInformation?.labelOffsetSupport === true,
|
|
3319
3505
|
definitionLinks: params.capabilities.textDocument?.definition?.linkSupport === true,
|
|
3506
|
+
renamePrepareSupport: params.capabilities.textDocument?.rename?.prepareSupport === true,
|
|
3320
3507
|
completionTriggerSuggestCommand: supportsCompletionCommand(params.initializationOptions, "supportsTriggerSuggestCommand"),
|
|
3321
3508
|
completionTriggerParameterHintsCommand: supportsCompletionCommand(params.initializationOptions, "supportsTriggerParameterHintsCommand"),
|
|
3322
3509
|
pullDiagnostics: params.capabilities.textDocument?.diagnostic?.relatedDocumentSupport === true,
|
|
@@ -3580,4 +3767,4 @@ function startServer(streams) {
|
|
|
3580
3767
|
//#endregion
|
|
3581
3768
|
export { startServer };
|
|
3582
3769
|
|
|
3583
|
-
//# sourceMappingURL=exports-
|
|
3770
|
+
//# sourceMappingURL=exports-8j3KNNBj.mjs.map
|