@dbml/parse 10.1.0-alpha.0 → 10.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbml-parse.js +12 -12
- package/dist/dbml-parse.mjs +315 -346
- package/dist/src/compiler/index.d.ts +1 -1
- package/dist/src/compiler/queries/transform/syncDep.d.ts +1 -1
- package/dist/src/compiler/queries/transform/utils/dep.d.ts +26 -0
- package/dist/src/compiler/queries/transform/utils/index.d.ts +1 -2
- package/package.json +2 -2
package/dist/dbml-parse.mjs
CHANGED
|
@@ -13771,13 +13771,13 @@ var jb = class {
|
|
|
13771
13771
|
createDiagnostic(e, t) {
|
|
13772
13772
|
let n = e.nodeOrToken, r = n.startPos, i = n.endPos, a = e.details, o = a?.quickFixes?.filter((e) => e.edits.length > 0).map((e) => ({
|
|
13773
13773
|
title: e.title,
|
|
13774
|
-
|
|
13774
|
+
shortTitle: e.shortTitle,
|
|
13775
13775
|
edits: e.edits.map((e) => ({
|
|
13776
13776
|
start: e.start,
|
|
13777
13777
|
end: e.end,
|
|
13778
13778
|
newText: e.newText
|
|
13779
13779
|
})),
|
|
13780
|
-
|
|
13780
|
+
isPreferred: e.isPreferred
|
|
13781
13781
|
}));
|
|
13782
13782
|
return {
|
|
13783
13783
|
type: t,
|
|
@@ -13787,10 +13787,10 @@ var jb = class {
|
|
|
13787
13787
|
endRow: i.line + 1,
|
|
13788
13788
|
endColumn: i.column + 1,
|
|
13789
13789
|
code: e.code,
|
|
13790
|
-
|
|
13791
|
-
|
|
13790
|
+
category: a?.category,
|
|
13791
|
+
explanation: a?.explanation,
|
|
13792
13792
|
filepath: e.filepath,
|
|
13793
|
-
|
|
13793
|
+
quickFixes: o
|
|
13794
13794
|
};
|
|
13795
13795
|
}
|
|
13796
13796
|
getSeverityValue(e) {
|
|
@@ -16491,23 +16491,56 @@ function cC(e, t, n) {
|
|
|
16491
16491
|
return sC(r, i, s) && sC(a, o, c) || sC(r, i, c) && sC(a, o, s);
|
|
16492
16492
|
}
|
|
16493
16493
|
//#endregion
|
|
16494
|
+
//#region src/compiler/queries/transform/utils/dep.ts
|
|
16495
|
+
function lC(e, t, n) {
|
|
16496
|
+
let r = hC(e, t, pC(n.schemaName), n.tableName, F.Table);
|
|
16497
|
+
return {
|
|
16498
|
+
table: r,
|
|
16499
|
+
columns: (n.fieldNames ?? []).map((t) => r ? e.lookupMembers(r, F.Column, t) : void 0)
|
|
16500
|
+
};
|
|
16501
|
+
}
|
|
16502
|
+
function uC(e, t) {
|
|
16503
|
+
let n = e?.originalSymbol.declaration;
|
|
16504
|
+
return !!n && n === t?.originalSymbol.declaration;
|
|
16505
|
+
}
|
|
16506
|
+
function dC(e, t, n) {
|
|
16507
|
+
return !uC(e, n.table) || t.length !== n.columns.length ? !1 : t.every((e, t) => uC(e, n.columns[t]));
|
|
16508
|
+
}
|
|
16509
|
+
function fC(e, n, r) {
|
|
16510
|
+
let a = e.parseFile(n).getValue().ast, o = e.nodeSymbol(a).getFiltered(t);
|
|
16511
|
+
if (!o) return;
|
|
16512
|
+
let s = lC(e, n, r.upstream), c = lC(e, n, r.downstream);
|
|
16513
|
+
if (!s.table || !c.table) return;
|
|
16514
|
+
let l = e.getSource(n) ?? "";
|
|
16515
|
+
for (let t of e.symbolMetadata(o)) {
|
|
16516
|
+
if (!(t instanceof Km)) continue;
|
|
16517
|
+
let n = t.upstreamTables(e), r = t.upstreamColumns(e), a = t.downstreamTables(e), o = t.downstreamColumns(e);
|
|
16518
|
+
if (!n.some((e, t) => dC(n[t], r[t] ?? [], s) && dC(a[t], o[t] ?? [], c))) continue;
|
|
16519
|
+
if (t.declaration instanceof R) return {
|
|
16520
|
+
kind: "block",
|
|
16521
|
+
declaration: t.declaration
|
|
16522
|
+
};
|
|
16523
|
+
let u = t.declaration.parentOfKind(H);
|
|
16524
|
+
if (!u) continue;
|
|
16525
|
+
let d = Og(u, i.Dep, l);
|
|
16526
|
+
if (!d) continue;
|
|
16527
|
+
let f = t.declaration.value;
|
|
16528
|
+
if (!(f instanceof B)) continue;
|
|
16529
|
+
let p = f.op?.value;
|
|
16530
|
+
if (p) return {
|
|
16531
|
+
kind: "inline",
|
|
16532
|
+
op: p,
|
|
16533
|
+
fullStart: d.start,
|
|
16534
|
+
fullEnd: d.end
|
|
16535
|
+
};
|
|
16536
|
+
}
|
|
16537
|
+
}
|
|
16538
|
+
//#endregion
|
|
16494
16539
|
//#region src/compiler/queries/transform/utils/index.ts
|
|
16495
|
-
function
|
|
16540
|
+
function pC(e) {
|
|
16496
16541
|
return e && e.length > 0 ? e : v;
|
|
16497
16542
|
}
|
|
16498
|
-
function
|
|
16499
|
-
if (lC(e.schemaName) !== lC(t.schemaName) || e.tableName !== t.tableName) return !1;
|
|
16500
|
-
let n = e.fieldNames ?? [], r = t.fieldNames ?? [];
|
|
16501
|
-
return n.length === r.length ? n.every((e, t) => e === r[t]) : !1;
|
|
16502
|
-
}
|
|
16503
|
-
function dC(e, t) {
|
|
16504
|
-
if (lC(e.schemaName) !== lC(t.schemaName) || e.tableName !== t.tableName) return !1;
|
|
16505
|
-
let n = t.fieldNames ?? [];
|
|
16506
|
-
if (n.length === 0) return !0;
|
|
16507
|
-
let r = e.fieldNames ?? [];
|
|
16508
|
-
return r.length === n.length ? r.every((e, t) => e === n[t]) : !1;
|
|
16509
|
-
}
|
|
16510
|
-
function fC(e) {
|
|
16543
|
+
function mC(e) {
|
|
16511
16544
|
if (typeof e != "string") return {
|
|
16512
16545
|
schema: e.schema ?? "public",
|
|
16513
16546
|
table: e.table
|
|
@@ -16531,33 +16564,33 @@ function fC(e) {
|
|
|
16531
16564
|
table: n
|
|
16532
16565
|
};
|
|
16533
16566
|
}
|
|
16534
|
-
function
|
|
16567
|
+
function hC(e, n, r, i, a = F.Table) {
|
|
16535
16568
|
let o = e.parseFile(n).getValue().ast, s = e.nodeSymbol(o).getFiltered(t);
|
|
16536
16569
|
if (!s) return;
|
|
16537
16570
|
if (r === "public") return e.lookupMembers(s, a, i) ?? void 0;
|
|
16538
16571
|
let c = e.lookupMembers(s, F.Schema, r);
|
|
16539
16572
|
if (c) return e.lookupMembers(c, a, i) ?? void 0;
|
|
16540
16573
|
}
|
|
16541
|
-
function
|
|
16574
|
+
function gC(e) {
|
|
16542
16575
|
return e.startsWith("\"") && e.endsWith("\"") && e.length >= 2 ? e.slice(1, -1) : e;
|
|
16543
16576
|
}
|
|
16544
|
-
function
|
|
16577
|
+
function _C(e) {
|
|
16545
16578
|
let t = [];
|
|
16546
16579
|
e.schemaName && e.schemaName !== "public" && t.push(R_(e.schemaName)), t.push(R_(e.tableName));
|
|
16547
16580
|
for (let n of e.fieldNames ?? []) t.push(R_(n));
|
|
16548
16581
|
return t.join(".");
|
|
16549
16582
|
}
|
|
16550
|
-
function
|
|
16583
|
+
function vC(e, t) {
|
|
16551
16584
|
return t === void 0 ? e : t === null ? "" : `${e}: ${t}`;
|
|
16552
16585
|
}
|
|
16553
16586
|
//#endregion
|
|
16554
16587
|
//#region src/compiler/queries/transform/renameTable.ts
|
|
16555
|
-
function
|
|
16588
|
+
function yC(e, t) {
|
|
16556
16589
|
if (!e || !(e instanceof R)) return !1;
|
|
16557
16590
|
let n = e.name;
|
|
16558
16591
|
return n ? t.substring(n.start, n.end).includes("\"") : !1;
|
|
16559
16592
|
}
|
|
16560
|
-
function
|
|
16593
|
+
function bC(e, t, n) {
|
|
16561
16594
|
let r = !L_(t), i = !L_(e), a = n || r, o = n || i;
|
|
16562
16595
|
return {
|
|
16563
16596
|
schema: e,
|
|
@@ -16568,10 +16601,10 @@ function vC(e, t, n) {
|
|
|
16568
16601
|
shouldQuoteTable: a
|
|
16569
16602
|
};
|
|
16570
16603
|
}
|
|
16571
|
-
function
|
|
16572
|
-
return n === i && r === a ? !1 :
|
|
16604
|
+
function xC(e, t, n, r, i, a) {
|
|
16605
|
+
return n === i && r === a ? !1 : hC(e, t, i, a) !== void 0;
|
|
16573
16606
|
}
|
|
16574
|
-
function
|
|
16607
|
+
function SC(e, t, n) {
|
|
16575
16608
|
let r = e.start - 1;
|
|
16576
16609
|
for (; r >= 0 && /\s/.test(n[r]);) r--;
|
|
16577
16610
|
if (r < 0 || n[r] !== ".") return null;
|
|
@@ -16586,19 +16619,19 @@ function bC(e, t, n) {
|
|
|
16586
16619
|
for (a = r + 1; r >= 0 && /[a-zA-Z0-9_]/.test(n[r]);) r--;
|
|
16587
16620
|
i = r + 1;
|
|
16588
16621
|
}
|
|
16589
|
-
return
|
|
16622
|
+
return gC(n.substring(i, a)) === t ? {
|
|
16590
16623
|
start: i,
|
|
16591
16624
|
end: e.end
|
|
16592
16625
|
} : null;
|
|
16593
16626
|
}
|
|
16594
|
-
function
|
|
16627
|
+
function CC(e) {
|
|
16595
16628
|
return e.schema === "public" ? e.formattedTable : `${e.formattedSchema}.${e.formattedTable}`;
|
|
16596
16629
|
}
|
|
16597
|
-
function
|
|
16598
|
-
let a = [], o = /* @__PURE__ */ new Set(), s =
|
|
16630
|
+
function wC(e, t, n, r, i) {
|
|
16631
|
+
let a = [], o = /* @__PURE__ */ new Set(), s = CC(r);
|
|
16599
16632
|
for (let r of e) {
|
|
16600
|
-
if (
|
|
16601
|
-
let e =
|
|
16633
|
+
if (gC(i.substring(r.start, r.end)) !== n) continue;
|
|
16634
|
+
let e = SC(r, t, i) ?? {
|
|
16602
16635
|
start: r.start,
|
|
16603
16636
|
end: r.end
|
|
16604
16637
|
}, c = `${e.start}-${e.end}`;
|
|
@@ -16610,19 +16643,19 @@ function SC(e, t, n, r, i) {
|
|
|
16610
16643
|
}
|
|
16611
16644
|
return a;
|
|
16612
16645
|
}
|
|
16613
|
-
function
|
|
16614
|
-
let i =
|
|
16615
|
-
if (!u || u instanceof cm ||
|
|
16646
|
+
function TC(e, n, r) {
|
|
16647
|
+
let i = mC(n), a = mC(r), o = i.schema, s = i.table, c = a.schema, l = a.table, u = hC(this, e, o, s);
|
|
16648
|
+
if (!u || u instanceof cm || xC(this, e, o, s, c, l)) return /* @__PURE__ */ new Map();
|
|
16616
16649
|
if (u instanceof lm && u.useSpecifierDeclaration instanceof mm && u.useSpecifierDeclaration.alias) {
|
|
16617
16650
|
let n = u.useSpecifierDeclaration;
|
|
16618
|
-
if (this.nodeAlias(n).getFiltered(t) === s) return
|
|
16651
|
+
if (this.nodeAlias(n).getFiltered(t) === s) return EC(this, e, n, u, c, l);
|
|
16619
16652
|
}
|
|
16620
|
-
return
|
|
16653
|
+
return DC(this, u, o, s, c, l);
|
|
16621
16654
|
}
|
|
16622
|
-
function
|
|
16655
|
+
function EC(e, t, n, r, i, a) {
|
|
16623
16656
|
let o = e.getSource(t) ?? "";
|
|
16624
16657
|
if (!n.alias) return /* @__PURE__ */ new Map();
|
|
16625
|
-
let s =
|
|
16658
|
+
let s = bC(i, a, o.substring(n.alias.start, n.alias.end).includes("\"")), c = [];
|
|
16626
16659
|
c.push({
|
|
16627
16660
|
start: n.alias.start,
|
|
16628
16661
|
end: n.alias.end,
|
|
@@ -16636,12 +16669,12 @@ function wC(e, t, n, r, i, a) {
|
|
|
16636
16669
|
});
|
|
16637
16670
|
return new Map([[t.absolute, aC(o, c)]]);
|
|
16638
16671
|
}
|
|
16639
|
-
function
|
|
16672
|
+
function DC(e, t, n, r, i, a) {
|
|
16640
16673
|
let o = t.originalSymbol, s = o.declaration;
|
|
16641
16674
|
if (!s || !(s instanceof R)) return /* @__PURE__ */ new Map();
|
|
16642
16675
|
let c = s.filepath;
|
|
16643
16676
|
if (!c) return /* @__PURE__ */ new Map();
|
|
16644
|
-
let l =
|
|
16677
|
+
let l = bC(i, a, yC(s, e.getSource(c) ?? "")), u = /* @__PURE__ */ new Map(), d = (e, t) => {
|
|
16645
16678
|
let n = e.absolute, r = u.get(n);
|
|
16646
16679
|
r || (r = {
|
|
16647
16680
|
fp: e,
|
|
@@ -16651,13 +16684,13 @@ function TC(e, t, n, r, i, a) {
|
|
|
16651
16684
|
f && d(c, {
|
|
16652
16685
|
start: f.start,
|
|
16653
16686
|
end: f.end,
|
|
16654
|
-
newText:
|
|
16687
|
+
newText: CC(l)
|
|
16655
16688
|
});
|
|
16656
16689
|
let p = e.symbolReferences(o);
|
|
16657
16690
|
for (let t of p) {
|
|
16658
16691
|
if (t === f) continue;
|
|
16659
16692
|
let i = t.filepath, a = e.getSource(i) ?? "";
|
|
16660
|
-
for (let e of
|
|
16693
|
+
for (let e of wC([t], n, r, l, a)) d(i, e);
|
|
16661
16694
|
}
|
|
16662
16695
|
let m = /* @__PURE__ */ new Map();
|
|
16663
16696
|
for (let { fp: t, edits: n } of u.values()) {
|
|
@@ -16667,26 +16700,204 @@ function TC(e, t, n, r, i, a) {
|
|
|
16667
16700
|
return m;
|
|
16668
16701
|
}
|
|
16669
16702
|
//#endregion
|
|
16703
|
+
//#region src/compiler/queries/transform/updateElementSetting.ts
|
|
16704
|
+
function OC(e, t, n, r) {
|
|
16705
|
+
if (t.kind === "dep") return jC(this, e, t, n, r);
|
|
16706
|
+
if (t.kind === "ref") return MC(this, e, t, n, r);
|
|
16707
|
+
let i = AC(this, e, t);
|
|
16708
|
+
if (!i) return [];
|
|
16709
|
+
let a = Dg(i, n, r, this.getSource(e) ?? "");
|
|
16710
|
+
return a ? [a] : [];
|
|
16711
|
+
}
|
|
16712
|
+
function kC(e, t, n, r) {
|
|
16713
|
+
let i = this.getSource(e) ?? "", a = this.updateElementSettingEdit(e, t, n, r);
|
|
16714
|
+
return a.length === 0 ? i : aC(i, a);
|
|
16715
|
+
}
|
|
16716
|
+
function AC(e, t, n) {
|
|
16717
|
+
let r = ("schema" in n ? n.schema : void 0) ?? "public";
|
|
16718
|
+
switch (n.kind) {
|
|
16719
|
+
case F.Column: {
|
|
16720
|
+
let i = hC(e, t, r, n.table, F.Table);
|
|
16721
|
+
return i ? e.lookupMembers(i, F.Column, n.column)?.declaration : void 0;
|
|
16722
|
+
}
|
|
16723
|
+
case F.Table: return hC(e, t, r, n.table)?.declaration;
|
|
16724
|
+
case F.Enum:
|
|
16725
|
+
case F.StickyNote:
|
|
16726
|
+
case F.TableGroup: return hC(e, t, r, n.name, n.kind)?.declaration;
|
|
16727
|
+
case F.Schema: return hC(e, t, n.schema, "", F.Schema)?.declaration;
|
|
16728
|
+
default: return;
|
|
16729
|
+
}
|
|
16730
|
+
}
|
|
16731
|
+
function jC(e, t, n, r, i) {
|
|
16732
|
+
let a = e.getSource(t) ?? "", o = fC(e, t, n);
|
|
16733
|
+
if (!o) return [];
|
|
16734
|
+
if (o.kind === "inline") {
|
|
16735
|
+
if (i === null) return [];
|
|
16736
|
+
let e = _C(n.upstream), t = _C(n.downstream), s = vC(r, i), c = s ? `Dep [${s}] {\n ${e} -> ${t}\n}` : `Dep {\n ${e} -> ${t}\n}`;
|
|
16737
|
+
return [{
|
|
16738
|
+
start: o.fullStart,
|
|
16739
|
+
end: o.fullEnd,
|
|
16740
|
+
newText: ""
|
|
16741
|
+
}, {
|
|
16742
|
+
start: a.length,
|
|
16743
|
+
end: a.length,
|
|
16744
|
+
newText: "\n\n" + c + "\n"
|
|
16745
|
+
}];
|
|
16746
|
+
}
|
|
16747
|
+
let { declaration: s } = o, { body: c } = s;
|
|
16748
|
+
if (c instanceof H) {
|
|
16749
|
+
let e = Dg(s, r, i, a);
|
|
16750
|
+
if (e) return [e];
|
|
16751
|
+
let t = Dg(c, r, i, a);
|
|
16752
|
+
return t ? [t] : [];
|
|
16753
|
+
}
|
|
16754
|
+
let l = Dg(s, r, i, a);
|
|
16755
|
+
return l ? [l] : [];
|
|
16756
|
+
}
|
|
16757
|
+
function MC(e, t, n, r, i) {
|
|
16758
|
+
let a = e.getSource(t) ?? "", o = oC(e, t, n);
|
|
16759
|
+
if (!o) return [];
|
|
16760
|
+
if (o.kind === "inline") {
|
|
16761
|
+
if (i === null) return [];
|
|
16762
|
+
let e = _C(n.endpoints[0]), t = _C(n.endpoints[1]), s = vC(r, i), c = s ? `Ref: ${e} ${o.op} ${t} [${s}]` : `Ref: ${e} ${o.op} ${t}`;
|
|
16763
|
+
return [{
|
|
16764
|
+
start: o.fullStart,
|
|
16765
|
+
end: o.fullEnd,
|
|
16766
|
+
newText: ""
|
|
16767
|
+
}, {
|
|
16768
|
+
start: a.length,
|
|
16769
|
+
end: a.length,
|
|
16770
|
+
newText: "\n\n" + c + "\n"
|
|
16771
|
+
}];
|
|
16772
|
+
}
|
|
16773
|
+
let s = Dg(o.node, r, i, a);
|
|
16774
|
+
return s ? [s] : [];
|
|
16775
|
+
}
|
|
16776
|
+
//#endregion
|
|
16777
|
+
//#region src/compiler/queries/transform/syncDiagramView.ts
|
|
16778
|
+
function NC(e) {
|
|
16779
|
+
let t = [], n = new PS(e, Do).lex();
|
|
16780
|
+
if (n.getErrors().length > 0) return t;
|
|
16781
|
+
let i = new RS(e, n.getValue(), new dm(), Do).parse();
|
|
16782
|
+
if (i.getErrors().length > 0) return t;
|
|
16783
|
+
let a = i.getValue().ast;
|
|
16784
|
+
for (let e of a.declarations) if (e.isKind(r.DiagramView)) {
|
|
16785
|
+
let n = e.name ? j(e.name) ?? [] : [], r = n.length > 0 ? n[n.length - 1] : "";
|
|
16786
|
+
t.push({
|
|
16787
|
+
name: r,
|
|
16788
|
+
startIndex: e.start,
|
|
16789
|
+
endIndex: e.end
|
|
16790
|
+
});
|
|
16791
|
+
}
|
|
16792
|
+
return t;
|
|
16793
|
+
}
|
|
16794
|
+
function PC(e, t, n) {
|
|
16795
|
+
e.push(` ${t} {`), n.forEach((t) => e.push(` ${t}`)), e.push(" }");
|
|
16796
|
+
}
|
|
16797
|
+
function FC(e, t) {
|
|
16798
|
+
e.push(` ${t} { * }`);
|
|
16799
|
+
}
|
|
16800
|
+
function IC(e) {
|
|
16801
|
+
return e == null ? "null" : e.length === 0 ? "empty" : "items";
|
|
16802
|
+
}
|
|
16803
|
+
function LC(e, t) {
|
|
16804
|
+
let n = `DiagramView ${R_(e)} {`, r = (e) => R_(e.name), i = t?.tables?.map((e) => {
|
|
16805
|
+
let t = R_(e.name);
|
|
16806
|
+
return e.schemaName === "public" ? t : `${R_(e.schemaName)}.${t}`;
|
|
16807
|
+
}) ?? [], a = t?.tableGroups?.map(r) ?? [], o = t?.schemas?.map(r) ?? [], s = t?.stickyNotes?.map(r) ?? [];
|
|
16808
|
+
if (!t) return `${n}\n}`;
|
|
16809
|
+
let c = {
|
|
16810
|
+
tables: IC(t.tables),
|
|
16811
|
+
tableGroups: IC(t.tableGroups),
|
|
16812
|
+
schemas: IC(t.schemas),
|
|
16813
|
+
stickyNotes: IC(t.stickyNotes)
|
|
16814
|
+
};
|
|
16815
|
+
if (Object.values(c).every((e) => e === "null")) return `${n}\n}`;
|
|
16816
|
+
if (Object.values(c).every((e) => e === "empty")) return `${n}\n *\n}`;
|
|
16817
|
+
let l = c.tables === "items" || c.tableGroups === "items" || c.schemas === "items", u = c.tables === "empty" && c.tableGroups === "empty" && c.schemas === "empty", d = [n];
|
|
16818
|
+
return l ? (c.tables === "items" && PC(d, "Tables", i), c.tableGroups === "items" && PC(d, "TableGroups", a), c.schemas === "items" && PC(d, "Schemas", o)) : u && FC(d, "Tables"), c.stickyNotes === "items" ? PC(d, "Notes", s) : c.stickyNotes === "empty" && FC(d, "Notes"), d.push("}"), d.join("\n");
|
|
16819
|
+
}
|
|
16820
|
+
function RC(e, t, n) {
|
|
16821
|
+
let r = this.getSource(e) ?? "", i = n ?? NC(r), a = [];
|
|
16822
|
+
for (let e of t) {
|
|
16823
|
+
let t = zC(r, e, i);
|
|
16824
|
+
a.push(...t);
|
|
16825
|
+
}
|
|
16826
|
+
return a.sort((e, t) => t.start - e.start), {
|
|
16827
|
+
newDbml: aC(r, a, !0),
|
|
16828
|
+
edits: a
|
|
16829
|
+
};
|
|
16830
|
+
}
|
|
16831
|
+
function zC(e, t, n) {
|
|
16832
|
+
switch (t.operation) {
|
|
16833
|
+
case "create": return BC(e, t, n);
|
|
16834
|
+
case "update": return VC(e, t, n);
|
|
16835
|
+
case "delete": return HC(e, t, n);
|
|
16836
|
+
default: return [];
|
|
16837
|
+
}
|
|
16838
|
+
}
|
|
16839
|
+
function BC(e, t, n) {
|
|
16840
|
+
if (n.find((e) => e.name === t.name)) return VC(e, t, n);
|
|
16841
|
+
let r = "\n\n" + LC(t.name, t.visibleEntities) + "\n";
|
|
16842
|
+
return [{
|
|
16843
|
+
start: e.length,
|
|
16844
|
+
end: e.length,
|
|
16845
|
+
newText: r
|
|
16846
|
+
}];
|
|
16847
|
+
}
|
|
16848
|
+
function VC(e, t, n) {
|
|
16849
|
+
let r = n.find((e) => e.name === t.name);
|
|
16850
|
+
if (!r) return [];
|
|
16851
|
+
let i = [];
|
|
16852
|
+
if (t.newName || t.visibleEntities) {
|
|
16853
|
+
let e = LC(t.newName || t.name, t.visibleEntities);
|
|
16854
|
+
i.push({
|
|
16855
|
+
start: r.startIndex,
|
|
16856
|
+
end: r.endIndex,
|
|
16857
|
+
newText: e
|
|
16858
|
+
});
|
|
16859
|
+
}
|
|
16860
|
+
return i;
|
|
16861
|
+
}
|
|
16862
|
+
function HC(e, t, n) {
|
|
16863
|
+
let r = n.find((e) => e.name === t.name);
|
|
16864
|
+
if (!r) return [];
|
|
16865
|
+
let i = r.startIndex, a = r.endIndex;
|
|
16866
|
+
for (; i > 0 && e[i - 1] === "\n";) {
|
|
16867
|
+
i--, i > 0 && e[i - 1] === "\r" && i--;
|
|
16868
|
+
let t = e.lastIndexOf("\n", i - 1) + 1;
|
|
16869
|
+
if (e.substring(t, i).trim() !== "") {
|
|
16870
|
+
i = r.startIndex, i > 0 && e[i - 1] === "\n" && (i--, i > 0 && e[i - 1] === "\r" && i--);
|
|
16871
|
+
break;
|
|
16872
|
+
}
|
|
16873
|
+
}
|
|
16874
|
+
return a < e.length && e[a] === "\r" && a++, a < e.length && e[a] === "\n" && a++, [{
|
|
16875
|
+
start: i,
|
|
16876
|
+
end: a,
|
|
16877
|
+
newText: ""
|
|
16878
|
+
}];
|
|
16879
|
+
}
|
|
16880
|
+
//#endregion
|
|
16670
16881
|
//#region src/core/utils/note.ts
|
|
16671
|
-
function
|
|
16672
|
-
let n =
|
|
16882
|
+
function UC(e, t) {
|
|
16883
|
+
let n = KC(e);
|
|
16673
16884
|
if (n) return {
|
|
16674
16885
|
start: n.noteValueStart,
|
|
16675
16886
|
end: n.noteValueEnd,
|
|
16676
16887
|
newText: K_(t)
|
|
16677
16888
|
};
|
|
16678
16889
|
}
|
|
16679
|
-
function
|
|
16680
|
-
let t =
|
|
16890
|
+
function WC(e) {
|
|
16891
|
+
let t = KC(e);
|
|
16681
16892
|
if (t) return {
|
|
16682
16893
|
start: t.fullNoteStart,
|
|
16683
16894
|
end: t.fullNoteEnd,
|
|
16684
16895
|
newText: ""
|
|
16685
16896
|
};
|
|
16686
16897
|
}
|
|
16687
|
-
function
|
|
16688
|
-
if (
|
|
16689
|
-
let n =
|
|
16898
|
+
function GC(e, t) {
|
|
16899
|
+
if (KC(e) || !(e instanceof R)) return;
|
|
16900
|
+
let n = qC(e);
|
|
16690
16901
|
if (n !== void 0) return {
|
|
16691
16902
|
start: n,
|
|
16692
16903
|
end: n,
|
|
@@ -16710,12 +16921,12 @@ function OC(e, t) {
|
|
|
16710
16921
|
};
|
|
16711
16922
|
}
|
|
16712
16923
|
}
|
|
16713
|
-
function
|
|
16924
|
+
function KC(e) {
|
|
16714
16925
|
if (!(e instanceof R)) return;
|
|
16715
16926
|
let t = e.body;
|
|
16716
16927
|
if (t && !(t instanceof H)) for (let e of t.body) {
|
|
16717
16928
|
if (!(e instanceof R) || !e.isKind(r.Note)) continue;
|
|
16718
|
-
let t =
|
|
16929
|
+
let t = JC(e);
|
|
16719
16930
|
if (t) return {
|
|
16720
16931
|
kind: fm.ELEMENT_DECLARATION,
|
|
16721
16932
|
noteValueStart: t.start,
|
|
@@ -16725,18 +16936,18 @@ function kC(e) {
|
|
|
16725
16936
|
};
|
|
16726
16937
|
}
|
|
16727
16938
|
let n = e.attributeList ?? (t instanceof H ? t.args.find((e) => e instanceof W) : void 0);
|
|
16728
|
-
if (n) return
|
|
16939
|
+
if (n) return YC(n);
|
|
16729
16940
|
}
|
|
16730
|
-
function
|
|
16941
|
+
function qC(e) {
|
|
16731
16942
|
let t = e.body;
|
|
16732
16943
|
if (!(!t || t instanceof H) && t.blockCloseBrace) return t.blockCloseBrace.start;
|
|
16733
16944
|
}
|
|
16734
|
-
function
|
|
16945
|
+
function JC(e) {
|
|
16735
16946
|
let t = e.body;
|
|
16736
16947
|
if (t instanceof H) return t.callee ?? void 0;
|
|
16737
16948
|
if (t instanceof U && t.body[0] instanceof H) return t.body[0].callee ?? void 0;
|
|
16738
16949
|
}
|
|
16739
|
-
function
|
|
16950
|
+
function YC(e) {
|
|
16740
16951
|
let t = T(e).getValue()[i.Note];
|
|
16741
16952
|
if (!t?.length) return;
|
|
16742
16953
|
let n = t[0];
|
|
@@ -16752,36 +16963,36 @@ function MC(e) {
|
|
|
16752
16963
|
}
|
|
16753
16964
|
//#endregion
|
|
16754
16965
|
//#region src/compiler/queries/transform/syncDep.ts
|
|
16755
|
-
function
|
|
16756
|
-
let
|
|
16757
|
-
for (let
|
|
16758
|
-
return
|
|
16759
|
-
newDbml: aC(
|
|
16760
|
-
edits:
|
|
16966
|
+
function XC(e, t) {
|
|
16967
|
+
let n = this.getSource(e) ?? "", r = [];
|
|
16968
|
+
for (let i of t) r.push(...nw(this, e, n, i));
|
|
16969
|
+
return r.sort((e, t) => t.start - e.start), {
|
|
16970
|
+
newDbml: aC(n, r, !0),
|
|
16971
|
+
edits: r
|
|
16761
16972
|
};
|
|
16762
16973
|
}
|
|
16763
|
-
function
|
|
16974
|
+
function ZC(e) {
|
|
16764
16975
|
let t = new PS(e, Do).lex();
|
|
16765
16976
|
if (t.getErrors().length > 0) return [];
|
|
16766
16977
|
let n = new RS(e, t.getValue(), new dm(), Do).parse();
|
|
16767
|
-
return n.getErrors().length > 0 ? [] :
|
|
16978
|
+
return n.getErrors().length > 0 ? [] : $C(n.getValue().ast);
|
|
16768
16979
|
}
|
|
16769
|
-
function
|
|
16770
|
-
return `Dep [color: ${t}] {\n ${
|
|
16980
|
+
function QC(e, t) {
|
|
16981
|
+
return `Dep [color: ${t}] {\n ${_C(e.upstream)} -> ${_C(e.downstream)}\n}`;
|
|
16771
16982
|
}
|
|
16772
|
-
function
|
|
16983
|
+
function $C(e) {
|
|
16773
16984
|
let t = [];
|
|
16774
16985
|
for (let n of e.declarations) {
|
|
16775
16986
|
if (!(n instanceof R) || !n.isKind(r.Dep)) continue;
|
|
16776
16987
|
let e = [], i = n.body;
|
|
16777
16988
|
if (i instanceof H) {
|
|
16778
16989
|
if (i.callee instanceof V) {
|
|
16779
|
-
let t =
|
|
16990
|
+
let t = ew(i.callee);
|
|
16780
16991
|
t && e.push(t);
|
|
16781
16992
|
}
|
|
16782
16993
|
} else if (i) {
|
|
16783
16994
|
for (let t of i.body) if (t instanceof H && t.callee instanceof V) {
|
|
16784
|
-
let n =
|
|
16995
|
+
let n = ew(t.callee);
|
|
16785
16996
|
n && e.push(n);
|
|
16786
16997
|
}
|
|
16787
16998
|
}
|
|
@@ -16794,45 +17005,20 @@ function IC(e) {
|
|
|
16794
17005
|
}
|
|
16795
17006
|
return t;
|
|
16796
17007
|
}
|
|
16797
|
-
function
|
|
16798
|
-
let n = [];
|
|
16799
|
-
for (let a of t.declarations) {
|
|
16800
|
-
if (!(a instanceof R) || !a.isKind(r.Table)) continue;
|
|
16801
|
-
let t = a.name ? j(a.name) ?? [] : [];
|
|
16802
|
-
if (t.length === 0) continue;
|
|
16803
|
-
let o = t[t.length - 1], s = t.length > 1 ? t[t.length - 2] : void 0, c = a.body;
|
|
16804
|
-
if (!(!c || c instanceof H)) for (let t of c.body) {
|
|
16805
|
-
if (!(t instanceof H) || !t.callee) continue;
|
|
16806
|
-
let r = j(t.callee)?.at(-1);
|
|
16807
|
-
if (!r) continue;
|
|
16808
|
-
let a = {
|
|
16809
|
-
schemaName: s,
|
|
16810
|
-
tableName: o,
|
|
16811
|
-
fieldNames: [r]
|
|
16812
|
-
}, c = Og(t, i.Dep, e);
|
|
16813
|
-
if (c) for (let e of BC(t, a)) n.push({
|
|
16814
|
-
edge: e,
|
|
16815
|
-
fullStart: c.start,
|
|
16816
|
-
fullEnd: c.end
|
|
16817
|
-
});
|
|
16818
|
-
}
|
|
16819
|
-
}
|
|
16820
|
-
return n;
|
|
16821
|
-
}
|
|
16822
|
-
function RC(e) {
|
|
17008
|
+
function ew(e) {
|
|
16823
17009
|
let t = e.op?.value;
|
|
16824
17010
|
if (t !== "->" && t !== "<-") return;
|
|
16825
17011
|
let n = e.leftExpression, r = e.rightExpression;
|
|
16826
17012
|
if (!n || !r) return;
|
|
16827
17013
|
let i = t === "<-" ? r : n, a = t === "<-" ? n : r, o = j(i), s = j(a);
|
|
16828
17014
|
if (!o || !s) return;
|
|
16829
|
-
let c = o.length > 1 && s.length > 1, l =
|
|
17015
|
+
let c = o.length > 1 && s.length > 1, l = tw(o, c), u = tw(s, c);
|
|
16830
17016
|
if (!(!l || !u)) return {
|
|
16831
17017
|
upstream: l,
|
|
16832
17018
|
downstream: u
|
|
16833
17019
|
};
|
|
16834
17020
|
}
|
|
16835
|
-
function
|
|
17021
|
+
function tw(e, t) {
|
|
16836
17022
|
if (e.length === 0) return;
|
|
16837
17023
|
if (!t) {
|
|
16838
17024
|
let t = e[e.length - 1];
|
|
@@ -16849,269 +17035,52 @@ function zC(e, t) {
|
|
|
16849
17035
|
fieldNames: n
|
|
16850
17036
|
};
|
|
16851
17037
|
}
|
|
16852
|
-
function
|
|
16853
|
-
let
|
|
16854
|
-
|
|
16855
|
-
|
|
16856
|
-
|
|
16857
|
-
|
|
16858
|
-
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
|
|
16862
|
-
let o = j(n.expression);
|
|
16863
|
-
if (!o) continue;
|
|
16864
|
-
let s = zC(o, o.length > 1);
|
|
16865
|
-
s && r.push(a === "->" ? {
|
|
16866
|
-
upstream: t,
|
|
16867
|
-
downstream: s
|
|
16868
|
-
} : {
|
|
16869
|
-
upstream: s,
|
|
16870
|
-
downstream: t
|
|
16871
|
-
});
|
|
16872
|
-
}
|
|
16873
|
-
return r;
|
|
16874
|
-
}
|
|
16875
|
-
function VC(e, t) {
|
|
16876
|
-
return dC(e.upstream, t.upstream) && dC(e.downstream, t.downstream);
|
|
16877
|
-
}
|
|
16878
|
-
function HC(e, t) {
|
|
16879
|
-
return e.edges.some((e) => VC(e, t));
|
|
16880
|
-
}
|
|
16881
|
-
function UC(e, t) {
|
|
16882
|
-
return e.find((e) => HC(e, t));
|
|
16883
|
-
}
|
|
16884
|
-
function WC(e, t, n, r) {
|
|
16885
|
-
switch (t.operation) {
|
|
16886
|
-
case "create": return KC(e, t, n, r);
|
|
16887
|
-
case "update": {
|
|
16888
|
-
let r = UC(n, t.edge);
|
|
16889
|
-
return r ? GC(t, r, e) : [];
|
|
16890
|
-
}
|
|
16891
|
-
case "remove": {
|
|
16892
|
-
let r = UC(n, t.edge);
|
|
16893
|
-
return r ? GC({
|
|
16894
|
-
...t,
|
|
16895
|
-
color: void 0,
|
|
16896
|
-
note: void 0
|
|
16897
|
-
}, r, e) : [];
|
|
16898
|
-
}
|
|
17038
|
+
function nw(e, t, n, r) {
|
|
17039
|
+
let i = fC(e, t, r.edge);
|
|
17040
|
+
switch (r.operation) {
|
|
17041
|
+
case "create": return iw(n, r, i);
|
|
17042
|
+
case "update": return i?.kind === "block" ? rw(r, i.declaration, n) : [];
|
|
17043
|
+
case "remove": return i?.kind === "block" ? rw({
|
|
17044
|
+
...r,
|
|
17045
|
+
color: void 0,
|
|
17046
|
+
note: void 0
|
|
17047
|
+
}, i.declaration, n) : [];
|
|
16899
17048
|
default: return [];
|
|
16900
17049
|
}
|
|
16901
17050
|
}
|
|
16902
|
-
function
|
|
17051
|
+
function rw(e, t, n) {
|
|
16903
17052
|
let r = [];
|
|
16904
17053
|
if (e.color !== void 0) {
|
|
16905
|
-
let a = Dg(t
|
|
17054
|
+
let a = Dg(t, i.Color, e.color, n);
|
|
16906
17055
|
a && r.push(a);
|
|
16907
17056
|
}
|
|
16908
17057
|
if (e.note === null) {
|
|
16909
|
-
let e =
|
|
17058
|
+
let e = WC(t);
|
|
16910
17059
|
e && r.push(e);
|
|
16911
17060
|
} else if (e.note !== void 0) {
|
|
16912
|
-
let n =
|
|
17061
|
+
let n = UC(t, e.note) ?? GC(t, e.note);
|
|
16913
17062
|
n && r.push(n);
|
|
16914
17063
|
}
|
|
16915
17064
|
return r;
|
|
16916
17065
|
}
|
|
16917
|
-
function KC(e, t, n, r) {
|
|
16918
|
-
let i = UC(n, t.edge);
|
|
16919
|
-
if (i) return GC(t, i, e);
|
|
16920
|
-
let a = FC(t.edge, t.color ?? ""), o = {
|
|
16921
|
-
start: e.length,
|
|
16922
|
-
end: e.length,
|
|
16923
|
-
newText: "\n\n" + a + "\n"
|
|
16924
|
-
}, s = r.find((e) => VC(e.edge, t.edge));
|
|
16925
|
-
return s ? [{
|
|
16926
|
-
start: s.fullStart,
|
|
16927
|
-
end: s.fullEnd,
|
|
16928
|
-
newText: ""
|
|
16929
|
-
}, o] : [o];
|
|
16930
|
-
}
|
|
16931
|
-
//#endregion
|
|
16932
|
-
//#region src/compiler/queries/transform/updateElementSetting.ts
|
|
16933
|
-
function qC(e, t, n, r) {
|
|
16934
|
-
if (t.kind === "dep") return XC(this, e, t, n, r);
|
|
16935
|
-
if (t.kind === "ref") return ZC(this, e, t, n, r);
|
|
16936
|
-
let i = YC(this, e, t);
|
|
16937
|
-
if (!i) return [];
|
|
16938
|
-
let a = Dg(i, n, r, this.getSource(e) ?? "");
|
|
16939
|
-
return a ? [a] : [];
|
|
16940
|
-
}
|
|
16941
|
-
function JC(e, t, n, r) {
|
|
16942
|
-
let i = this.getSource(e) ?? "", a = this.updateElementSettingEdit(e, t, n, r);
|
|
16943
|
-
return a.length === 0 ? i : aC(i, a);
|
|
16944
|
-
}
|
|
16945
|
-
function YC(e, t, n) {
|
|
16946
|
-
let r = ("schema" in n ? n.schema : void 0) ?? "public";
|
|
16947
|
-
switch (n.kind) {
|
|
16948
|
-
case F.Column: {
|
|
16949
|
-
let i = pC(e, t, r, n.table, F.Table);
|
|
16950
|
-
return i ? e.lookupMembers(i, F.Column, n.column)?.declaration : void 0;
|
|
16951
|
-
}
|
|
16952
|
-
case F.Table: return pC(e, t, r, n.table)?.declaration;
|
|
16953
|
-
case F.Enum:
|
|
16954
|
-
case F.StickyNote:
|
|
16955
|
-
case F.TableGroup: return pC(e, t, r, n.name, n.kind)?.declaration;
|
|
16956
|
-
case F.Schema: return pC(e, t, n.schema, "", F.Schema)?.declaration;
|
|
16957
|
-
default: return;
|
|
16958
|
-
}
|
|
16959
|
-
}
|
|
16960
|
-
function XC(e, t, n, r, i) {
|
|
16961
|
-
let a = e.getSource(t) ?? "", o = e.parseFile(t).getValue().ast, s = IC(o).find((e) => e.edges.some((e) => uC(e.upstream, n.upstream) && uC(e.downstream, n.downstream)));
|
|
16962
|
-
if (!s) {
|
|
16963
|
-
if (i === null) return [];
|
|
16964
|
-
let e = LC(a, o).find((e) => dC(e.edge.upstream, n.upstream) && dC(e.edge.downstream, n.downstream));
|
|
16965
|
-
if (!e) return [];
|
|
16966
|
-
let t = hC(n.upstream), s = hC(n.downstream), c = gC(r, i), l = c ? `Dep [${c}] {\n ${t} -> ${s}\n}` : `Dep {\n ${t} -> ${s}\n}`;
|
|
16967
|
-
return [{
|
|
16968
|
-
start: e.fullStart,
|
|
16969
|
-
end: e.fullEnd,
|
|
16970
|
-
newText: ""
|
|
16971
|
-
}, {
|
|
16972
|
-
start: a.length,
|
|
16973
|
-
end: a.length,
|
|
16974
|
-
newText: "\n\n" + l + "\n"
|
|
16975
|
-
}];
|
|
16976
|
-
}
|
|
16977
|
-
let { declaration: c } = s, { body: l } = c;
|
|
16978
|
-
if (l instanceof H) {
|
|
16979
|
-
let e = Dg(c, r, i, a);
|
|
16980
|
-
if (e) return [e];
|
|
16981
|
-
let t = Dg(l, r, i, a);
|
|
16982
|
-
return t ? [t] : [];
|
|
16983
|
-
}
|
|
16984
|
-
let u = Dg(c, r, i, a);
|
|
16985
|
-
return u ? [u] : [];
|
|
16986
|
-
}
|
|
16987
|
-
function ZC(e, t, n, r, i) {
|
|
16988
|
-
let a = e.getSource(t) ?? "", o = oC(e, t, n);
|
|
16989
|
-
if (!o) return [];
|
|
16990
|
-
if (o.kind === "inline") {
|
|
16991
|
-
if (i === null) return [];
|
|
16992
|
-
let e = hC(n.endpoints[0]), t = hC(n.endpoints[1]), s = gC(r, i), c = s ? `Ref: ${e} ${o.op} ${t} [${s}]` : `Ref: ${e} ${o.op} ${t}`;
|
|
16993
|
-
return [{
|
|
16994
|
-
start: o.fullStart,
|
|
16995
|
-
end: o.fullEnd,
|
|
16996
|
-
newText: ""
|
|
16997
|
-
}, {
|
|
16998
|
-
start: a.length,
|
|
16999
|
-
end: a.length,
|
|
17000
|
-
newText: "\n\n" + c + "\n"
|
|
17001
|
-
}];
|
|
17002
|
-
}
|
|
17003
|
-
let s = Dg(o.node, r, i, a);
|
|
17004
|
-
return s ? [s] : [];
|
|
17005
|
-
}
|
|
17006
|
-
//#endregion
|
|
17007
|
-
//#region src/compiler/queries/transform/syncDiagramView.ts
|
|
17008
|
-
function QC(e) {
|
|
17009
|
-
let t = [], n = new PS(e, Do).lex();
|
|
17010
|
-
if (n.getErrors().length > 0) return t;
|
|
17011
|
-
let i = new RS(e, n.getValue(), new dm(), Do).parse();
|
|
17012
|
-
if (i.getErrors().length > 0) return t;
|
|
17013
|
-
let a = i.getValue().ast;
|
|
17014
|
-
for (let e of a.declarations) if (e.isKind(r.DiagramView)) {
|
|
17015
|
-
let n = e.name ? j(e.name) ?? [] : [], r = n.length > 0 ? n[n.length - 1] : "";
|
|
17016
|
-
t.push({
|
|
17017
|
-
name: r,
|
|
17018
|
-
startIndex: e.start,
|
|
17019
|
-
endIndex: e.end
|
|
17020
|
-
});
|
|
17021
|
-
}
|
|
17022
|
-
return t;
|
|
17023
|
-
}
|
|
17024
|
-
function $C(e, t, n) {
|
|
17025
|
-
e.push(` ${t} {`), n.forEach((t) => e.push(` ${t}`)), e.push(" }");
|
|
17026
|
-
}
|
|
17027
|
-
function ew(e, t) {
|
|
17028
|
-
e.push(` ${t} { * }`);
|
|
17029
|
-
}
|
|
17030
|
-
function tw(e) {
|
|
17031
|
-
return e == null ? "null" : e.length === 0 ? "empty" : "items";
|
|
17032
|
-
}
|
|
17033
|
-
function nw(e, t) {
|
|
17034
|
-
let n = `DiagramView ${R_(e)} {`, r = (e) => R_(e.name), i = t?.tables?.map((e) => {
|
|
17035
|
-
let t = R_(e.name);
|
|
17036
|
-
return e.schemaName === "public" ? t : `${R_(e.schemaName)}.${t}`;
|
|
17037
|
-
}) ?? [], a = t?.tableGroups?.map(r) ?? [], o = t?.schemas?.map(r) ?? [], s = t?.stickyNotes?.map(r) ?? [];
|
|
17038
|
-
if (!t) return `${n}\n}`;
|
|
17039
|
-
let c = {
|
|
17040
|
-
tables: tw(t.tables),
|
|
17041
|
-
tableGroups: tw(t.tableGroups),
|
|
17042
|
-
schemas: tw(t.schemas),
|
|
17043
|
-
stickyNotes: tw(t.stickyNotes)
|
|
17044
|
-
};
|
|
17045
|
-
if (Object.values(c).every((e) => e === "null")) return `${n}\n}`;
|
|
17046
|
-
if (Object.values(c).every((e) => e === "empty")) return `${n}\n *\n}`;
|
|
17047
|
-
let l = c.tables === "items" || c.tableGroups === "items" || c.schemas === "items", u = c.tables === "empty" && c.tableGroups === "empty" && c.schemas === "empty", d = [n];
|
|
17048
|
-
return l ? (c.tables === "items" && $C(d, "Tables", i), c.tableGroups === "items" && $C(d, "TableGroups", a), c.schemas === "items" && $C(d, "Schemas", o)) : u && ew(d, "Tables"), c.stickyNotes === "items" ? $C(d, "Notes", s) : c.stickyNotes === "empty" && ew(d, "Notes"), d.push("}"), d.join("\n");
|
|
17049
|
-
}
|
|
17050
|
-
function rw(e, t, n) {
|
|
17051
|
-
let r = this.getSource(e) ?? "", i = n ?? QC(r), a = [];
|
|
17052
|
-
for (let e of t) {
|
|
17053
|
-
let t = iw(r, e, i);
|
|
17054
|
-
a.push(...t);
|
|
17055
|
-
}
|
|
17056
|
-
return a.sort((e, t) => t.start - e.start), {
|
|
17057
|
-
newDbml: aC(r, a, !0),
|
|
17058
|
-
edits: a
|
|
17059
|
-
};
|
|
17060
|
-
}
|
|
17061
17066
|
function iw(e, t, n) {
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
case "update": return ow(e, t, n);
|
|
17065
|
-
case "delete": return sw(e, t, n);
|
|
17066
|
-
default: return [];
|
|
17067
|
-
}
|
|
17068
|
-
}
|
|
17069
|
-
function aw(e, t, n) {
|
|
17070
|
-
if (n.find((e) => e.name === t.name)) return ow(e, t, n);
|
|
17071
|
-
let r = "\n\n" + nw(t.name, t.visibleEntities) + "\n";
|
|
17072
|
-
return [{
|
|
17067
|
+
if (n?.kind === "block") return rw(t, n.declaration, e);
|
|
17068
|
+
let r = QC(t.edge, t.color ?? ""), i = {
|
|
17073
17069
|
start: e.length,
|
|
17074
17070
|
end: e.length,
|
|
17075
|
-
newText: r
|
|
17076
|
-
}
|
|
17077
|
-
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
if (!r) return [];
|
|
17081
|
-
let i = [];
|
|
17082
|
-
if (t.newName || t.visibleEntities) {
|
|
17083
|
-
let e = nw(t.newName || t.name, t.visibleEntities);
|
|
17084
|
-
i.push({
|
|
17085
|
-
start: r.startIndex,
|
|
17086
|
-
end: r.endIndex,
|
|
17087
|
-
newText: e
|
|
17088
|
-
});
|
|
17089
|
-
}
|
|
17090
|
-
return i;
|
|
17091
|
-
}
|
|
17092
|
-
function sw(e, t, n) {
|
|
17093
|
-
let r = n.find((e) => e.name === t.name);
|
|
17094
|
-
if (!r) return [];
|
|
17095
|
-
let i = r.startIndex, a = r.endIndex;
|
|
17096
|
-
for (; i > 0 && e[i - 1] === "\n";) {
|
|
17097
|
-
i--, i > 0 && e[i - 1] === "\r" && i--;
|
|
17098
|
-
let t = e.lastIndexOf("\n", i - 1) + 1;
|
|
17099
|
-
if (e.substring(t, i).trim() !== "") {
|
|
17100
|
-
i = r.startIndex, i > 0 && e[i - 1] === "\n" && (i--, i > 0 && e[i - 1] === "\r" && i--);
|
|
17101
|
-
break;
|
|
17102
|
-
}
|
|
17103
|
-
}
|
|
17104
|
-
return a < e.length && e[a] === "\r" && a++, a < e.length && e[a] === "\n" && a++, [{
|
|
17105
|
-
start: i,
|
|
17106
|
-
end: a,
|
|
17071
|
+
newText: "\n\n" + r + "\n"
|
|
17072
|
+
};
|
|
17073
|
+
return n?.kind === "inline" ? [{
|
|
17074
|
+
start: n.fullStart,
|
|
17075
|
+
end: n.fullEnd,
|
|
17107
17076
|
newText: ""
|
|
17108
|
-
}];
|
|
17077
|
+
}, i] : [i];
|
|
17109
17078
|
}
|
|
17110
17079
|
//#endregion
|
|
17111
17080
|
//#region src/compiler/index.ts
|
|
17112
|
-
var
|
|
17081
|
+
var aw = Symbol("COMPUTING"), ow = class {
|
|
17113
17082
|
constructor(e) {
|
|
17114
|
-
this.layout = e, this.nodeIdGenerator = new dm(), this.symbolIdGenerator = new Up(), this.symbolFactory = new to(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.globallyQuerying = !1, this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(YS), this.parseProject = this.globalQuery(XS), this.validateNode = this.localQuery(yy), this.validateFile = this.localQuery(NS), this.nodeFullname = this.localQuery(xy), this.nodeAlias = this.localQuery(Sy), this.nodeSettings = this.localQuery(by), this.canonicalName = this.globalQuery(mS), this.bindNode = this.globalQuery(Ev), this.bindFile = this.globalQuery(kS), this.bindProject = this.globalQuery(AS), this.interpretSymbol = this.globalQuery(Ov), this.interpretMetadata = this.globalQuery(kv), this.interpretFile = this.globalQuery(jS), this.interpretProject = this.globalQuery(MS), this.nodeSymbol = this.globalQuery(Cv), this.nodeMetadata = this.globalQuery(Dv), this.symbolMembers = this.globalQuery(wv), this.symbolMembersLookupMap = this.globalQuery(ZS), this.lookupMembers = this.globalQuery(QS), this.nodeReferee = this.globalQuery(Tv), this.resolutionIndex = this.globalQuery(eC), this.symbolReferences = this.globalQuery(nC), this.symbolParent = this.globalQuery(tC), this.symbolMetadata = this.globalQuery(rC), this.symbolAliases = this.globalQuery($S), this.symbolUses = this.globalQuery(iC), this.fileDependencies = this.localQuery(_S), this.reachableFiles = this.globalQuery(yS), this.usableMembers = this.globalQuery(l_), this.nodeAtPosition = this.localQuery(OS), this.renameTable =
|
|
17083
|
+
this.layout = e, this.nodeIdGenerator = new dm(), this.symbolIdGenerator = new Up(), this.symbolFactory = new to(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.globallyQuerying = !1, this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(YS), this.parseProject = this.globalQuery(XS), this.validateNode = this.localQuery(yy), this.validateFile = this.localQuery(NS), this.nodeFullname = this.localQuery(xy), this.nodeAlias = this.localQuery(Sy), this.nodeSettings = this.localQuery(by), this.canonicalName = this.globalQuery(mS), this.bindNode = this.globalQuery(Ev), this.bindFile = this.globalQuery(kS), this.bindProject = this.globalQuery(AS), this.interpretSymbol = this.globalQuery(Ov), this.interpretMetadata = this.globalQuery(kv), this.interpretFile = this.globalQuery(jS), this.interpretProject = this.globalQuery(MS), this.nodeSymbol = this.globalQuery(Cv), this.nodeMetadata = this.globalQuery(Dv), this.symbolMembers = this.globalQuery(wv), this.symbolMembersLookupMap = this.globalQuery(ZS), this.lookupMembers = this.globalQuery(QS), this.nodeReferee = this.globalQuery(Tv), this.resolutionIndex = this.globalQuery(eC), this.symbolReferences = this.globalQuery(nC), this.symbolParent = this.globalQuery(tC), this.symbolMetadata = this.globalQuery(rC), this.symbolAliases = this.globalQuery($S), this.symbolUses = this.globalQuery(iC), this.fileDependencies = this.localQuery(_S), this.reachableFiles = this.globalQuery(yS), this.usableMembers = this.globalQuery(l_), this.nodeAtPosition = this.localQuery(OS), this.renameTable = TC.bind(this), this.updateElementSetting = kC.bind(this), this.updateElementSettingEdit = OC.bind(this), this.syncDiagramView = RC.bind(this), this.syncDep = XC.bind(this), this.token = {
|
|
17115
17084
|
invalidStream: this.localQuery(DS),
|
|
17116
17085
|
flatStream: this.localQuery(ES)
|
|
17117
17086
|
}, this.parse = {
|
|
@@ -17153,10 +17122,10 @@ var cw = Symbol("COMPUTING"), lw = class {
|
|
|
17153
17122
|
r || (r = /* @__PURE__ */ new Map(), this.globalCache.set(t, r));
|
|
17154
17123
|
let i = n.length === 0 ? "" : n.length === 1 ? fh(n[0]) : n.map((e) => fh(e)).join("\0"), a = r.get(i);
|
|
17155
17124
|
if (a) {
|
|
17156
|
-
if (a ===
|
|
17125
|
+
if (a === aw) throw Error(`Cycle detected in query: ${e.name}(${i})`);
|
|
17157
17126
|
return a;
|
|
17158
17127
|
}
|
|
17159
|
-
r.set(i,
|
|
17128
|
+
r.set(i, aw);
|
|
17160
17129
|
try {
|
|
17161
17130
|
let t = e.apply(this, n);
|
|
17162
17131
|
return r.set(i, t), t;
|
|
@@ -17178,10 +17147,10 @@ var cw = Symbol("COMPUTING"), lw = class {
|
|
|
17178
17147
|
let c = s.get(t);
|
|
17179
17148
|
if (c || (c = /* @__PURE__ */ new Map(), s.set(t, c)), c.has(o)) {
|
|
17180
17149
|
let t = c.get(o);
|
|
17181
|
-
if (t ===
|
|
17150
|
+
if (t === aw) throw Error(`Cycle detected in query: ${e.name}(${a}, ${o})`);
|
|
17182
17151
|
return t;
|
|
17183
17152
|
}
|
|
17184
|
-
c.set(o,
|
|
17153
|
+
c.set(o, aw);
|
|
17185
17154
|
try {
|
|
17186
17155
|
let t = e.apply(this, n);
|
|
17187
17156
|
return c.set(o, t), t;
|
|
@@ -17200,7 +17169,7 @@ var cw = Symbol("COMPUTING"), lw = class {
|
|
|
17200
17169
|
codeActionProvider: new jb(this)
|
|
17201
17170
|
};
|
|
17202
17171
|
}
|
|
17203
|
-
},
|
|
17172
|
+
}, sw = class e {
|
|
17204
17173
|
constructor(e = {}) {
|
|
17205
17174
|
this.files = e instanceof Map ? new Map(e) : new Map(Object.entries(e));
|
|
17206
17175
|
}
|
|
@@ -17244,4 +17213,4 @@ var cw = Symbol("COMPUTING"), lw = class {
|
|
|
17244
17213
|
}
|
|
17245
17214
|
};
|
|
17246
17215
|
//#endregion
|
|
17247
|
-
export { Om as ArrayNode, z as AttributeNode, U as BlockExpressionNode, cf as CARDINALITY_MANY, of as CARDINALITY_MAYBE, af as CARDINALITY_ONE, sf as CARDINALITY_SOME, Sm as CallExpressionNode, bm as CommaExpressionNode, w as CompileError, C as CompileErrorCode,
|
|
17216
|
+
export { Om as ArrayNode, z as AttributeNode, U as BlockExpressionNode, cf as CARDINALITY_MANY, of as CARDINALITY_MAYBE, af as CARDINALITY_ONE, sf as CARDINALITY_SOME, Sm as CallExpressionNode, bm as CommaExpressionNode, w as CompileError, C as CompileErrorCode, ow as Compiler, Y as CompletionItemInsertTextRule, J as CompletionItemKind, jb as DBMLCodeActionProvider, Dx as DBMLCompletionItemProvider, Mb as DBMLDefinitionProvider, Nb as DBMLDiagnosticsProvider, Pb as DBMLReferencesProvider, Do as DEFAULT_ENTRY, R as ElementDeclarationNode, r as ElementKind, Dm as EmptyNode, wp as FALSY_VALUES, xo as Filepath, H as FunctionApplicationNode, vm as FunctionExpressionNode, xm as GroupExpressionNode, gm as IdentifierStreamNode, V as InfixExpressionNode, W as ListExpressionNode, Cm as LiteralNode, Ob as MarkerSeverity, sw as MemoryProjectLayout, Um as MetadataKind, _m as PostfixExpressionNode, B as PrefixExpressionNode, Em as PrimaryExpressionNode, L as ProgramNode, Q as ScopeKind, F as SymbolKind, I as SyntaxNode, dm as SyntaxNodeIdGenerator, fm as SyntaxNodeKind, Ha as SyntaxToken, _ as SyntaxTokenKind, Cp as TRUTHY_VALUES, ym as TupleExpressionNode, t as UNHANDLED, _b as Uri, pm as UseDeclarationNode, hm as UseSpecifierListNode, mm as UseSpecifierNode, Tm as VariableNode, wm as WildcardNode, R_ as addDoubleQuoteIfNeeded, sS as dbmlLanguageConfig, cS as dbmlMonarchTokensProvider, V_ as escapeString, pp as extractNumericLiteral, bp as extractSignedNumber, ZC as findDepBlocks, NC as findDiagramViewBlocks, H_ as formatRecordValue, df as getMultiplicities, Wo as getRecordValueType, _f as getRelationshipOp, Vo as isBinaryType, zo as isBooleanType, Ho as isDateTimeType, vp as isEmptyStringLiteral, pf as isEndpointManySide, ff as isEndpointOneSide, mf as isEndpointOptional, hf as isEndpointRequired, Lo as isFloatType, yp as isFunctionExpression, Io as isIntegerType, _p as isNullish, Ro as isNumericType, Ba as isOp, Va as isOpToken, Uo as isSerialType, Bo as isStringType, za as isTriviaToken, L_ as isValidIdentifier, vf as makeCardinalityOptional, yf as makeCardinalityRequired, gf as makeRelationshipRequired, z_ as normalizeQualifiedName, Fo as normalizeTypeName, rf as parseCardinality, U_ as splitQualifiedIdentifier, Tp as tryExtractBoolean, jp as tryExtractDateTime, Ep as tryExtractEnum, Sp as tryExtractInteger, xp as tryExtractNumeric, Dp as tryExtractString, B_ as unescapeString, bg as validateForeignKeys, ug as validatePrimaryKey, gg as validateUnique };
|