@dbml/core 8.0.0-alpha.0 → 8.0.0-alpha.11
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/lib/index.cjs +106 -110
- package/lib/index.mjs +515 -350
- package/package.json +3 -3
package/lib/index.mjs
CHANGED
|
@@ -2229,6 +2229,10 @@ function baseUniq(_, VY, P) {
|
|
|
2229
2229
|
return KY;
|
|
2230
2230
|
}
|
|
2231
2231
|
var _baseUniq_default = baseUniq;
|
|
2232
|
+
function uniq(_) {
|
|
2233
|
+
return _ && _.length ? _baseUniq_default(_) : [];
|
|
2234
|
+
}
|
|
2235
|
+
var uniq_default = uniq;
|
|
2232
2236
|
function uniqBy(_, VY) {
|
|
2233
2237
|
return _ && _.length ? _baseUniq_default(_, _baseIteratee_default(VY, 2)) : [];
|
|
2234
2238
|
}
|
|
@@ -2475,13 +2479,13 @@ var isAbsolute = function(_) {
|
|
|
2475
2479
|
function resolveImportFilepath(_, VY) {
|
|
2476
2480
|
if (!Filepath.isRelative(VY)) return;
|
|
2477
2481
|
let P = Filepath.resolve(_.dirname, VY);
|
|
2478
|
-
return P.absolute.endsWith(".dbml") ? P : Filepath.from(P.absolute +
|
|
2482
|
+
return P.absolute.endsWith(".dbml") ? P : Filepath.from(P.absolute + ".dbml");
|
|
2479
2483
|
}
|
|
2480
2484
|
var KEYWORDS_OF_DEFAULT_SETTING = [
|
|
2481
2485
|
"null",
|
|
2482
2486
|
"true",
|
|
2483
2487
|
"false"
|
|
2484
|
-
],
|
|
2488
|
+
], NUMERIC_LITERAL_PREFIX = ["-", "+"], DEFAULT_SCHEMA_NAME$1 = "public", DEFAULT_ENTRY = Filepath.from("/main.dbml"), CompileErrorCode = /* @__PURE__ */ function(_) {
|
|
2485
2489
|
return _[_.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", _[_.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", _[_.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", _[_.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", _[_.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", _[_.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", _[_.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", _[_.MISSING_SPACES = 1007] = "MISSING_SPACES", _[_.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", _[_.INVALID_OPERAND = 1009] = "INVALID_OPERAND", _[_.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", _[_.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", _[_.INVALID_NAME = 3e3] = "INVALID_NAME", _[_.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", _[_.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", _[_.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", _[_.INVALID_ALIAS = 3004] = "INVALID_ALIAS", _[_.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", _[_.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", _[_.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", _[_.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", _[_.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", _[_.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", _[_.UNKNOWN_TABLE_SETTING = 3011] = "UNKNOWN_TABLE_SETTING", _[_.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", _[_.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", _[_.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", _[_.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", _[_.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", _[_.EMPTY_TABLE = 3018] = "EMPTY_TABLE", _[_.INVALID_COLUMN = 3019] = "INVALID_COLUMN", _[_.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", _[_.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", _[_.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", _[_.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", _[_.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", _[_.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", _[_.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", _[_.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", _[_.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", _[_.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", _[_.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", _[_.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", _[_.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", _[_.EMPTY_ENUM = 3033] = "EMPTY_ENUM", _[_.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", _[_.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", _[_.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", _[_.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", _[_.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", _[_.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", _[_.EMPTY_REF = 3040] = "EMPTY_REF", _[_.REF_REDEFINED = 3041] = "REF_REDEFINED", _[_.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", _[_.INVALID_NOTE = 3043] = "INVALID_NOTE", _[_.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", _[_.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", _[_.EMPTY_NOTE = 3046] = "EMPTY_NOTE", _[_.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", _[_.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", _[_.INVALID_INDEX = 3049] = "INVALID_INDEX", _[_.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", _[_.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", _[_.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", _[_.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", _[_.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", _[_.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", _[_.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", _[_.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", _[_.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", _[_.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", _[_.INVALID_TABLE_PARTIAL_CONTEXT = 3060] = "INVALID_TABLE_PARTIAL_CONTEXT", _[_.INVALID_TABLE_PARTIAL_ELEMENT_NAME = 3061] = "INVALID_TABLE_PARTIAL_ELEMENT_NAME", _[_.INVALID_TABLE_PARTIAL_SETTING_VALUE = 3062] = "INVALID_TABLE_PARTIAL_SETTING_VALUE", _[_.DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME = 3063] = "DUPLICATE_TABLE_PARTIAL_ELEMENT_NAME", _[_.DUPLICATE_TABLE_PARTIAL_SETTING = 3064] = "DUPLICATE_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_PARTIAL_INJECTION = 3065] = "INVALID_TABLE_PARTIAL_INJECTION", _[_.INVALID_TABLE_PARTIAL_INJECTION_OP = 3066] = "INVALID_TABLE_PARTIAL_INJECTION_OP", _[_.INVALID_TABLE_PARTIAL_INJECTION_NAME = 3067] = "INVALID_TABLE_PARTIAL_INJECTION_NAME", _[_.DUPLICATE_TABLE_PARTIAL_INJECTION_NAME = 3068] = "DUPLICATE_TABLE_PARTIAL_INJECTION_NAME", _[_.UNKNOWN_TABLE_PARTIAL_SETTING = 3069] = "UNKNOWN_TABLE_PARTIAL_SETTING", _[_.INVALID_TABLE_SETTING_VALUE = 3070] = "INVALID_TABLE_SETTING_VALUE", _[_.INVALID_CHECKS_CONTEXT = 3071] = "INVALID_CHECKS_CONTEXT", _[_.INVALID_CHECKS_FIELD = 3072] = "INVALID_CHECKS_FIELD", _[_.INVALID_CHECK = 3073] = "INVALID_CHECK", _[_.UNKNOWN_CHECK_SETTING = 3074] = "UNKNOWN_CHECK_SETTING", _[_.DUPLICATE_CHECK_SETTING = 3075] = "DUPLICATE_CHECK_SETTING", _[_.INVALID_CHECK_SETTING_VALUE = 3076] = "INVALID_CHECK_SETTING_VALUE", _[_.INVALID_RECORDS_CONTEXT = 3077] = "INVALID_RECORDS_CONTEXT", _[_.INVALID_RECORDS_NAME = 3078] = "INVALID_RECORDS_NAME", _[_.INVALID_RECORDS_FIELD = 3079] = "INVALID_RECORDS_FIELD", _[_.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS = 3080] = "DUPLICATE_COLUMN_REFERENCES_IN_RECORDS", _[_.DUPLICATE_RECORDS_FOR_TABLE = 3081] = "DUPLICATE_RECORDS_FOR_TABLE", _[_.INVALID_USE_CONTEXT = 3082] = "INVALID_USE_CONTEXT", _[_.INVALID_USE_SPECIFIER_KIND = 3083] = "INVALID_USE_SPECIFIER_KIND", _[_.INVALID_USE_SPECIFIER_NAME = 3084] = "INVALID_USE_SPECIFIER_NAME", _[_.INVALID_DIAGRAMVIEW_CONTEXT = 3085] = "INVALID_DIAGRAMVIEW_CONTEXT", _[_.DUPLICATE_DIAGRAMVIEW_NAME = 3086] = "DUPLICATE_DIAGRAMVIEW_NAME", _[_.INVALID_DIAGRAMVIEW_FIELD = 3087] = "INVALID_DIAGRAMVIEW_FIELD", _[_.DUPLICATE_DIAGRAMVIEW_FIELD = 3088] = "DUPLICATE_DIAGRAMVIEW_FIELD", _[_.BINDING_ERROR = 4e3] = "BINDING_ERROR", _[_.NONEXISTENT_MODULE = 4001] = "NONEXISTENT_MODULE", _[_.UNSUPPORTED = 5e3] = "UNSUPPORTED", _[_.CIRCULAR_REF = 5001] = "CIRCULAR_REF", _[_.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", _[_.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", _[_.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", _[_.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", _;
|
|
2486
2490
|
}({}), CompileError = class _ extends Error {
|
|
2487
2491
|
constructor(VY, P, HY) {
|
|
@@ -2526,6 +2530,9 @@ function isValidAlias(_) {
|
|
|
2526
2530
|
function isSimpleName(_) {
|
|
2527
2531
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof VariableNode;
|
|
2528
2532
|
}
|
|
2533
|
+
function hasSimpleBody(_) {
|
|
2534
|
+
return !!_.bodyColon;
|
|
2535
|
+
}
|
|
2529
2536
|
function isValidPartialInjection(_) {
|
|
2530
2537
|
return _ instanceof PrefixExpressionNode && _.op?.value === "~" && isExpressionAVariableNode(_.expression);
|
|
2531
2538
|
}
|
|
@@ -2720,7 +2727,7 @@ function destructureIndexNode(_) {
|
|
|
2720
2727
|
};
|
|
2721
2728
|
}
|
|
2722
2729
|
function extractQuotedStringToken(_) {
|
|
2723
|
-
if (isExpressionAQuotedString(_)) return _
|
|
2730
|
+
if (isExpressionAQuotedString(_)) return _.expression instanceof VariableNode ? _?.expression?.variable?.value : _.expression.literal.value;
|
|
2724
2731
|
}
|
|
2725
2732
|
function extractNumericLiteral(_) {
|
|
2726
2733
|
return _ instanceof PrimaryExpressionNode && _.expression instanceof LiteralNode && _.expression.literal?.kind === SyntaxTokenKind.NUMERIC_LITERAL ? Number(_.expression.literal.value) : null;
|
|
@@ -4007,7 +4014,9 @@ var DiagramViewBinder = class {
|
|
|
4007
4014
|
let [VY] = partition_default(_.body, (_) => _ instanceof FunctionApplicationNode);
|
|
4008
4015
|
return VY.flatMap((_) => !_.callee || isWildcardExpression(_.callee) ? [] : [_.callee, ..._.args].flatMap(scanNonListNodeForBinding).flatMap((_) => {
|
|
4009
4016
|
let VY = _.variables.pop();
|
|
4010
|
-
|
|
4017
|
+
if (!VY) return [];
|
|
4018
|
+
let P = _.variables.pop();
|
|
4019
|
+
return [...P ? this.compiler.nodeReferee(P).getErrors() : [], ...this.compiler.nodeReferee(VY).getErrors()];
|
|
4011
4020
|
}));
|
|
4012
4021
|
}
|
|
4013
4022
|
bindNoteReferences(_) {
|
|
@@ -4452,7 +4461,7 @@ var EnumBinder = class {
|
|
|
4452
4461
|
let WY = isExpressionAVariableNode(VY) ? VY.expression.variable?.value ?? "" : "", GY = _.lookupMembers(UY, SymbolKind.Column, WY);
|
|
4453
4462
|
if (GY) return Report.create(GY);
|
|
4454
4463
|
let KY = isElementNode(HY, ElementKind.TablePartial) ? "TablePartial" : "Table";
|
|
4455
|
-
return new Report(void 0, [new CompileError(CompileErrorCode.
|
|
4464
|
+
return new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${WY}' does not exist in ${KY} 'public.${UY.name}'`, VY)]);
|
|
4456
4465
|
},
|
|
4457
4466
|
bindNode(_, VY) {
|
|
4458
4467
|
return isElementNode(VY, ElementKind.Indexes) ? Report.create(void 0, new IndexesBinder(_, VY).bind()) : Report.create(PASS_THROUGH);
|
|
@@ -8553,11 +8562,18 @@ var ProgramInterpreter = class {
|
|
|
8553
8562
|
let HY = P.getValue();
|
|
8554
8563
|
HY && this.pushElement(VY, HY);
|
|
8555
8564
|
}
|
|
8556
|
-
let _ = this.compiler.symbolMembers(this.programSymbol).getFiltered(UNHANDLED) ?? [];
|
|
8557
|
-
for (
|
|
8558
|
-
|
|
8559
|
-
let
|
|
8560
|
-
|
|
8565
|
+
let _ = /* @__PURE__ */ new Set(), VY = (this.compiler.symbolMembers(this.programSymbol).getFiltered(UNHANDLED) ?? []).filter((_) => _ instanceof SchemaSymbol);
|
|
8566
|
+
for (; VY.length > 0;) {
|
|
8567
|
+
let P = VY.shift(), HY = this.compiler.symbolMembers(P).getFiltered(UNHANDLED) ?? [];
|
|
8568
|
+
for (let P of HY) {
|
|
8569
|
+
if (P instanceof SchemaSymbol) {
|
|
8570
|
+
VY.push(P);
|
|
8571
|
+
continue;
|
|
8572
|
+
}
|
|
8573
|
+
if (!(P instanceof UseSymbol)) continue;
|
|
8574
|
+
let HY = P.originalSymbol.intern();
|
|
8575
|
+
_.has(HY) || (_.add(HY), this.interpretUseSymbol(P));
|
|
8576
|
+
}
|
|
8561
8577
|
}
|
|
8562
8578
|
}
|
|
8563
8579
|
interpretUseSymbol(_) {
|
|
@@ -8760,24 +8776,16 @@ var ProgramInterpreter = class {
|
|
|
8760
8776
|
},
|
|
8761
8777
|
symbolMembers(_, VY) {
|
|
8762
8778
|
if (!VY.isKind(SymbolKind.Program)) return Report.create(PASS_THROUGH);
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
let HY
|
|
8766
|
-
|
|
8767
|
-
let
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
let { name: UY } = P;
|
|
8774
|
-
HY.has(UY) || HY.set(UY, _.symbolFactory.create(SchemaSymbol, { name: UY }, VY.filepath));
|
|
8775
|
-
}
|
|
8776
|
-
}
|
|
8777
|
-
let UY = HY.get(DEFAULT_SCHEMA_NAME$1);
|
|
8778
|
-
if (!UY) return Report.create([...HY.values()]);
|
|
8779
|
-
let WY = _.symbolMembers(UY).getFiltered(UNHANDLED)?.filter((_) => !_.isKind(SymbolKind.Schema));
|
|
8780
|
-
return WY ? Report.create([...HY.values(), ...WY]) : Report.create([...HY.values()]);
|
|
8779
|
+
if (!(VY.declaration instanceof ProgramNode)) return Report.create([]);
|
|
8780
|
+
let P = /* @__PURE__ */ new Map();
|
|
8781
|
+
for (let HY of _.reachableFiles(VY.filepath)) {
|
|
8782
|
+
let { schemaMembers: VY } = _.usableMembers(HY).getValue();
|
|
8783
|
+
for (let _ of VY) P.has(_.name) || P.set(_.name, _);
|
|
8784
|
+
}
|
|
8785
|
+
let HY = P.get(DEFAULT_SCHEMA_NAME$1);
|
|
8786
|
+
if (!HY) return Report.create([...P.values()]);
|
|
8787
|
+
let UY = _.symbolMembers(HY).getFiltered(UNHANDLED)?.filter((_) => !_.isKind(SymbolKind.Schema));
|
|
8788
|
+
return UY ? Report.create([...P.values(), ...UY]) : Report.create([...P.values()]);
|
|
8781
8789
|
},
|
|
8782
8790
|
bindNode(_, VY) {
|
|
8783
8791
|
return isProgramNode(VY) ? new Binder(VY, _).resolve() : Report.create(PASS_THROUGH);
|
|
@@ -9194,23 +9202,23 @@ function nodeRefereeOfRecordsName(_, VY, P) {
|
|
|
9194
9202
|
let HY = extractVarNameFromPrimaryVariable(P) ?? "";
|
|
9195
9203
|
if (!isAccessExpression(P.parentNode)) {
|
|
9196
9204
|
let UY = _.lookupMembers(VY, [SymbolKind.Table, SymbolKind.Schema], HY);
|
|
9197
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9205
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9198
9206
|
}
|
|
9199
9207
|
let UY = nodeRefereeOfLeftExpression(_, P);
|
|
9200
9208
|
if (!UY) {
|
|
9201
9209
|
let UY = _.lookupMembers(VY, [SymbolKind.Table, SymbolKind.Schema], HY);
|
|
9202
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9210
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
|
|
9203
9211
|
}
|
|
9204
9212
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
9205
9213
|
let VY = _.lookupMembers(UY, [SymbolKind.Table, SymbolKind.Schema], HY);
|
|
9206
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9214
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
|
|
9207
9215
|
}
|
|
9208
9216
|
return new Report(void 0);
|
|
9209
9217
|
}
|
|
9210
9218
|
function nodeRefereeOfRecordsColumn(_, VY, P) {
|
|
9211
9219
|
if (!isExpressionAVariableNode(P)) return new Report(void 0);
|
|
9212
9220
|
let HY = extractVarNameFromPrimaryVariable(P) ?? "", UY = _.lookupMembers(VY, SymbolKind.Column, HY);
|
|
9213
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9221
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in Table 'public.${VY.name}'`, P)]);
|
|
9214
9222
|
}
|
|
9215
9223
|
function nodeRefereeOfEnumValue(_, VY, P) {
|
|
9216
9224
|
if (!isExpressionAVariableNode(P)) return new Report(void 0);
|
|
@@ -9220,7 +9228,7 @@ function nodeRefereeOfEnumValue(_, VY, P) {
|
|
|
9220
9228
|
if (UY) {
|
|
9221
9229
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
9222
9230
|
let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
|
|
9223
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9231
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
|
|
9224
9232
|
}
|
|
9225
9233
|
if (UY.isKind(SymbolKind.Enum)) {
|
|
9226
9234
|
let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
|
|
@@ -9232,7 +9240,7 @@ function nodeRefereeOfEnumValue(_, VY, P) {
|
|
|
9232
9240
|
if (WY.leftExpression === P) {
|
|
9233
9241
|
if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
|
|
9234
9242
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
9235
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9243
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9236
9244
|
}
|
|
9237
9245
|
let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
|
|
9238
9246
|
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
|
|
@@ -9403,7 +9411,7 @@ function nodeRefereeOfRefEndpoint(_, VY, P) {
|
|
|
9403
9411
|
}
|
|
9404
9412
|
var useUtils = { visibleName(_, VY) {
|
|
9405
9413
|
let P = VY instanceof SyntaxNode ? VY : VY.useSpecifierDeclaration instanceof UseSpecifierNode ? VY.useSpecifierDeclaration : VY.declaration;
|
|
9406
|
-
if (P) return _.nodeAlias(P).mapFiltered((_) => [_], UNHANDLED, void 0).getFiltered(UNHANDLED) || _.nodeFullname(P).getFiltered(UNHANDLED);
|
|
9414
|
+
if (P instanceof UseSpecifierNode && VY instanceof NodeSymbol && P.getSymbolKind() !== VY.kind && (P = VY.declaration), P) return _.nodeAlias(P).mapFiltered((_) => [_], UNHANDLED, void 0).getFiltered(UNHANDLED) || _.nodeFullname(P).getFiltered(UNHANDLED);
|
|
9407
9415
|
} }, useModule$1 = {
|
|
9408
9416
|
nodeSymbol(_, VY) {
|
|
9409
9417
|
if (!isUseSpecifier(VY) || !VY.name) return Report.create(PASS_THROUGH);
|
|
@@ -9416,7 +9424,7 @@ var useUtils = { visibleName(_, VY) {
|
|
|
9416
9424
|
usedSymbol: HY,
|
|
9417
9425
|
kind: P,
|
|
9418
9426
|
name: useUtils.visibleName(_, VY)?.at(-1)
|
|
9419
|
-
}, VY.filepath), HY === void 0 ? [new CompileError(CompileErrorCode.BINDING_ERROR, `Failed to resolve the import of ${P} '${(
|
|
9427
|
+
}, VY.filepath), HY === void 0 ? [new CompileError(CompileErrorCode.BINDING_ERROR, `Failed to resolve the import of ${P} '${(destructureComplexVariable(VY.name) || []).map(addDoubleQuoteIfNeeded).join(".")}'`, VY)] : []);
|
|
9420
9428
|
},
|
|
9421
9429
|
symbolMembers(_, VY) {
|
|
9422
9430
|
if (!(VY instanceof UseSymbol)) return Report.create(PASS_THROUGH);
|
|
@@ -9434,14 +9442,14 @@ var useUtils = { visibleName(_, VY) {
|
|
|
9434
9442
|
let GY = VY.parentOfKind(UseDeclarationNode);
|
|
9435
9443
|
if (GY?.importPath?.value === void 0) return Report.create(void 0);
|
|
9436
9444
|
let KY = resolveImportFilepath(VY.filepath, GY.importPath.value);
|
|
9437
|
-
if (!KY) return Report.create(void 0);
|
|
9445
|
+
if (!KY) return Report.create(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Import path must be relative, got '${GY.importPath.value}'`, VY)]);
|
|
9438
9446
|
if (!_.layout.exists(KY)) return Report.create(void 0, [new CompileError(CompileErrorCode.NONEXISTENT_MODULE, `${HY} '${UY?.join(".") ?? WY}' does not exist in file ${KY.toString()}. Does the file exist?`, VY)]);
|
|
9439
9447
|
let qY = VY.parentOfKind(InfixExpressionNode)?.leftExpression;
|
|
9440
9448
|
if (qY && qY !== VY) {
|
|
9441
9449
|
let P = _.nodeReferee(qY).getFiltered(UNHANDLED);
|
|
9442
9450
|
if (!P) return Report.create(void 0);
|
|
9443
9451
|
let UY = _.lookupMembers(P, HY, WY);
|
|
9444
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9452
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Could not find ${HY} '${WY}'`, VY)]);
|
|
9445
9453
|
}
|
|
9446
9454
|
let JY = lookupMemberInFilepath(_, KY, WY, HY);
|
|
9447
9455
|
return JY ? Report.create(JY) : Report.create(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `${HY} '${WY}' does not exist in file ${KY.toString()}`, VY)]);
|
|
@@ -9451,7 +9459,7 @@ var useUtils = { visibleName(_, VY) {
|
|
|
9451
9459
|
let P = [];
|
|
9452
9460
|
if (VY.importPath?.value) {
|
|
9453
9461
|
let HY = resolveImportFilepath(VY.filepath, VY.importPath.value);
|
|
9454
|
-
HY
|
|
9462
|
+
HY ? _.layout.exists(HY) || P.push(new CompileError(CompileErrorCode.NONEXISTENT_MODULE, `Failed to resolve the non-existent file '${VY.importPath.value}'`, VY.importPath)) : P.push(new CompileError(CompileErrorCode.BINDING_ERROR, `Import path must be relative, got '${VY.importPath.value}'`, VY.importPath));
|
|
9455
9463
|
}
|
|
9456
9464
|
if (VY.specifiers) {
|
|
9457
9465
|
let HY = _.bindNode(VY.specifiers);
|
|
@@ -9497,74 +9505,151 @@ function lookupMemberInFilepath(_, VY, P, HY, UY = /* @__PURE__ */ new Set()) {
|
|
|
9497
9505
|
}
|
|
9498
9506
|
}
|
|
9499
9507
|
function usableMembers(_) {
|
|
9500
|
-
let VY = [], P = /* @__PURE__ */ new Map(), HY = [], UY = [], WY = [], GY = [], KY = _ instanceof Filepath ? _ : _.filepath, qY = this.parseFile(KY), { ast: JY } = qY.getValue();
|
|
9501
|
-
for (let _ of JY.body) {
|
|
9502
|
-
if (!(_ instanceof UseDeclarationNode) || !_.specifiers || !_.importPath) continue;
|
|
9503
|
-
let VY = resolveImportFilepath(KY, _.importPath.value);
|
|
9504
|
-
VY && (_.isReuse ? _.specifiers instanceof WildcardNode ? HY.push({
|
|
9505
|
-
importPath: VY,
|
|
9506
|
-
node: _.specifiers
|
|
9507
|
-
}) : UY.push(..._.specifiers.specifiers) : _.specifiers instanceof WildcardNode ? WY.push({
|
|
9508
|
-
importPath: VY,
|
|
9509
|
-
node: _.specifiers
|
|
9510
|
-
}) : GY.push(..._.specifiers.specifiers));
|
|
9511
|
-
}
|
|
9512
|
-
let YY = [];
|
|
9513
9508
|
if (_ instanceof Filepath) {
|
|
9514
|
-
let
|
|
9515
|
-
|
|
9516
|
-
let HY = this.nodeFullname(VY).getFiltered(UNHANDLED) || [], UY = HY.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : HY[0];
|
|
9517
|
-
P.has(UY) || P.set(UY, this.symbolFactory.create(SchemaSymbol, { name: UY }, _));
|
|
9518
|
-
}
|
|
9519
|
-
YY.push(...P.values());
|
|
9520
|
-
let HY = YY.find((_) => _.isPublicSchema());
|
|
9521
|
-
if (HY) {
|
|
9522
|
-
let _ = this.usableMembers(HY).getFiltered(UNHANDLED);
|
|
9523
|
-
_ && VY.push(..._.nonSchemaMembers);
|
|
9524
|
-
}
|
|
9525
|
-
} else {
|
|
9526
|
-
let HY = _;
|
|
9527
|
-
for (let _ of JY.body) {
|
|
9528
|
-
if (!(_ instanceof ElementDeclarationNode)) continue;
|
|
9529
|
-
let UY = schemaMembership(this, HY, _), WY = this.nodeAlias(_).getFiltered(UNHANDLED), GY = this.nodeSymbol(_).getFiltered(UNHANDLED);
|
|
9530
|
-
if (WY !== void 0 && HY.isPublicSchema() && GY && VY.push(this.symbolFactory.create(AliasSymbol, {
|
|
9531
|
-
kind: GY.kind,
|
|
9532
|
-
declaration: _,
|
|
9533
|
-
aliasedSymbol: GY,
|
|
9534
|
-
name: WY
|
|
9535
|
-
}, HY.filepath)), UY.kind !== "none") if (UY.kind === "direct") {
|
|
9536
|
-
let P = this.nodeSymbol(_).getFiltered(UNHANDLED);
|
|
9537
|
-
if (!P) continue;
|
|
9538
|
-
VY.push(P);
|
|
9539
|
-
} else P.has(UY.schemaName) || P.set(UY.schemaName, this.symbolFactory.create(SchemaSymbol, {
|
|
9540
|
-
name: UY.schemaName,
|
|
9541
|
-
parent: HY
|
|
9542
|
-
}, HY.filepath));
|
|
9543
|
-
}
|
|
9544
|
-
YY.push(...P.values());
|
|
9509
|
+
let { ast: VY } = this.parseFile(_).getValue(), P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
|
|
9510
|
+
return this.usableMembers(P);
|
|
9545
9511
|
}
|
|
9512
|
+
let VY = _.filepath, P = collectImports(this, VY), { nonSchemaMembers: HY, schemaMembers: UY } = _ instanceof ProgramSymbol ? usableMembersForProgram(this, _, P) : usableMembersForSchema(this, _, P);
|
|
9546
9513
|
return new Report({
|
|
9547
|
-
nonSchemaMembers:
|
|
9548
|
-
schemaMembers:
|
|
9514
|
+
nonSchemaMembers: HY,
|
|
9515
|
+
schemaMembers: UY,
|
|
9549
9516
|
reuses: {
|
|
9550
|
-
selective:
|
|
9551
|
-
wildcard:
|
|
9517
|
+
selective: P.selectiveReuses,
|
|
9518
|
+
wildcard: P.wildcardReuses
|
|
9552
9519
|
},
|
|
9553
9520
|
uses: {
|
|
9554
|
-
selective:
|
|
9555
|
-
wildcard:
|
|
9521
|
+
selective: P.selectiveUses,
|
|
9522
|
+
wildcard: P.wildcardUses
|
|
9556
9523
|
}
|
|
9557
|
-
},
|
|
9524
|
+
}, P.parseResult.getErrors(), P.parseResult.getWarnings());
|
|
9558
9525
|
}
|
|
9559
9526
|
function schemaMembership(_, VY, P) {
|
|
9560
9527
|
let HY = VY.qualifiedName, UY;
|
|
9561
9528
|
if (UY = P instanceof UseSpecifierNode ? useUtils.visibleName(_, P) : _.nodeFullname(P).getFiltered(UNHANDLED), !UY) return { kind: "none" };
|
|
9562
|
-
let WY = UY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : UY.slice(0, -1);
|
|
9529
|
+
let WY = P instanceof UseSpecifierNode && P.getSymbolKind() === SymbolKind.Schema ? UY : UY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : UY.slice(0, -1);
|
|
9563
9530
|
return WY.length < HY.length || !HY.every((_, VY) => _ === WY[VY]) ? { kind: "none" } : WY.length === HY.length ? { kind: "direct" } : {
|
|
9564
9531
|
kind: "child",
|
|
9565
9532
|
schemaName: WY[HY.length]
|
|
9566
9533
|
};
|
|
9567
9534
|
}
|
|
9535
|
+
function collectImports(_, VY) {
|
|
9536
|
+
let P = _.parseFile(VY), { ast: HY } = P.getValue(), UY = [], WY = [], GY = [], KY = [];
|
|
9537
|
+
for (let _ of HY.body) {
|
|
9538
|
+
if (!(_ instanceof UseDeclarationNode) || !_.specifiers || !_.importPath) continue;
|
|
9539
|
+
let P = resolveImportFilepath(VY, _.importPath.value);
|
|
9540
|
+
P && (_.isReuse ? _.specifiers instanceof WildcardNode ? UY.push({
|
|
9541
|
+
importPath: P,
|
|
9542
|
+
node: _.specifiers
|
|
9543
|
+
}) : WY.push(..._.specifiers.specifiers) : _.specifiers instanceof WildcardNode ? GY.push({
|
|
9544
|
+
importPath: P,
|
|
9545
|
+
node: _.specifiers
|
|
9546
|
+
}) : KY.push(..._.specifiers.specifiers));
|
|
9547
|
+
}
|
|
9548
|
+
return {
|
|
9549
|
+
ast: HY,
|
|
9550
|
+
parseResult: P,
|
|
9551
|
+
selectiveReuses: WY,
|
|
9552
|
+
wildcardReuses: UY,
|
|
9553
|
+
selectiveUses: KY,
|
|
9554
|
+
wildcardUses: GY
|
|
9555
|
+
};
|
|
9556
|
+
}
|
|
9557
|
+
function usableMembersForProgram(_, VY, P) {
|
|
9558
|
+
let { ast: HY, selectiveUses: UY, selectiveReuses: WY } = P, GY = VY.filepath, KY = new Map([[DEFAULT_SCHEMA_NAME$1, _.symbolFactory.create(SchemaSymbol, { name: DEFAULT_SCHEMA_NAME$1 }, GY)]]);
|
|
9559
|
+
for (let VY of HY.declarations) {
|
|
9560
|
+
let P = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], HY = P.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : P[0];
|
|
9561
|
+
KY.has(HY) || KY.set(HY, _.symbolFactory.create(SchemaSymbol, { name: HY }, GY));
|
|
9562
|
+
}
|
|
9563
|
+
registerProgramSchemas(_, [...UY, ...WY], KY, GY);
|
|
9564
|
+
for (let VY of _.reachableFiles(GY)) for (let P of collectTopLevelSchemaNames(_, VY)) KY.has(P) || KY.set(P, _.symbolFactory.create(SchemaSymbol, { name: P }, GY));
|
|
9565
|
+
let qY = [...KY.values()], JY = [], YY = qY.find((_) => _.isPublicSchema());
|
|
9566
|
+
if (YY) {
|
|
9567
|
+
let VY = _.usableMembers(YY).getFiltered(UNHANDLED);
|
|
9568
|
+
VY && JY.push(...VY.nonSchemaMembers);
|
|
9569
|
+
}
|
|
9570
|
+
return {
|
|
9571
|
+
nonSchemaMembers: JY,
|
|
9572
|
+
schemaMembers: qY
|
|
9573
|
+
};
|
|
9574
|
+
}
|
|
9575
|
+
function usableMembersForSchema(_, VY, P) {
|
|
9576
|
+
let { ast: HY, selectiveUses: UY, selectiveReuses: WY } = P, GY = [], KY = /* @__PURE__ */ new Map();
|
|
9577
|
+
for (let P of HY.body) {
|
|
9578
|
+
if (!(P instanceof ElementDeclarationNode)) continue;
|
|
9579
|
+
let HY = schemaMembership(_, VY, P), UY = _.nodeAlias(P).getFiltered(UNHANDLED), WY = _.nodeSymbol(P).getFiltered(UNHANDLED);
|
|
9580
|
+
if (UY !== void 0 && VY.isPublicSchema() && WY && GY.push(_.symbolFactory.create(AliasSymbol, {
|
|
9581
|
+
kind: WY.kind,
|
|
9582
|
+
declaration: P,
|
|
9583
|
+
aliasedSymbol: WY,
|
|
9584
|
+
name: UY
|
|
9585
|
+
}, VY.filepath)), HY.kind !== "none") if (HY.kind === "direct") {
|
|
9586
|
+
let VY = _.nodeSymbol(P).getFiltered(UNHANDLED);
|
|
9587
|
+
if (!VY) continue;
|
|
9588
|
+
GY.push(VY);
|
|
9589
|
+
} else KY.has(HY.schemaName) || KY.set(HY.schemaName, _.symbolFactory.create(SchemaSymbol, {
|
|
9590
|
+
name: HY.schemaName,
|
|
9591
|
+
parent: VY
|
|
9592
|
+
}, VY.filepath));
|
|
9593
|
+
}
|
|
9594
|
+
registerSchemaChildren(_, [...UY, ...WY], VY, KY);
|
|
9595
|
+
let qY = VY.qualifiedName;
|
|
9596
|
+
for (let P of _.reachableFiles(VY.filepath)) for (let HY of collectChildSchemaNames(_, P, qY)) KY.has(HY) || KY.set(HY, _.symbolFactory.create(SchemaSymbol, {
|
|
9597
|
+
name: HY,
|
|
9598
|
+
parent: VY
|
|
9599
|
+
}, VY.filepath));
|
|
9600
|
+
return {
|
|
9601
|
+
nonSchemaMembers: GY,
|
|
9602
|
+
schemaMembers: [...KY.values()]
|
|
9603
|
+
};
|
|
9604
|
+
}
|
|
9605
|
+
function registerProgramSchemas(_, VY, P, HY) {
|
|
9606
|
+
for (let UY of VY) {
|
|
9607
|
+
if (UY.getSymbolKind() !== SymbolKind.Schema) continue;
|
|
9608
|
+
let VY = useUtils.visibleName(_, UY)?.at(0);
|
|
9609
|
+
VY !== void 0 && !P.has(VY) && P.set(VY, _.symbolFactory.create(SchemaSymbol, { name: VY }, HY));
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
function registerSchemaChildren(_, VY, P, HY) {
|
|
9613
|
+
let UY = P.qualifiedName;
|
|
9614
|
+
for (let WY of VY) {
|
|
9615
|
+
if (WY.getSymbolKind() !== SymbolKind.Schema) continue;
|
|
9616
|
+
let VY = useUtils.visibleName(_, WY);
|
|
9617
|
+
if (!VY || VY.length <= UY.length || !UY.every((_, P) => _ === VY[P])) continue;
|
|
9618
|
+
let GY = VY[UY.length];
|
|
9619
|
+
GY && !HY.has(GY) && HY.set(GY, _.symbolFactory.create(SchemaSymbol, {
|
|
9620
|
+
name: GY,
|
|
9621
|
+
parent: P
|
|
9622
|
+
}, P.filepath));
|
|
9623
|
+
}
|
|
9624
|
+
}
|
|
9625
|
+
function collectTopLevelSchemaNames(_, VY) {
|
|
9626
|
+
let { ast: P } = _.parseFile(VY).getValue(), HY = [];
|
|
9627
|
+
for (let VY of P.declarations) {
|
|
9628
|
+
let P = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], UY = P.length <= 1 ? DEFAULT_SCHEMA_NAME$1 : P[0];
|
|
9629
|
+
HY.push(UY);
|
|
9630
|
+
}
|
|
9631
|
+
let UY = collectImports(_, VY);
|
|
9632
|
+
for (let VY of [...UY.selectiveUses, ...UY.selectiveReuses]) {
|
|
9633
|
+
if (VY.getSymbolKind() !== SymbolKind.Schema) continue;
|
|
9634
|
+
let P = useUtils.visibleName(_, VY)?.at(0);
|
|
9635
|
+
P !== void 0 && HY.push(P);
|
|
9636
|
+
}
|
|
9637
|
+
return HY;
|
|
9638
|
+
}
|
|
9639
|
+
function collectChildSchemaNames(_, VY, P) {
|
|
9640
|
+
let { ast: HY } = _.parseFile(VY).getValue(), UY = [];
|
|
9641
|
+
for (let VY of HY.declarations) {
|
|
9642
|
+
let HY = _.nodeFullname(VY).getFiltered(UNHANDLED) || [], WY = HY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : HY.slice(0, -1);
|
|
9643
|
+
WY.length > P.length && P.every((_, VY) => _ === WY[VY]) && UY.push(WY[P.length]);
|
|
9644
|
+
}
|
|
9645
|
+
let WY = collectImports(_, VY);
|
|
9646
|
+
for (let VY of [...WY.selectiveUses, ...WY.selectiveReuses]) {
|
|
9647
|
+
if (VY.getSymbolKind() !== SymbolKind.Schema) continue;
|
|
9648
|
+
let HY = useUtils.visibleName(_, VY);
|
|
9649
|
+
!HY || HY.length <= P.length || P.every((_, VY) => _ === HY[VY]) && UY.push(HY[P.length]);
|
|
9650
|
+
}
|
|
9651
|
+
return UY;
|
|
9652
|
+
}
|
|
9568
9653
|
var TableBinder = class {
|
|
9569
9654
|
constructor(_, VY) {
|
|
9570
9655
|
this.compiler = _, this.declarationNode = VY;
|
|
@@ -9883,7 +9968,7 @@ function nodeRefereeOfPartialInjection(_, VY, P) {
|
|
|
9883
9968
|
}
|
|
9884
9969
|
}
|
|
9885
9970
|
let WY = _.lookupMembers(VY, SymbolKind.TablePartial, HY);
|
|
9886
|
-
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9971
|
+
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `TablePartial '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9887
9972
|
}
|
|
9888
9973
|
function nodeRefereeOfEnumType$1(_, VY, P) {
|
|
9889
9974
|
if (!isExpressionAVariableNode(P)) return new Report(void 0);
|
|
@@ -9893,13 +9978,13 @@ function nodeRefereeOfEnumType$1(_, VY, P) {
|
|
|
9893
9978
|
if (UY) {
|
|
9894
9979
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
9895
9980
|
let VY = isTerminalAccessFragment(P), WY = _.lookupMembers(UY, VY ? SymbolKind.Enum : SymbolKind.Schema, HY);
|
|
9896
|
-
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9981
|
+
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, VY ? `Enum '${HY}' does not exist in Schema 'public'` : `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9897
9982
|
}
|
|
9898
9983
|
return new Report(void 0);
|
|
9899
9984
|
}
|
|
9900
9985
|
if (P.parentNode.leftExpression === P) {
|
|
9901
9986
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
9902
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
9987
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9903
9988
|
}
|
|
9904
9989
|
return new Report(void 0);
|
|
9905
9990
|
}
|
|
@@ -9946,11 +10031,11 @@ function nodeRefereeOfEnumDefault$1(_, VY, P) {
|
|
|
9946
10031
|
if (UY) {
|
|
9947
10032
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
9948
10033
|
let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
|
|
9949
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10034
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
|
|
9950
10035
|
}
|
|
9951
10036
|
if (UY.isKind(SymbolKind.Enum)) {
|
|
9952
10037
|
let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
|
|
9953
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10038
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
|
|
9954
10039
|
}
|
|
9955
10040
|
return new Report(void 0);
|
|
9956
10041
|
}
|
|
@@ -9958,10 +10043,10 @@ function nodeRefereeOfEnumDefault$1(_, VY, P) {
|
|
|
9958
10043
|
if (WY.leftExpression === P) {
|
|
9959
10044
|
if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
|
|
9960
10045
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
9961
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10046
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9962
10047
|
}
|
|
9963
10048
|
let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
|
|
9964
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10049
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
|
|
9965
10050
|
}
|
|
9966
10051
|
return new Report(void 0);
|
|
9967
10052
|
}
|
|
@@ -10225,16 +10310,11 @@ function nodeRefereeOfTableGroupField(_, VY, P) {
|
|
|
10225
10310
|
let HY = extractVarNameFromPrimaryVariable(P) ?? "";
|
|
10226
10311
|
if (!isAccessExpression(P.parentNode)) {
|
|
10227
10312
|
let UY = _.symbolMembers(VY).getFiltered(UNHANDLED);
|
|
10228
|
-
if (UY)
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
let P = _.symbolMembers(VY).getFiltered(UNHANDLED);
|
|
10234
|
-
if (P) {
|
|
10235
|
-
let VY = P.find((VY) => !VY.isKind(SymbolKind.Table) || !VY.declaration ? !1 : _.nodeAlias(VY.declaration).getFiltered(UNHANDLED) === HY);
|
|
10236
|
-
if (VY) return new Report(VY);
|
|
10237
|
-
}
|
|
10313
|
+
if (UY) {
|
|
10314
|
+
let VY = UY.find((_) => _ instanceof SchemaSymbol && _.isPublicSchema());
|
|
10315
|
+
if (VY) {
|
|
10316
|
+
let P = _.lookupMembers(VY, SymbolKind.Table, HY);
|
|
10317
|
+
if (P) return Report.create(P);
|
|
10238
10318
|
}
|
|
10239
10319
|
}
|
|
10240
10320
|
let WY = _.lookupMembers(VY, SymbolKind.Table, HY);
|
|
@@ -10343,7 +10423,7 @@ var TablePartialBinder = class {
|
|
|
10343
10423
|
this.tablePartial.headerColor = P ? extractColor(P.value) : void 0;
|
|
10344
10424
|
let [HY] = VY[SettingName.Note] || [];
|
|
10345
10425
|
return this.tablePartial.note = HY && {
|
|
10346
|
-
value:
|
|
10426
|
+
value: normalizeNote(extractQuotedStringToken(HY?.value)),
|
|
10347
10427
|
token: getTokenPosition(HY)
|
|
10348
10428
|
}, [];
|
|
10349
10429
|
}
|
|
@@ -10470,13 +10550,13 @@ function nodeRefereeOfEnumType(_, VY, P) {
|
|
|
10470
10550
|
if (UY) {
|
|
10471
10551
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
10472
10552
|
let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
|
|
10473
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10553
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
|
|
10474
10554
|
}
|
|
10475
10555
|
return new Report(void 0);
|
|
10476
10556
|
}
|
|
10477
10557
|
if (P.parentNode.leftExpression === P) {
|
|
10478
10558
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
10479
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10559
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
10480
10560
|
}
|
|
10481
10561
|
return new Report(void 0);
|
|
10482
10562
|
}
|
|
@@ -10489,21 +10569,21 @@ function nodeRefereeOfInlineRef(_, VY, P) {
|
|
|
10489
10569
|
let VY = _.nodeSymbol(UY).getFiltered(UNHANDLED);
|
|
10490
10570
|
if (VY) {
|
|
10491
10571
|
let UY = _.lookupMembers(VY, SymbolKind.Column, HY);
|
|
10492
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10572
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in TablePartial '${VY.name}'`, P)]);
|
|
10493
10573
|
}
|
|
10494
10574
|
}
|
|
10495
10575
|
let WY = _.lookupMembers(VY, SymbolKind.Column, HY);
|
|
10496
|
-
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10576
|
+
return WY ? Report.create(WY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist`, P)]);
|
|
10497
10577
|
}
|
|
10498
10578
|
let UY = nodeRefereeOfLeftExpression(_, P);
|
|
10499
10579
|
if (UY) {
|
|
10500
10580
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
10501
10581
|
let VY = _.lookupMembers(UY, [SymbolKind.Table, SymbolKind.Schema], HY);
|
|
10502
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10582
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table or schema '${HY}' does not exist`, P)]);
|
|
10503
10583
|
}
|
|
10504
10584
|
if (UY.isKind(SymbolKind.Table)) {
|
|
10505
10585
|
let VY = _.lookupMembers(UY, SymbolKind.Column, HY);
|
|
10506
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10586
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Column '${HY}' does not exist in Table 'public.${UY.name}'`, P)]);
|
|
10507
10587
|
}
|
|
10508
10588
|
return new Report(void 0);
|
|
10509
10589
|
}
|
|
@@ -10511,10 +10591,10 @@ function nodeRefereeOfInlineRef(_, VY, P) {
|
|
|
10511
10591
|
if (WY.leftExpression === P) {
|
|
10512
10592
|
if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
|
|
10513
10593
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
10514
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10594
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
10515
10595
|
}
|
|
10516
10596
|
let UY = _.lookupMembers(VY, SymbolKind.Table, HY);
|
|
10517
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10597
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Table '${HY}' does not exist in Schema 'public'`, P)]);
|
|
10518
10598
|
}
|
|
10519
10599
|
return new Report(void 0);
|
|
10520
10600
|
}
|
|
@@ -10526,11 +10606,11 @@ function nodeRefereeOfEnumDefault(_, VY, P) {
|
|
|
10526
10606
|
if (UY) {
|
|
10527
10607
|
if (UY.isKind(SymbolKind.Schema)) {
|
|
10528
10608
|
let VY = _.lookupMembers(UY, [SymbolKind.Enum, SymbolKind.Schema], HY);
|
|
10529
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10609
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum or schema '${HY}' does not exist`, P)]);
|
|
10530
10610
|
}
|
|
10531
10611
|
if (UY.isKind(SymbolKind.Enum)) {
|
|
10532
10612
|
let VY = _.lookupMembers(UY, SymbolKind.EnumField, HY);
|
|
10533
|
-
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10613
|
+
return VY ? Report.create(VY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum field '${HY}' does not exist in Enum 'public.${UY.name}'`, P)]);
|
|
10534
10614
|
}
|
|
10535
10615
|
return new Report(void 0);
|
|
10536
10616
|
}
|
|
@@ -10538,10 +10618,10 @@ function nodeRefereeOfEnumDefault(_, VY, P) {
|
|
|
10538
10618
|
if (WY.leftExpression === P) {
|
|
10539
10619
|
if (isAccessExpression(WY.parentNode) && WY.parentNode.leftExpression === WY) {
|
|
10540
10620
|
let UY = _.lookupMembers(VY, SymbolKind.Schema, HY);
|
|
10541
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10621
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Schema '${HY}' does not exist in Schema 'public'`, P)]);
|
|
10542
10622
|
}
|
|
10543
10623
|
let UY = _.lookupMembers(VY, SymbolKind.Enum, HY);
|
|
10544
|
-
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.
|
|
10624
|
+
return UY ? Report.create(UY) : new Report(void 0, [new CompileError(CompileErrorCode.BINDING_ERROR, `Enum '${HY}' does not exist in Schema 'public'`, P)]);
|
|
10545
10625
|
}
|
|
10546
10626
|
return new Report(void 0);
|
|
10547
10627
|
}
|
|
@@ -10554,26 +10634,38 @@ var schemaModule = { symbolMembers(_, VY) {
|
|
|
10554
10634
|
let HY = handleMemberSelectiveUses(_, VY, P, WY);
|
|
10555
10635
|
GY.push(...HY.getErrors());
|
|
10556
10636
|
let KY = HY.getFiltered(UNHANDLED);
|
|
10557
|
-
KY && UY.push(KY);
|
|
10637
|
+
KY && UY.push(KY), UY.push(...mergeImportedSchema(_, VY, P));
|
|
10558
10638
|
}
|
|
10559
10639
|
for (let { importPath: P, node: GY } of HY.reuses.wildcard) UY.push(...handleMemberWildcardUses(_, VY, P, GY, WY));
|
|
10560
10640
|
for (let P of HY.uses.selective) {
|
|
10561
10641
|
let HY = handleMemberSelectiveUses(_, VY, P, WY);
|
|
10562
10642
|
GY.push(...HY.getErrors());
|
|
10563
10643
|
let KY = HY.getFiltered(UNHANDLED);
|
|
10564
|
-
KY && UY.push(KY);
|
|
10644
|
+
KY && UY.push(KY), UY.push(...mergeImportedSchema(_, VY, P));
|
|
10565
10645
|
}
|
|
10566
10646
|
for (let { importPath: P, node: GY } of HY.uses.wildcard) UY.push(...handleMemberWildcardUses(_, VY, P, GY, WY));
|
|
10567
10647
|
UY.push(...WY.values());
|
|
10568
10648
|
let KY = [...UY];
|
|
10569
|
-
|
|
10649
|
+
{
|
|
10650
|
+
let P = UY.filter((_) => _.isKind(SymbolKind.TableGroup));
|
|
10651
|
+
if (!VY.isPublicSchema()) {
|
|
10652
|
+
let HY = _.usableMembers(VY.filepath).getFiltered(UNHANDLED)?.schemaMembers.find((_) => _.isPublicSchema());
|
|
10653
|
+
if (HY) {
|
|
10654
|
+
let VY = _.symbolMembers(HY).getFiltered(UNHANDLED);
|
|
10655
|
+
VY && P.push(...VY.filter((_) => _.isKind(SymbolKind.TableGroup)));
|
|
10656
|
+
}
|
|
10657
|
+
}
|
|
10658
|
+
for (let HY of P) KY.push(...expandTableGroup(_, VY, HY));
|
|
10659
|
+
}
|
|
10570
10660
|
let qY = /* @__PURE__ */ new Set(), JY = KY.filter((_) => {
|
|
10661
|
+
if (_ instanceof UseSymbol && _.isKind(SymbolKind.Schema)) return !1;
|
|
10571
10662
|
let VY = `${_.originalSymbol.intern()}:${_.name ?? ""}`;
|
|
10572
10663
|
return qY.has(VY) ? !1 : (qY.add(VY), !0);
|
|
10573
10664
|
}), YY = /* @__PURE__ */ new Map();
|
|
10574
10665
|
for (let _ of JY) {
|
|
10575
10666
|
let VY = `${_.kind}:${_.name}`;
|
|
10576
10667
|
if (YY.get(VY)) {
|
|
10668
|
+
if (_.isKind(SymbolKind.Schema)) continue;
|
|
10577
10669
|
let VY = _ instanceof UseSymbol ? _.useSpecifierDeclaration ?? _.declaration : _.declaration instanceof ElementDeclarationNode && _.declaration.name ? _.declaration.name : _.declaration;
|
|
10578
10670
|
VY && _.name !== void 0 && GY.push(getDuplicateSchemaMemberError(_.kind, _.name, P.join("."), VY));
|
|
10579
10671
|
} else YY.set(VY, _);
|
|
@@ -10602,6 +10694,43 @@ function handleMemberSelectiveUses(_, VY, P, HY) {
|
|
|
10602
10694
|
parent: VY
|
|
10603
10695
|
}, VY.filepath)), Report.create(void 0);
|
|
10604
10696
|
}
|
|
10697
|
+
function mergeImportedSchema(_, VY, P, HY = /* @__PURE__ */ new Set()) {
|
|
10698
|
+
if (P.getSymbolKind() !== SymbolKind.Schema || !P.name) return [];
|
|
10699
|
+
let UY = _.nodeReferee(P.name).getFiltered(UNHANDLED);
|
|
10700
|
+
if (!UY || !UY.isKind(SymbolKind.Schema)) return [];
|
|
10701
|
+
let WY = useUtils.visibleName(_, P), GY = VY.qualifiedName;
|
|
10702
|
+
return !WY || WY.length !== GY.length || !WY.every((_, VY) => _ === GY[VY]) ? [] : mergeSchemaMembers(_, VY, P, UY, HY);
|
|
10703
|
+
}
|
|
10704
|
+
function mergeSchemaMembers(_, VY, P, HY, UY) {
|
|
10705
|
+
let WY = HY.intern();
|
|
10706
|
+
if (UY.has(WY)) return [];
|
|
10707
|
+
UY.add(WY);
|
|
10708
|
+
let GY = _.usableMembers(HY).getFiltered(UNHANDLED);
|
|
10709
|
+
if (!GY) return [];
|
|
10710
|
+
let KY = GY.nonSchemaMembers.filter((_) => _.canBeImported).map((HY) => _.symbolFactory.create(UseSymbol, {
|
|
10711
|
+
kind: HY.kind,
|
|
10712
|
+
declaration: HY.originalSymbol.declaration,
|
|
10713
|
+
usedSymbol: HY.originalSymbol,
|
|
10714
|
+
useSpecifierDeclaration: P,
|
|
10715
|
+
name: HY.name
|
|
10716
|
+
}, VY.filepath));
|
|
10717
|
+
for (let P of [...KY]) P.isKind(SymbolKind.TableGroup) && KY.push(...expandTableGroup(_, VY, P));
|
|
10718
|
+
for (let HY of GY.reuses.selective) if (KY.push(...mergeImportedSchema(_, VY, HY, UY)), schemaMembership(_, VY, HY).kind === "direct") {
|
|
10719
|
+
let UY = _.nodeSymbol(HY).getFiltered(UNHANDLED);
|
|
10720
|
+
UY && UY.canBeImported && KY.push(_.symbolFactory.create(UseSymbol, {
|
|
10721
|
+
kind: UY.kind,
|
|
10722
|
+
declaration: UY.originalSymbol.declaration,
|
|
10723
|
+
usedSymbol: UY.originalSymbol,
|
|
10724
|
+
useSpecifierDeclaration: P,
|
|
10725
|
+
name: UY.name
|
|
10726
|
+
}, VY.filepath));
|
|
10727
|
+
}
|
|
10728
|
+
for (let { importPath: HY } of GY.reuses.wildcard) {
|
|
10729
|
+
let WY = findSchemaSymbolInFilepath(_, HY, VY.qualifiedName);
|
|
10730
|
+
WY && KY.push(...mergeSchemaMembers(_, VY, P, WY, UY));
|
|
10731
|
+
}
|
|
10732
|
+
return KY;
|
|
10733
|
+
}
|
|
10605
10734
|
function handleMemberWildcardUses(_, VY, P, HY, UY, WY = /* @__PURE__ */ new Set()) {
|
|
10606
10735
|
if (WY.has(P)) return [];
|
|
10607
10736
|
WY.add(P);
|
|
@@ -10620,7 +10749,7 @@ function handleMemberWildcardUses(_, VY, P, HY, UY, WY = /* @__PURE__ */ new Set
|
|
|
10620
10749
|
let { reuses: { selective: JY, wildcard: YY } } = KY;
|
|
10621
10750
|
for (let P of JY) {
|
|
10622
10751
|
let HY = handleMemberSelectiveUses(_, VY, P, UY).getFiltered(UNHANDLED);
|
|
10623
|
-
HY && qY.push(HY);
|
|
10752
|
+
HY && qY.push(HY), qY.push(...mergeImportedSchema(_, VY, P));
|
|
10624
10753
|
}
|
|
10625
10754
|
for (let { importPath: P } of YY) qY.push(...handleMemberWildcardUses(_, VY, P, HY, UY, WY));
|
|
10626
10755
|
return qY;
|
|
@@ -10638,34 +10767,36 @@ function findSchemaSymbolInFilepath(_, VY, P) {
|
|
|
10638
10767
|
}
|
|
10639
10768
|
return WY;
|
|
10640
10769
|
}
|
|
10641
|
-
function expandTableGroup(_, VY) {
|
|
10642
|
-
if (!
|
|
10643
|
-
let
|
|
10644
|
-
if (!
|
|
10645
|
-
let
|
|
10646
|
-
for (let
|
|
10647
|
-
if (!
|
|
10648
|
-
let HY =
|
|
10770
|
+
function expandTableGroup(_, VY, P) {
|
|
10771
|
+
if (!P.isKind(SymbolKind.TableGroup) || !(P instanceof UseSymbol)) return [];
|
|
10772
|
+
let HY = P.originalSymbol, UY = _.symbolMembers(HY).getFiltered(UNHANDLED);
|
|
10773
|
+
if (!UY) return [];
|
|
10774
|
+
let WY = VY.qualifiedName, GY = [];
|
|
10775
|
+
for (let VY of UY) {
|
|
10776
|
+
if (!VY.isKind(SymbolKind.TableGroupField) || !VY.declaration) continue;
|
|
10777
|
+
let HY = VY.declaration.callee;
|
|
10649
10778
|
if (!HY) continue;
|
|
10650
|
-
let
|
|
10651
|
-
if (!
|
|
10652
|
-
let
|
|
10653
|
-
KY
|
|
10779
|
+
let UY = destructureComplexVariable(HY);
|
|
10780
|
+
if (!UY || UY.length === 0) continue;
|
|
10781
|
+
let KY = UY.length <= 1 ? [DEFAULT_SCHEMA_NAME$1] : UY.slice(0, -1);
|
|
10782
|
+
if (KY.length !== WY.length || !WY.every((_, VY) => _ === KY[VY])) continue;
|
|
10783
|
+
let qY = VY.declaration.filepath, JY = lookupTableInFile(_, qY, UY);
|
|
10784
|
+
JY && GY.push(_.symbolFactory.create(UseSymbol, {
|
|
10654
10785
|
kind: SymbolKind.Table,
|
|
10655
|
-
declaration:
|
|
10656
|
-
usedSymbol:
|
|
10786
|
+
declaration: JY.declaration,
|
|
10787
|
+
usedSymbol: JY,
|
|
10657
10788
|
useSpecifierDeclaration: void 0,
|
|
10658
|
-
name:
|
|
10659
|
-
},
|
|
10789
|
+
name: JY.name
|
|
10790
|
+
}, P.filepath));
|
|
10660
10791
|
}
|
|
10661
|
-
return
|
|
10792
|
+
return GY;
|
|
10662
10793
|
}
|
|
10663
10794
|
function lookupTableInFile(_, VY, P) {
|
|
10664
10795
|
if (P.length === 1) {
|
|
10665
10796
|
let HY = _.usableMembers(VY).getFiltered(UNHANDLED);
|
|
10666
10797
|
return HY ? HY.nonSchemaMembers.find((_) => _.isKind(SymbolKind.Table) && _.name === P[0]) : void 0;
|
|
10667
10798
|
}
|
|
10668
|
-
let
|
|
10799
|
+
let HY = P[0], UY = P[P.length - 1], WY = _.usableMembers(VY).getFiltered(UNHANDLED);
|
|
10669
10800
|
if (!WY) return;
|
|
10670
10801
|
let GY = WY.schemaMembers.find((_) => _.name === HY);
|
|
10671
10802
|
if (!GY) return;
|
|
@@ -10981,6 +11112,10 @@ var customModule = {
|
|
|
10981
11112
|
}
|
|
10982
11113
|
validateSubBlock(_) {
|
|
10983
11114
|
let VY = [], P = [];
|
|
11115
|
+
if (hasSimpleBody(_)) return VY.push(new CompileError(CompileErrorCode.UNEXPECTED_SIMPLE_BODY, `${_.type?.value} body must be a block`, _.bodyColon)), {
|
|
11116
|
+
errors: VY,
|
|
11117
|
+
warnings: P
|
|
11118
|
+
};
|
|
10984
11119
|
if (!_.body || !(_.body instanceof BlockExpressionNode)) return {
|
|
10985
11120
|
errors: VY,
|
|
10986
11121
|
warnings: P
|
|
@@ -12196,7 +12331,7 @@ var tablePartialModule = {
|
|
|
12196
12331
|
nodeFullname(_, VY) {
|
|
12197
12332
|
if (!isUseSpecifier(VY)) return Report.create(PASS_THROUGH);
|
|
12198
12333
|
let P = destructureComplexVariable(VY.name);
|
|
12199
|
-
return !P || P.length === 0 ? Report.create(void 0, [new CompileError(CompileErrorCode.INVALID_NAME, "Use specifiers must have a valid name (simple name or schema-qualified name)", VY)]) : VY.isKind(ImportKind.TableGroup) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TableGroup name must be a simple name", VY)]) : VY.isKind(ImportKind.TablePartial) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TablePartial name must be a simple name", VY)]) : VY.isKind(ImportKind.Note) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A Sticky note name must be a simple name", VY)]) : (P.length === 1 && P.unshift(DEFAULT_SCHEMA_NAME$1), new Report(P));
|
|
12334
|
+
return !P || P.length === 0 ? Report.create(void 0, [new CompileError(CompileErrorCode.INVALID_NAME, "Use specifiers must have a valid name (simple name or schema-qualified name)", VY)]) : VY.isKind(ImportKind.TableGroup) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TableGroup name must be a simple name", VY)]) : VY.isKind(ImportKind.TablePartial) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A TablePartial name must be a simple name", VY)]) : VY.isKind(ImportKind.Note) && P.length > 1 ? Report.create(P, [new CompileError(CompileErrorCode.INVALID_USE_SPECIFIER_NAME, "A Sticky note name must be a simple name", VY)]) : (P.length === 1 && !VY.isKind(ImportKind.Schema) && P.unshift(DEFAULT_SCHEMA_NAME$1), new Report(P));
|
|
12200
12335
|
},
|
|
12201
12336
|
nodeAlias(_, VY) {
|
|
12202
12337
|
return isUseSpecifier(VY) ? VY.alias ? isValidAlias(VY.alias) ? new Report(extractVariableFromExpression(VY.alias)) : new Report(void 0, [new CompileError(CompileErrorCode.INVALID_ALIAS, "Use aliases can only contain alphanumeric and underscore unless surrounded by double quotes", VY.alias)]) : new Report(void 0) : Report.create(PASS_THROUGH);
|
|
@@ -13070,77 +13205,47 @@ function isOffsetWithinElementHeader(_, VY) {
|
|
|
13070
13205
|
let P = VY.bodyColon?.start ?? VY.body?.start;
|
|
13071
13206
|
return P === void 0 ? _ >= VY.start && _ <= VY.end : _ >= VY.start && _ < P;
|
|
13072
13207
|
}
|
|
13073
|
-
function scanExistingUses(_, VY
|
|
13074
|
-
let
|
|
13075
|
-
if (!
|
|
13076
|
-
for (let _ of
|
|
13077
|
-
let VY = _.importPath?.value ?? "";
|
|
13078
|
-
if (
|
|
13079
|
-
let
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
if (_.specifiers instanceof UseSpecifierListNode) {
|
|
13084
|
-
let VY = new Set([
|
|
13085
|
-
"table",
|
|
13086
|
-
"enum",
|
|
13087
|
-
"tablepartial",
|
|
13088
|
-
"tablegroup",
|
|
13089
|
-
"note",
|
|
13090
|
-
"schema",
|
|
13091
|
-
"from"
|
|
13092
|
-
]);
|
|
13093
|
-
for (let HY of _.specifiers.specifiers) {
|
|
13094
|
-
let _, WY;
|
|
13095
|
-
if (HY.name) _ = HY.importKind?.value, WY = extractVariableFromExpression(HY.name), !WY && HY.name.start !== void 0 && HY.name.end !== void 0 && (WY = P.slice(HY.name.start, HY.name.end).trim());
|
|
13096
|
-
else if (HY.importKind) {
|
|
13097
|
-
let _ = HY.importKind.value ?? void 0;
|
|
13098
|
-
_ && !VY.has(_.toLowerCase()) && (WY = _);
|
|
13099
|
-
}
|
|
13100
|
-
WY && WY.toLowerCase() !== "from" && UY.push({
|
|
13208
|
+
function scanExistingUses(_, VY) {
|
|
13209
|
+
let P = [], HY = _.parseFile(VY).getValue()?.ast;
|
|
13210
|
+
if (!HY) return P;
|
|
13211
|
+
for (let _ of HY.uses) {
|
|
13212
|
+
let VY = _.importPath?.value ?? "", HY = [];
|
|
13213
|
+
if (_.specifiers instanceof UseSpecifierListNode) for (let VY of _.specifiers.specifiers) {
|
|
13214
|
+
let _, P;
|
|
13215
|
+
if (VY.name ? (_ = VY.importKind?.value, P = extractVariableFromExpression(VY.name)) : VY.importKind && (P = VY.importKind.value ?? void 0), P) {
|
|
13216
|
+
let UY = VY.alias ? extractVariableFromExpression(VY.alias) : void 0;
|
|
13217
|
+
HY.push({
|
|
13101
13218
|
kind: _,
|
|
13102
|
-
name:
|
|
13219
|
+
name: P,
|
|
13220
|
+
alias: UY
|
|
13103
13221
|
});
|
|
13104
13222
|
}
|
|
13105
|
-
} else _.specifiers instanceof WildcardNode && UY.push({ name: "*" });
|
|
13106
|
-
if (UY.length === 0 && !(_.specifiers instanceof WildcardNode)) continue;
|
|
13107
|
-
let WY = _.fullEnd;
|
|
13108
|
-
if (!_.importPath) {
|
|
13109
|
-
let VY = _.useKeyword?.start ?? _.fullStart, HY = P.indexOf("\n", VY);
|
|
13110
|
-
WY = HY === -1 ? P.length : HY;
|
|
13111
13223
|
}
|
|
13112
|
-
HY.push({
|
|
13224
|
+
else _.specifiers instanceof WildcardNode && HY.push({ name: "*" });
|
|
13225
|
+
HY.length === 0 && !(_.specifiers instanceof WildcardNode) || P.push({
|
|
13113
13226
|
startOffset: _.fullStart,
|
|
13114
|
-
endOffset:
|
|
13227
|
+
endOffset: _.fullEnd,
|
|
13115
13228
|
sourceFile: VY,
|
|
13116
|
-
specifiers:
|
|
13229
|
+
specifiers: HY,
|
|
13117
13230
|
node: _
|
|
13118
13231
|
});
|
|
13119
13232
|
}
|
|
13120
|
-
return
|
|
13233
|
+
return P;
|
|
13121
13234
|
}
|
|
13122
13235
|
function mergeSymbolIntoUses(_, VY, P, HY, UY, WY) {
|
|
13123
|
-
let GY = scanExistingUses(_, UY
|
|
13236
|
+
let GY = scanExistingUses(_, UY), KY = HY.relativeTo(UY.dirname).replace(/\.dbml$/, ""), qY = GY.findIndex((_) => _.sourceFile === KY), JY = `${P} ${VY}`;
|
|
13124
13237
|
if (qY !== -1) {
|
|
13125
13238
|
let _ = GY[qY];
|
|
13126
13239
|
return _.specifiers.some((_) => _.name === VY) ? { topInsert: "" } : {
|
|
13127
|
-
topInsert: buildUseStatement(
|
|
13240
|
+
topInsert: buildUseStatement(uniq_default([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}${_.alias ? ` as ${_.alias}` : ""}`), JY]), KY, "\n"),
|
|
13128
13241
|
removeRange: expandToFullLines(WY, _.startOffset, _.endOffset)
|
|
13129
13242
|
};
|
|
13130
13243
|
}
|
|
13131
|
-
return { topInsert: buildUseStatement([JY], KY,
|
|
13244
|
+
return { topInsert: buildUseStatement([JY], KY, "\n") };
|
|
13132
13245
|
}
|
|
13133
13246
|
function buildUseStatement(_, VY, P) {
|
|
13134
13247
|
return `use {${P}${_.map((_) => ` ${_}`).join(P)}${P}} from '${VY}'${P}${P}`;
|
|
13135
13248
|
}
|
|
13136
|
-
function uniqueInOrder(_) {
|
|
13137
|
-
let VY = /* @__PURE__ */ new Set(), P = [];
|
|
13138
|
-
for (let HY of _) {
|
|
13139
|
-
let _ = HY.trim();
|
|
13140
|
-
VY.has(_) || (VY.add(_), P.push(HY));
|
|
13141
|
-
}
|
|
13142
|
-
return P;
|
|
13143
|
-
}
|
|
13144
13249
|
function expandToFullLines(_, VY, P) {
|
|
13145
13250
|
let HY = _.lastIndexOf("\n", VY - 1) + 1, UY = P;
|
|
13146
13251
|
for (; UY < _.length && (_[UY] === " " || _[UY] === " ");) UY++;
|
|
@@ -13149,12 +13254,6 @@ function expandToFullLines(_, VY, P) {
|
|
|
13149
13254
|
endOffset: UY
|
|
13150
13255
|
};
|
|
13151
13256
|
}
|
|
13152
|
-
function detectLineEnding(_) {
|
|
13153
|
-
return _.includes("\r\n") ? "\r\n" : "\n";
|
|
13154
|
-
}
|
|
13155
|
-
function normalizeSourcePath(_, VY) {
|
|
13156
|
-
return _.relativeTo(VY.dirname).replace(/\.dbml$/, "");
|
|
13157
|
-
}
|
|
13158
13257
|
function pickCompletionItemKind(_) {
|
|
13159
13258
|
switch (_) {
|
|
13160
13259
|
case SymbolKind.Schema: return CompletionItemKind.Module;
|
|
@@ -13214,7 +13313,7 @@ function addSuggestAllSuggestion(_, VY = ", ") {
|
|
|
13214
13313
|
}
|
|
13215
13314
|
function collectCrossFileSuggestions(_, VY, P) {
|
|
13216
13315
|
let HY = [], UY = /* @__PURE__ */ new Set(), WY = _.layout.getSource(P) ?? "";
|
|
13217
|
-
for (let GY of _.layout.
|
|
13316
|
+
for (let GY of _.layout.getEntrypoints()) {
|
|
13218
13317
|
if (GY.equals(P)) continue;
|
|
13219
13318
|
let KY = _.usableMembers(GY).getFiltered(UNHANDLED);
|
|
13220
13319
|
if (KY) for (let qY of [...KY.nonSchemaMembers, ...KY.schemaMembers]) {
|
|
@@ -13334,6 +13433,7 @@ function suggestUseCompletion(_, VY, P, HY, UY) {
|
|
|
13334
13433
|
}
|
|
13335
13434
|
function suggestInUseDeclaration(_, VY, P, HY, UY, WY) {
|
|
13336
13435
|
if (HY.importPath && isOffsetWithinSpan(P, HY.importPath)) return suggestUseFilepath(_, VY, HY.importPath, UY, HY);
|
|
13436
|
+
if (HY.importPath && P >= HY.importPath.end) return noSuggestions();
|
|
13337
13437
|
if (HY.fromKeyword && P > HY.fromKeyword.end) return suggestUseFilepath(_, VY, void 0, UY, HY);
|
|
13338
13438
|
if (HY.specifiers instanceof UseSpecifierListNode) {
|
|
13339
13439
|
if (!HY.specifiers.openBrace) {
|
|
@@ -13403,14 +13503,14 @@ function suggestUseSpecifierStart() {
|
|
|
13403
13503
|
return { suggestions: [{
|
|
13404
13504
|
label: "* from",
|
|
13405
13505
|
detail: "import all",
|
|
13406
|
-
insertText: "* from '${1
|
|
13506
|
+
insertText: "* from '${1:./path}'",
|
|
13407
13507
|
insertTextRules: CompletionItemInsertTextRule.InsertAsSnippet,
|
|
13408
13508
|
kind: CompletionItemKind.Snippet,
|
|
13409
13509
|
range: void 0
|
|
13410
13510
|
}, {
|
|
13411
13511
|
label: "{ } from",
|
|
13412
13512
|
detail: "import named",
|
|
13413
|
-
insertText: "{ ${1:
|
|
13513
|
+
insertText: "{ ${1:kind} ${2:name} } from '${3:./path}'",
|
|
13414
13514
|
insertTextRules: CompletionItemInsertTextRule.InsertAsSnippet,
|
|
13415
13515
|
kind: CompletionItemKind.Snippet,
|
|
13416
13516
|
range: void 0
|
|
@@ -13427,7 +13527,7 @@ function suggestUseFilepath(_, VY, P, HY, UY) {
|
|
|
13427
13527
|
endColumn: _.endColumn - 1
|
|
13428
13528
|
};
|
|
13429
13529
|
}
|
|
13430
|
-
let JY = /* @__PURE__ */ new Map(), YY = /* @__PURE__ */ new Map(), XY = uniqBy_default(_.layout.
|
|
13530
|
+
let JY = /* @__PURE__ */ new Map(), YY = /* @__PURE__ */ new Map(), XY = uniqBy_default(_.layout.getEntrypoints().flatMap((VY) => [..._.reachableFiles(VY)]), (_) => _.intern());
|
|
13431
13531
|
for (let P of XY) {
|
|
13432
13532
|
if (P.equals(VY)) continue;
|
|
13433
13533
|
let HY = P.relativeTo(WY);
|
|
@@ -14216,7 +14316,7 @@ var dbmlMonarchTokensProvider = {
|
|
|
14216
14316
|
}
|
|
14217
14317
|
return [...HY].sort().map(Filepath.from);
|
|
14218
14318
|
}
|
|
14219
|
-
|
|
14319
|
+
getEntrypoints() {
|
|
14220
14320
|
return [...this.files.keys()].map(Filepath.from).sort((_, VY) => _.absolute.localeCompare(VY.absolute));
|
|
14221
14321
|
}
|
|
14222
14322
|
clone() {
|
|
@@ -14236,7 +14336,7 @@ function containerStack(_, VY) {
|
|
|
14236
14336
|
for (; qY.length > 0;) {
|
|
14237
14337
|
let P = !1, HY = last_default$1(qY);
|
|
14238
14338
|
if (HY instanceof FunctionApplicationNode) {
|
|
14239
|
-
let UY = this.
|
|
14339
|
+
let UY = this.getSource(_) || "";
|
|
14240
14340
|
for (let _ = HY.end; _ < VY; _ += 1) UY[_] === "\n" && (qY.pop(), P = !0);
|
|
14241
14341
|
} else HY instanceof PrefixExpressionNode || HY instanceof InfixExpressionNode ? this.container.token(_, VY).token !== HY.op && (qY.pop(), P = !0) : HY instanceof ListExpressionNode ? HY.listCloseBracket && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof TupleExpressionNode ? HY.tupleCloseParen && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof CommaExpressionNode ? HY.end <= VY && (qY.pop(), P = !0) : HY instanceof BlockExpressionNode ? HY.blockCloseBrace && HY.end <= VY && (qY.pop(), P = !0) : HY instanceof IdentifierStreamNode || HY.end < VY && (qY.pop(), P = !0);
|
|
14242
14342
|
if (P) {
|
|
@@ -14293,32 +14393,40 @@ function containerScopeKind(_, VY) {
|
|
|
14293
14393
|
}
|
|
14294
14394
|
function canonicalName(_, VY) {
|
|
14295
14395
|
let P = VY.originalSymbol;
|
|
14296
|
-
if (P.filepath.
|
|
14297
|
-
let HY = this.
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
VY && GY.push(...VY);
|
|
14303
|
-
}
|
|
14304
|
-
for (let VY of GY) if (VY.filepath.intern() === _.intern() && VY.originalSymbol === P && (VY instanceof UseSymbol || VY instanceof AliasSymbol)) {
|
|
14305
|
-
let _ = VY.name;
|
|
14306
|
-
if (!_) continue;
|
|
14307
|
-
if (_ !== P.name) return Report.create({
|
|
14396
|
+
if (P.filepath.equals(_)) return Report.create(fullnameToCanonical(this, P));
|
|
14397
|
+
let HY = [...this.symbolUses(P).getValue(), ...this.symbolAliases(P).getValue()].filter((VY) => VY.filepath.equals(_));
|
|
14398
|
+
for (let _ of HY) {
|
|
14399
|
+
let VY = _.name;
|
|
14400
|
+
if (!VY) continue;
|
|
14401
|
+
if (VY !== P.name) return Report.create({
|
|
14308
14402
|
schema: "",
|
|
14309
|
-
name:
|
|
14403
|
+
name: VY
|
|
14404
|
+
});
|
|
14405
|
+
let HY = getSchemaChain(this, _);
|
|
14406
|
+
if (HY.length > 0) return Report.create({
|
|
14407
|
+
schema: HY.join("."),
|
|
14408
|
+
name: VY
|
|
14310
14409
|
});
|
|
14311
|
-
let
|
|
14312
|
-
return
|
|
14313
|
-
...
|
|
14314
|
-
name:
|
|
14410
|
+
let UY = fullnameToCanonical(this, P);
|
|
14411
|
+
return UY ? Report.create({
|
|
14412
|
+
...UY,
|
|
14413
|
+
name: VY
|
|
14315
14414
|
}) : Report.create({
|
|
14316
14415
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
14317
|
-
name:
|
|
14416
|
+
name: VY
|
|
14318
14417
|
});
|
|
14319
14418
|
}
|
|
14320
14419
|
return Report.create(fullnameToCanonical(this, P));
|
|
14321
14420
|
}
|
|
14421
|
+
function getSchemaChain(_, VY) {
|
|
14422
|
+
let P = [], HY = VY;
|
|
14423
|
+
for (; HY;) {
|
|
14424
|
+
let VY = _.symbolParent(HY).find((_) => _ instanceof SchemaSymbol && _.isKind(SymbolKind.Schema));
|
|
14425
|
+
if (!VY || VY.isPublicSchema()) break;
|
|
14426
|
+
P.unshift(VY.name ?? ""), HY = VY;
|
|
14427
|
+
}
|
|
14428
|
+
return P;
|
|
14429
|
+
}
|
|
14322
14430
|
function fullnameToCanonical(_, VY) {
|
|
14323
14431
|
if (!VY.declaration) return VY.name ? {
|
|
14324
14432
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
@@ -14344,16 +14452,19 @@ function fileDependencies(_) {
|
|
|
14344
14452
|
}
|
|
14345
14453
|
return P;
|
|
14346
14454
|
}
|
|
14347
|
-
function
|
|
14348
|
-
let
|
|
14349
|
-
for (;
|
|
14350
|
-
let
|
|
14351
|
-
if (!
|
|
14352
|
-
|
|
14353
|
-
for (let
|
|
14455
|
+
function walkDependencies(_, VY) {
|
|
14456
|
+
let P = /* @__PURE__ */ new Set(), HY = [], UY = [...VY], WY = 0;
|
|
14457
|
+
for (; WY < UY.length;) {
|
|
14458
|
+
let VY = UY[WY++], GY = VY.intern();
|
|
14459
|
+
if (!P.has(GY)) {
|
|
14460
|
+
P.add(GY), HY.push(VY);
|
|
14461
|
+
for (let P of _.fileDependencies(VY)) UY.push(P);
|
|
14354
14462
|
}
|
|
14355
14463
|
}
|
|
14356
|
-
return
|
|
14464
|
+
return HY;
|
|
14465
|
+
}
|
|
14466
|
+
function reachableFiles(_) {
|
|
14467
|
+
return walkDependencies(this, _ ? [_] : this.layout.getEntrypoints());
|
|
14357
14468
|
}
|
|
14358
14469
|
function ast(_) {
|
|
14359
14470
|
return this.bindFile(_), this.parseFile(_).getValue().ast;
|
|
@@ -14404,7 +14515,7 @@ function bindFile(_) {
|
|
|
14404
14515
|
return new Report(void 0, [...VY.getErrors(), ...HY.getErrors()], [...VY.getWarnings(), ...HY.getWarnings()]);
|
|
14405
14516
|
}
|
|
14406
14517
|
function bindProject() {
|
|
14407
|
-
let _ = collectTransitiveDependencies(this, this.layout.
|
|
14518
|
+
let _ = collectTransitiveDependencies(this, this.layout.getEntrypoints()), VY = /* @__PURE__ */ new Map();
|
|
14408
14519
|
for (let P of _) {
|
|
14409
14520
|
let _ = this.bindFile(P);
|
|
14410
14521
|
VY.set(P.absolute, _);
|
|
@@ -14419,7 +14530,7 @@ function interpretFile(_) {
|
|
|
14419
14530
|
}
|
|
14420
14531
|
function interpretProject() {
|
|
14421
14532
|
let _ = [], VY = [], P = /* @__PURE__ */ new Set(), HY = [];
|
|
14422
|
-
for (let _ of this.layout.
|
|
14533
|
+
for (let _ of this.layout.getEntrypoints()) for (let VY of this.reachableFiles(_)) {
|
|
14423
14534
|
let _ = VY.intern();
|
|
14424
14535
|
P.has(_) || (P.add(_), HY.push(VY));
|
|
14425
14536
|
}
|
|
@@ -14427,8 +14538,10 @@ function interpretProject() {
|
|
|
14427
14538
|
for (let P of HY) {
|
|
14428
14539
|
let HY = this.parseFile(P);
|
|
14429
14540
|
_.push(...HY.getErrors()), VY.push(...HY.getWarnings());
|
|
14430
|
-
let WY =
|
|
14431
|
-
|
|
14541
|
+
let WY = this.bindFile(P);
|
|
14542
|
+
_.push(...WY.getErrors()), VY.push(...WY.getWarnings());
|
|
14543
|
+
let GY = HY.getValue().ast, KY = this.nodeSymbol(GY).getFiltered(UNHANDLED), qY = KY ? this.interpretSymbol(KY, P) : Report.create(UNHANDLED), JY = qY.getFiltered(UNHANDLED);
|
|
14544
|
+
JY && UY.set(P.absolute, JY), _.push(...qY.getErrors()), VY.push(...qY.getWarnings());
|
|
14432
14545
|
}
|
|
14433
14546
|
let WY = {};
|
|
14434
14547
|
for (let [_, VY] of UY) WY[_] = VY;
|
|
@@ -14780,7 +14893,47 @@ var Lexer = class {
|
|
|
14780
14893
|
}
|
|
14781
14894
|
}, Parser$1 = class {
|
|
14782
14895
|
constructor(_, VY, P, HY) {
|
|
14783
|
-
this.current = 0, this.errors = [], this.contextStack = new ParsingContextStack(), this.
|
|
14896
|
+
this.current = 0, this.errors = [], this.contextStack = new ParsingContextStack(), this.useSpecifierList = this.contextStack.withContextDo(ParsingContext.BlockExpression, () => {
|
|
14897
|
+
let _ = { specifiers: [] }, VY = () => this.nodeFactory.create(UseSpecifierListNode, _);
|
|
14898
|
+
try {
|
|
14899
|
+
this.consume("Expect an opening brace '{'", SyntaxTokenKind.LBRACE), _.openBrace = this.previous();
|
|
14900
|
+
} catch (_) {
|
|
14901
|
+
if (!(_ instanceof PartialParsingError)) throw _;
|
|
14902
|
+
if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
|
|
14903
|
+
this.synchronizeUseSpecifierList();
|
|
14904
|
+
}
|
|
14905
|
+
for (; !this.isAtEnd() && !this.check(SyntaxTokenKind.RBRACE);) {
|
|
14906
|
+
try {
|
|
14907
|
+
_.specifiers.push(this.useSpecifier());
|
|
14908
|
+
} catch (P) {
|
|
14909
|
+
if (!(P instanceof PartialParsingError)) throw P;
|
|
14910
|
+
if (P.partialNode instanceof UseSpecifierNode && _.specifiers.push(P.partialNode), !this.canHandle(P)) throw new PartialParsingError(P.token, VY(), P.handlerContext);
|
|
14911
|
+
this.synchronizeUseSpecifierList();
|
|
14912
|
+
}
|
|
14913
|
+
if (this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(this.peek())) break;
|
|
14914
|
+
!hasTrailingNewLines(this.previous()) && !this.check(SyntaxTokenKind.RBRACE) && this.logError(this.peek(), CompileErrorCode.MISSING_SPACES, "Expect a newline between use specifiers");
|
|
14915
|
+
}
|
|
14916
|
+
try {
|
|
14917
|
+
this.consume("Expect a closing brace '}'", SyntaxTokenKind.RBRACE), _.closeBrace = this.previous();
|
|
14918
|
+
} catch (_) {
|
|
14919
|
+
if (!(_ instanceof PartialParsingError)) throw _;
|
|
14920
|
+
if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
|
|
14921
|
+
this.synchronizeUseSpecifierList();
|
|
14922
|
+
}
|
|
14923
|
+
return VY();
|
|
14924
|
+
}), this.synchronizeUseSpecifierList = () => {
|
|
14925
|
+
if (!this.check(SyntaxTokenKind.RBRACE)) for (markInvalid(this.advance()); !this.isAtEnd();) {
|
|
14926
|
+
let _ = this.peek();
|
|
14927
|
+
if (this.check(SyntaxTokenKind.RBRACE) || this.check(SyntaxTokenKind.STRING_LITERAL) || this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(_) || isAtStartOfLine(this.previous(), _)) break;
|
|
14928
|
+
markInvalid(_), this.advance();
|
|
14929
|
+
}
|
|
14930
|
+
}, this.synchronizeUseSpecifier = () => {
|
|
14931
|
+
for (; !this.isAtEnd();) {
|
|
14932
|
+
let _ = this.peek();
|
|
14933
|
+
if (this.check(SyntaxTokenKind.RBRACE) || isAtStartOfLine(this.previous(), _)) break;
|
|
14934
|
+
markInvalid(_), this.advance();
|
|
14935
|
+
}
|
|
14936
|
+
}, this.synchronizeProgram = () => {
|
|
14784
14937
|
let _ = this.peek();
|
|
14785
14938
|
_.kind === SyntaxTokenKind.EOF ? this.logError(_, CompileErrorCode.UNEXPECTED_EOF, "Unexpected EOF") : markInvalid(this.advance());
|
|
14786
14939
|
}, this.synchronizeElementDeclarationName = () => {
|
|
@@ -15002,59 +15155,39 @@ var Lexer = class {
|
|
|
15002
15155
|
if (this.advance(), _.useKeyword = this.previous(), this.peek().kind === SyntaxTokenKind.WILDCARD) this.advance(), _.specifiers = this.nodeFactory.create(WildcardNode, { token: this.previous() });
|
|
15003
15156
|
else try {
|
|
15004
15157
|
_.specifiers = this.useSpecifierList();
|
|
15005
|
-
} catch (
|
|
15006
|
-
|
|
15158
|
+
} catch (VY) {
|
|
15159
|
+
if (!(VY instanceof PartialParsingError)) throw VY;
|
|
15160
|
+
VY.partialNode instanceof UseSpecifierListNode && (_.specifiers = VY.partialNode);
|
|
15007
15161
|
}
|
|
15008
15162
|
let P = _.specifiers instanceof WildcardNode ? "'*'" : "specifier list";
|
|
15009
|
-
|
|
15010
|
-
else throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, `Expect 'from' after ${P}`), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
|
|
15011
|
-
if (this.match(SyntaxTokenKind.STRING_LITERAL)) _.importPath = this.previous();
|
|
15012
|
-
else throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect a string literal path"), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
|
|
15013
|
-
return VY();
|
|
15014
|
-
}
|
|
15015
|
-
useSpecifierList() {
|
|
15016
|
-
let _ = { specifiers: [] }, VY = () => this.nodeFactory.create(UseSpecifierListNode, _);
|
|
15017
|
-
try {
|
|
15018
|
-
this.consume("Expect an opening brace '{'", SyntaxTokenKind.LBRACE), _.openBrace = this.previous();
|
|
15019
|
-
} catch (_) {
|
|
15020
|
-
throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
|
|
15021
|
-
}
|
|
15022
|
-
for (; !this.isAtEnd() && !this.check(SyntaxTokenKind.RBRACE);) {
|
|
15023
|
-
try {
|
|
15024
|
-
_.specifiers.push(this.useSpecifier());
|
|
15025
|
-
} catch (P) {
|
|
15026
|
-
throw P instanceof PartialParsingError ? (P.partialNode instanceof UseSpecifierNode && _.specifiers.push(P.partialNode), new PartialParsingError(P.token, VY(), P.handlerContext)) : P;
|
|
15027
|
-
}
|
|
15028
|
-
if (this.check(SyntaxTokenKind.IDENTIFIER) && isFromKeyword(this.peek())) break;
|
|
15029
|
-
!hasTrailingNewLines(this.previous()) && !this.check(SyntaxTokenKind.RBRACE) && this.logError(this.peek(), CompileErrorCode.MISSING_SPACES, "Expect a newline between use specifiers");
|
|
15030
|
-
}
|
|
15031
|
-
try {
|
|
15032
|
-
this.consume("Expect a closing brace '}'", SyntaxTokenKind.RBRACE), _.closeBrace = this.previous();
|
|
15033
|
-
} catch (_) {
|
|
15034
|
-
throw _ instanceof PartialParsingError ? new PartialParsingError(_.token, VY(), _.handlerContext) : _;
|
|
15035
|
-
}
|
|
15036
|
-
return VY();
|
|
15163
|
+
return isFromKeyword(this.peek()) ? _.fromKeyword = this.advance() : this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, `Expect 'from' after ${P}`), this.match(SyntaxTokenKind.STRING_LITERAL) ? _.importPath = this.previous() : this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect a string literal path"), VY();
|
|
15037
15164
|
}
|
|
15038
15165
|
useSpecifier() {
|
|
15039
15166
|
let _ = {}, VY = () => this.nodeFactory.create(UseSpecifierNode, _);
|
|
15040
15167
|
try {
|
|
15041
15168
|
this.consume("Expect an import kind specifier (e.g. table, enum)", SyntaxTokenKind.IDENTIFIER), _.importKind = this.previous();
|
|
15042
15169
|
} catch (_) {
|
|
15043
|
-
|
|
15170
|
+
if (!(_ instanceof PartialParsingError)) throw _;
|
|
15171
|
+
if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
|
|
15172
|
+
this.synchronizeUseSpecifier();
|
|
15044
15173
|
}
|
|
15045
15174
|
if (this.check(SyntaxTokenKind.IDENTIFIER, SyntaxTokenKind.QUOTED_STRING)) try {
|
|
15046
15175
|
_.name = this.normalExpression();
|
|
15047
|
-
} catch (
|
|
15048
|
-
|
|
15176
|
+
} catch (P) {
|
|
15177
|
+
if (!(P instanceof PartialParsingError)) throw P;
|
|
15178
|
+
if (P.partialNode instanceof SyntaxNode && (_.name = P.partialNode), !this.canHandle(P)) throw new PartialParsingError(P.token, VY(), P.handlerContext);
|
|
15179
|
+
this.synchronizeUseSpecifier();
|
|
15049
15180
|
}
|
|
15050
|
-
else this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an element name");
|
|
15181
|
+
else _.importKind && this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an element name");
|
|
15051
15182
|
if (isAsKeyword(this.peek())) {
|
|
15052
15183
|
_.asKeyword = this.advance();
|
|
15053
15184
|
try {
|
|
15054
15185
|
if (!this.check(SyntaxTokenKind.IDENTIFIER, SyntaxTokenKind.QUOTED_STRING)) throw this.logError(this.peek(), CompileErrorCode.UNEXPECTED_TOKEN, "Expect an alias name after 'as'"), new PartialParsingError(this.peek(), VY(), this.contextStack.findHandlerContext(this.tokens, this.current));
|
|
15055
15186
|
_.alias = this.normalExpression();
|
|
15056
15187
|
} catch (_) {
|
|
15057
|
-
|
|
15188
|
+
if (!(_ instanceof PartialParsingError)) throw _;
|
|
15189
|
+
if (!this.canHandle(_)) throw new PartialParsingError(_.token, VY(), _.handlerContext);
|
|
15190
|
+
this.synchronizeUseSpecifier();
|
|
15058
15191
|
}
|
|
15059
15192
|
}
|
|
15060
15193
|
return VY();
|
|
@@ -15434,7 +15567,7 @@ function postfixBindingPower(_) {
|
|
|
15434
15567
|
};
|
|
15435
15568
|
}
|
|
15436
15569
|
function parseFile(_) {
|
|
15437
|
-
let VY = this.
|
|
15570
|
+
let VY = this.getSource(_);
|
|
15438
15571
|
return new Lexer(VY ?? "", _).lex().chain((P) => new Parser$1(VY ?? "", P, this.nodeIdGenerator, _).parse()).map(({ ast: VY, tokens: P }) => ({
|
|
15439
15572
|
ast: VY,
|
|
15440
15573
|
tokens: P,
|
|
@@ -15442,7 +15575,7 @@ function parseFile(_) {
|
|
|
15442
15575
|
}));
|
|
15443
15576
|
}
|
|
15444
15577
|
function parseProject() {
|
|
15445
|
-
let _ = collectTransitiveDependencies(this, this.layout.
|
|
15578
|
+
let _ = collectTransitiveDependencies(this, this.layout.getEntrypoints()), VY = /* @__PURE__ */ new Map();
|
|
15446
15579
|
for (let P of _) {
|
|
15447
15580
|
let _ = this.parseFile(P);
|
|
15448
15581
|
VY.set(P.absolute, _);
|
|
@@ -15513,11 +15646,30 @@ function resolutionIndex() {
|
|
|
15513
15646
|
};
|
|
15514
15647
|
P(VY);
|
|
15515
15648
|
}
|
|
15649
|
+
let GY = /* @__PURE__ */ new Map(), KY = /* @__PURE__ */ new Set();
|
|
15650
|
+
function qY(_, VY) {
|
|
15651
|
+
let P = VY.intern();
|
|
15652
|
+
if (KY.has(P)) return;
|
|
15653
|
+
KY.add(P);
|
|
15654
|
+
let HY = _.symbolMembers(VY).getFiltered(UNHANDLED);
|
|
15655
|
+
if (HY) for (let P of HY) {
|
|
15656
|
+
let HY = P.intern(), UY = GY.get(HY);
|
|
15657
|
+
UY || (UY = [], GY.set(HY, UY)), UY.push(VY), P instanceof SchemaSymbol && P.isKind(SymbolKind.Schema) && qY(_, P);
|
|
15658
|
+
}
|
|
15659
|
+
}
|
|
15660
|
+
for (let _ of P.values()) {
|
|
15661
|
+
let VY = _.getValue().ast, P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
|
|
15662
|
+
P && qY(this, P);
|
|
15663
|
+
}
|
|
15516
15664
|
return {
|
|
15517
15665
|
references: _,
|
|
15518
|
-
metadata: VY
|
|
15666
|
+
metadata: VY,
|
|
15667
|
+
parents: GY
|
|
15519
15668
|
};
|
|
15520
15669
|
}
|
|
15670
|
+
function symbolParent(_) {
|
|
15671
|
+
return this.resolutionIndex().parents.get(_.intern()) ?? [];
|
|
15672
|
+
}
|
|
15521
15673
|
function symbolReferences(_) {
|
|
15522
15674
|
return this.resolutionIndex().references.get(_.intern()) ?? [];
|
|
15523
15675
|
}
|
|
@@ -15626,59 +15778,60 @@ function findReplacements(_, VY, P, HY, UY) {
|
|
|
15626
15778
|
return WY;
|
|
15627
15779
|
}
|
|
15628
15780
|
function renameTable$1(_, VY, P) {
|
|
15629
|
-
let HY =
|
|
15630
|
-
if (!
|
|
15631
|
-
if (
|
|
15632
|
-
let VY =
|
|
15633
|
-
if (this.nodeAlias(VY).getFiltered(UNHANDLED) ===
|
|
15781
|
+
let HY = normalizeTableName(VY), UY = normalizeTableName(P), WY = HY.schema, GY = HY.table, KY = UY.schema, qY = UY.table, JY = lookupTableSymbol(this, _, WY, GY);
|
|
15782
|
+
if (!JY || JY instanceof AliasSymbol || checkForNameCollision(this, _, WY, GY, KY, qY)) return /* @__PURE__ */ new Map();
|
|
15783
|
+
if (JY instanceof UseSymbol && JY.useSpecifierDeclaration instanceof UseSpecifierNode && JY.useSpecifierDeclaration.alias) {
|
|
15784
|
+
let VY = JY.useSpecifierDeclaration;
|
|
15785
|
+
if (this.nodeAlias(VY).getFiltered(UNHANDLED) === GY) return renameAlias(this, _, VY, JY, KY, qY);
|
|
15634
15786
|
}
|
|
15635
|
-
return renameRealDeclaration(this,
|
|
15787
|
+
return renameRealDeclaration(this, JY, WY, GY, KY, qY);
|
|
15636
15788
|
}
|
|
15637
|
-
function renameAlias(_, VY, P, HY, UY, WY
|
|
15638
|
-
let
|
|
15639
|
-
if (!
|
|
15640
|
-
let
|
|
15641
|
-
|
|
15642
|
-
start:
|
|
15643
|
-
end:
|
|
15644
|
-
newText:
|
|
15789
|
+
function renameAlias(_, VY, P, HY, UY, WY) {
|
|
15790
|
+
let GY = _.getSource(VY) ?? "";
|
|
15791
|
+
if (!P.alias) return /* @__PURE__ */ new Map();
|
|
15792
|
+
let KY = formatTableName(UY, WY, GY.substring(P.alias.start, P.alias.end).includes("\"")), qY = [];
|
|
15793
|
+
qY.push({
|
|
15794
|
+
start: P.alias.start,
|
|
15795
|
+
end: P.alias.end,
|
|
15796
|
+
newText: KY.formattedTable
|
|
15645
15797
|
});
|
|
15646
|
-
let
|
|
15647
|
-
for (let _ of
|
|
15798
|
+
let JY = _.symbolReferences(HY);
|
|
15799
|
+
for (let _ of JY) _.filepath.absolute === VY.absolute && _ !== P.alias && qY.push({
|
|
15648
15800
|
start: _.start,
|
|
15649
15801
|
end: _.end,
|
|
15650
|
-
newText:
|
|
15802
|
+
newText: KY.formattedTable
|
|
15651
15803
|
});
|
|
15652
|
-
return VY.
|
|
15804
|
+
return new Map([[VY.absolute, applyTextEdits(GY, qY)]]);
|
|
15653
15805
|
}
|
|
15654
|
-
function renameRealDeclaration(_, VY, P, HY, UY, WY
|
|
15655
|
-
let
|
|
15656
|
-
if (!
|
|
15657
|
-
let
|
|
15658
|
-
if (!
|
|
15659
|
-
let
|
|
15660
|
-
let P = _.absolute, HY =
|
|
15806
|
+
function renameRealDeclaration(_, VY, P, HY, UY, WY) {
|
|
15807
|
+
let GY = VY.originalSymbol, KY = GY.declaration;
|
|
15808
|
+
if (!KY || !(KY instanceof ElementDeclarationNode)) return /* @__PURE__ */ new Map();
|
|
15809
|
+
let qY = KY.filepath;
|
|
15810
|
+
if (!qY) return /* @__PURE__ */ new Map();
|
|
15811
|
+
let JY = formatTableName(UY, WY, checkIfDeclarationUsesQuotes(KY, _.getSource(qY) ?? "")), YY = /* @__PURE__ */ new Map(), XY = (_, VY) => {
|
|
15812
|
+
let P = _.absolute, HY = YY.get(P);
|
|
15661
15813
|
HY || (HY = {
|
|
15662
15814
|
fp: _,
|
|
15663
15815
|
edits: []
|
|
15664
|
-
},
|
|
15665
|
-
},
|
|
15666
|
-
|
|
15667
|
-
start:
|
|
15668
|
-
end:
|
|
15669
|
-
newText: buildReplacementText(
|
|
15816
|
+
}, YY.set(P, HY)), HY.edits.push(VY);
|
|
15817
|
+
}, ZY = KY.name;
|
|
15818
|
+
ZY && XY(qY, {
|
|
15819
|
+
start: ZY.start,
|
|
15820
|
+
end: ZY.end,
|
|
15821
|
+
newText: buildReplacementText(JY)
|
|
15670
15822
|
});
|
|
15671
|
-
let
|
|
15672
|
-
for (let VY of
|
|
15673
|
-
if (VY ===
|
|
15674
|
-
let
|
|
15675
|
-
for (let _ of findReplacements([VY],
|
|
15676
|
-
}
|
|
15677
|
-
|
|
15678
|
-
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15823
|
+
let QY = _.symbolReferences(GY);
|
|
15824
|
+
for (let VY of QY) {
|
|
15825
|
+
if (VY === ZY) continue;
|
|
15826
|
+
let UY = VY.filepath, WY = _.getSource(UY) ?? "";
|
|
15827
|
+
for (let _ of findReplacements([VY], P, HY, JY, WY)) XY(UY, _);
|
|
15828
|
+
}
|
|
15829
|
+
let $Y = /* @__PURE__ */ new Map();
|
|
15830
|
+
for (let { fp: VY, edits: P } of YY.values()) {
|
|
15831
|
+
let HY = _.getSource(VY) ?? "";
|
|
15832
|
+
$Y.set(VY.absolute, applyTextEdits(HY, P));
|
|
15833
|
+
}
|
|
15834
|
+
return $Y;
|
|
15682
15835
|
}
|
|
15683
15836
|
function findDiagramViewBlocks$1(_) {
|
|
15684
15837
|
let VY = [], P = new Lexer(_, DEFAULT_ENTRY).lex();
|
|
@@ -15741,7 +15894,7 @@ function generateDiagramViewBlock(_, VY) {
|
|
|
15741
15894
|
return YY.length > 0 && emitTablesBlock(eX, YY), XY.length > 0 && emitTableGroupsBlock(eX, XY), ZY.length > 0 && emitSchemasBlock(eX, ZY), $Y && emitNotesBlock(eX, GY), eX.push("}"), eX.join("\n");
|
|
15742
15895
|
}
|
|
15743
15896
|
function syncDiagramView$1(_, VY, P) {
|
|
15744
|
-
let HY = this.
|
|
15897
|
+
let HY = this.getSource(_) ?? "", UY = P ?? findDiagramViewBlocks$1(HY), WY = [];
|
|
15745
15898
|
for (let _ of VY) {
|
|
15746
15899
|
let VY = applyOperation(HY, _, UY);
|
|
15747
15900
|
WY.push(...VY);
|
|
@@ -15801,12 +15954,12 @@ function computeDeleteEdit(_, VY, P) {
|
|
|
15801
15954
|
}];
|
|
15802
15955
|
}
|
|
15803
15956
|
var COMPUTING = Symbol("COMPUTING"), Compiler = class {
|
|
15804
|
-
constructor() {
|
|
15805
|
-
this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.
|
|
15957
|
+
constructor(_ = new MemoryProjectLayout()) {
|
|
15958
|
+
this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(parseFile), this.parseProject = this.globalQuery(parseProject), this.validateNode = this.localQuery(validateNode), this.validateFile = this.localQuery(validateFile), this.nodeFullname = this.localQuery(nodeFullname), this.nodeAlias = this.localQuery(nodeAlias), this.nodeSettings = this.localQuery(nodeSettings), this.canonicalName = this.globalQuery(canonicalName), this.bindNode = this.globalQuery(bindNode), this.bindFile = this.globalQuery(bindFile), this.bindProject = this.globalQuery(bindProject), this.interpretSymbol = this.globalQuery(interpretSymbol), this.interpretMetadata = interpretMetadata.bind(this), this.interpretFile = this.globalQuery(interpretFile), this.interpretProject = this.globalQuery(interpretProject), this.nodeSymbol = this.globalQuery(nodeSymbol), this.nodeMetadata = this.globalQuery(nodeMetadata), this.symbolMembers = this.globalQuery(symbolMembers), this.lookupMembers = this.globalQuery(lookupMembers), this.nodeReferee = this.globalQuery(nodeReferee), this.resolutionIndex = this.globalQuery(resolutionIndex), this.symbolReferences = this.globalQuery(symbolReferences), this.symbolParent = this.globalQuery(symbolParent), this.symbolMetadata = this.globalQuery(symbolMetadata), this.symbolAliases = this.globalQuery(symbolAliases), this.symbolUses = this.globalQuery(symbolUses), this.fileDependencies = this.localQuery(fileDependencies), this.reachableFiles = this.globalQuery(reachableFiles), this.usableMembers = this.globalQuery(usableMembers), this.nodeAtPosition = this.localQuery(nodeAtPosition), this.renameTable = renameTable$1.bind(this), this.syncDiagramView = syncDiagramView$1.bind(this), this.token = {
|
|
15806
15959
|
invalidStream: this.localQuery(invalidStream),
|
|
15807
15960
|
flatStream: this.localQuery(flatStream)
|
|
15808
15961
|
}, this.parse = {
|
|
15809
|
-
source: (_) => this.
|
|
15962
|
+
source: (_) => this.getSource(_) || "",
|
|
15810
15963
|
ast: (_ = DEFAULT_ENTRY) => ast.call(this, _),
|
|
15811
15964
|
errors: (_ = DEFAULT_ENTRY) => errors.call(this, _),
|
|
15812
15965
|
warnings: (_ = DEFAULT_ENTRY) => warnings.call(this, _),
|
|
@@ -15819,21 +15972,25 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
|
|
|
15819
15972
|
element: this.localQuery(containerElement),
|
|
15820
15973
|
scope: this.localQuery(containerScope),
|
|
15821
15974
|
scopeKind: this.localQuery(containerScopeKind)
|
|
15822
|
-
};
|
|
15975
|
+
}, this.layout = _;
|
|
15823
15976
|
}
|
|
15824
|
-
|
|
15825
|
-
this.layout.
|
|
15977
|
+
getSource(_) {
|
|
15978
|
+
return this.layout.getSource(_);
|
|
15826
15979
|
}
|
|
15827
|
-
|
|
15828
|
-
|
|
15980
|
+
cleanStaleLocalCache(_) {
|
|
15981
|
+
let VY = this.layout.getSource(_), P = _.absolute;
|
|
15982
|
+
this.sourceSnapshot.has(P) && this.sourceSnapshot.get(P) !== VY && (this.localCache.delete(_.intern()), this.globalCache.clear()), this.sourceSnapshot.set(P, VY);
|
|
15829
15983
|
}
|
|
15830
|
-
|
|
15831
|
-
|
|
15984
|
+
cleanStaleGlobalCache() {
|
|
15985
|
+
let _ = this.layout.getEntrypoints(), VY = !1;
|
|
15986
|
+
this.entrypointsSnapshot !== void 0 && (this.entrypointsSnapshot.length !== _.length || this.entrypointsSnapshot.some((VY, P) => VY.absolute !== _[P].absolute)) && (VY = !0), this.entrypointsSnapshot = _;
|
|
15987
|
+
for (let VY of walkDependencies(this, _)) this.cleanStaleLocalCache(VY);
|
|
15988
|
+
VY && this.globalCache.clear();
|
|
15832
15989
|
}
|
|
15833
15990
|
globalQuery(_) {
|
|
15834
15991
|
let VY = Symbol();
|
|
15835
15992
|
return ((...P) => {
|
|
15836
|
-
this.globalCache.has(VY) || this.globalCache.set(VY, /* @__PURE__ */ new Map());
|
|
15993
|
+
this.cleanStaleGlobalCache(), this.globalCache.has(VY) || this.globalCache.set(VY, /* @__PURE__ */ new Map());
|
|
15837
15994
|
let HY = P.map((_) => intern(_)).join("\0"), UY = this.globalCache.get(VY);
|
|
15838
15995
|
if (UY.has(HY)) {
|
|
15839
15996
|
let VY = UY.get(HY);
|
|
@@ -15852,25 +16009,27 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
|
|
|
15852
16009
|
localQuery(_) {
|
|
15853
16010
|
let VY = Symbol();
|
|
15854
16011
|
return ((...P) => {
|
|
15855
|
-
let [HY] = P, UY =
|
|
15856
|
-
|
|
15857
|
-
let
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
16012
|
+
let [HY] = P, UY = HY instanceof SyntaxNode ? HY.filepath : HY;
|
|
16013
|
+
this.cleanStaleLocalCache(UY);
|
|
16014
|
+
let WY = UY.intern(), GY = P.map((_) => intern(_)).join("\0"), KY = this.localCache.get(WY);
|
|
16015
|
+
KY || (KY = /* @__PURE__ */ new Map(), this.localCache.set(WY, KY));
|
|
16016
|
+
let qY = KY.get(VY);
|
|
16017
|
+
if (qY || (qY = /* @__PURE__ */ new Map(), KY.set(VY, qY)), qY.has(GY)) {
|
|
16018
|
+
let VY = qY.get(GY);
|
|
16019
|
+
if (VY === COMPUTING) throw Error(`Cycle detected in query: ${_.name}(${WY}, ${GY})`);
|
|
15861
16020
|
return VY;
|
|
15862
16021
|
}
|
|
15863
|
-
|
|
16022
|
+
qY.set(GY, COMPUTING);
|
|
15864
16023
|
try {
|
|
15865
16024
|
let VY = _.apply(this, P);
|
|
15866
|
-
return
|
|
16025
|
+
return qY.set(GY, VY), VY;
|
|
15867
16026
|
} catch (_) {
|
|
15868
|
-
throw
|
|
16027
|
+
throw qY.delete(GY), _;
|
|
15869
16028
|
}
|
|
15870
16029
|
});
|
|
15871
16030
|
}
|
|
15872
16031
|
findDiagramViewBlocks(_) {
|
|
15873
|
-
return findDiagramViewBlocks$1(this.
|
|
16032
|
+
return findDiagramViewBlocks$1(this.getSource(_) ?? "");
|
|
15874
16033
|
}
|
|
15875
16034
|
initMonacoServices(_) {
|
|
15876
16035
|
let VY = _?.autocompletion?.triggerCharacters ?? [
|
|
@@ -1825423,9 +1825582,9 @@ var init_actions = __esmMin((() => {
|
|
|
1825423
1825582
|
return import_postgresParser.default.parse(_);
|
|
1825424
1825583
|
}
|
|
1825425
1825584
|
static parseDBMLToJSONv2(_, VY) {
|
|
1825426
|
-
let P = VY || new Compiler();
|
|
1825427
|
-
|
|
1825428
|
-
let
|
|
1825585
|
+
let P = VY || new Compiler(), HY = new MemoryProjectLayout();
|
|
1825586
|
+
HY.setSource(DEFAULT_ENTRY, _), P.layout = HY;
|
|
1825587
|
+
let UY = P.parse.errors(DEFAULT_ENTRY).map((_) => ({
|
|
1825429
1825588
|
message: _.diagnostic,
|
|
1825430
1825589
|
location: {
|
|
1825431
1825590
|
start: {
|
|
@@ -1825439,7 +1825598,7 @@ var init_actions = __esmMin((() => {
|
|
|
1825439
1825598
|
},
|
|
1825440
1825599
|
code: _.code
|
|
1825441
1825600
|
}));
|
|
1825442
|
-
if (
|
|
1825601
|
+
if (UY.length > 0) throw CompilerError.create(UY);
|
|
1825443
1825602
|
return P.parse.rawDb(DEFAULT_ENTRY);
|
|
1825444
1825603
|
}
|
|
1825445
1825604
|
static parseDBMLToJSON(_) {
|
|
@@ -1825635,16 +1825794,22 @@ var import_default = {
|
|
|
1825635
1825794
|
generateDbml
|
|
1825636
1825795
|
};
|
|
1825637
1825796
|
function renameTable(_, VY, P) {
|
|
1825638
|
-
let HY = new
|
|
1825639
|
-
|
|
1825797
|
+
let HY = new MemoryProjectLayout();
|
|
1825798
|
+
HY.setSource(DEFAULT_ENTRY, P);
|
|
1825799
|
+
let UY = new Compiler();
|
|
1825800
|
+
return UY.layout = HY, UY.renameTable(DEFAULT_ENTRY, _, VY).get(DEFAULT_ENTRY.absolute) ?? P;
|
|
1825640
1825801
|
}
|
|
1825641
1825802
|
function syncDiagramView(_, VY, P) {
|
|
1825642
|
-
let HY = new
|
|
1825643
|
-
|
|
1825803
|
+
let HY = new MemoryProjectLayout();
|
|
1825804
|
+
HY.setSource(DEFAULT_ENTRY, _);
|
|
1825805
|
+
let UY = new Compiler();
|
|
1825806
|
+
return UY.layout = HY, UY.syncDiagramView(DEFAULT_ENTRY, VY, P);
|
|
1825644
1825807
|
}
|
|
1825645
1825808
|
function findDiagramViewBlocks(_) {
|
|
1825646
|
-
let VY = new
|
|
1825647
|
-
|
|
1825809
|
+
let VY = new MemoryProjectLayout();
|
|
1825810
|
+
VY.setSource(DEFAULT_ENTRY, _);
|
|
1825811
|
+
let P = new Compiler();
|
|
1825812
|
+
return P.layout = VY, P.findDiagramViewBlocks(DEFAULT_ENTRY);
|
|
1825648
1825813
|
}
|
|
1825649
|
-
const VERSION = "8.0.0-alpha.
|
|
1825814
|
+
const VERSION = "8.0.0-alpha.11";
|
|
1825650
1825815
|
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, dbmlMonarchTokensProvider, export_default as exporter, findDiagramViewBlocks, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, syncDiagramView, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString };
|