@formspec/analysis 0.1.0-alpha.20 → 0.1.0-alpha.21
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/analysis.d.ts +69 -450
- package/dist/compiler-signatures.d.ts +48 -0
- package/dist/compiler-signatures.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/file-snapshots.d.ts +3 -0
- package/dist/file-snapshots.d.ts.map +1 -1
- package/dist/index.cjs +169 -2800
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +168 -2761
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +3995 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.ts +21 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +3902 -0
- package/dist/internal.js.map +1 -0
- package/dist/perf-tracing.d.ts +16 -0
- package/dist/perf-tracing.d.ts.map +1 -0
- package/dist/protocol.cjs +951 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.ts +4 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +904 -0
- package/dist/protocol.js.map +1 -0
- package/dist/semantic-protocol.d.ts +49 -1
- package/dist/semantic-protocol.d.ts.map +1 -1
- package/dist/tag-registry.d.ts +2 -0
- package/dist/tag-registry.d.ts.map +1 -1
- package/dist/workspace-runtime.d.ts +6 -0
- package/dist/workspace-runtime.d.ts.map +1 -1
- package/package.json +12 -2
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,904 @@
|
|
|
1
|
+
// src/tag-registry.ts
|
|
2
|
+
import {
|
|
3
|
+
BUILTIN_CONSTRAINT_DEFINITIONS,
|
|
4
|
+
normalizeConstraintTagName
|
|
5
|
+
} from "@formspec/core";
|
|
6
|
+
var FORM_SPEC_PLACEMENTS = [
|
|
7
|
+
"class",
|
|
8
|
+
"class-field",
|
|
9
|
+
"class-method",
|
|
10
|
+
"interface",
|
|
11
|
+
"interface-field",
|
|
12
|
+
"type-alias",
|
|
13
|
+
"type-alias-field",
|
|
14
|
+
"variable",
|
|
15
|
+
"function",
|
|
16
|
+
"function-parameter",
|
|
17
|
+
"method-parameter"
|
|
18
|
+
];
|
|
19
|
+
var FORM_SPEC_TARGET_KINDS = [
|
|
20
|
+
"none",
|
|
21
|
+
"path",
|
|
22
|
+
"member",
|
|
23
|
+
"variant"
|
|
24
|
+
];
|
|
25
|
+
var FIELD_PLACEMENTS = [
|
|
26
|
+
"class-field",
|
|
27
|
+
"interface-field",
|
|
28
|
+
"type-alias-field",
|
|
29
|
+
"variable",
|
|
30
|
+
"function-parameter",
|
|
31
|
+
"method-parameter"
|
|
32
|
+
];
|
|
33
|
+
var TYPE_PLACEMENTS = [
|
|
34
|
+
"class",
|
|
35
|
+
"interface",
|
|
36
|
+
"type-alias"
|
|
37
|
+
];
|
|
38
|
+
var DECLARATION_PLACEMENTS = [
|
|
39
|
+
"class-method",
|
|
40
|
+
"function"
|
|
41
|
+
];
|
|
42
|
+
var ALL_PLACEMENTS = [
|
|
43
|
+
...TYPE_PLACEMENTS,
|
|
44
|
+
...FIELD_PLACEMENTS,
|
|
45
|
+
...DECLARATION_PLACEMENTS
|
|
46
|
+
];
|
|
47
|
+
var INTEGER_VALUE_TAGS = /* @__PURE__ */ new Set(["minLength", "maxLength", "minItems", "maxItems"]);
|
|
48
|
+
var SIGNED_INTEGER_VALUE_TAGS = /* @__PURE__ */ new Set(["order"]);
|
|
49
|
+
var JSON_VALUE_TAGS = /* @__PURE__ */ new Set(["const", "enumOptions"]);
|
|
50
|
+
var BOOLEAN_VALUE_TAGS = /* @__PURE__ */ new Set(["uniqueItems"]);
|
|
51
|
+
var STRING_VALUE_TAGS = /* @__PURE__ */ new Set([
|
|
52
|
+
"pattern",
|
|
53
|
+
"displayName",
|
|
54
|
+
"description",
|
|
55
|
+
"format",
|
|
56
|
+
"placeholder",
|
|
57
|
+
"group",
|
|
58
|
+
"example",
|
|
59
|
+
"remarks",
|
|
60
|
+
"see",
|
|
61
|
+
"apiName"
|
|
62
|
+
]);
|
|
63
|
+
var CONDITION_VALUE_TAGS = /* @__PURE__ */ new Set(["showWhen", "hideWhen", "enableWhen", "disableWhen"]);
|
|
64
|
+
var CONSTRAINT_COMPLETION_DETAIL = {
|
|
65
|
+
minimum: "Minimum numeric value (inclusive). Example: `@minimum 0`",
|
|
66
|
+
maximum: "Maximum numeric value (inclusive). Example: `@maximum 100`",
|
|
67
|
+
exclusiveMinimum: "Minimum numeric value (exclusive). Example: `@exclusiveMinimum 0`",
|
|
68
|
+
exclusiveMaximum: "Maximum numeric value (exclusive). Example: `@exclusiveMaximum 100`",
|
|
69
|
+
multipleOf: "Value must be a multiple of this number. Example: `@multipleOf 0.01`",
|
|
70
|
+
minLength: "Minimum string length. Example: `@minLength 1`",
|
|
71
|
+
maxLength: "Maximum string length. Example: `@maxLength 255`",
|
|
72
|
+
minItems: "Minimum number of array items. Example: `@minItems 1`",
|
|
73
|
+
maxItems: "Maximum number of array items. Example: `@maxItems 10`",
|
|
74
|
+
uniqueItems: "Require all array items to be distinct. Example: `@uniqueItems`",
|
|
75
|
+
pattern: "Regular expression pattern for string validation. Example: `@pattern ^[a-z]+$`",
|
|
76
|
+
enumOptions: 'Inline JSON array of allowed enum values. Example: `@enumOptions ["a","b","c"]`',
|
|
77
|
+
const: 'Require a constant JSON value. Example: `@const "USD"`'
|
|
78
|
+
};
|
|
79
|
+
var CONSTRAINT_HOVER_DOCS = {
|
|
80
|
+
minimum: [
|
|
81
|
+
"**@minimum** `<number>`",
|
|
82
|
+
"",
|
|
83
|
+
"Sets an inclusive lower bound on a numeric field.",
|
|
84
|
+
"",
|
|
85
|
+
"Maps to `minimum` in JSON Schema.",
|
|
86
|
+
"",
|
|
87
|
+
"**Signature:** `@minimum [:path] <number>`"
|
|
88
|
+
].join("\n"),
|
|
89
|
+
maximum: [
|
|
90
|
+
"**@maximum** `<number>`",
|
|
91
|
+
"",
|
|
92
|
+
"Sets an inclusive upper bound on a numeric field.",
|
|
93
|
+
"",
|
|
94
|
+
"Maps to `maximum` in JSON Schema.",
|
|
95
|
+
"",
|
|
96
|
+
"**Signature:** `@maximum [:path] <number>`"
|
|
97
|
+
].join("\n"),
|
|
98
|
+
exclusiveMinimum: [
|
|
99
|
+
"**@exclusiveMinimum** `<number>`",
|
|
100
|
+
"",
|
|
101
|
+
"Sets an exclusive lower bound on a numeric field.",
|
|
102
|
+
"",
|
|
103
|
+
"Maps to `exclusiveMinimum` in JSON Schema.",
|
|
104
|
+
"",
|
|
105
|
+
"**Signature:** `@exclusiveMinimum [:path] <number>`"
|
|
106
|
+
].join("\n"),
|
|
107
|
+
exclusiveMaximum: [
|
|
108
|
+
"**@exclusiveMaximum** `<number>`",
|
|
109
|
+
"",
|
|
110
|
+
"Sets an exclusive upper bound on a numeric field.",
|
|
111
|
+
"",
|
|
112
|
+
"Maps to `exclusiveMaximum` in JSON Schema.",
|
|
113
|
+
"",
|
|
114
|
+
"**Signature:** `@exclusiveMaximum [:path] <number>`"
|
|
115
|
+
].join("\n"),
|
|
116
|
+
multipleOf: [
|
|
117
|
+
"**@multipleOf** `<number>`",
|
|
118
|
+
"",
|
|
119
|
+
"Requires the numeric value to be a multiple of the given number.",
|
|
120
|
+
"",
|
|
121
|
+
"Maps to `multipleOf` in JSON Schema.",
|
|
122
|
+
"",
|
|
123
|
+
"**Signature:** `@multipleOf [:path] <number>`"
|
|
124
|
+
].join("\n"),
|
|
125
|
+
minLength: [
|
|
126
|
+
"**@minLength** `<integer>`",
|
|
127
|
+
"",
|
|
128
|
+
"Sets a minimum character length on a string field.",
|
|
129
|
+
"",
|
|
130
|
+
"Maps to `minLength` in JSON Schema.",
|
|
131
|
+
"",
|
|
132
|
+
"**Signature:** `@minLength [:path] <integer>`"
|
|
133
|
+
].join("\n"),
|
|
134
|
+
maxLength: [
|
|
135
|
+
"**@maxLength** `<integer>`",
|
|
136
|
+
"",
|
|
137
|
+
"Sets a maximum character length on a string field.",
|
|
138
|
+
"",
|
|
139
|
+
"Maps to `maxLength` in JSON Schema.",
|
|
140
|
+
"",
|
|
141
|
+
"**Signature:** `@maxLength [:path] <integer>`"
|
|
142
|
+
].join("\n"),
|
|
143
|
+
minItems: [
|
|
144
|
+
"**@minItems** `<integer>`",
|
|
145
|
+
"",
|
|
146
|
+
"Sets a minimum number of items in an array field.",
|
|
147
|
+
"",
|
|
148
|
+
"Maps to `minItems` in JSON Schema.",
|
|
149
|
+
"",
|
|
150
|
+
"**Signature:** `@minItems [:path] <integer>`"
|
|
151
|
+
].join("\n"),
|
|
152
|
+
maxItems: [
|
|
153
|
+
"**@maxItems** `<integer>`",
|
|
154
|
+
"",
|
|
155
|
+
"Sets a maximum number of items in an array field.",
|
|
156
|
+
"",
|
|
157
|
+
"Maps to `maxItems` in JSON Schema.",
|
|
158
|
+
"",
|
|
159
|
+
"**Signature:** `@maxItems [:path] <integer>`"
|
|
160
|
+
].join("\n"),
|
|
161
|
+
uniqueItems: [
|
|
162
|
+
"**@uniqueItems**",
|
|
163
|
+
"",
|
|
164
|
+
"Requires all items in an array field to be distinct.",
|
|
165
|
+
"",
|
|
166
|
+
"Maps to `uniqueItems` in JSON Schema.",
|
|
167
|
+
"",
|
|
168
|
+
"**Signature:** `@uniqueItems [:path]`"
|
|
169
|
+
].join("\n"),
|
|
170
|
+
pattern: [
|
|
171
|
+
"**@pattern** `<regex>`",
|
|
172
|
+
"",
|
|
173
|
+
"Sets a regular expression pattern that a string field must match.",
|
|
174
|
+
"",
|
|
175
|
+
"Maps to `pattern` in JSON Schema.",
|
|
176
|
+
"",
|
|
177
|
+
"**Signature:** `@pattern [:path] <regex>`"
|
|
178
|
+
].join("\n"),
|
|
179
|
+
enumOptions: [
|
|
180
|
+
"**@enumOptions** `<json-array>`",
|
|
181
|
+
"",
|
|
182
|
+
"Specifies the allowed values for an enum field as an inline JSON array.",
|
|
183
|
+
"",
|
|
184
|
+
"Maps to `enum` in JSON Schema.",
|
|
185
|
+
"",
|
|
186
|
+
"**Signature:** `@enumOptions <json-array>`"
|
|
187
|
+
].join("\n"),
|
|
188
|
+
const: [
|
|
189
|
+
"**@const** `<json-literal>`",
|
|
190
|
+
"",
|
|
191
|
+
"Requires the field value to equal a single constant JSON value.",
|
|
192
|
+
"",
|
|
193
|
+
"Maps to `const` in JSON Schema.",
|
|
194
|
+
"",
|
|
195
|
+
"**Signature:** `@const [:path] <json-literal>`"
|
|
196
|
+
].join("\n")
|
|
197
|
+
};
|
|
198
|
+
function inferValueKind(name) {
|
|
199
|
+
if (INTEGER_VALUE_TAGS.has(name)) return "integer";
|
|
200
|
+
if (SIGNED_INTEGER_VALUE_TAGS.has(name)) return "signedInteger";
|
|
201
|
+
if (JSON_VALUE_TAGS.has(name)) return "json";
|
|
202
|
+
if (BOOLEAN_VALUE_TAGS.has(name)) return "boolean";
|
|
203
|
+
if (STRING_VALUE_TAGS.has(name)) return "string";
|
|
204
|
+
if (CONDITION_VALUE_TAGS.has(name)) return "condition";
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
function getBuiltinValueKind(name) {
|
|
208
|
+
return inferValueKind(name) ?? "number";
|
|
209
|
+
}
|
|
210
|
+
function getBuiltinConstraintCapability(name) {
|
|
211
|
+
switch (name) {
|
|
212
|
+
case "minimum":
|
|
213
|
+
case "maximum":
|
|
214
|
+
case "exclusiveMinimum":
|
|
215
|
+
case "exclusiveMaximum":
|
|
216
|
+
case "multipleOf":
|
|
217
|
+
return "numeric-comparable";
|
|
218
|
+
case "minLength":
|
|
219
|
+
case "maxLength":
|
|
220
|
+
case "pattern":
|
|
221
|
+
return "string-like";
|
|
222
|
+
case "minItems":
|
|
223
|
+
case "maxItems":
|
|
224
|
+
case "uniqueItems":
|
|
225
|
+
return "array-like";
|
|
226
|
+
case "enumOptions":
|
|
227
|
+
return "enum-member-addressable";
|
|
228
|
+
case "const":
|
|
229
|
+
return "json-like";
|
|
230
|
+
default: {
|
|
231
|
+
const exhaustive = name;
|
|
232
|
+
return exhaustive;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function capabilitiesForValueKind(valueKind) {
|
|
237
|
+
switch (valueKind) {
|
|
238
|
+
case "number":
|
|
239
|
+
case "integer":
|
|
240
|
+
case "signedInteger":
|
|
241
|
+
return ["numeric-comparable"];
|
|
242
|
+
case "string":
|
|
243
|
+
return ["string-like"];
|
|
244
|
+
case "json":
|
|
245
|
+
return ["json-like"];
|
|
246
|
+
case "condition":
|
|
247
|
+
return ["condition-like"];
|
|
248
|
+
case "boolean":
|
|
249
|
+
case null:
|
|
250
|
+
return [];
|
|
251
|
+
default: {
|
|
252
|
+
const exhaustive = valueKind;
|
|
253
|
+
return exhaustive;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function valueLabelForKind(valueKind, fallback = "<value>") {
|
|
258
|
+
switch (valueKind) {
|
|
259
|
+
case "number":
|
|
260
|
+
return "<number>";
|
|
261
|
+
case "integer":
|
|
262
|
+
case "signedInteger":
|
|
263
|
+
return "<integer>";
|
|
264
|
+
case "string":
|
|
265
|
+
return "<text>";
|
|
266
|
+
case "json":
|
|
267
|
+
return "<json>";
|
|
268
|
+
case "condition":
|
|
269
|
+
return "<condition>";
|
|
270
|
+
case "boolean":
|
|
271
|
+
case null:
|
|
272
|
+
return "";
|
|
273
|
+
default: {
|
|
274
|
+
const exhaustive = valueKind;
|
|
275
|
+
void exhaustive;
|
|
276
|
+
return fallback;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function targetLabelForKind(kind) {
|
|
281
|
+
switch (kind) {
|
|
282
|
+
case "path":
|
|
283
|
+
return "[:path]";
|
|
284
|
+
case "member":
|
|
285
|
+
return ":member";
|
|
286
|
+
case "variant":
|
|
287
|
+
return ":variant";
|
|
288
|
+
default: {
|
|
289
|
+
const exhaustive = kind;
|
|
290
|
+
return exhaustive;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function parameterKindForTarget(targetKind) {
|
|
295
|
+
switch (targetKind) {
|
|
296
|
+
case "path":
|
|
297
|
+
return "target-path";
|
|
298
|
+
case "member":
|
|
299
|
+
return "target-member";
|
|
300
|
+
case "variant":
|
|
301
|
+
return "target-variant";
|
|
302
|
+
default: {
|
|
303
|
+
const exhaustive = targetKind;
|
|
304
|
+
return exhaustive;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function createTargetParameter(targetKind, valueKind, pathCapability) {
|
|
309
|
+
const base = {
|
|
310
|
+
kind: parameterKindForTarget(targetKind),
|
|
311
|
+
label: targetLabelForKind(targetKind),
|
|
312
|
+
optional: targetKind === "path"
|
|
313
|
+
};
|
|
314
|
+
if (targetKind === "path") {
|
|
315
|
+
const capability = pathCapability ?? capabilitiesForValueKind(valueKind)[0];
|
|
316
|
+
return capability === void 0 ? base : { ...base, capability };
|
|
317
|
+
}
|
|
318
|
+
if (targetKind === "member") {
|
|
319
|
+
return { ...base, capability: "enum-member-addressable" };
|
|
320
|
+
}
|
|
321
|
+
return base;
|
|
322
|
+
}
|
|
323
|
+
function createSignature(name, placements, targetKind, valueKind, valueLabel, pathCapability) {
|
|
324
|
+
const parameters = [];
|
|
325
|
+
if (targetKind !== null) {
|
|
326
|
+
parameters.push(createTargetParameter(targetKind, valueKind, pathCapability));
|
|
327
|
+
}
|
|
328
|
+
if (valueLabel !== "") {
|
|
329
|
+
parameters.push(
|
|
330
|
+
valueKind === null ? {
|
|
331
|
+
kind: "value",
|
|
332
|
+
label: valueLabel
|
|
333
|
+
} : {
|
|
334
|
+
kind: "value",
|
|
335
|
+
label: valueLabel,
|
|
336
|
+
valueKind
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
const targetLabel = targetKind === null ? "" : ` ${targetLabelForKind(targetKind)}`;
|
|
341
|
+
const valueLabelSuffix = valueLabel === "" ? "" : ` ${valueLabel}`;
|
|
342
|
+
return {
|
|
343
|
+
label: `@${name}${targetLabel}${valueLabelSuffix}`,
|
|
344
|
+
placements,
|
|
345
|
+
parameters
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function buildHoverMarkdown(name, hoverSummary, signatures, valueLabel) {
|
|
349
|
+
const header = valueLabel === "" ? `**@${name}**` : `**@${name}** \`${valueLabel}\``;
|
|
350
|
+
const signatureLines = signatures.length === 1 ? [`**Signature:** \`${signatures[0]?.label ?? `@${name}`}\``] : ["**Signatures:**", ...signatures.map((signature) => `- \`${signature.label}\``)];
|
|
351
|
+
return [header, "", hoverSummary, "", ...signatureLines].join("\n");
|
|
352
|
+
}
|
|
353
|
+
function makeConstraintSignatures(name) {
|
|
354
|
+
const valueKind = getBuiltinValueKind(name);
|
|
355
|
+
const subjectCapability = getBuiltinConstraintCapability(name);
|
|
356
|
+
const valueLabel = name === "pattern" ? "<regex>" : name === "enumOptions" ? "<json-array>" : name === "const" ? "<json-literal>" : valueLabelForKind(valueKind);
|
|
357
|
+
return [
|
|
358
|
+
createSignature(name, FIELD_PLACEMENTS, null, valueKind, valueLabel),
|
|
359
|
+
createSignature(name, FIELD_PLACEMENTS, "path", valueKind, valueLabel, subjectCapability)
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
var BUILTIN_TAG_DEFINITIONS = Object.fromEntries(
|
|
363
|
+
Object.keys(BUILTIN_CONSTRAINT_DEFINITIONS).map((name) => {
|
|
364
|
+
const valueKind = getBuiltinValueKind(name);
|
|
365
|
+
const subjectCapability = getBuiltinConstraintCapability(name);
|
|
366
|
+
return [
|
|
367
|
+
name,
|
|
368
|
+
{
|
|
369
|
+
canonicalName: name,
|
|
370
|
+
valueKind,
|
|
371
|
+
requiresArgument: valueKind !== "boolean",
|
|
372
|
+
supportedTargets: ["none", "path"],
|
|
373
|
+
allowDuplicates: false,
|
|
374
|
+
category: "constraint",
|
|
375
|
+
placements: FIELD_PLACEMENTS,
|
|
376
|
+
capabilities: [subjectCapability],
|
|
377
|
+
completionDetail: CONSTRAINT_COMPLETION_DETAIL[name] ?? `@${name}`,
|
|
378
|
+
hoverMarkdown: CONSTRAINT_HOVER_DOCS[name] ?? `**@${name}**`,
|
|
379
|
+
signatures: makeConstraintSignatures(name)
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
})
|
|
383
|
+
);
|
|
384
|
+
var EXTRA_TAG_SPECS = {
|
|
385
|
+
displayName: {
|
|
386
|
+
requiresArgument: true,
|
|
387
|
+
supportedTargets: ["none", "member", "variant"],
|
|
388
|
+
allowDuplicates: false,
|
|
389
|
+
category: "annotation",
|
|
390
|
+
placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],
|
|
391
|
+
completionDetail: "Display label for a type, field, or enum member.",
|
|
392
|
+
hoverSummary: "Provides a user-facing display label.",
|
|
393
|
+
valueLabel: "<label>",
|
|
394
|
+
targetPlacements: {
|
|
395
|
+
member: FIELD_PLACEMENTS,
|
|
396
|
+
variant: TYPE_PLACEMENTS
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
description: {
|
|
400
|
+
requiresArgument: true,
|
|
401
|
+
supportedTargets: ["none"],
|
|
402
|
+
allowDuplicates: false,
|
|
403
|
+
category: "annotation",
|
|
404
|
+
placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],
|
|
405
|
+
completionDetail: "Description text for a type or field.",
|
|
406
|
+
hoverSummary: "Provides descriptive documentation for a type or field."
|
|
407
|
+
},
|
|
408
|
+
format: {
|
|
409
|
+
requiresArgument: true,
|
|
410
|
+
supportedTargets: ["none"],
|
|
411
|
+
allowDuplicates: false,
|
|
412
|
+
category: "annotation",
|
|
413
|
+
placements: FIELD_PLACEMENTS,
|
|
414
|
+
completionDetail: "Format hint for a field.",
|
|
415
|
+
hoverSummary: "Provides a format hint for a field.",
|
|
416
|
+
valueLabel: "<format>"
|
|
417
|
+
},
|
|
418
|
+
placeholder: {
|
|
419
|
+
requiresArgument: true,
|
|
420
|
+
supportedTargets: ["none"],
|
|
421
|
+
allowDuplicates: false,
|
|
422
|
+
category: "annotation",
|
|
423
|
+
placements: FIELD_PLACEMENTS,
|
|
424
|
+
completionDetail: "Placeholder text for a field.",
|
|
425
|
+
hoverSummary: "Provides placeholder text for a field."
|
|
426
|
+
},
|
|
427
|
+
order: {
|
|
428
|
+
requiresArgument: true,
|
|
429
|
+
supportedTargets: ["none"],
|
|
430
|
+
allowDuplicates: false,
|
|
431
|
+
category: "annotation",
|
|
432
|
+
placements: FIELD_PLACEMENTS,
|
|
433
|
+
completionDetail: "Field display order hint.",
|
|
434
|
+
hoverSummary: "Provides an integer ordering hint for UI layout."
|
|
435
|
+
},
|
|
436
|
+
apiName: {
|
|
437
|
+
requiresArgument: true,
|
|
438
|
+
supportedTargets: ["none", "member", "variant"],
|
|
439
|
+
allowDuplicates: false,
|
|
440
|
+
category: "annotation",
|
|
441
|
+
placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],
|
|
442
|
+
completionDetail: "API-facing serialized name for a type, field, or variant.",
|
|
443
|
+
hoverSummary: "Overrides the serialized API name used in generated schema output.",
|
|
444
|
+
valueLabel: "<identifier>",
|
|
445
|
+
targetPlacements: {
|
|
446
|
+
member: FIELD_PLACEMENTS,
|
|
447
|
+
variant: TYPE_PLACEMENTS
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
group: {
|
|
451
|
+
requiresArgument: true,
|
|
452
|
+
supportedTargets: ["none"],
|
|
453
|
+
allowDuplicates: false,
|
|
454
|
+
category: "structure",
|
|
455
|
+
placements: FIELD_PLACEMENTS,
|
|
456
|
+
completionDetail: "Assigns a field to a UI group.",
|
|
457
|
+
hoverSummary: "Assigns the field to a named grouping container.",
|
|
458
|
+
valueLabel: "<group>"
|
|
459
|
+
},
|
|
460
|
+
showWhen: {
|
|
461
|
+
requiresArgument: true,
|
|
462
|
+
supportedTargets: ["none"],
|
|
463
|
+
allowDuplicates: true,
|
|
464
|
+
category: "structure",
|
|
465
|
+
placements: FIELD_PLACEMENTS,
|
|
466
|
+
completionDetail: "Conditional visibility rule.",
|
|
467
|
+
hoverSummary: "Shows the field only when the condition is satisfied."
|
|
468
|
+
},
|
|
469
|
+
hideWhen: {
|
|
470
|
+
requiresArgument: true,
|
|
471
|
+
supportedTargets: ["none"],
|
|
472
|
+
allowDuplicates: true,
|
|
473
|
+
category: "structure",
|
|
474
|
+
placements: FIELD_PLACEMENTS,
|
|
475
|
+
completionDetail: "Conditional visibility suppression rule.",
|
|
476
|
+
hoverSummary: "Hides the field when the condition is satisfied."
|
|
477
|
+
},
|
|
478
|
+
enableWhen: {
|
|
479
|
+
requiresArgument: true,
|
|
480
|
+
supportedTargets: ["none"],
|
|
481
|
+
allowDuplicates: true,
|
|
482
|
+
category: "structure",
|
|
483
|
+
placements: FIELD_PLACEMENTS,
|
|
484
|
+
completionDetail: "Conditional interactivity rule.",
|
|
485
|
+
hoverSummary: "Enables the field only when the condition is satisfied."
|
|
486
|
+
},
|
|
487
|
+
disableWhen: {
|
|
488
|
+
requiresArgument: true,
|
|
489
|
+
supportedTargets: ["none"],
|
|
490
|
+
allowDuplicates: true,
|
|
491
|
+
category: "structure",
|
|
492
|
+
placements: FIELD_PLACEMENTS,
|
|
493
|
+
completionDetail: "Conditional disablement rule.",
|
|
494
|
+
hoverSummary: "Disables the field when the condition is satisfied."
|
|
495
|
+
},
|
|
496
|
+
defaultValue: {
|
|
497
|
+
requiresArgument: true,
|
|
498
|
+
supportedTargets: ["none"],
|
|
499
|
+
allowDuplicates: false,
|
|
500
|
+
category: "ecosystem",
|
|
501
|
+
placements: FIELD_PLACEMENTS,
|
|
502
|
+
completionDetail: "Default JSON value for a field.",
|
|
503
|
+
hoverSummary: "Provides a default JSON value for ecosystem integrations.",
|
|
504
|
+
valueLabel: "<value>"
|
|
505
|
+
},
|
|
506
|
+
deprecated: {
|
|
507
|
+
requiresArgument: false,
|
|
508
|
+
supportedTargets: ["none"],
|
|
509
|
+
allowDuplicates: false,
|
|
510
|
+
category: "ecosystem",
|
|
511
|
+
placements: ALL_PLACEMENTS,
|
|
512
|
+
completionDetail: "Marks a declaration as deprecated.",
|
|
513
|
+
hoverSummary: "Marks the declaration as deprecated."
|
|
514
|
+
},
|
|
515
|
+
example: {
|
|
516
|
+
requiresArgument: true,
|
|
517
|
+
supportedTargets: ["none"],
|
|
518
|
+
allowDuplicates: true,
|
|
519
|
+
category: "ecosystem",
|
|
520
|
+
placements: [...TYPE_PLACEMENTS, ...FIELD_PLACEMENTS],
|
|
521
|
+
completionDetail: "Example serialized value.",
|
|
522
|
+
hoverSummary: "Provides an example value for documentation and tooling."
|
|
523
|
+
},
|
|
524
|
+
remarks: {
|
|
525
|
+
requiresArgument: true,
|
|
526
|
+
supportedTargets: ["none"],
|
|
527
|
+
allowDuplicates: false,
|
|
528
|
+
category: "ecosystem",
|
|
529
|
+
placements: ALL_PLACEMENTS,
|
|
530
|
+
completionDetail: "Additional remarks text.",
|
|
531
|
+
hoverSummary: "Provides additional remarks for the declaration."
|
|
532
|
+
},
|
|
533
|
+
see: {
|
|
534
|
+
requiresArgument: true,
|
|
535
|
+
supportedTargets: ["none"],
|
|
536
|
+
allowDuplicates: true,
|
|
537
|
+
category: "ecosystem",
|
|
538
|
+
placements: ALL_PLACEMENTS,
|
|
539
|
+
completionDetail: "Reference to related documentation.",
|
|
540
|
+
hoverSummary: "References related documentation or declarations.",
|
|
541
|
+
valueLabel: "<reference>"
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
function buildExtraTagDefinition(canonicalName, spec) {
|
|
545
|
+
const valueKind = spec.valueKind ?? inferValueKind(canonicalName);
|
|
546
|
+
const valueLabel = spec.requiresArgument ? spec.valueLabel ?? valueLabelForKind(valueKind) : "";
|
|
547
|
+
const signatures = [];
|
|
548
|
+
if (spec.supportedTargets.includes("none")) {
|
|
549
|
+
signatures.push(createSignature(canonicalName, spec.placements, null, valueKind, valueLabel));
|
|
550
|
+
}
|
|
551
|
+
if (spec.supportedTargets.includes("path")) {
|
|
552
|
+
signatures.push(
|
|
553
|
+
createSignature(
|
|
554
|
+
canonicalName,
|
|
555
|
+
spec.targetPlacements?.path ?? spec.placements,
|
|
556
|
+
"path",
|
|
557
|
+
valueKind,
|
|
558
|
+
valueLabel
|
|
559
|
+
)
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
if (spec.supportedTargets.includes("member")) {
|
|
563
|
+
signatures.push(
|
|
564
|
+
createSignature(
|
|
565
|
+
canonicalName,
|
|
566
|
+
spec.targetPlacements?.member ?? spec.placements,
|
|
567
|
+
"member",
|
|
568
|
+
valueKind,
|
|
569
|
+
valueLabel
|
|
570
|
+
)
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
if (spec.supportedTargets.includes("variant")) {
|
|
574
|
+
signatures.push(
|
|
575
|
+
createSignature(
|
|
576
|
+
canonicalName,
|
|
577
|
+
spec.targetPlacements?.variant ?? spec.placements,
|
|
578
|
+
"variant",
|
|
579
|
+
valueKind,
|
|
580
|
+
valueLabel
|
|
581
|
+
)
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
return {
|
|
585
|
+
canonicalName,
|
|
586
|
+
valueKind,
|
|
587
|
+
requiresArgument: spec.requiresArgument,
|
|
588
|
+
supportedTargets: spec.supportedTargets,
|
|
589
|
+
allowDuplicates: spec.allowDuplicates,
|
|
590
|
+
category: spec.category,
|
|
591
|
+
placements: spec.placements,
|
|
592
|
+
capabilities: capabilitiesForValueKind(valueKind),
|
|
593
|
+
completionDetail: spec.completionDetail,
|
|
594
|
+
hoverMarkdown: buildHoverMarkdown(canonicalName, spec.hoverSummary, signatures, valueLabel),
|
|
595
|
+
signatures
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
var EXTRA_TAG_DEFINITIONS = Object.fromEntries(
|
|
599
|
+
Object.entries(EXTRA_TAG_SPECS).map(([canonicalName, spec]) => [
|
|
600
|
+
canonicalName,
|
|
601
|
+
buildExtraTagDefinition(canonicalName, spec)
|
|
602
|
+
])
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
// src/semantic-protocol.ts
|
|
606
|
+
var FORMSPEC_ANALYSIS_PROTOCOL_VERSION = 1;
|
|
607
|
+
var FORMSPEC_ANALYSIS_SCHEMA_VERSION = 1;
|
|
608
|
+
function isObjectRecord(value) {
|
|
609
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
610
|
+
}
|
|
611
|
+
function isCommentSpan(value) {
|
|
612
|
+
if (!isObjectRecord(value)) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
const candidate = value;
|
|
616
|
+
return typeof candidate.start === "number" && typeof candidate.end === "number";
|
|
617
|
+
}
|
|
618
|
+
function isStringArray(value) {
|
|
619
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
620
|
+
}
|
|
621
|
+
var FORM_SPEC_PLACEMENT_VALUES = new Set(FORM_SPEC_PLACEMENTS);
|
|
622
|
+
var FORM_SPEC_TARGET_KIND_VALUES = new Set(FORM_SPEC_TARGET_KINDS);
|
|
623
|
+
function isPlacementValue(value) {
|
|
624
|
+
return typeof value === "string" && FORM_SPEC_PLACEMENT_VALUES.has(value);
|
|
625
|
+
}
|
|
626
|
+
function isTargetKindValue(value) {
|
|
627
|
+
return typeof value === "string" && FORM_SPEC_TARGET_KIND_VALUES.has(value);
|
|
628
|
+
}
|
|
629
|
+
function isPlacementArray(value) {
|
|
630
|
+
return Array.isArray(value) && value.every(isPlacementValue);
|
|
631
|
+
}
|
|
632
|
+
function isTargetKindArray(value) {
|
|
633
|
+
return Array.isArray(value) && value.every(isTargetKindValue);
|
|
634
|
+
}
|
|
635
|
+
function isIpcEndpoint(value) {
|
|
636
|
+
if (!isObjectRecord(value)) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
const candidate = value;
|
|
640
|
+
return (candidate.kind === "unix-socket" || candidate.kind === "windows-pipe") && typeof candidate.address === "string";
|
|
641
|
+
}
|
|
642
|
+
function isSerializedTagDefinition(value) {
|
|
643
|
+
if (!isObjectRecord(value)) {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
const candidate = value;
|
|
647
|
+
return typeof candidate.canonicalName === "string" && typeof candidate.completionDetail === "string" && typeof candidate.hoverMarkdown === "string";
|
|
648
|
+
}
|
|
649
|
+
function isSerializedTagSignature(value) {
|
|
650
|
+
if (!isObjectRecord(value)) {
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
const candidate = value;
|
|
654
|
+
return typeof candidate.label === "string" && isPlacementArray(candidate.placements);
|
|
655
|
+
}
|
|
656
|
+
function isSerializedCommentTargetSpecifier(value) {
|
|
657
|
+
if (!isObjectRecord(value)) {
|
|
658
|
+
return false;
|
|
659
|
+
}
|
|
660
|
+
const candidate = value;
|
|
661
|
+
return typeof candidate.rawText === "string" && typeof candidate.valid === "boolean" && typeof candidate.kind === "string" && isCommentSpan(candidate.fullSpan) && isCommentSpan(candidate.colonSpan) && isCommentSpan(candidate.span);
|
|
662
|
+
}
|
|
663
|
+
function isSerializedTagSemanticContext(value) {
|
|
664
|
+
if (!isObjectRecord(value)) {
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
const candidate = value;
|
|
668
|
+
return typeof candidate.tagName === "string" && (candidate.tagDefinition === null || isSerializedTagDefinition(candidate.tagDefinition)) && (candidate.placement === null || isPlacementValue(candidate.placement)) && isTargetKindArray(candidate.supportedTargets) && isStringArray(candidate.targetCompletions) && isStringArray(candidate.compatiblePathTargets) && isStringArray(candidate.valueLabels) && Array.isArray(candidate.signatures) && candidate.signatures.every(isSerializedTagSignature) && (candidate.tagHoverMarkdown === null || typeof candidate.tagHoverMarkdown === "string") && (candidate.targetHoverMarkdown === null || typeof candidate.targetHoverMarkdown === "string") && (candidate.argumentHoverMarkdown === null || typeof candidate.argumentHoverMarkdown === "string");
|
|
669
|
+
}
|
|
670
|
+
function isSerializedCompletionContext(value) {
|
|
671
|
+
if (!isObjectRecord(value)) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
const candidate = value;
|
|
675
|
+
if (typeof candidate.kind !== "string") {
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
switch (candidate.kind) {
|
|
679
|
+
case "tag-name":
|
|
680
|
+
return typeof candidate.prefix === "string" && Array.isArray(candidate.availableTags) ? candidate.availableTags.every(isSerializedTagDefinition) : false;
|
|
681
|
+
case "target":
|
|
682
|
+
return isSerializedTagSemanticContext(candidate.semantic);
|
|
683
|
+
case "argument":
|
|
684
|
+
return isSerializedTagSemanticContext(candidate.semantic) && isStringArray(candidate.valueLabels);
|
|
685
|
+
case "none":
|
|
686
|
+
return true;
|
|
687
|
+
default:
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
function isSerializedHoverInfo(value) {
|
|
692
|
+
if (!isObjectRecord(value)) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
const candidate = value;
|
|
696
|
+
return (candidate.kind === "tag-name" || candidate.kind === "target" || candidate.kind === "argument") && typeof candidate.markdown === "string";
|
|
697
|
+
}
|
|
698
|
+
function hasCurrentProtocolVersion(value) {
|
|
699
|
+
return isObjectRecord(value) && value["protocolVersion"] === FORMSPEC_ANALYSIS_PROTOCOL_VERSION;
|
|
700
|
+
}
|
|
701
|
+
function isAnalysisDiagnostic(value) {
|
|
702
|
+
if (!isObjectRecord(value)) {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
const candidate = value;
|
|
706
|
+
return typeof candidate.code === "string" && typeof candidate.message === "string" && isCommentSpan(candidate.range) && (candidate.severity === "error" || candidate.severity === "warning" || candidate.severity === "info");
|
|
707
|
+
}
|
|
708
|
+
function isAnalysisTagSnapshot(value) {
|
|
709
|
+
if (!isObjectRecord(value)) {
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
const candidate = value;
|
|
713
|
+
return typeof candidate.rawTagName === "string" && typeof candidate.normalizedTagName === "string" && typeof candidate.recognized === "boolean" && isCommentSpan(candidate.fullSpan) && isCommentSpan(candidate.tagNameSpan) && (candidate.payloadSpan === null || isCommentSpan(candidate.payloadSpan)) && (candidate.target === null || isSerializedCommentTargetSpecifier(candidate.target)) && (candidate.argumentSpan === null || isCommentSpan(candidate.argumentSpan)) && typeof candidate.argumentText === "string" && isSerializedTagSemanticContext(candidate.semantic);
|
|
714
|
+
}
|
|
715
|
+
function isAnalysisCommentSnapshot(value) {
|
|
716
|
+
if (!isObjectRecord(value)) {
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
const candidate = value;
|
|
720
|
+
return isCommentSpan(candidate.commentSpan) && isCommentSpan(candidate.declarationSpan) && (candidate.placement === null || isPlacementValue(candidate.placement)) && (candidate.subjectType === null || typeof candidate.subjectType === "string") && (candidate.hostType === null || typeof candidate.hostType === "string") && Array.isArray(candidate.tags) && candidate.tags.every(isAnalysisTagSnapshot);
|
|
721
|
+
}
|
|
722
|
+
function isAnalysisFileSnapshot(value) {
|
|
723
|
+
if (!isObjectRecord(value)) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
const candidate = value;
|
|
727
|
+
return typeof candidate.filePath === "string" && typeof candidate.sourceHash === "string" && typeof candidate.generatedAt === "string" && Array.isArray(candidate.comments) && candidate.comments.every(isAnalysisCommentSnapshot) && Array.isArray(candidate.diagnostics) && candidate.diagnostics.every(isAnalysisDiagnostic);
|
|
728
|
+
}
|
|
729
|
+
function isFormSpecAnalysisManifest(value) {
|
|
730
|
+
if (!isObjectRecord(value)) {
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
const candidate = value;
|
|
734
|
+
return candidate.protocolVersion === FORMSPEC_ANALYSIS_PROTOCOL_VERSION && candidate.analysisSchemaVersion === FORMSPEC_ANALYSIS_SCHEMA_VERSION && typeof candidate.workspaceRoot === "string" && typeof candidate.workspaceId === "string" && isIpcEndpoint(candidate.endpoint) && typeof candidate.typescriptVersion === "string" && typeof candidate.extensionFingerprint === "string" && typeof candidate.generation === "number" && typeof candidate.updatedAt === "string";
|
|
735
|
+
}
|
|
736
|
+
function isFormSpecSemanticQuery(value) {
|
|
737
|
+
if (!hasCurrentProtocolVersion(value)) {
|
|
738
|
+
return false;
|
|
739
|
+
}
|
|
740
|
+
const candidate = value;
|
|
741
|
+
if (typeof candidate.kind !== "string") {
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
switch (candidate.kind) {
|
|
745
|
+
case "health":
|
|
746
|
+
return true;
|
|
747
|
+
case "completion":
|
|
748
|
+
case "hover":
|
|
749
|
+
return typeof candidate.filePath === "string" && typeof candidate.offset === "number";
|
|
750
|
+
case "diagnostics":
|
|
751
|
+
case "file-snapshot":
|
|
752
|
+
return typeof candidate.filePath === "string";
|
|
753
|
+
default:
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
function isFormSpecSemanticResponse(value) {
|
|
758
|
+
if (!hasCurrentProtocolVersion(value)) {
|
|
759
|
+
return false;
|
|
760
|
+
}
|
|
761
|
+
const candidate = value;
|
|
762
|
+
if (typeof candidate.kind !== "string") {
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
switch (candidate.kind) {
|
|
766
|
+
case "health":
|
|
767
|
+
return isFormSpecAnalysisManifest(candidate.manifest);
|
|
768
|
+
case "completion":
|
|
769
|
+
return typeof candidate.sourceHash === "string" && isSerializedCompletionContext(candidate.context);
|
|
770
|
+
case "hover":
|
|
771
|
+
return typeof candidate.sourceHash === "string" && (candidate.hover === null || isSerializedHoverInfo(candidate.hover));
|
|
772
|
+
case "diagnostics":
|
|
773
|
+
return typeof candidate.sourceHash === "string" && Array.isArray(candidate.diagnostics) && candidate.diagnostics.every(isAnalysisDiagnostic);
|
|
774
|
+
case "file-snapshot":
|
|
775
|
+
return candidate.snapshot === null || isAnalysisFileSnapshot(candidate.snapshot);
|
|
776
|
+
case "error":
|
|
777
|
+
return typeof candidate.error === "string";
|
|
778
|
+
default:
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function computeFormSpecTextHash(text) {
|
|
783
|
+
let hash = 2166136261;
|
|
784
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
785
|
+
hash ^= text.charCodeAt(index);
|
|
786
|
+
hash = Math.imul(hash, 16777619);
|
|
787
|
+
}
|
|
788
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
789
|
+
}
|
|
790
|
+
function serializeCommentTargetSpecifier(target) {
|
|
791
|
+
if (target === null) {
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
return {
|
|
795
|
+
rawText: target.rawText,
|
|
796
|
+
valid: target.valid,
|
|
797
|
+
kind: target.kind,
|
|
798
|
+
fullSpan: target.fullSpan,
|
|
799
|
+
colonSpan: target.colonSpan,
|
|
800
|
+
span: target.span
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
function serializeCommentTagSemanticContext(semantic) {
|
|
804
|
+
return {
|
|
805
|
+
tagName: semantic.tag.normalizedTagName,
|
|
806
|
+
tagDefinition: semantic.tagDefinition === null ? null : {
|
|
807
|
+
canonicalName: semantic.tagDefinition.canonicalName,
|
|
808
|
+
completionDetail: semantic.tagDefinition.completionDetail,
|
|
809
|
+
hoverMarkdown: semantic.tagDefinition.hoverMarkdown
|
|
810
|
+
},
|
|
811
|
+
placement: semantic.placement,
|
|
812
|
+
supportedTargets: semantic.supportedTargets,
|
|
813
|
+
targetCompletions: semantic.targetCompletions,
|
|
814
|
+
compatiblePathTargets: semantic.compatiblePathTargets,
|
|
815
|
+
valueLabels: semantic.valueLabels,
|
|
816
|
+
signatures: semantic.signatures.map((signature) => ({
|
|
817
|
+
label: signature.label,
|
|
818
|
+
placements: signature.placements
|
|
819
|
+
})),
|
|
820
|
+
tagHoverMarkdown: semantic.tagHoverMarkdown,
|
|
821
|
+
targetHoverMarkdown: semantic.targetHoverMarkdown,
|
|
822
|
+
argumentHoverMarkdown: semantic.argumentHoverMarkdown
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
function serializeCompletionContext(context) {
|
|
826
|
+
switch (context.kind) {
|
|
827
|
+
case "tag-name":
|
|
828
|
+
return {
|
|
829
|
+
kind: "tag-name",
|
|
830
|
+
prefix: context.prefix,
|
|
831
|
+
availableTags: context.availableTags.map((tag) => ({
|
|
832
|
+
canonicalName: tag.canonicalName,
|
|
833
|
+
completionDetail: tag.completionDetail,
|
|
834
|
+
hoverMarkdown: tag.hoverMarkdown
|
|
835
|
+
}))
|
|
836
|
+
};
|
|
837
|
+
case "target":
|
|
838
|
+
return {
|
|
839
|
+
kind: "target",
|
|
840
|
+
semantic: serializeCommentTagSemanticContext(context.semantic)
|
|
841
|
+
};
|
|
842
|
+
case "argument":
|
|
843
|
+
return {
|
|
844
|
+
kind: "argument",
|
|
845
|
+
semantic: serializeCommentTagSemanticContext(context.semantic),
|
|
846
|
+
valueLabels: context.valueLabels
|
|
847
|
+
};
|
|
848
|
+
case "none":
|
|
849
|
+
return { kind: "none" };
|
|
850
|
+
default: {
|
|
851
|
+
const exhaustive = context;
|
|
852
|
+
return exhaustive;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function serializeHoverInfo(hover) {
|
|
857
|
+
return hover === null ? null : {
|
|
858
|
+
kind: hover.kind,
|
|
859
|
+
markdown: hover.markdown
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
function serializeParsedCommentTag(tag, semantic) {
|
|
863
|
+
return {
|
|
864
|
+
rawTagName: tag.rawTagName,
|
|
865
|
+
normalizedTagName: tag.normalizedTagName,
|
|
866
|
+
recognized: tag.recognized,
|
|
867
|
+
fullSpan: tag.fullSpan,
|
|
868
|
+
tagNameSpan: tag.tagNameSpan,
|
|
869
|
+
payloadSpan: tag.payloadSpan,
|
|
870
|
+
target: serializeCommentTargetSpecifier(tag.target),
|
|
871
|
+
argumentSpan: tag.argumentSpan,
|
|
872
|
+
argumentText: tag.argumentText,
|
|
873
|
+
semantic: serializeCommentTagSemanticContext(semantic)
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// src/workspace-runtime.ts
|
|
878
|
+
import path from "path";
|
|
879
|
+
function getFormSpecWorkspaceId(workspaceRoot) {
|
|
880
|
+
return computeFormSpecTextHash(workspaceRoot);
|
|
881
|
+
}
|
|
882
|
+
function getFormSpecWorkspaceRuntimeDirectory(workspaceRoot) {
|
|
883
|
+
return path.join(workspaceRoot, ".cache", "formspec", "tooling");
|
|
884
|
+
}
|
|
885
|
+
function getFormSpecManifestPath(workspaceRoot) {
|
|
886
|
+
return path.join(getFormSpecWorkspaceRuntimeDirectory(workspaceRoot), "manifest.json");
|
|
887
|
+
}
|
|
888
|
+
export {
|
|
889
|
+
FORMSPEC_ANALYSIS_PROTOCOL_VERSION,
|
|
890
|
+
FORMSPEC_ANALYSIS_SCHEMA_VERSION,
|
|
891
|
+
computeFormSpecTextHash,
|
|
892
|
+
getFormSpecManifestPath,
|
|
893
|
+
getFormSpecWorkspaceId,
|
|
894
|
+
getFormSpecWorkspaceRuntimeDirectory,
|
|
895
|
+
isFormSpecAnalysisManifest,
|
|
896
|
+
isFormSpecSemanticQuery,
|
|
897
|
+
isFormSpecSemanticResponse,
|
|
898
|
+
serializeCommentTagSemanticContext,
|
|
899
|
+
serializeCommentTargetSpecifier,
|
|
900
|
+
serializeCompletionContext,
|
|
901
|
+
serializeHoverInfo,
|
|
902
|
+
serializeParsedCommentTag
|
|
903
|
+
};
|
|
904
|
+
//# sourceMappingURL=protocol.js.map
|