@hydranium/conformance 1.0.0-next.8 → 1.0.0-next.85

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/src/model.ts CHANGED
@@ -82,6 +82,46 @@ export interface EditSpec {
82
82
  readonly expect: (root: unknown) => boolean;
83
83
  }
84
84
 
85
+ /**
86
+ * A reference-picker query for an element that does not exist yet, plus the
87
+ * candidate the adopter expects it to offer.
88
+ *
89
+ * **The URI a create-element flow holds is a FOLDER**, because the file is not
90
+ * written until the dialog is confirmed. A folder URI names no file and so
91
+ * carries no extension, which is the one shape a head cannot route to a grammar
92
+ * by URI alone — it has to resolve the language some other way. That makes this
93
+ * the create dialog's load-bearing precondition and the reason the query is
94
+ * worth a conformance check of its own: a head that gets it wrong answers no
95
+ * candidates or throws, and the dialog never opens.
96
+ */
97
+ export interface ReferenceQuerySpec {
98
+ /** AST type of the element being created — the synthetic source's own type. */
99
+ readonly type: string;
100
+ /** The reference property on the source (or on `syntheticPath`'s leaf) whose candidates the picker fills. */
101
+ readonly property: string;
102
+ /**
103
+ * Steps from the synthetic source down to the node holding `property`, when
104
+ * the reference is not on the source itself. Each step is
105
+ * `[containerProperty, type]` — the kit builds the `SyntheticStep`s, so the
106
+ * fixture names no protocol type.
107
+ */
108
+ readonly path?: ReadonlyArray<readonly [containerProperty: string, type: string]>;
109
+ /**
110
+ * Folder the create flow asks at. {@link Deferred} because a fixture may name
111
+ * a workspace the driver's `connect` only just created. Defaults to the parent
112
+ * of `valid.uri`, which is the folder a sibling of the valid model would go
113
+ * into — the common case, so most fixtures supply only `type` + `property`.
114
+ */
115
+ readonly folderUri?: Deferred<string>;
116
+ /**
117
+ * A candidate label the query MUST offer. Without it an empty result passes,
118
+ * and empty is exactly what the defect this check exists for produces — so
119
+ * the expectation is what makes the check discriminating rather than a
120
+ * smoke test.
121
+ */
122
+ readonly expectCandidate: string;
123
+ }
124
+
85
125
  /**
86
126
  * The per-language fixture. `valid` and `invalid` are defined once and reused
87
127
  * across heads; the two extras are per-head opt-ins.
@@ -98,6 +138,9 @@ export interface EditSpec {
98
138
  * uses `invalid.text` and never calls `edit.expect`, so an LSP-only adopter
99
139
  * has nothing to supply here.
100
140
  * - `completionPosition` — read by the **LSP slice only**.
141
+ * - `referenceQuery` — read by the **data slice only**, and only when the
142
+ * driver supplies `references` (the reference surface is opt-in on the head
143
+ * too, so both halves have to be present for the check to run).
101
144
  *
102
145
  * Both extras are optional and their checks report *skipped* when absent,
103
146
  * rather than silently not running. Making either mandatory would defeat the
@@ -119,4 +162,67 @@ export interface LanguageFixture {
119
162
  readonly edit?: EditSpec;
120
163
  /** Optional: a position at which the LSP completion check requests completion. */
121
164
  readonly completionPosition?: { readonly line: number; readonly character: number };
165
+ /**
166
+ * Optional: the create-dialog reference query. Read by the **data slice
167
+ * only**, and only when the driver exposes the opt-in reference surface.
168
+ */
169
+ readonly referenceQuery?: ReferenceQuerySpec;
170
+ /**
171
+ * Optional: a second document that REFERENCES {@link valid}, so the data
172
+ * slice can provoke a CASCADE — a rebuild of this document caused by
173
+ * editing the one it points at, with its own text never touched.
174
+ *
175
+ * Opt-in because a grammar need not have cross-document references at all,
176
+ * and because only the adopter knows which pair of documents forms one.
177
+ * Supplying it IS the claim that editing `valid` rebuilds this document; the
178
+ * check then holds the head to reporting that on `onDocumentsBuilt`, which
179
+ * is the only channel that can carry it — the document has no subscriber and
180
+ * its file did not change, so neither the update channel nor a filesystem
181
+ * watcher can.
182
+ */
183
+ readonly dependent?: ConformanceModel;
184
+ /**
185
+ * Optional: a locale plus the sentence the server must publish in it. Read
186
+ * by the **LSP slice only**.
187
+ */
188
+ readonly renderedDiagnostic?: RenderedDiagnosticSpec;
189
+ }
190
+
191
+ /**
192
+ * A locale, and one sentence the server must produce in it for the `invalid`
193
+ * fixture.
194
+ *
195
+ * **Opt-in, and it has to be.** The framework ships no catalogue and selects no
196
+ * locale, so a server that installs no renderer correctly publishes English —
197
+ * mandating this check would fail every adopter without i18n for doing the right
198
+ * thing. Supplying the field is the adopter saying "I render server-side, hold me
199
+ * to it".
200
+ *
201
+ * `expected` is a SUBSTRING, not the whole message. The kit owns no grammar, so
202
+ * it cannot know how many diagnostics `invalid` produces or in what order, and
203
+ * an adopter should be able to pin the translated fragment without restating a
204
+ * sentence they may reword. A substring long enough to be wrong if the render
205
+ * did not happen is the whole requirement.
206
+ *
207
+ * `absentWithoutLocale` is what makes the check a pair rather than a single
208
+ * assertion: "the message contains X" also passes for a server whose English
209
+ * happens to contain X, and for one that renders regardless of locale. Naming
210
+ * the fragment that must DISAPPEAR when no locale is declared is what
211
+ * distinguishes those.
212
+ */
213
+ export interface RenderedDiagnosticSpec {
214
+ /** The locale to declare at `initialize` — the tag whose catalogue the server has. */
215
+ readonly locale: string;
216
+ /** A fragment of the translated sentence, present in some diagnostic of the `invalid` fixture. */
217
+ readonly expected: string;
218
+ /**
219
+ * A fragment that must be absent once `locale` is declared, and present
220
+ * without it — normally a piece of the server's own English.
221
+ *
222
+ * Optional only because a catalogue may translate a message whose English
223
+ * shares no distinctive fragment with it. Omitting it drops the second half
224
+ * of the pair and leaves a check that a render-nothing server can pass; the
225
+ * kit reports that rather than pretending otherwise.
226
+ */
227
+ readonly absentWithLocale?: string;
122
228
  }