ddd-ts-kit 0.113.1 → 0.114.1

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +54 -1
  2. package/README.fr.md +6 -6
  3. package/README.md +5 -5
  4. package/dist/help/work-notes.d.ts.map +1 -1
  5. package/dist/help/work-notes.js +7 -5
  6. package/dist/help/work-notes.js.map +1 -1
  7. package/dist/init/managed-settings-note.js +1 -1
  8. package/dist/init/managed-settings-note.js.map +1 -1
  9. package/dist/init/manifest/versions.js +25 -25
  10. package/dist/init/run-init.js +1 -1
  11. package/dist/init/run-init.js.map +1 -1
  12. package/dist/init/write-copilot-settings.js +1 -1
  13. package/dist/init/write-copilot-settings.js.map +1 -1
  14. package/dist/issues-url.d.ts +1 -1
  15. package/dist/issues-url.d.ts.map +1 -1
  16. package/dist/issues-url.js +1 -1
  17. package/dist/issues-url.js.map +1 -1
  18. package/dist/merge/declarations/binds-the-name.d.ts +8 -0
  19. package/dist/merge/declarations/binds-the-name.d.ts.map +1 -0
  20. package/dist/merge/declarations/binds-the-name.js +40 -0
  21. package/dist/merge/declarations/binds-the-name.js.map +1 -0
  22. package/dist/merge/declarations/close-of.d.ts +3 -0
  23. package/dist/merge/declarations/close-of.d.ts.map +1 -0
  24. package/dist/merge/declarations/close-of.js +15 -0
  25. package/dist/merge/declarations/close-of.js.map +1 -0
  26. package/dist/merge/declarations/declarations-of.d.ts +2 -0
  27. package/dist/merge/declarations/declarations-of.d.ts.map +1 -1
  28. package/dist/merge/declarations/declarations-of.js +1 -1
  29. package/dist/merge/declarations/declarations-of.js.map +1 -1
  30. package/dist/merge/declarations/declares-a-member.d.ts +7 -0
  31. package/dist/merge/declarations/declares-a-member.d.ts.map +1 -0
  32. package/dist/merge/declarations/declares-a-member.js +29 -0
  33. package/dist/merge/declarations/declares-a-member.js.map +1 -0
  34. package/dist/merge/declarations/enclosing-group.d.ts +8 -0
  35. package/dist/merge/declarations/enclosing-group.d.ts.map +1 -0
  36. package/dist/merge/declarations/enclosing-group.js +16 -0
  37. package/dist/merge/declarations/enclosing-group.js.map +1 -0
  38. package/dist/merge/declarations/imports-read-as-merged.d.ts +9 -0
  39. package/dist/merge/declarations/imports-read-as-merged.d.ts.map +1 -0
  40. package/dist/merge/declarations/imports-read-as-merged.js +23 -0
  41. package/dist/merge/declarations/imports-read-as-merged.js.map +1 -0
  42. package/dist/merge/declarations/inverts-a-reference.d.ts +12 -0
  43. package/dist/merge/declarations/inverts-a-reference.d.ts.map +1 -0
  44. package/dist/merge/declarations/inverts-a-reference.js +25 -0
  45. package/dist/merge/declarations/inverts-a-reference.js.map +1 -0
  46. package/dist/merge/declarations/lead-of.d.ts +15 -0
  47. package/dist/merge/declarations/lead-of.d.ts.map +1 -0
  48. package/dist/merge/declarations/lead-of.js +19 -0
  49. package/dist/merge/declarations/lead-of.js.map +1 -0
  50. package/dist/merge/declarations/lines-of-both-sides.d.ts +10 -0
  51. package/dist/merge/declarations/lines-of-both-sides.d.ts.map +1 -0
  52. package/dist/merge/declarations/lines-of-both-sides.js +22 -0
  53. package/dist/merge/declarations/lines-of-both-sides.js.map +1 -0
  54. package/dist/merge/declarations/merge-declarations.d.ts.map +1 -1
  55. package/dist/merge/declarations/merge-declarations.js +1 -15
  56. package/dist/merge/declarations/merge-declarations.js.map +1 -1
  57. package/dist/merge/declarations/merged-file.d.ts +15 -0
  58. package/dist/merge/declarations/merged-file.d.ts.map +1 -0
  59. package/dist/merge/declarations/merged-file.js +55 -0
  60. package/dist/merge/declarations/merged-file.js.map +1 -0
  61. package/dist/merge/declarations/merged-lines.d.ts +5 -11
  62. package/dist/merge/declarations/merged-lines.d.ts.map +1 -1
  63. package/dist/merge/declarations/merged-lines.js +6 -39
  64. package/dist/merge/declarations/merged-lines.js.map +1 -1
  65. package/dist/merge/declarations/merged-region.d.ts +2 -1
  66. package/dist/merge/declarations/merged-region.d.ts.map +1 -1
  67. package/dist/merge/declarations/merged-region.js +60 -22
  68. package/dist/merge/declarations/merged-region.js.map +1 -1
  69. package/dist/merge/declarations/reads-a-removed.d.ts +8 -0
  70. package/dist/merge/declarations/reads-a-removed.d.ts.map +1 -0
  71. package/dist/merge/declarations/reads-a-removed.js +27 -0
  72. package/dist/merge/declarations/reads-a-removed.js.map +1 -0
  73. package/dist/merge/declarations/reads-the-name.d.ts +10 -0
  74. package/dist/merge/declarations/reads-the-name.d.ts.map +1 -0
  75. package/dist/merge/declarations/reads-the-name.js +23 -0
  76. package/dist/merge/declarations/reads-the-name.js.map +1 -0
  77. package/dist/merge/declarations/settle-declarations.d.ts +9 -5
  78. package/dist/merge/declarations/settle-declarations.d.ts.map +1 -1
  79. package/dist/merge/declarations/settle-declarations.js +39 -13
  80. package/dist/merge/declarations/settle-declarations.js.map +1 -1
  81. package/dist/merge/declarations/sides-of-region.d.ts +5 -0
  82. package/dist/merge/declarations/sides-of-region.d.ts.map +1 -0
  83. package/dist/merge/declarations/sides-of-region.js +19 -0
  84. package/dist/merge/declarations/sides-of-region.js.map +1 -0
  85. package/dist/merge/declarations/union-in-doubt.d.ts +17 -0
  86. package/dist/merge/declarations/union-in-doubt.d.ts.map +1 -0
  87. package/dist/merge/declarations/union-in-doubt.js +84 -0
  88. package/dist/merge/declarations/union-in-doubt.js.map +1 -0
  89. package/dist/merge/declarations/union-reads-as-merged.d.ts +23 -0
  90. package/dist/merge/declarations/union-reads-as-merged.d.ts.map +1 -0
  91. package/dist/merge/declarations/union-reads-as-merged.js +155 -0
  92. package/dist/merge/declarations/union-reads-as-merged.js.map +1 -0
  93. package/dist/merge/resolve-conflict.d.ts +2 -1
  94. package/dist/merge/resolve-conflict.d.ts.map +1 -1
  95. package/dist/merge/resolve-conflict.js +5 -3
  96. package/dist/merge/resolve-conflict.js.map +1 -1
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.js +1 -1
  99. package/package.json +9 -9
  100. package/templates/init/AGENTS.md.tpl +1 -1
  101. package/templates/init/README.md.tpl +3 -3
  102. package/templates/pipeline/github/workflows/intent-to-spec.yml +1 -1
  103. package/templates/pipeline/package-scripts.json +1 -1
@@ -1,31 +1,31 @@
1
- import { regionsOf } from '../../markers/index.js';
2
- import { declarationsOf } from './declarations-of.js';
3
1
  import { declaredLines } from './declared-lines.js';
4
2
  import { mergeDeclarations } from './merge-declarations.js';
5
3
  import { mergedLines } from './merged-lines.js';
4
+ import { invertsAReference } from './inverts-a-reference.js';
5
+ import { readsARemoved } from './reads-a-removed.js';
6
6
  import { readsAsMerged } from './reads-as-merged.js';
7
7
  import { shownOf } from './shown-of.js';
8
+ import { sidesOfRegion } from './sides-of-region.js';
8
9
  import { mergedImports } from './merged-imports.js';
9
10
  /**
10
11
  * A region of a conflicted file merged from its three sides, declaration by declaration. Its
11
12
  * lines hold a conflict for each declaration the two sides do not agree on. Nothing is written,
12
13
  * and the conflicts git wrote stay for a person, when the region is not read with certainty: a
13
14
  * side, the base among them, does not hold it once or cannot be read, the declarations of the
14
- * sides cannot be paired or ordered, or the merged lines do not read back as the declarations merged.
15
+ * sides cannot be paired or ordered, the merged lines do not read back as the declarations merged, a
16
+ * side removed a declaration the other started to read, or a declaration would stand above one it reads.
15
17
  */
16
18
  export function mergedRegion(name, path, { top, labels, blocks }) {
17
- const ours = sideOf(path.ours, name);
18
- const theirs = sideOf(path.theirs, name);
19
- const base = sideOf(path.base, name);
20
- if (ours === undefined || theirs === undefined || base === undefined) {
19
+ const sides = sidesOfRegion(name, path);
20
+ if (sides === undefined) {
21
21
  return unread(name, blocks);
22
22
  }
23
- const imports = name === 'imports' ? mergedImports({ ours, base, theirs }) : undefined;
23
+ const imports = name === 'imports' ? mergedImports(sides) : undefined;
24
24
  if (imports !== undefined) {
25
25
  return { lines: imports };
26
26
  }
27
- const outcome = mergeDeclarations({ ours, base, theirs }, (versions) => mergedLines(top, versions));
28
- const why = whyNot(outcome);
27
+ const outcome = mergeDeclarations(sides, (versions) => mergedLines(top, versions));
28
+ const why = whyNot(outcome, sides);
29
29
  if ('refused' in outcome || why !== undefined) {
30
30
  return unread(name, blocks, why);
31
31
  }
@@ -33,18 +33,46 @@ export function mergedRegion(name, path, { top, labels, blocks }) {
33
33
  const conflicts = outcome.merged.flatMap((item) => (item.kind === 'conflict' ? [item] : []));
34
34
  return conflicts.length === 0
35
35
  ? { lines }
36
- : { lines, held: { advice: adviceOf(name, conflicts), blocks: conflicts.length } };
36
+ : {
37
+ lines,
38
+ held: { advice: `${adviceOf(name, conflicts)}${renamedOf(conflicts, sides)}`, blocks: conflicts.length },
39
+ };
37
40
  }
38
- /** Why a region is not written as merged: its declarations were not merged, they do not read back, or they give the file two default exports. */
39
- function whyNot(outcome) {
41
+ /**
42
+ * Why a region is not written as merged: its declarations were not merged, they do not read
43
+ * back, a side removed one the other started to read, the merged region sets one above a
44
+ * declaration it reads against the sides, or they give the file two default exports.
45
+ */
46
+ function whyNot(outcome, sides) {
40
47
  if ('refused' in outcome) {
41
- return outcome.refused;
48
+ return outcome.refused === 'unnamed' && !oneSideAlone(sides) ? 'gone' : outcome.refused;
42
49
  }
43
50
  if (!readsAsMerged(outcome.merged, outcome.lead)) {
44
51
  return 'unread';
45
52
  }
53
+ if (readsARemoved(sides)) {
54
+ return 'removed';
55
+ }
56
+ const declarations = outcome.merged.flatMap((item) => shownOf(item) ?? []);
57
+ if (invertsAReference({ declarations, trailing: 0 }, sides)) {
58
+ return 'above';
59
+ }
46
60
  return outcome.merged.filter(exportsADefault).length > 1 ? 'defaults' : undefined;
47
61
  }
62
+ /**
63
+ * Whether a side changed or removed a statement of the base that declares no name and the other
64
+ * did not do the same: one side alone holds it as the base does, or a side wrote a statement the
65
+ * base does not hold, which may be that one changed. Otherwise both removed it.
66
+ */
67
+ function oneSideAlone({ ours, base, theirs }) {
68
+ const keys = (side) => new Set(side.declarations.map(({ key }) => key));
69
+ const inOurs = keys(ours);
70
+ const inTheirs = keys(theirs);
71
+ const inBase = keys(base);
72
+ const nameless = (side) => side.declarations.filter(({ name }) => name === undefined);
73
+ return (nameless(base).some(({ key }) => inOurs.has(key) !== inTheirs.has(key)) ||
74
+ [...nameless(ours), ...nameless(theirs)].some(({ key }) => !inBase.has(key)));
75
+ }
48
76
  /** A default export in either spelling: `export default ...` or `export { name as default }`. */
49
77
  const DEFAULT_EXPORT = /^\s*export\s+(?:default\b|(?:type\s+)?\{[^}]*\bas\s+default\b)/;
50
78
  /** Whether a declaration of the merged region, in the version of a side when it is left to a person, gives the file its default export. */
@@ -59,6 +87,9 @@ const WHY = {
59
87
  entries: `holds lines that end no statement (entries of a list, or statements written without \`;\`) on which the two sides differ, which the kit does not merge one by one${WHOLE}.`,
60
88
  twice: 'holds two statements with no declared name that open alike, one holding every line of the other, which the kit cannot tell from one statement written twice, and its hunks show lines, not whole statements: write it once if it is one statement, each whole if they are two.',
61
89
  order: `holds declarations the two sides set in two different orders${WHOLE}, in the order that holds for both.`,
90
+ gone: `holds a statement that declares no name and that both sides removed, which the kit does not merge${WHOLE}.`,
91
+ above: `holds a declaration that would stand above one it reads once the two sides are merged${WHOLE}, in the order that holds for both.`,
92
+ removed: `holds a declaration one side removed and that a declaration the other side wrote reads${WHOLE}, the one removed kept or the other written without it.`,
62
93
  defaults: 'holds a default export of each side, and a file has one: write the one the file keeps, whole, and export what the other side declared under a name.',
63
94
  };
64
95
  function unread(name, blocks, why = 'unread') {
@@ -72,13 +103,20 @@ function adviceOf(name, conflicts) {
72
103
  : `on ${names.map((declared) => `\`${declared}\``).join(', ')} in the region \`${name}\`: for each`;
73
104
  return `the two sides do not agree ${what}, write the one declaration that keeps the intent of both, whole, or remove it.`;
74
105
  }
75
- /** The declarations a side holds in its one region of that name; undefined when it holds none, several, or one that is not read. */
76
- function sideOf(text, name) {
77
- const lines = (text ?? '').split('\n');
78
- const regions = regionsOf(lines).filter((region) => region.name === name);
79
- const [region] = regions;
80
- return region === undefined || regions.length > 1
81
- ? undefined
82
- : declarationsOf(lines.slice(region.open + 1, region.close));
106
+ /**
107
+ * What is said more when one side removed a declaration the other changed and that side also
108
+ * wrote one neither the base nor the other side holds: the kit cannot tell a declaration given
109
+ * another name from one replaced by another.
110
+ */
111
+ function renamedOf(conflicts, sides) {
112
+ const keys = (side) => new Set(side.declarations.map(({ key }) => key));
113
+ const inBase = keys(sides.base);
114
+ const wroteAnother = (side, other) => side.declarations.some(({ key }) => !inBase.has(key) && !keys(other).has(key));
115
+ const renamed = conflicts.some(({ ours, base, theirs }) => base !== undefined &&
116
+ ((ours === undefined && wroteAnother(sides.ours, sides.theirs)) ||
117
+ (theirs === undefined && wroteAnother(sides.theirs, sides.ours))));
118
+ return renamed
119
+ ? ' If a declaration of the side that removed it is this one under another name, write the change there and remove the hunk.'
120
+ : '';
83
121
  }
84
122
  //# sourceMappingURL=merged-region.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merged-region.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-region.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAA0B,iBAAiB,EAAgB,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBjD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAoB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAS;IAC7F,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,I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,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CACzB,IAAI,KAAK,SAAS;QAClB,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7D,CAAC,MAAM,KAAK,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CACtE,CAAC;IAEF,OAAO,OAAO;QACZ,CAAC,CAAC,2HAA2H;QAC7H,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { DeclaredSides } from './merge-declarations.js';
2
+ /**
3
+ * Whether a side removed a declaration the other left as the base holds it, while that other
4
+ * side wrote or changed a declaration that reads it and whose base version, if any, did not: one
5
+ * removed what the other started to read, and no merge of the two holds for both.
6
+ */
7
+ export declare function readsARemoved({ ours, base, theirs }: DeclaredSides): boolean;
8
+ //# sourceMappingURL=reads-a-removed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reads-a-removed.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/reads-a-removed.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAE5E"}
@@ -0,0 +1,27 @@
1
+ import { readsTheName } from './reads-the-name.js';
2
+ /**
3
+ * Whether a side removed a declaration the other left as the base holds it, while that other
4
+ * side wrote or changed a declaration that reads it and whose base version, if any, did not: one
5
+ * removed what the other started to read, and no merge of the two holds for both.
6
+ */
7
+ export function readsARemoved({ ours, base, theirs }) {
8
+ return startedToRead(ours, base, theirs) || startedToRead(theirs, base, ours);
9
+ }
10
+ /** Whether a side started to read a declaration it left alone and the other side removed. */
11
+ function startedToRead(keeper, base, remover) {
12
+ const inBase = byKey(base);
13
+ const removed = new Set(remover.declarations.map(({ key }) => key));
14
+ const gone = keeper.declarations.filter((kept) => kept.name !== undefined && !removed.has(kept.key) && same(kept, inBase.get(kept.key)));
15
+ return keeper.declarations.some((written) => {
16
+ const before = inBase.get(written.key);
17
+ return (!same(written, before) &&
18
+ gone.some(({ key, name }) => key !== written.key && readsTheName(written, name) && !(before !== undefined && readsTheName(before, name))));
19
+ });
20
+ }
21
+ function byKey(side) {
22
+ return new Map(side.declarations.map((declaration) => [declaration.key, declaration]));
23
+ }
24
+ function same(one, other) {
25
+ return one.lines.join('\n') === other?.lines.join('\n');
26
+ }
27
+ //# sourceMappingURL=reads-a-removed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reads-a-removed.js","sourceRoot":"","sources":["../../../src/merge/declarations/reads-a-removed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAiB;IACjE,OAAO,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,6FAA6F;AAC7F,SAAS,aAAa,CAAC,MAAoB,EAAE,IAAkB,EAAE,OAAqB;IACpF,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CACrC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAChG,CAAC;IAEF,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAEvC,OAAO,CACL,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;YACtB,IAAI,CAAC,IAAI,CACP,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAChB,GAAG,KAAK,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAC9G,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,IAAkB;IAC/B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,IAAI,CAAC,GAAgB,EAAE,KAA8B;IAC5D,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Declaration } from './declaration.js';
2
+ /**
3
+ * Whether the code of a declaration reads a name: it holds it as a whole word, comments and
4
+ * strings left out, a type that names it and a spread of it among them (`typeof orders`,
5
+ * `...orders`). A member of another value (`other.orders`, `other?.orders`) is not a read of it,
6
+ * nor a member the code declares under that name. No scope is read: a declaration that binds the
7
+ * name itself is not taken to read the outer one at all.
8
+ */
9
+ export declare function readsTheName({ lines }: Declaration, name: string | undefined): boolean;
10
+ //# sourceMappingURL=reads-the-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reads-the-name.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/reads-the-name.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAetF"}
@@ -0,0 +1,23 @@
1
+ import { scan } from '../../check/scan/scan.js';
2
+ import { bindsTheName } from './binds-the-name.js';
3
+ import { declaresAMember } from './declares-a-member.js';
4
+ /**
5
+ * Whether the code of a declaration reads a name: it holds it as a whole word, comments and
6
+ * strings left out, a type that names it and a spread of it among them (`typeof orders`,
7
+ * `...orders`). A member of another value (`other.orders`, `other?.orders`) is not a read of it,
8
+ * nor a member the code declares under that name. No scope is read: a declaration that binds the
9
+ * name itself is not taken to read the outer one at all.
10
+ */
11
+ export function readsTheName({ lines }, name) {
12
+ const code = scan(lines.join('\n')).code;
13
+ if (name === undefined || bindsTheName(code, name)) {
14
+ return false;
15
+ }
16
+ const word = new RegExp(`(?<![\\w$])${name.replaceAll('$', '\\$')}(?![\\w$])`, 'g');
17
+ return [...code.matchAll(word)].some(({ index }) => {
18
+ const before = code.slice(0, index).trimEnd();
19
+ const member = before.endsWith('.') && !before.endsWith('...');
20
+ return !member && !declaresAMember(code, index, name);
21
+ });
22
+ }
23
+ //# sourceMappingURL=reads-the-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reads-the-name.js","sourceRoot":"","sources":["../../../src/merge/declarations/reads-the-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAe,EAAE,IAAwB;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzC,IAAI,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,cAAc,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAEpF,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE/D,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -11,11 +11,15 @@ export interface SettledDeclarations {
11
11
  }
12
12
  /**
13
13
  * Merges, in the text a merge wrote for a file, each generated region in which the lines of both
14
- * sides, kept, would leave a declaration open: git sets two tables, two models or two functions
15
- * added at one place side by side and keeps the lines they share once, so that the union of the
16
- * lines no longer pairs their brackets. Such a region is merged from the three sides of the
17
- * file, declaration by declaration. Any other region is left to the union of lines, untouched:
18
- * `top` is the repository the lines of a declaration both sides changed are merged in.
14
+ * sides, kept, would not give the two sides merged. They leave a declaration open: git sets two
15
+ * tables, two models or two functions added at one place side by side and keeps the lines they
16
+ * share once, so that the union of the lines no longer pairs their brackets. Or they pair them
17
+ * and the region they give, read back, is not the declarations of the three sides merged one by
18
+ * one: a line of one side stands inside a declaration of the other, a declaration lacks a line,
19
+ * stands twice, came back, or stands above one it reads. Such a region is merged from the
20
+ * three sides of the file, declaration by declaration. Any other region is left to the union of
21
+ * lines, untouched: `top` is the repository the lines of a declaration both sides changed are
22
+ * merged in.
19
23
  */
20
24
  export declare function settleDeclarations(path: ConflictedPath, top: string): SettledDeclarations;
21
25
  //# sourceMappingURL=settle-declarations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settle-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/settle-declarations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAGhE,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sHAAsH;IACtH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CA4BzF"}
1
+ {"version":3,"file":"settle-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/settle-declarations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMzD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAMhE,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sHAAsH;IACtH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CA4BzF"}
@@ -3,15 +3,23 @@ import { REGION_MARKER, regionsOf } from '../../markers/index.js';
3
3
  import { conflictBlocks } from '../conflict-blocks.js';
4
4
  import { registryUnion } from '../registry-union.js';
5
5
  import { bracketsLeftOpen } from './brackets-left-open.js';
6
+ import { linesOfBothSides } from './lines-of-both-sides.js';
7
+ import { importsReadAsMerged } from './imports-read-as-merged.js';
6
8
  import { mergedRegion } from './merged-region.js';
7
9
  import { sharesHalfAPair } from './shares-half-a-pair.js';
10
+ import { sidesOfRegion } from './sides-of-region.js';
11
+ import { unionReadsAsMerged } from './union-reads-as-merged.js';
8
12
  /**
9
13
  * Merges, in the text a merge wrote for a file, each generated region in which the lines of both
10
- * sides, kept, would leave a declaration open: git sets two tables, two models or two functions
11
- * added at one place side by side and keeps the lines they share once, so that the union of the
12
- * lines no longer pairs their brackets. Such a region is merged from the three sides of the
13
- * file, declaration by declaration. Any other region is left to the union of lines, untouched:
14
- * `top` is the repository the lines of a declaration both sides changed are merged in.
14
+ * sides, kept, would not give the two sides merged. They leave a declaration open: git sets two
15
+ * tables, two models or two functions added at one place side by side and keeps the lines they
16
+ * share once, so that the union of the lines no longer pairs their brackets. Or they pair them
17
+ * and the region they give, read back, is not the declarations of the three sides merged one by
18
+ * one: a line of one side stands inside a declaration of the other, a declaration lacks a line,
19
+ * stands twice, came back, or stands above one it reads. Such a region is merged from the
20
+ * three sides of the file, declaration by declaration. Any other region is left to the union of
21
+ * lines, untouched: `top` is the repository the lines of a declaration both sides changed are
22
+ * merged in.
15
23
  */
16
24
  export function settleDeclarations(path, top) {
17
25
  const text = path.merged ?? '';
@@ -22,7 +30,7 @@ export function settleDeclarations(path, top) {
22
30
  const frame = regionsOf(lines.map((line, at) => (owners[at] === undefined ? line : '')));
23
31
  const written = [];
24
32
  let from = 0;
25
- for (const region of frame.filter((candidate) => leavesADeclarationOpen(candidate, lines, owners))) {
33
+ for (const region of frame.filter((candidate) => unionIsWrong(candidate, { path, top, lines, owners }))) {
26
34
  const blocks = blocksIn(region, owners);
27
35
  const outcome = mergedRegion(region.name, path, { top, labels: labelsOf(blocks[0]), blocks: blocks.length });
28
36
  if ('held' in outcome) {
@@ -55,13 +63,14 @@ function blocksIn(region, owners) {
55
63
  return [...new Set(owners.slice(region.open + 1, region.close))].flatMap((owner) => owner === undefined ? [] : [owner]);
56
64
  }
57
65
  /**
58
- * Whether the lines of both sides, kept as the registry keeps them, would leave a declaration of
59
- * the region open: the region the union of lines writes does not pair its brackets, or it pairs
60
- * them by chance, two different statements added in one conflict opening or closing on one line
61
- * the union keeps once. A region with no conflict, or with one that holds a marker, which no
62
- * union settles, is not concerned.
66
+ * Whether the lines of both sides, kept as the registry keeps them, give a region that is not the
67
+ * two sides merged. Three cases. The region the union of lines writes does not pair its brackets.
68
+ * It pairs them by chance, two different statements added in one conflict opening or closing on
69
+ * one line the union keeps once. Or it pairs them and does not read back as the declarations of
70
+ * the three sides merged one by one. A region with no conflict, or with one that holds a marker,
71
+ * which no union settles, is not concerned.
63
72
  */
64
- function leavesADeclarationOpen(region, lines, owners) {
73
+ function unionIsWrong(region, { path, top, lines, owners }) {
65
74
  const blocks = blocksIn(region, owners);
66
75
  const sides = blocks.flatMap((block) => [...block.ours, ...block.base, ...block.theirs]);
67
76
  if (blocks.length === 0 || sides.some((line) => REGION_MARKER.test(line))) {
@@ -74,7 +83,24 @@ function leavesADeclarationOpen(region, lines, owners) {
74
83
  }
75
84
  return owner === owners[region.open + at] ? [] : registryUnion(owner, region.name);
76
85
  });
77
- return blocks.some(sharesHalfAPair) || bracketsLeftOpen(scan(union.join('\n')).code)?.length !== 0;
86
+ return (blocks.some(sharesHalfAPair) ||
87
+ bracketsLeftOpen(scan(union.join('\n')).code)?.length !== 0 ||
88
+ !readsAsMerged(union, { name: region.name, path, top }));
89
+ }
90
+ /**
91
+ * Whether the region the union of lines gives is the two sides merged. It is read back against
92
+ * the three sides merged declaration by declaration, and kept when it reads as that merge. It is
93
+ * kept too, as it always was, when the kit has nothing certain to read it against: a side is not
94
+ * read with certainty, or the two sides differ on lines that end no statement, read as lines
95
+ * only. The `imports` region is read by what it brings.
96
+ */
97
+ function readsAsMerged(union, { name, path, top }) {
98
+ const readAs = { region: name, prisma: path.file.endsWith('.prisma') };
99
+ const sides = sidesOfRegion(name, path);
100
+ if (sides === undefined || (name === 'imports' && importsReadAsMerged(union, sides))) {
101
+ return true;
102
+ }
103
+ return unionReadsAsMerged(union, sides, (versions) => linesOfBothSides(top, versions, readAs)) !== 'mixed';
78
104
  }
79
105
  /** The marker lines of the first conflict of a region: the declarations left to a person are written with the same. */
80
106
  function labelsOf(block) {
@@ -1 +1 @@
1
- {"version":3,"file":"settle-declarations.js","sourceRoot":"","sources":["../../../src/merge/declarations/settle-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAe,SAAS,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAmB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAA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I,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;IAC/E,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAExC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACrF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,OAAO,CAAC;AAC7G,CAAC;AAED,uHAAuH;AACvH,SAAS,QAAQ,CAAC,KAAgC;IAChD,MAAM,IAAI,GAAG,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAErD,OAAO;QACL,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,cAAc;QACrC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;QACxD,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ConflictedPath } from '../conflicted-path.js';
2
+ import type { DeclaredSides } from './merge-declarations.js';
3
+ /** The three sides of a region of a conflicted file, each read as declarations; undefined when one of them, the base among them, does not hold it once or is not read with certainty. */
4
+ export declare function sidesOfRegion(name: string, path: ConflictedPath): DeclaredSides | undefined;
5
+ //# sourceMappingURL=sides-of-region.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sides-of-region.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/sides-of-region.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,yLAAyL;AACzL,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,GAAG,SAAS,CAM3F"}
@@ -0,0 +1,19 @@
1
+ import { regionsOf } from '../../markers/index.js';
2
+ import { declarationsOf } from './declarations-of.js';
3
+ /** The three sides of a region of a conflicted file, each read as declarations; undefined when one of them, the base among them, does not hold it once or is not read with certainty. */
4
+ export function sidesOfRegion(name, path) {
5
+ const ours = sideOf(path.ours, name);
6
+ const theirs = sideOf(path.theirs, name);
7
+ const base = sideOf(path.base, name);
8
+ return ours === undefined || theirs === undefined || base === undefined ? undefined : { ours, base, theirs };
9
+ }
10
+ /** The declarations a side holds in its one region of that name; undefined when it holds none, several, or one that is not read. */
11
+ function sideOf(text, name) {
12
+ const lines = (text ?? '').split('\n');
13
+ const regions = regionsOf(lines).filter((region) => region.name === name);
14
+ const [region] = regions;
15
+ return region === undefined || regions.length > 1
16
+ ? undefined
17
+ : declarationsOf(lines.slice(region.open + 1, region.close));
18
+ }
19
+ //# sourceMappingURL=sides-of-region.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sides-of-region.js","sourceRoot":"","sources":["../../../src/merge/declarations/sides-of-region.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,yLAAyL;AACzL,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAoB;IAC9D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAErC,OAAO,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/G,CAAC;AAED,oIAAoI;AACpI,SAAS,MAAM,CAAC,IAAwB,EAAE,IAAY;IACpD,MAAM,KAAK,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IAEzB,OAAO,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAC/C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { ConflictBlock } from '../conflict-blocks.js';
2
+ /** Where the lines of a conflict are read: the region they lie in, and whether the file is a schema of Prisma, where a line is a statement. */
3
+ export interface ReadAs {
4
+ readonly region: string;
5
+ readonly prisma: boolean;
6
+ }
7
+ /**
8
+ * Whether the union of the lines of a conflict may set a line of one side inside a statement of
9
+ * the other, or leave a statement without one of its lines, while every bracket still pairs. Two
10
+ * signs, read on the lines alone. A side of the conflict does not hold whole statements: it opens
11
+ * a bracket it does not close, or closes one it did not open, git having cut it in the middle of
12
+ * a declaration. Or a statement a side wrote on several lines (a call, a chain, a block comment,
13
+ * a decorator with what it decorates) is whole neither in the union, which keeps each line once,
14
+ * nor in the base, where the other side changed or removed it.
15
+ */
16
+ export declare function unionInDoubt(block: ConflictBlock, readAs: ReadAs): boolean;
17
+ //# sourceMappingURL=union-in-doubt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-in-doubt.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/union-in-doubt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQxD,+IAA+I;AAC/I,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAe1E"}
@@ -0,0 +1,84 @@
1
+ import { scan } from '../../check/scan/scan.js';
2
+ import { registryUnion } from '../registry-union.js';
3
+ import { bracketsLeftOpen } from './brackets-left-open.js';
4
+ import { GOES_ON } from './declarations-of.js';
5
+ /** How a line ends that the next one goes on with: an operator, an arrow, a dot. */
6
+ const LEFT_OPEN = /(?:[=+\-*|&?:.]|=>)$/;
7
+ /**
8
+ * Whether the union of the lines of a conflict may set a line of one side inside a statement of
9
+ * the other, or leave a statement without one of its lines, while every bracket still pairs. Two
10
+ * signs, read on the lines alone. A side of the conflict does not hold whole statements: it opens
11
+ * a bracket it does not close, or closes one it did not open, git having cut it in the middle of
12
+ * a declaration. Or a statement a side wrote on several lines (a call, a chain, a block comment,
13
+ * a decorator with what it decorates) is whole neither in the union, which keeps each line once,
14
+ * nor in the base, where the other side changed or removed it.
15
+ */
16
+ export function unionInDoubt(block, readAs) {
17
+ const sides = [block.ours, block.theirs].map((lines) => statementsOf(lines, readAs.prisma));
18
+ const base = statementsOf(block.base, readAs.prisma);
19
+ if (base === undefined || sides.includes(undefined)) {
20
+ return true;
21
+ }
22
+ const kept = [registryUnion(block, readAs.region), block.base].map((lines) => lines.filter((line) => line.trim() !== ''));
23
+ return sides.some((statements) => (statements ?? []).some((statement) => statement.length > 1 && !kept.some((lines) => holdsRun(lines, statement))));
24
+ }
25
+ /** Whether `lines` holds the lines of `run` one after the other. */
26
+ function holdsRun(lines, run) {
27
+ return lines.some((_, from) => run.every((line, at) => lines[from + at] === line));
28
+ }
29
+ /**
30
+ * The lines of one side of a conflict in statements, blank lines and the line comments written
31
+ * between two statements left out: a
32
+ * statement runs until its brackets are closed and the next line does not go on with it, a block
33
+ * comment to its last line, a decorator to the end of what it decorates. Undefined when the side
34
+ * does not pair its brackets.
35
+ */
36
+ function statementsOf(lines, prisma) {
37
+ const code = scan(lines.join('\n')).code.split('\n');
38
+ let reading = { statements: [], statement: [], open: [], commented: false };
39
+ for (const [at, line] of lines.entries()) {
40
+ const read = (code[at] ?? '').trim();
41
+ reading = reading === undefined ? undefined : followed(reading, { line, read, next: nextOf(code, at), prisma });
42
+ }
43
+ return reading === undefined || reading.open.length > 0 ? undefined : closed(reading).statements;
44
+ }
45
+ /** The reading after one more line; undefined when the line closes a bracket that is not open. */
46
+ function followed(reading, { line, read, next, prisma }) {
47
+ const comment = read === '' && reading.open.length === 0;
48
+ if (line.trim() === '' || (comment && line.trim().startsWith('//'))) {
49
+ return reading;
50
+ }
51
+ const open = bracketsLeftOpen(read, reading.open);
52
+ const started = comment === reading.commented ? reading : closed(reading);
53
+ if (open === undefined) {
54
+ return undefined;
55
+ }
56
+ const grown = { ...started, statement: [...started.statement, line], open, commented: comment };
57
+ return open.length === 0 && !goesOn({ line, read, next, prisma }, comment) ? closed(grown) : grown;
58
+ }
59
+ /** A reading whose statement is over: the next line starts another. */
60
+ function closed({ statements, statement, open }) {
61
+ return {
62
+ statements: statement.length > 0 ? [...statements, [...statement]] : statements,
63
+ statement: [],
64
+ open,
65
+ commented: false,
66
+ };
67
+ }
68
+ /** The code of the first line after `at` that holds some. */
69
+ function nextOf(code, at) {
70
+ return (code.slice(at + 1).find((after) => after.trim() !== '') ?? '').trim();
71
+ }
72
+ /** Whether the statement a line is the last of so far goes on with the next line: an entry spread into a list starts one of its own. */
73
+ function goesOn({ line, read, next, prisma }, comment) {
74
+ if (comment) {
75
+ return !line.trimEnd().endsWith('*/');
76
+ }
77
+ if (prisma) {
78
+ return false;
79
+ }
80
+ return ((GOES_ON.test(next) && !next.startsWith('...')) ||
81
+ LEFT_OPEN.test(read) ||
82
+ (read.startsWith('@') && !read.endsWith(';') && next !== ''));
83
+ }
84
+ //# sourceMappingURL=union-in-doubt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-in-doubt.js","sourceRoot":"","sources":["../../../src/merge/declarations/union-in-doubt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,oFAAoF;AACpF,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAQzC;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAoB,EAAE,MAAc;IAC/D,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5F,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAErD,IAAI,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,aAAa,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AAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QACpB,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,EAAE,CAAC,CAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { DeclaredSides } from './merge-declarations.js';
2
+ import type { LineMerge } from './merged-lines.js';
3
+ /**
4
+ * What the region the union of lines gives reads as: the three sides `merged`, declarations of
5
+ * the two sides `mixed`, or `lines`: a side holds lines that end no statement, entries of a list,
6
+ * which are read as lines only, and the kit has nothing to say of the region.
7
+ */
8
+ type ReadBack = 'merged' | 'mixed' | 'lines';
9
+ /**
10
+ * Reads the region the union of lines gives against the three sides merged declaration by
11
+ * declaration. It is `merged` when it holds, whole and once, each declaration with the comments
12
+ * above it: the one a side added, changed or removed while the other left it as the base holds
13
+ * it, the one both wrote alike, and for one both changed the lines `lineMerge` gives, those the
14
+ * kit keeps of that declaration merged alone; and when no declaration stands above one it reads,
15
+ * against the sides. It is `mixed` when it is not read with certainty, holds a declaration no
16
+ * side wrote, lacks one, inverts a reference, or when the two sides do not agree on a
17
+ * declaration: one removed it and the other changed it or started to read it, both added it
18
+ * differently, its lines do not merge. The order of the lines of both sides is otherwise theirs to
19
+ * keep, and blank lines are not compared: the lines of both sides keep one of each run.
20
+ */
21
+ export declare function unionReadsAsMerged(union: readonly string[], written: DeclaredSides, lineMerge: LineMerge): ReadBack;
22
+ export {};
23
+ //# sourceMappingURL=union-reads-as-merged.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"union-reads-as-merged.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/union-reads-as-merged.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;GAIG;AACH,KAAK,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,QAAQ,CAmBnH"}