@stillwind/language-server 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.js +1 -1
- package/dist/{server-D7Wg5GbT.d.ts → server-Bp6CUeN4.d.ts} +9 -2
- package/dist/{server-GjZU1QxS.js → server-ZB6y2ShG.js} +316 -64
- package/dist/server-ZB6y2ShG.js.map +1 -0
- package/package.json +4 -4
- package/dist/server-GjZU1QxS.js.map +0 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LanguageServerOptions } from "./server-
|
|
1
|
+
import { t as LanguageServerOptions } from "./server-Bp6CUeN4.js";
|
|
2
2
|
import { BrowserMessageReader } from "vscode-languageserver/browser";
|
|
3
3
|
/**
|
|
4
4
|
* Starts LSP message transport using analysis services supplied by the embedding application.
|
package/dist/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createLanguageServer } from "./server-
|
|
1
|
+
import { t as createLanguageServer } from "./server-ZB6y2ShG.js";
|
|
2
2
|
import { BrowserMessageReader, BrowserMessageWriter, ProposedFeatures, createConnection } from "vscode-languageserver/browser";
|
|
3
3
|
// src/browser.ts
|
|
4
4
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createLanguageServer, t as LanguageServerOptions } from "./server-
|
|
1
|
+
import { n as createLanguageServer, t as LanguageServerOptions } from "./server-Bp6CUeN4.js";
|
|
2
2
|
export { type LanguageServerOptions, createLanguageServer };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createLanguageServer } from "./server-
|
|
1
|
+
export { t as createLanguageServer } from "./server-ZB6y2ShG.js";
|
package/dist/node.js
CHANGED
|
@@ -10,7 +10,10 @@ interface LanguageServerOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* Opens a configuration for an open document that no service analyzes. The server calls this once
|
|
12
12
|
* for each document until services reopen. Supplying it advertises editor features before any
|
|
13
|
-
* service exists. Omission leaves such documents without analysis.
|
|
13
|
+
* service exists. Omission leaves such documents without analysis. A client with pull diagnostics
|
|
14
|
+
* decides which documents reach this call, because only a diagnostic request starts discovery.
|
|
15
|
+
* Editors open documents in the background, and each configuration starts a process that runs
|
|
16
|
+
* its code.
|
|
14
17
|
*/
|
|
15
18
|
discoverWorkspace?: DiscoverWorkspace;
|
|
16
19
|
/**
|
|
@@ -35,6 +38,10 @@ interface LanguageServerOptions {
|
|
|
35
38
|
* Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited
|
|
36
39
|
* document to be open and to match the report's source fingerprint.
|
|
37
40
|
*
|
|
41
|
+
* A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the
|
|
42
|
+
* server reports only the findings located in that document. Other clients receive every open
|
|
43
|
+
* document's findings through `textDocument/publishDiagnostics`.
|
|
44
|
+
*
|
|
38
45
|
* @param connection - Caller-owned connection. Call listen after registration and dispose the
|
|
39
46
|
* transport when finished. Diagnostic locations must use original documents and UTF-16 positions.
|
|
40
47
|
* @param options - Workspace factory and optional exit handler. This server owns the opened services.
|
|
@@ -62,4 +69,4 @@ declare function createLanguageServer(connection: Connection, options: LanguageS
|
|
|
62
69
|
dispose(): Promise<void>;
|
|
63
70
|
};
|
|
64
71
|
export { createLanguageServer as n, LanguageServerOptions as t };
|
|
65
|
-
//# sourceMappingURL=server-
|
|
72
|
+
//# sourceMappingURL=server-Bp6CUeN4.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeActionKind, CompletionItemKind, DiagnosticSeverity, DidChangeWatchedFilesNotification, InsertTextFormat, MarkupKind, MessageType, ShowMessageNotification, TextDocumentSyncKind, TextDocuments } from "vscode-languageserver";
|
|
1
|
+
import { CodeActionKind, CompletionItemKind, DiagnosticSeverity, DidChangeWatchedFilesNotification, InsertTextFormat, LSPErrorCodes, MarkupKind, MessageType, ResponseError, ShowMessageNotification, TextDocumentSyncKind, TextDocuments } from "vscode-languageserver";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
// src/editor.ts
|
|
4
4
|
const sortKind = "source.sort.stillwind";
|
|
@@ -125,8 +125,11 @@ function registerEditorFeatures(connection, documents, query) {
|
|
|
125
125
|
connection.onDocumentColor(async (params, token) => {
|
|
126
126
|
const document = documents.get(params.textDocument.uri);
|
|
127
127
|
if (!document) return [];
|
|
128
|
-
const colors = (await query(document.uri, { kind: "colors" }, token)).flatMap((entry) => entry.result.colors ?? []);
|
|
129
|
-
return colors.filter((color
|
|
128
|
+
const colors = (await query(document.uri, { kind: "colors" }, token)).flatMap((entry) => entry.result.colors ?? []).filter((color, index, colors) => colors.findIndex((other) => JSON.stringify(other) === JSON.stringify(color)) === index);
|
|
129
|
+
return colors.filter((color) => {
|
|
130
|
+
const range = colors.filter((other) => other.start === color.start && other.end === color.end);
|
|
131
|
+
return range.length === 1 || range.length === 2 && range.some((other) => other.scheme === "light") && range.some((other) => other.scheme === "dark");
|
|
132
|
+
}).map((color) => ({
|
|
130
133
|
range: offsets(document, color),
|
|
131
134
|
color: {
|
|
132
135
|
red: color.red,
|
|
@@ -238,6 +241,10 @@ function offsets(document, range) {
|
|
|
238
241
|
* Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited
|
|
239
242
|
* document to be open and to match the report's source fingerprint.
|
|
240
243
|
*
|
|
244
|
+
* A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the
|
|
245
|
+
* server reports only the findings located in that document. Other clients receive every open
|
|
246
|
+
* document's findings through `textDocument/publishDiagnostics`.
|
|
247
|
+
*
|
|
241
248
|
* @param connection - Caller-owned connection. Call listen after registration and dispose the
|
|
242
249
|
* transport when finished. Diagnostic locations must use original documents and UTF-16 positions.
|
|
243
250
|
* @param options - Workspace factory and optional exit handler. This server owns the opened services.
|
|
@@ -251,12 +258,27 @@ function createLanguageServer(connection, options) {
|
|
|
251
258
|
const published = /* @__PURE__ */ new Set();
|
|
252
259
|
/** Documents already passed to discovery, which keeps later analysis passes from searching again. */
|
|
253
260
|
const discovered = /* @__PURE__ */ new Set();
|
|
254
|
-
/**
|
|
261
|
+
/** Identities whose current error the user has seen, which keeps each from notifying again. */
|
|
255
262
|
const reported = /* @__PURE__ */ new Set();
|
|
263
|
+
/** Last logged error message of each identity, which keeps an unchanged error from repeating. */
|
|
264
|
+
const logged = /* @__PURE__ */ new Map();
|
|
265
|
+
/** Editor query failures already logged since services opened, which keeps each from repeating. */
|
|
266
|
+
const queryFailures = /* @__PURE__ */ new Set();
|
|
256
267
|
let roots = [];
|
|
257
268
|
let initializationOptions;
|
|
258
269
|
let registryDirectives = false;
|
|
259
270
|
let snippets = false;
|
|
271
|
+
/** Whether the client requests diagnostics instead of receiving published ones. */
|
|
272
|
+
let pull = false;
|
|
273
|
+
/** Whether the client accepts `workspace/diagnostic/refresh`. */
|
|
274
|
+
let pullRefresh = false;
|
|
275
|
+
/** Control generation whose open documents were prepared together for pull diagnostics. */
|
|
276
|
+
let prepared;
|
|
277
|
+
/** Serializes pull diagnostics, because a worker analyzes one document at a time. */
|
|
278
|
+
let pulls = Promise.resolve();
|
|
279
|
+
/** Last report for each pulled document. Its identity lets the client keep unchanged results. */
|
|
280
|
+
const pullReports = /* @__PURE__ */ new Map();
|
|
281
|
+
let nextReport = 0;
|
|
260
282
|
let generation = 0;
|
|
261
283
|
let controls = Promise.resolve();
|
|
262
284
|
let timer;
|
|
@@ -277,7 +299,7 @@ function createLanguageServer(connection, options) {
|
|
|
277
299
|
generation++;
|
|
278
300
|
cache.clear();
|
|
279
301
|
controls = controls.then(action).catch((error) => {
|
|
280
|
-
connection.console.error(
|
|
302
|
+
connection.console.error(errorText(error));
|
|
281
303
|
});
|
|
282
304
|
};
|
|
283
305
|
/**
|
|
@@ -290,25 +312,36 @@ function createLanguageServer(connection, options) {
|
|
|
290
312
|
const adopt = async (opened) => {
|
|
291
313
|
for (const [id, error] of opened.errors ?? []) errors.set(id, error);
|
|
292
314
|
for (const [id, workspace] of opened.workspaces) {
|
|
315
|
+
connection.console.info(`Opened the Stillwind workspace ${id}`);
|
|
293
316
|
workspaces.set(id, workspace);
|
|
294
317
|
for (const document of documents.all()) await workspace.update(document.uri, document.getText(), document.version);
|
|
295
318
|
}
|
|
296
319
|
};
|
|
297
320
|
/**
|
|
298
|
-
* Closes existing services, opens the current roots,
|
|
321
|
+
* Closes existing services, opens the current roots, replays every open buffer, and logs the
|
|
322
|
+
* outcome.
|
|
299
323
|
*
|
|
324
|
+
* @param reason - Event that requires the services, logged at debug level.
|
|
300
325
|
* @returns Completion of service replacement and buffer replay.
|
|
301
326
|
* @throws If service closure, the workspace factory, or buffer replay fails.
|
|
302
327
|
*/
|
|
303
|
-
const open = async () => {
|
|
328
|
+
const open = async (reason) => {
|
|
329
|
+
connection.console.debug(`Opening Stillwind workspaces after ${reason}`);
|
|
330
|
+
const start = performance.now();
|
|
304
331
|
await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));
|
|
305
332
|
workspaces.clear();
|
|
306
333
|
errors.clear();
|
|
307
334
|
discovered.clear();
|
|
335
|
+
queryFailures.clear();
|
|
308
336
|
await adopt(await options.openWorkspaces({
|
|
309
337
|
workspaceFolders: roots,
|
|
310
338
|
initializationOptions
|
|
311
339
|
}));
|
|
340
|
+
const elapsed = Math.round(performance.now() - start);
|
|
341
|
+
if (workspaces.size) {
|
|
342
|
+
const count = `${workspaces.size} Stillwind workspace${workspaces.size === 1 ? "" : "s"}`;
|
|
343
|
+
connection.console.info(`Opened ${count} in ${elapsed} ms`);
|
|
344
|
+
} else if (!errors.size) connection.console.info([roots.length ? `No Stillwind configuration was found in ${roots.join(", ")}.` : "No workspace folder is open.", ...options.discoverWorkspace ? ["A configuration in a subdirectory opens when a document in that directory opens."] : []].join(" "));
|
|
312
345
|
};
|
|
313
346
|
/**
|
|
314
347
|
* Opens configurations for documents that the last analysis pass left without results.
|
|
@@ -328,28 +361,14 @@ function createLanguageServer(connection, options) {
|
|
|
328
361
|
}
|
|
329
362
|
};
|
|
330
363
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
364
|
+
* Converts one document's analysis results to diagnostics.
|
|
365
|
+
*
|
|
366
|
+
* @param uri - Analyzed document, which receives the note about an incomplete analysis.
|
|
367
|
+
* @param results - Results of each project that analyzed the document.
|
|
368
|
+
* @param add - Receives each diagnostic with the URI of its location.
|
|
333
369
|
*/
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
const seen = /* @__PURE__ */ new Set();
|
|
337
|
-
/**
|
|
338
|
-
* Appends a diagnostic only once for its document and complete serialized value.
|
|
339
|
-
*
|
|
340
|
-
* @param uri - Original document URI used to group publication.
|
|
341
|
-
* @param diagnostic - Diagnostic with original LSP positions.
|
|
342
|
-
*/
|
|
343
|
-
const add = (uri, diagnostic) => {
|
|
344
|
-
const key = JSON.stringify([uri, diagnostic]);
|
|
345
|
-
if (!seen.has(key)) {
|
|
346
|
-
seen.add(key);
|
|
347
|
-
const list = grouped.get(uri) ?? [];
|
|
348
|
-
list.push(diagnostic);
|
|
349
|
-
grouped.set(uri, list);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
for (const [uri, results] of cache) for (const entry of results) {
|
|
370
|
+
const collect = (uri, results, add) => {
|
|
371
|
+
for (const entry of results) {
|
|
353
372
|
const source = `stillwind:${entry.config}:${entry.project + 1}`;
|
|
354
373
|
for (const report of entry.result.reports) {
|
|
355
374
|
const location = report.primary.location;
|
|
@@ -383,9 +402,14 @@ function createLanguageServer(connection, options) {
|
|
|
383
402
|
});
|
|
384
403
|
}
|
|
385
404
|
}
|
|
386
|
-
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Converts workspace errors to diagnostics on their configuration files.
|
|
408
|
+
*
|
|
409
|
+
* @param add - Receives each diagnostic with the URI of its configuration file.
|
|
410
|
+
*/
|
|
411
|
+
const collectErrors = (add) => {
|
|
387
412
|
for (const [file, error] of errors) {
|
|
388
|
-
const message = `${file}: ${error}`;
|
|
389
413
|
const uri = options.configurationUri?.(file, roots);
|
|
390
414
|
if (uri) add(uri, {
|
|
391
415
|
range: range(),
|
|
@@ -394,22 +418,66 @@ function createLanguageServer(connection, options) {
|
|
|
394
418
|
code: "SW_HOST",
|
|
395
419
|
message: error
|
|
396
420
|
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Logs each new or changed workspace error and forgets errors that ended. The user receives one
|
|
425
|
+
* notification for each identity until its error ends, because the message of a configuration
|
|
426
|
+
* error can change with each edit of the configuration.
|
|
427
|
+
*/
|
|
428
|
+
const notifyErrors = () => {
|
|
429
|
+
for (const [file, error] of errors) {
|
|
430
|
+
const message = `${file}: ${error}`;
|
|
431
|
+
if (logged.get(file) !== message) {
|
|
432
|
+
logged.set(file, message);
|
|
400
433
|
connection.console.error(message);
|
|
434
|
+
}
|
|
435
|
+
if (!reported.has(file)) {
|
|
436
|
+
reported.add(file);
|
|
401
437
|
connection.sendNotification(ShowMessageNotification.type, {
|
|
402
|
-
type: MessageType.
|
|
438
|
+
type: MessageType.Error,
|
|
403
439
|
message: `Stillwind: ${message}`
|
|
404
440
|
});
|
|
405
441
|
}
|
|
406
442
|
}
|
|
407
|
-
for (const
|
|
408
|
-
|
|
443
|
+
for (const file of reported) if (!errors.has(file)) {
|
|
444
|
+
reported.delete(file);
|
|
445
|
+
logged.delete(file);
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.
|
|
450
|
+
* Empty notifications clear diagnostics for previously published or currently open documents.
|
|
451
|
+
*/
|
|
452
|
+
const publish = () => {
|
|
453
|
+
const open = new Map(documents.all().map((document) => [uriKey(document.uri), document.uri]));
|
|
454
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
455
|
+
const seen = /* @__PURE__ */ new Set();
|
|
456
|
+
/**
|
|
457
|
+
* Appends a diagnostic only once for its document and complete serialized value.
|
|
458
|
+
*
|
|
459
|
+
* @param reported - Original document URI, in any spelling of that document.
|
|
460
|
+
* @param diagnostic - Diagnostic with original LSP positions.
|
|
461
|
+
*/
|
|
462
|
+
const add = (reported, diagnostic) => {
|
|
463
|
+
const uri = open.get(uriKey(reported)) ?? reported;
|
|
464
|
+
const key = JSON.stringify([uri, diagnostic]);
|
|
465
|
+
if (!seen.has(key)) {
|
|
466
|
+
seen.add(key);
|
|
467
|
+
const list = grouped.get(uri) ?? [];
|
|
468
|
+
list.push(diagnostic);
|
|
469
|
+
grouped.set(uri, list);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
for (const [uri, results] of cache) collect(uri, results, add);
|
|
473
|
+
collectErrors(add);
|
|
474
|
+
notifyErrors();
|
|
475
|
+
const targets = new Map([
|
|
409
476
|
...published,
|
|
410
477
|
...grouped.keys(),
|
|
411
|
-
...
|
|
412
|
-
]))
|
|
478
|
+
...open.values()
|
|
479
|
+
].map((uri) => [uriKey(uri), uri]));
|
|
480
|
+
for (const uri of targets.values()) connection.sendDiagnostics({
|
|
413
481
|
uri,
|
|
414
482
|
version: documents.get(uri)?.version,
|
|
415
483
|
diagnostics: grouped.get(uri) ?? []
|
|
@@ -454,27 +522,135 @@ function createLanguageServer(connection, options) {
|
|
|
454
522
|
cache.clear();
|
|
455
523
|
for (const [uri, result] of next) cache.set(uri, result);
|
|
456
524
|
publish();
|
|
457
|
-
|
|
458
|
-
if (uncovered.length) {
|
|
459
|
-
for (const uri of uncovered) discovered.add(uri);
|
|
460
|
-
control(() => discover(uncovered));
|
|
461
|
-
schedule();
|
|
462
|
-
}
|
|
525
|
+
discoverUncovered();
|
|
463
526
|
}
|
|
464
527
|
};
|
|
465
|
-
/**
|
|
528
|
+
/**
|
|
529
|
+
* Starts discovery for documents that the last analysis pass left without results. Each document
|
|
530
|
+
* is passed to discovery once until services reopen.
|
|
531
|
+
*/
|
|
532
|
+
const discoverUncovered = () => {
|
|
533
|
+
const uncovered = options.discoverWorkspace ? [...cache].flatMap(([uri, results]) => results.length || discovered.has(uri) ? [] : [uri]) : [];
|
|
534
|
+
if (uncovered.length) {
|
|
535
|
+
for (const uri of uncovered) discovered.add(uri);
|
|
536
|
+
control(() => discover(uncovered));
|
|
537
|
+
schedule();
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Replaces the pending 40 ms timer with an analysis pass for the current control generation. A
|
|
542
|
+
* pull client instead receives a request to pull its documents again, without a pass here.
|
|
543
|
+
*/
|
|
466
544
|
const schedule = () => {
|
|
467
545
|
if (timer) clearTimeout(timer);
|
|
546
|
+
if (pull) {
|
|
547
|
+
timer = setTimeout(() => {
|
|
548
|
+
notifyErrors();
|
|
549
|
+
if (pullRefresh) connection.languages.diagnostics.refresh().catch((error) => {
|
|
550
|
+
connection.console.error(errorText(error));
|
|
551
|
+
});
|
|
552
|
+
}, 40);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
468
555
|
const revision = generation;
|
|
469
556
|
timer = setTimeout(() => {
|
|
470
557
|
analyze(revision).catch((error) => {
|
|
471
|
-
connection.console.error(
|
|
558
|
+
connection.console.error(errorText(error));
|
|
472
559
|
});
|
|
473
560
|
}, 40);
|
|
474
561
|
};
|
|
475
562
|
/**
|
|
563
|
+
* Analyzes one document for a pull request, and retries once after discovery opens a service.
|
|
564
|
+
* Results stay cached until the next control generation. Open documents are prepared together
|
|
565
|
+
* once per generation, because the checker then loads them in one batch.
|
|
566
|
+
*
|
|
567
|
+
* @param uri - Requested document URI.
|
|
568
|
+
* @param token - Client cancellation.
|
|
569
|
+
* @returns Results of each project, or an empty list for a closed document or after shutdown.
|
|
570
|
+
* @throws A `ResponseError` with `RequestCancelled` after client cancellation, or with
|
|
571
|
+
* `ServerCancelled` and `retriggerRequest` after a change makes the analysis obsolete.
|
|
572
|
+
*/
|
|
573
|
+
const pullResults = async (uri, token) => {
|
|
574
|
+
for (;;) {
|
|
575
|
+
await controls;
|
|
576
|
+
if (token.isCancellationRequested) throw new ResponseError(LSPErrorCodes.RequestCancelled, "Diagnostics request cancelled");
|
|
577
|
+
if (shutdown || !documents.get(uri)) return [];
|
|
578
|
+
const cached = cache.get(uri);
|
|
579
|
+
if (cached) return cached;
|
|
580
|
+
const revision = generation;
|
|
581
|
+
const cancellation = new AbortController();
|
|
582
|
+
active = cancellation;
|
|
583
|
+
const subscription = token.onCancellationRequested(() => cancellation.abort());
|
|
584
|
+
const results = [];
|
|
585
|
+
try {
|
|
586
|
+
for (const [file, workspace] of workspaces) try {
|
|
587
|
+
if (prepared !== revision) await workspace.prepare?.(documents.all().map((document) => document.uri), cancellation.signal);
|
|
588
|
+
results.push(...await workspace.analyze(uri, cancellation.signal));
|
|
589
|
+
errors.delete(file);
|
|
590
|
+
} catch (error) {
|
|
591
|
+
errors.set(file, String(error));
|
|
592
|
+
}
|
|
593
|
+
} finally {
|
|
594
|
+
subscription.dispose();
|
|
595
|
+
}
|
|
596
|
+
if (shutdown) return [];
|
|
597
|
+
if (token.isCancellationRequested) throw new ResponseError(LSPErrorCodes.RequestCancelled, "Diagnostics request cancelled");
|
|
598
|
+
if (revision !== generation || results.some(({ result }) => result.status === "stale" || result.status === "cancelled")) throw new ResponseError(LSPErrorCodes.ServerCancelled, "Stillwind analysis became obsolete", { retriggerRequest: true });
|
|
599
|
+
prepared = revision;
|
|
600
|
+
cache.set(uri, results);
|
|
601
|
+
if (results.length || discovered.has(uri) || !options.discoverWorkspace) return results;
|
|
602
|
+
discovered.add(uri);
|
|
603
|
+
control(() => discover([uri]));
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Answers a pull request with the findings located in one document and in its configuration
|
|
608
|
+
* errors. Findings in other documents appear when the client pulls those documents.
|
|
609
|
+
*
|
|
610
|
+
* @param uri - Requested document URI.
|
|
611
|
+
* @param previous - Report identity that the client retains.
|
|
612
|
+
* @param token - Client cancellation.
|
|
613
|
+
* @returns An unchanged report when the content matches the retained report, otherwise a full one.
|
|
614
|
+
* @throws The errors of `pullResults`.
|
|
615
|
+
*/
|
|
616
|
+
const pullDiagnostics = async (uri, previous, token) => {
|
|
617
|
+
const results = await pullResults(uri, token);
|
|
618
|
+
const key = uriKey(uri);
|
|
619
|
+
const items = /* @__PURE__ */ new Map();
|
|
620
|
+
/**
|
|
621
|
+
* Keeps a diagnostic only when it belongs to the requested document.
|
|
622
|
+
*
|
|
623
|
+
* @param location - URI of the diagnostic, in any spelling.
|
|
624
|
+
* @param diagnostic - Diagnostic with original LSP positions.
|
|
625
|
+
*/
|
|
626
|
+
const add = (location, diagnostic) => {
|
|
627
|
+
if (uriKey(location) === key) items.set(JSON.stringify(diagnostic), diagnostic);
|
|
628
|
+
};
|
|
629
|
+
collect(uri, results, add);
|
|
630
|
+
collectErrors(add);
|
|
631
|
+
notifyErrors();
|
|
632
|
+
const text = [...items.keys()].join("\n");
|
|
633
|
+
let report = pullReports.get(uri);
|
|
634
|
+
if (report?.text !== text) {
|
|
635
|
+
report = {
|
|
636
|
+
id: String(++nextReport),
|
|
637
|
+
text
|
|
638
|
+
};
|
|
639
|
+
pullReports.set(uri, report);
|
|
640
|
+
}
|
|
641
|
+
return previous === report.id ? {
|
|
642
|
+
kind: "unchanged",
|
|
643
|
+
resultId: report.id
|
|
644
|
+
} : {
|
|
645
|
+
kind: "full",
|
|
646
|
+
resultId: report.id,
|
|
647
|
+
items: [...items.values()]
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
476
651
|
* Queries services after queued mutations and checks document versions and source fingerprints.
|
|
477
|
-
*
|
|
652
|
+
* Each distinct query failure is logged once until services reopen. The cancellation subscription
|
|
653
|
+
* is released after the request.
|
|
478
654
|
*
|
|
479
655
|
* @param uri - URI of the open original document.
|
|
480
656
|
* @param request - Editor operation expressed in that document's UTF-16 coordinates.
|
|
@@ -501,7 +677,11 @@ function createLanguageServer(connection, options) {
|
|
|
501
677
|
const { fingerprint } = await import("@stillwind/native");
|
|
502
678
|
return results.filter((entry) => entry.result.revision === fingerprint(document.getText()));
|
|
503
679
|
} catch (error) {
|
|
504
|
-
|
|
680
|
+
const message = errorText(error);
|
|
681
|
+
if (!queryFailures.has(message)) {
|
|
682
|
+
queryFailures.add(message);
|
|
683
|
+
connection.console.error(message);
|
|
684
|
+
}
|
|
505
685
|
return [];
|
|
506
686
|
} finally {
|
|
507
687
|
subscription.dispose();
|
|
@@ -511,16 +691,23 @@ function createLanguageServer(connection, options) {
|
|
|
511
691
|
connection.onInitialize(async (params) => {
|
|
512
692
|
initializationOptions = params.initializationOptions;
|
|
513
693
|
registryDirectives = completionRegistrySetting(initializationOptions) ?? false;
|
|
694
|
+
pull = params.capabilities.textDocument?.diagnostic !== void 0;
|
|
695
|
+
pullRefresh = params.capabilities.workspace?.diagnostics?.refreshSupport === true;
|
|
514
696
|
snippets = params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;
|
|
515
697
|
foldersSupported = params.capabilities.workspace?.workspaceFolders === true;
|
|
516
698
|
dynamicWatch = params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;
|
|
517
699
|
roots = params.workspaceFolders?.map((folder) => folder.uri) ?? (params.rootUri ? [params.rootUri] : []);
|
|
518
|
-
await open();
|
|
700
|
+
await open("initialization");
|
|
519
701
|
const editor = options.discoverWorkspace != null || [...workspaces.values()].some((workspace) => workspace.query != null);
|
|
520
702
|
return {
|
|
521
703
|
capabilities: {
|
|
522
704
|
textDocumentSync: TextDocumentSyncKind.Incremental,
|
|
523
705
|
codeActionProvider: { codeActionKinds: [CodeActionKind.QuickFix, ...editor ? editorCodeActionKinds : []] },
|
|
706
|
+
...pull ? { diagnosticProvider: {
|
|
707
|
+
identifier: "stillwind",
|
|
708
|
+
interFileDependencies: true,
|
|
709
|
+
workspaceDiagnostics: false
|
|
710
|
+
} } : {},
|
|
524
711
|
hoverProvider: editor,
|
|
525
712
|
definitionProvider: editor,
|
|
526
713
|
completionProvider: editor ? {
|
|
@@ -549,7 +736,7 @@ function createLanguageServer(connection, options) {
|
|
|
549
736
|
if (foldersSupported) connection.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {
|
|
550
737
|
const deleted = new Set(removed.map((folder) => folder.uri));
|
|
551
738
|
roots = [...roots.filter((root) => !deleted.has(root)), ...added.map((folder) => folder.uri)];
|
|
552
|
-
control(open);
|
|
739
|
+
control(() => open("a workspace folder change"));
|
|
553
740
|
schedule();
|
|
554
741
|
});
|
|
555
742
|
if (dynamicWatch) await connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: "**/*" }] });
|
|
@@ -560,9 +747,10 @@ function createLanguageServer(connection, options) {
|
|
|
560
747
|
if (documents.get(document.uri)?.version !== document.version) return;
|
|
561
748
|
for (const workspace of workspaces.values()) await workspace.update(document.uri, document.getText(), document.version);
|
|
562
749
|
});
|
|
563
|
-
schedule();
|
|
750
|
+
if (!pull) schedule();
|
|
564
751
|
});
|
|
565
752
|
documents.onDidClose(({ document }) => {
|
|
753
|
+
pullReports.delete(document.uri);
|
|
566
754
|
control(async () => {
|
|
567
755
|
for (const workspace of workspaces.values()) await workspace.closeDocument(document.uri);
|
|
568
756
|
});
|
|
@@ -572,32 +760,61 @@ function createLanguageServer(connection, options) {
|
|
|
572
760
|
* Reopens the workspaces if any service cannot reuse its current buffers after a save or file
|
|
573
761
|
* change. Without services, reopening lets a new or corrected configuration take effect.
|
|
574
762
|
*
|
|
575
|
-
* @param uris - Document URIs from the save or watch notification.
|
|
763
|
+
* @param uris - Document URIs from the save or watch notification. The list must not be empty.
|
|
764
|
+
* @param event - Notification kind for the log, such as `save`.
|
|
576
765
|
* @returns Completion of the checks and any required workspace replacement.
|
|
577
766
|
* @throws If a service check or workspace replacement fails.
|
|
578
767
|
*/
|
|
579
|
-
const refresh = async (uris) => {
|
|
580
|
-
|
|
581
|
-
|
|
768
|
+
const refresh = async (uris, event) => {
|
|
769
|
+
const others = uris.length > 1 ? ` and ${uris.length - 1} other files` : "";
|
|
770
|
+
const reason = `the ${event} of ${uris[0]}${others}`;
|
|
771
|
+
if (!workspaces.size || errors.size && uris.some(isConfigurationUri)) {
|
|
772
|
+
await open(reason);
|
|
582
773
|
return;
|
|
583
774
|
}
|
|
584
775
|
for (const workspace of workspaces.values()) if (!await workspace.refresh?.(uris)) {
|
|
585
|
-
await open();
|
|
776
|
+
await open(reason);
|
|
586
777
|
break;
|
|
587
778
|
}
|
|
588
779
|
};
|
|
589
780
|
documents.onDidSave(({ document }) => {
|
|
590
|
-
control(() => refresh([document.uri]));
|
|
781
|
+
control(() => refresh([document.uri], "save"));
|
|
591
782
|
schedule();
|
|
592
783
|
});
|
|
784
|
+
/**
|
|
785
|
+
* Decides whether watched changes need work. Starting that work cancels running analysis, so
|
|
786
|
+
* changes to unrelated files must not reach it.
|
|
787
|
+
*
|
|
788
|
+
* @param uris - Document URIs from the watch notification.
|
|
789
|
+
* @returns True for a configuration file while a service is missing or failed, and when a service
|
|
790
|
+
* reports that the changes affect it. A service without an `affects` check counts as affected.
|
|
791
|
+
* @throws If a service check fails.
|
|
792
|
+
*/
|
|
793
|
+
const affected = async (uris) => {
|
|
794
|
+
if ((!workspaces.size || errors.size) && uris.some(isConfigurationUri)) return true;
|
|
795
|
+
for (const workspace of workspaces.values()) if (await workspace.affects?.(uris) ?? true) return true;
|
|
796
|
+
return false;
|
|
797
|
+
};
|
|
593
798
|
connection.onDidChangeWatchedFiles(({ changes }) => {
|
|
594
|
-
|
|
595
|
-
|
|
799
|
+
const uris = changes.map((change) => change.uri);
|
|
800
|
+
affected(uris).then((result) => {
|
|
801
|
+
if (result) {
|
|
802
|
+
control(() => refresh(uris, "change"));
|
|
803
|
+
schedule();
|
|
804
|
+
}
|
|
805
|
+
}).catch((error) => {
|
|
806
|
+
connection.console.error(errorText(error));
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
connection.languages.diagnostics.on((params, token) => {
|
|
810
|
+
const task = pulls.then(() => pullDiagnostics(params.textDocument.uri, params.previousResultId, token));
|
|
811
|
+
pulls = task.then(() => void 0, () => void 0);
|
|
812
|
+
return task;
|
|
596
813
|
});
|
|
597
814
|
connection.onDidChangeConfiguration(({ settings }) => {
|
|
598
815
|
control(async () => {
|
|
599
816
|
registryDirectives = completionRegistrySetting(settings?.stillwind ?? settings) ?? registryDirectives;
|
|
600
|
-
await open();
|
|
817
|
+
await open("a configuration change");
|
|
601
818
|
});
|
|
602
819
|
schedule();
|
|
603
820
|
});
|
|
@@ -610,13 +827,14 @@ function createLanguageServer(connection, options) {
|
|
|
610
827
|
if (token.isCancellationRequested) return result;
|
|
611
828
|
for (const entries of cache.values()) for (const entry of entries) for (const report of entry.result.reports) {
|
|
612
829
|
const primary = report.primary.location;
|
|
613
|
-
if (primary.uri !== params.textDocument.uri || primary.endLine < params.range.start.line || primary.startLine > params.range.end.line) continue;
|
|
830
|
+
if (uriKey(primary.uri) !== uriKey(params.textDocument.uri) || primary.endLine < params.range.start.line || primary.startLine > params.range.end.line) continue;
|
|
614
831
|
if (document && (primary.endUtf16 < document.offsetAt(params.range.start) || primary.startUtf16 > document.offsetAt(params.range.end))) continue;
|
|
615
832
|
for (const action of report.actions) {
|
|
616
833
|
const changes = /* @__PURE__ */ new Map();
|
|
617
834
|
let valid = true;
|
|
618
835
|
for (const edit of action.edits) {
|
|
619
|
-
const
|
|
836
|
+
const key = uriKey(edit.location.uri);
|
|
837
|
+
const document = documents.all().find(({ uri }) => uriKey(uri) === key);
|
|
620
838
|
if (!document || fingerprint(document.getText()) !== edit.location.revision) {
|
|
621
839
|
valid = false;
|
|
622
840
|
break;
|
|
@@ -672,7 +890,7 @@ function createLanguageServer(connection, options) {
|
|
|
672
890
|
return {
|
|
673
891
|
ready: () => controls,
|
|
674
892
|
reload: async () => {
|
|
675
|
-
control(open);
|
|
893
|
+
control(() => open("a reload request"));
|
|
676
894
|
schedule();
|
|
677
895
|
await controls;
|
|
678
896
|
},
|
|
@@ -680,6 +898,40 @@ function createLanguageServer(connection, options) {
|
|
|
680
898
|
};
|
|
681
899
|
}
|
|
682
900
|
/**
|
|
901
|
+
* Creates a comparison key for spellings of one file URI. Editors and Node encode characters and
|
|
902
|
+
* spell Windows drive letters differently, for example `file:///f%3A/a` and `file:///F:/a`.
|
|
903
|
+
*
|
|
904
|
+
* @param uri - Document URI. Do not send the result to a client.
|
|
905
|
+
* @returns The decoded URI with a lowercase drive letter, or the input if it cannot be decoded.
|
|
906
|
+
*/
|
|
907
|
+
function uriKey(uri) {
|
|
908
|
+
try {
|
|
909
|
+
uri = decodeURIComponent(uri);
|
|
910
|
+
} catch {
|
|
911
|
+
return uri;
|
|
912
|
+
}
|
|
913
|
+
return uri.replace(/^file:\/\/\/[a-z]:/i, (drive) => drive.toLowerCase());
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Formats an unexpected failure for the log.
|
|
917
|
+
*
|
|
918
|
+
* @param error - Thrown value.
|
|
919
|
+
* @returns The stack trace of an `Error`, which includes its message, or the string form of other
|
|
920
|
+
* values.
|
|
921
|
+
*/
|
|
922
|
+
function errorText(error) {
|
|
923
|
+
return error instanceof Error && error.stack ? error.stack : String(error);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Recognizes a Stillwind configuration file by name.
|
|
927
|
+
*
|
|
928
|
+
* @param uri - Document URI.
|
|
929
|
+
* @returns Whether the file name is `stillwind.config` with any extension.
|
|
930
|
+
*/
|
|
931
|
+
function isConfigurationUri(uri) {
|
|
932
|
+
return /\/stillwind\.config\.[^/]+$/.test(uri);
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
683
935
|
* Reads the editor-only completion field from initialization options or configuration settings.
|
|
684
936
|
*
|
|
685
937
|
* @param value - A protocol object that may contain `completion.registryDirectives`.
|
|
@@ -712,4 +964,4 @@ function range(location) {
|
|
|
712
964
|
}
|
|
713
965
|
export { createLanguageServer as t };
|
|
714
966
|
|
|
715
|
-
//# sourceMappingURL=server-
|
|
967
|
+
//# sourceMappingURL=server-ZB6y2ShG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-ZB6y2ShG.js","names":[],"sources":["../src/editor.ts","../src/server.ts"],"sourcesContent":["import type { EditorRequest, WorkspaceEditorResult } from \"@stillwind/analysis\";\nimport {\n CompletionItemKind,\n InsertTextFormat,\n MarkupKind,\n type CancellationToken,\n type CodeAction,\n type CompletionItem,\n type Connection,\n type TextDocuments,\n} from \"vscode-languageserver\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\n\nconst sortKind = \"source.sort.stillwind\";\nconst fixAllKind = \"source.fixAll.stillwind\";\n\n/** Source actions advertised in fix-all order followed by utility sorting. */\nexport const editorCodeActionKinds = [fixAllKind, sortKind];\n\n/**\n * Queries the current original buffer and discards results after a document change or cancellation.\n *\n * @param uri - URI of an open original document.\n * @param request - Editor operation with offsets in that document's UTF-16 text.\n * @param token - Cancellation for this request.\n * @returns Results whose source fingerprints match the current document.\n */\nexport type EditorQuery = (\n uri: string,\n request: EditorRequest,\n token: CancellationToken,\n) => Promise<WorkspaceEditorResult[]>;\n\n/**\n * Registers hover, definitions, completion, colors, plugin links, and source actions.\n *\n * @param connection - Caller-owned connection on which handlers are installed.\n * @param documents - Open original buffers used to convert UTF-16 offsets to LSP positions.\n * @param query - Query implementation that rejects obsolete results and honors cancellation.\n */\nexport function registerEditorFeatures(\n connection: Connection,\n documents: TextDocuments<TextDocument>,\n query: EditorQuery,\n): void {\n connection.onDefinition(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"definition\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const definitions = entries.flatMap((entry) => entry.result.definitions ?? []);\n return definitions\n .filter(\n (definition, index) =>\n definitions.findIndex((other) => JSON.stringify(other) === JSON.stringify(definition)) ===\n index,\n )\n .map((definition) => ({\n uri: definition.uri,\n range: {\n start: {\n line: definition.startLine,\n character: definition.startColumn,\n },\n end: {\n line: definition.endLine,\n character: definition.endColumn,\n },\n },\n }));\n });\n connection.onDocumentLinks(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"links\",\n },\n token,\n );\n const links = entries.flatMap((entry) => entry.result.links ?? []);\n return links\n .filter(\n (link, index) =>\n link.target &&\n links.findIndex(\n (other) =>\n other.start === link.start && other.end === link.end && other.target === link.target,\n ) === index &&\n !links.some(\n (other) =>\n other.start === link.start && other.end === link.end && other.target !== link.target,\n ),\n )\n .map((link) => ({\n range: offsets(document, link),\n target: link.target,\n }));\n });\n connection.onHover(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"hover\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const answers = entries.filter((entry) => entry.result.hover);\n if (!answers.length) {\n return null;\n }\n\n const seen = new Set<string>();\n const contents = answers\n .flatMap((entry) => {\n const hover = entry.result.hover!;\n const key = JSON.stringify(hover);\n if (seen.has(key)) {\n return [];\n }\n seen.add(key);\n return [\n `${answers.length > 1 ? `${entry.config} · project ${entry.project + 1}\\n\\n` : \"\"}${hoverMarkdown(hover)}`,\n ];\n })\n .join(\"\\n\\n\");\n return {\n contents: {\n kind: MarkupKind.Markdown,\n value: contents,\n },\n range: offsets(document, answers[0].result.hover!),\n };\n });\n\n connection.onCompletion(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const version = document.version;\n const entries = await query(\n document.uri,\n {\n kind: \"completion\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const items: CompletionItem[] = entries.flatMap((entry) =>\n (entry.result.completions ?? []).map((item) => ({\n label: item.label,\n detail: item.detail,\n sortText: item.sortText,\n insertTextFormat: item.snippet ? InsertTextFormat.Snippet : undefined,\n command: item.retrigger\n ? { title: \"Continue completion\", command: \"editor.action.triggerSuggest\" }\n : undefined,\n kind: item.keyword\n ? CompletionItemKind.Keyword\n : item.category === \"directory\"\n ? CompletionItemKind.Folder\n : item.category === \"file\"\n ? CompletionItemKind.File\n : item.category === \"module\" || item.variant || item.candidate.endsWith(\":\")\n ? CompletionItemKind.Module\n : item.marker\n ? CompletionItemKind.Class\n : CompletionItemKind.Value,\n textEdit: {\n range: offsets(document, item),\n newText: item.snippet ?? item.newText,\n },\n data: {\n uri: document.uri,\n version,\n revision: entry.result.revision,\n candidate: item.candidate,\n input: item.input,\n snapshot: item.snapshot,\n project: entry.project,\n config: entry.config,\n },\n })),\n );\n return items.filter(\n (item, index) =>\n items.findIndex(\n (other) =>\n other.label === item.label &&\n JSON.stringify(other.textEdit) === JSON.stringify(item.textEdit),\n ) === index,\n );\n });\n\n connection.onCompletionResolve(async (item, token) => {\n const detail = item.detail;\n delete item.documentation;\n delete item.detail;\n const data = item.data as\n | {\n /** Original document URI captured when completion was requested. */\n uri?: unknown;\n /** Document version that must still match the open buffer. */\n version?: unknown;\n /** Full completion candidate, including surrounding variants. */\n candidate?: unknown;\n /** Configuration identity used to select the same project result. */\n config?: unknown;\n /** Zero-based project index within the configuration. */\n project?: unknown;\n /** Source fingerprint that must match the resolved result. */\n revision?: unknown;\n /** Original UTF-16 offset that identifies the completion's utility input. */\n input?: unknown;\n /** Graph and configuration fingerprint required by the resolve request. */\n snapshot?: unknown;\n }\n | undefined;\n if (\n !data ||\n typeof data.uri !== \"string\" ||\n typeof data.candidate !== \"string\" ||\n typeof data.input !== \"number\" ||\n typeof data.snapshot !== \"string\" ||\n documents.get(data.uri)?.version !== data.version\n ) {\n return item;\n }\n\n const entries = await query(\n data.uri,\n {\n kind: \"resolve\",\n candidate: data.candidate,\n input: data.input,\n snapshot: data.snapshot,\n },\n token,\n );\n const answer = entries.find(\n (entry) =>\n entry.project === data.project &&\n entry.config === data.config &&\n entry.result.revision === data.revision,\n )?.result.hover;\n if (answer) {\n item.detail = answer.detail ?? detail;\n item.documentation = {\n kind: MarkupKind.Markdown,\n value: hoverMarkdown(answer),\n };\n }\n return item;\n });\n\n connection.onDocumentColor(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colors\",\n },\n token,\n );\n const colors = entries\n .flatMap((entry) => entry.result.colors ?? [])\n .filter(\n (color, index, colors) =>\n colors.findIndex((other) => JSON.stringify(other) === JSON.stringify(color)) === index,\n );\n // Projects that disagree on a range omit it. A range may show one light and one dark color.\n return colors\n .filter((color) => {\n const range = colors.filter(\n (other) => other.start === color.start && other.end === color.end,\n );\n return (\n range.length === 1 ||\n (range.length === 2 &&\n range.some((other) => other.scheme === \"light\") &&\n range.some((other) => other.scheme === \"dark\"))\n );\n })\n .map((color) => ({\n range: offsets(document, color),\n color: {\n red: color.red,\n green: color.green,\n blue: color.blue,\n alpha: color.alpha,\n },\n }));\n });\n\n connection.onColorPresentation(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colorPresentation\",\n start: document.offsetAt(params.range.start),\n end: document.offsetAt(params.range.end),\n color: params.color,\n },\n token,\n );\n return entries\n .flatMap((entry) =>\n (entry.result.edits ?? []).map((edit) => ({\n label: edit.newText,\n textEdit: {\n range: offsets(document, edit),\n newText: edit.newText,\n },\n })),\n )\n .filter(\n (item, index, items) =>\n items.findIndex((other) => JSON.stringify(item) === JSON.stringify(other)) === index,\n );\n });\n}\n\n/**\n * Formats CSS previews and dialect documentation, and explains authored runtime key expressions.\n * Expression line breaks become spaces, and code-span delimiters exceed every authored\n * backtick run so expressions remain literal Markdown. The supplied hover remains unchanged.\n *\n * @param hover - CSS preview and optional authored expressions for runtime view-transition names.\n * @returns Markdown with CSS first and expression notes in their supplied order.\n */\nfunction hoverMarkdown(hover: {\n /** Formatted generated CSS included verbatim inside the CSS fence. */\n css: string;\n /** Markdown describing authored CSS syntax or theme semantics. */\n documentation?: string;\n /** Authored expressions in the order in which their notes should appear. */\n runtimeNames?: string[];\n}): string {\n const notes = (hover.runtimeNames ?? []).map((expression) => {\n const text = expression.replace(/\\r\\n?|\\n/g, \" \");\n const ticks = \"`\".repeat(\n Math.max(0, ...[...text.matchAll(/`+/g)].map((match) => match[0].length)) + 1,\n );\n return `view-transition-name is computed at runtime from ${ticks} ${text} ${ticks}.`;\n });\n return [hover.css ? `\\`\\`\\`css\\n${hover.css}\\n\\`\\`\\`` : undefined, hover.documentation, ...notes]\n .filter(Boolean)\n .join(\"\\n\\n\");\n}\n\n/**\n * Builds versioned source actions for each project and removes actions with identical edits.\n * Each action contains one project's edits, so differing project results remain separate.\n *\n * @param document - Open original buffer that the query reads and the returned edits target.\n * @param only - Requested source kinds or their prefixes. Omission or an empty list produces no actions.\n * @param token - Cancellation forwarded to each query.\n * @param query - Query implementation that discards changed buffers and cancelled requests.\n * @returns Fix-all actions followed by sort actions, preserving project order within each kind.\n * @throws If a query rejects.\n */\nexport async function sourceActions(\n document: TextDocument,\n only: readonly string[] | undefined,\n token: CancellationToken,\n query: EditorQuery,\n): Promise<CodeAction[]> {\n const actions: CodeAction[] = [];\n for (const [kind, operation, title] of [\n [fixAllKind, \"fixes\", \"Fix all Stillwind lint findings\"],\n [sortKind, \"sort\", \"Sort Stillwind utilities\"],\n ] as const) {\n if (!only?.some((requested) => kind === requested || kind.startsWith(`${requested}.`))) {\n continue;\n }\n const entries = await query(\n document.uri,\n {\n kind: operation,\n },\n token,\n );\n for (const entry of entries) {\n if (!entry.result.edits?.length) {\n continue;\n }\n const edit = {\n documentChanges: [\n {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: entry.result.edits.map((edit) => ({\n range: offsets(document, edit),\n newText: edit.newText,\n })),\n },\n ],\n };\n if (\n actions.some(\n (action) => action.kind === kind && JSON.stringify(action.edit) === JSON.stringify(edit),\n )\n ) {\n continue;\n }\n actions.push({\n title: `${title}${entries.length > 1 ? ` (${entry.config}, project ${entry.project + 1})` : \"\"}`,\n kind,\n edit,\n });\n }\n }\n return actions;\n}\n\n/**\n * Converts original UTF-16 offsets to positions using the open document's line table.\n *\n * @param document - Document containing the text from which the offsets were measured.\n * @param range - Half-open UTF-16 range. TextDocument clamps offsets outside the document.\n * @returns LSP positions with zero-based lines and UTF-16 character offsets.\n */\nfunction offsets(\n document: TextDocument,\n range: {\n /** Inclusive UTF-16 offset in the original document. */\n start: number;\n /** Exclusive UTF-16 offset in the original document. */\n end: number;\n },\n) {\n return {\n start: document.positionAt(range.start),\n end: document.positionAt(range.end),\n };\n}\n","import type {\n AnalysisWorkspaceService,\n DiscoverWorkspace,\n OpenAnalysisWorkspaces,\n OpenWorkspaces,\n WorkspaceEditorResult,\n WorkspaceResult,\n} from \"@stillwind/analysis\";\nimport {\n CodeActionKind,\n DiagnosticSeverity,\n DidChangeWatchedFilesNotification,\n LSPErrorCodes,\n MessageType,\n ResponseError,\n ShowMessageNotification,\n TextDocuments,\n TextDocumentSyncKind,\n type CancellationToken,\n type CodeAction,\n type Connection,\n type Diagnostic,\n type DiagnosticServerCancellationData,\n type DocumentDiagnosticReport,\n type InitializeParams,\n type TextDocumentEdit,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\n\nimport {\n editorCodeActionKinds,\n registerEditorFeatures,\n sourceActions,\n type EditorQuery,\n} from \"./editor.ts\";\n\n/** Supplies analysis services and delegates transport exit to the embedding application. */\nexport interface LanguageServerOptions {\n /**\n * Opens services at initialization and after saves, watched file changes, configuration changes,\n * or workspace folder changes. Previous services are closed first. Open buffers are replayed.\n */\n openWorkspaces: OpenWorkspaces;\n /**\n * Opens a configuration for an open document that no service analyzes. The server calls this once\n * for each document until services reopen. Supplying it advertises editor features before any\n * service exists. Omission leaves such documents without analysis. A client with pull diagnostics\n * decides which documents reach this call, because only a diagnostic request starts discovery.\n * Editors open documents in the background, and each configuration starts a process that runs\n * its code.\n */\n discoverWorkspace?: DiscoverWorkspace;\n /**\n * Converts a service identity to the URI of its configuration file, where the server publishes\n * that service's errors.\n *\n * @param id - Key from a workspace map or an error map.\n * @param folders - Current workspace directory URIs.\n * @returns The file URI, or undefined when the identity names no file. The server then only logs\n * the error and notifies the user. Omitting this option has the same effect.\n */\n configurationUri?(id: string, folders: readonly string[]): string | undefined;\n /**\n * Handles the LSP exit notification using the embedding's transport or process policy.\n *\n * @param shutdown - Whether shutdown or explicit disposal was requested before exit.\n */\n onExit?(shutdown: boolean): void;\n}\n\n/**\n * Registers synchronization, diagnostics, fixes, hover, completion, colors, and sorting.\n * Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited\n * document to be open and to match the report's source fingerprint.\n *\n * A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the\n * server reports only the findings located in that document. Other clients receive every open\n * document's findings through `textDocument/publishDiagnostics`.\n *\n * @param connection - Caller-owned connection. Call listen after registration and dispose the\n * transport when finished. Diagnostic locations must use original documents and UTF-16 positions.\n * @param options - Workspace factory and optional exit handler. This server owns the opened services.\n * @returns Cleanup for the analysis services. It does not dispose the connection or its transport.\n */\nexport function createLanguageServer(\n connection: Connection,\n options: LanguageServerOptions,\n): {\n /**\n * Waits for document and workspace changes already queued by the server.\n *\n * @returns The current control queue's completion promise. Queued failures are logged.\n */\n ready(): Promise<void>;\n /**\n * Reopens workspace configuration and files, replays current buffers, and schedules analysis.\n *\n * @returns Completion of the queued reload. Reload failures are logged, and analysis runs separately.\n */\n reload(): Promise<void>;\n /**\n * Stops scheduling analysis, cancels publication, and closes services after queued control work.\n *\n * @returns The same cleanup promise on repeated calls.\n * @throws An AggregateError if any service fails to close.\n */\n dispose(): Promise<void>;\n} {\n const documents = new TextDocuments(TextDocument);\n const workspaces = new Map<string, AnalysisWorkspaceService>();\n const errors = new Map<string, string>();\n const cache = new Map<string, WorkspaceResult[]>();\n const published = new Set<string>();\n /** Documents already passed to discovery, which keeps later analysis passes from searching again. */\n const discovered = new Set<string>();\n /** Identities whose current error the user has seen, which keeps each from notifying again. */\n const reported = new Set<string>();\n /** Last logged error message of each identity, which keeps an unchanged error from repeating. */\n const logged = new Map<string, string>();\n /** Editor query failures already logged since services opened, which keeps each from repeating. */\n const queryFailures = new Set<string>();\n\n let roots: string[] = [];\n let initializationOptions: unknown;\n let registryDirectives = false;\n let snippets = false;\n /** Whether the client requests diagnostics instead of receiving published ones. */\n let pull = false;\n /** Whether the client accepts `workspace/diagnostic/refresh`. */\n let pullRefresh = false;\n /** Control generation whose open documents were prepared together for pull diagnostics. */\n let prepared: number | undefined;\n /** Serializes pull diagnostics, because a worker analyzes one document at a time. */\n let pulls = Promise.resolve();\n /** Last report for each pulled document. Its identity lets the client keep unchanged results. */\n const pullReports = new Map<string, { id: string; text: string }>();\n let nextReport = 0;\n let generation = 0;\n let controls = Promise.resolve();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let shutdown = false;\n let foldersSupported = false;\n let dynamicWatch = false;\n let active: AbortController | undefined;\n let disposal: Promise<void> | undefined;\n\n /**\n * Invalidates current results and serializes a workspace or document mutation.\n * Callback failures are logged and absorbed so subsequent mutations can run.\n *\n * @param action - Mutation to execute after previous control work. Shutdown skips registration.\n */\n const control = (action: () => Promise<void>) => {\n if (shutdown) {\n return;\n }\n active?.abort();\n generation++;\n cache.clear();\n controls = controls.then(action).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n };\n\n /**\n * Takes ownership of opened services and replays every open buffer into them.\n *\n * @param opened - Services and initialization errors from the workspace factory or discovery.\n * @returns Completion of buffer replay.\n * @throws If buffer replay fails.\n */\n const adopt = async (opened: OpenAnalysisWorkspaces) => {\n for (const [id, error] of opened.errors ?? []) {\n errors.set(id, error);\n }\n for (const [id, workspace] of opened.workspaces) {\n connection.console.info(`Opened the Stillwind workspace ${id}`);\n workspaces.set(id, workspace);\n for (const document of documents.all()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n }\n };\n\n /**\n * Closes existing services, opens the current roots, replays every open buffer, and logs the\n * outcome.\n *\n * @param reason - Event that requires the services, logged at debug level.\n * @returns Completion of service replacement and buffer replay.\n * @throws If service closure, the workspace factory, or buffer replay fails.\n */\n const open = async (reason: string) => {\n connection.console.debug(`Opening Stillwind workspaces after ${reason}`);\n const start = performance.now();\n await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));\n workspaces.clear();\n errors.clear();\n discovered.clear();\n queryFailures.clear();\n await adopt(\n await options.openWorkspaces({\n workspaceFolders: roots,\n initializationOptions,\n }),\n );\n const elapsed = Math.round(performance.now() - start);\n if (workspaces.size) {\n const count = `${workspaces.size} Stillwind workspace${workspaces.size === 1 ? \"\" : \"s\"}`;\n connection.console.info(`Opened ${count} in ${elapsed} ms`);\n } else if (!errors.size) {\n connection.console.info(\n [\n roots.length\n ? `No Stillwind configuration was found in ${roots.join(\", \")}.`\n : \"No workspace folder is open.\",\n ...(options.discoverWorkspace\n ? [\"A configuration in a subdirectory opens when a document in that directory opens.\"]\n : []),\n ].join(\" \"),\n );\n }\n };\n\n /**\n * Opens configurations for documents that the last analysis pass left without results.\n *\n * @param uris - Document URIs. A document closed in the meantime is skipped.\n * @returns Completion of discovery and buffer replay.\n * @throws If discovery or buffer replay fails.\n */\n const discover = async (uris: readonly string[]) => {\n for (const uri of uris) {\n if (!documents.get(uri)) {\n continue;\n }\n const opened = await options.discoverWorkspace?.(\n uri,\n {\n workspaceFolders: roots,\n initializationOptions,\n },\n new Set([...workspaces.keys(), ...errors.keys()]),\n );\n if (opened) {\n await adopt(opened);\n }\n }\n };\n\n /**\n * Converts one document's analysis results to diagnostics.\n *\n * @param uri - Analyzed document, which receives the note about an incomplete analysis.\n * @param results - Results of each project that analyzed the document.\n * @param add - Receives each diagnostic with the URI of its location.\n */\n const collect = (\n uri: string,\n results: readonly WorkspaceResult[],\n add: (uri: string, diagnostic: Diagnostic) => void,\n ) => {\n for (const entry of results) {\n const source = `stillwind:${entry.config}:${entry.project + 1}`;\n for (const report of entry.result.reports) {\n const location = report.primary.location;\n add(location.uri, {\n range: range(location),\n severity:\n report.severity === \"error\" ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,\n source,\n code: report.code,\n message: [report.message, ...report.notes].join(\"\\n\"),\n relatedInformation: report.related.map((label) => ({\n location: {\n uri: label.location.uri,\n range: range(label.location),\n },\n message: label.message ?? report.message,\n })),\n });\n }\n if (entry.result.status === \"incomplete\") {\n const missing =\n entry.result.dependencies\n ?.filter(\n (dependency) =>\n dependency.status === \"unresolved\" || dependency.status === \"unsupported\",\n )\n .map(\n (dependency) =>\n `${dependency.status}: ${dependency.specifier} from ${dependency.importer}`,\n ) ?? [];\n add(uri, {\n range: range(),\n severity: entry.result.error ? DiagnosticSeverity.Error : DiagnosticSeverity.Information,\n source,\n code: entry.result.error ? \"SW_HOST\" : \"SW_UNVERIFIED\",\n message: [\n entry.result.error ?? \"Stillwind analysis is incomplete\",\n ...missing,\n ...(entry.result.unverified ?? []).map((item) => `${item.moduleId}: ${item.reason}`),\n ].join(\"\\n\"),\n });\n }\n }\n };\n\n /**\n * Converts workspace errors to diagnostics on their configuration files.\n *\n * @param add - Receives each diagnostic with the URI of its configuration file.\n */\n const collectErrors = (add: (uri: string, diagnostic: Diagnostic) => void) => {\n for (const [file, error] of errors) {\n const uri = options.configurationUri?.(file, roots);\n if (uri) {\n add(uri, {\n range: range(),\n severity: DiagnosticSeverity.Error,\n source: \"stillwind\",\n code: \"SW_HOST\",\n message: error,\n });\n }\n }\n };\n\n /**\n * Logs each new or changed workspace error and forgets errors that ended. The user receives one\n * notification for each identity until its error ends, because the message of a configuration\n * error can change with each edit of the configuration.\n */\n const notifyErrors = () => {\n for (const [file, error] of errors) {\n const message = `${file}: ${error}`;\n if (logged.get(file) !== message) {\n logged.set(file, message);\n connection.console.error(message);\n }\n if (!reported.has(file)) {\n reported.add(file);\n void connection.sendNotification(ShowMessageNotification.type, {\n type: MessageType.Error,\n message: `Stillwind: ${message}`,\n });\n }\n }\n for (const file of reported) {\n if (!errors.has(file)) {\n reported.delete(file);\n logged.delete(file);\n }\n }\n };\n\n /**\n * Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.\n * Empty notifications clear diagnostics for previously published or currently open documents.\n */\n const publish = () => {\n const open = new Map(documents.all().map((document) => [uriKey(document.uri), document.uri]));\n const grouped = new Map<string, Diagnostic[]>();\n const seen = new Set<string>();\n /**\n * Appends a diagnostic only once for its document and complete serialized value.\n *\n * @param reported - Original document URI, in any spelling of that document.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (reported: string, diagnostic: Diagnostic) => {\n const uri = open.get(uriKey(reported)) ?? reported;\n const key = JSON.stringify([uri, diagnostic]);\n if (!seen.has(key)) {\n seen.add(key);\n const list = grouped.get(uri) ?? [];\n list.push(diagnostic);\n grouped.set(uri, list);\n }\n };\n for (const [uri, results] of cache) {\n collect(uri, results, add);\n }\n collectErrors(add);\n notifyErrors();\n // Clients treat spellings of one file as one resource, so a second notification for another\n // spelling would replace the first.\n const targets = new Map(\n [...published, ...grouped.keys(), ...open.values()].map((uri) => [uriKey(uri), uri]),\n );\n for (const uri of targets.values()) {\n void connection.sendDiagnostics({\n uri,\n version: documents.get(uri)?.version,\n diagnostics: grouped.get(uri) ?? [],\n });\n }\n published.clear();\n for (const uri of grouped.keys()) {\n published.add(uri);\n }\n };\n\n /**\n * Analyzes open buffers after queued mutations and publishes only a current, non-stale batch.\n * Service failures become workspace errors. An obsolete or cancelled batch leaves the cache unchanged.\n *\n * @param revision - Control generation captured when analysis was scheduled.\n * @returns Completion of the analysis pass or its early discard.\n */\n const analyze = async (revision: number) => {\n await controls;\n if (shutdown || revision !== generation) {\n return;\n }\n const cancellation = new AbortController();\n active = cancellation;\n const next = new Map<string, WorkspaceResult[]>();\n for (const [file, workspace] of workspaces) {\n try {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n } catch (error) {\n errors.set(file, String(error));\n }\n if (revision !== generation || shutdown) {\n return;\n }\n }\n for (const document of documents.all()) {\n const results: WorkspaceResult[] = [];\n for (const [file, workspace] of workspaces) {\n try {\n results.push(...(await workspace.analyze(document.uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n if (revision !== generation || shutdown) {\n return;\n }\n if (\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n return;\n }\n next.set(document.uri, results);\n }\n if (revision === generation) {\n cache.clear();\n for (const [uri, result] of next) {\n cache.set(uri, result);\n }\n publish();\n discoverUncovered();\n }\n };\n\n /**\n * Starts discovery for documents that the last analysis pass left without results. Each document\n * is passed to discovery once until services reopen.\n */\n const discoverUncovered = () => {\n const uncovered = options.discoverWorkspace\n ? [...cache].flatMap(([uri, results]) => (results.length || discovered.has(uri) ? [] : [uri]))\n : [];\n if (uncovered.length) {\n for (const uri of uncovered) {\n discovered.add(uri);\n }\n control(() => discover(uncovered));\n schedule();\n }\n };\n\n /**\n * Replaces the pending 40 ms timer with an analysis pass for the current control generation. A\n * pull client instead receives a request to pull its documents again, without a pass here.\n */\n const schedule = () => {\n if (timer) {\n clearTimeout(timer);\n }\n if (pull) {\n timer = setTimeout(() => {\n notifyErrors();\n if (pullRefresh) {\n void connection.languages.diagnostics.refresh().catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }\n }, 40);\n return;\n }\n const revision = generation;\n timer = setTimeout(() => {\n void analyze(revision).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }, 40);\n };\n\n /**\n * Analyzes one document for a pull request, and retries once after discovery opens a service.\n * Results stay cached until the next control generation. Open documents are prepared together\n * once per generation, because the checker then loads them in one batch.\n *\n * @param uri - Requested document URI.\n * @param token - Client cancellation.\n * @returns Results of each project, or an empty list for a closed document or after shutdown.\n * @throws A `ResponseError` with `RequestCancelled` after client cancellation, or with\n * `ServerCancelled` and `retriggerRequest` after a change makes the analysis obsolete.\n */\n const pullResults = async (uri: string, token: CancellationToken): Promise<WorkspaceResult[]> => {\n for (;;) {\n await controls;\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (shutdown || !documents.get(uri)) {\n return [];\n }\n const cached = cache.get(uri);\n if (cached) {\n return cached;\n }\n const revision = generation;\n const cancellation = new AbortController();\n active = cancellation;\n const subscription = token.onCancellationRequested(() => cancellation.abort());\n const results: WorkspaceResult[] = [];\n try {\n for (const [file, workspace] of workspaces) {\n try {\n if (prepared !== revision) {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n }\n results.push(...(await workspace.analyze(uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n } finally {\n subscription.dispose();\n }\n if (shutdown) {\n return [];\n }\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (\n revision !== generation ||\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n throw new ResponseError<DiagnosticServerCancellationData>(\n LSPErrorCodes.ServerCancelled,\n \"Stillwind analysis became obsolete\",\n { retriggerRequest: true },\n );\n }\n prepared = revision;\n cache.set(uri, results);\n if (results.length || discovered.has(uri) || !options.discoverWorkspace) {\n return results;\n }\n discovered.add(uri);\n control(() => discover([uri]));\n }\n };\n\n /**\n * Answers a pull request with the findings located in one document and in its configuration\n * errors. Findings in other documents appear when the client pulls those documents.\n *\n * @param uri - Requested document URI.\n * @param previous - Report identity that the client retains.\n * @param token - Client cancellation.\n * @returns An unchanged report when the content matches the retained report, otherwise a full one.\n * @throws The errors of `pullResults`.\n */\n const pullDiagnostics = async (\n uri: string,\n previous: string | undefined,\n token: CancellationToken,\n ): Promise<DocumentDiagnosticReport> => {\n const results = await pullResults(uri, token);\n const key = uriKey(uri);\n const items = new Map<string, Diagnostic>();\n /**\n * Keeps a diagnostic only when it belongs to the requested document.\n *\n * @param location - URI of the diagnostic, in any spelling.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (location: string, diagnostic: Diagnostic) => {\n if (uriKey(location) === key) {\n items.set(JSON.stringify(diagnostic), diagnostic);\n }\n };\n collect(uri, results, add);\n collectErrors(add);\n notifyErrors();\n const text = [...items.keys()].join(\"\\n\");\n let report = pullReports.get(uri);\n if (report?.text !== text) {\n report = { id: String(++nextReport), text };\n pullReports.set(uri, report);\n }\n return previous === report.id\n ? { kind: \"unchanged\", resultId: report.id }\n : { kind: \"full\", resultId: report.id, items: [...items.values()] };\n };\n\n /**\n * Queries services after queued mutations and checks document versions and source fingerprints.\n * Each distinct query failure is logged once until services reopen. The cancellation subscription\n * is released after the request.\n *\n * @param uri - URI of the open original document.\n * @param request - Editor operation expressed in that document's UTF-16 coordinates.\n * @param token - LSP cancellation forwarded through an AbortSignal.\n * @returns Current project results, or an empty list after changes, cancellation, or failure.\n */\n const query: EditorQuery = async (uri, request, token: CancellationToken) => {\n await controls;\n if (request.kind === \"completion\" || request.kind === \"resolve\") {\n request = {\n ...request,\n registryDirectives,\n snippets,\n };\n }\n const document = documents.get(uri);\n if (!document || shutdown || token.isCancellationRequested) {\n return [];\n }\n const version = document.version;\n const revision = generation;\n const controller = new AbortController();\n const subscription = token.onCancellationRequested(() => controller.abort());\n const results: WorkspaceEditorResult[] = [];\n try {\n for (const workspace of workspaces.values()) {\n if (workspace.query) {\n results.push(...(await workspace.query(uri, request, controller.signal)));\n }\n }\n if (\n token.isCancellationRequested ||\n revision !== generation ||\n documents.get(uri)?.version !== version\n ) {\n return [];\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n return results.filter((entry) => entry.result.revision === fingerprint(document.getText()));\n } catch (error) {\n const message = errorText(error);\n if (!queryFailures.has(message)) {\n queryFailures.add(message);\n connection.console.error(message);\n }\n return [];\n } finally {\n subscription.dispose();\n }\n };\n registerEditorFeatures(connection, documents, query);\n\n connection.onInitialize(async (params: InitializeParams) => {\n initializationOptions = params.initializationOptions;\n registryDirectives = completionRegistrySetting(initializationOptions) ?? false;\n pull = params.capabilities.textDocument?.diagnostic !== undefined;\n pullRefresh = params.capabilities.workspace?.diagnostics?.refreshSupport === true;\n snippets =\n params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;\n foldersSupported = params.capabilities.workspace?.workspaceFolders === true;\n dynamicWatch =\n params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;\n roots =\n params.workspaceFolders?.map((folder) => folder.uri) ??\n (params.rootUri ? [params.rootUri] : []);\n await open(\"initialization\");\n const editor =\n options.discoverWorkspace != null ||\n [...workspaces.values()].some((workspace) => workspace.query != null);\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n codeActionProvider: {\n codeActionKinds: [CodeActionKind.QuickFix, ...(editor ? editorCodeActionKinds : [])],\n },\n ...(pull\n ? {\n diagnosticProvider: {\n identifier: \"stillwind\",\n interFileDependencies: true,\n workspaceDiagnostics: false,\n },\n }\n : {}),\n hoverProvider: editor,\n definitionProvider: editor,\n completionProvider: editor\n ? {\n resolveProvider: true,\n triggerCharacters: [\"@\", \":\", \"-\", \"/\", \"[\", \"(\", \" \"],\n }\n : undefined,\n colorProvider: editor,\n documentLinkProvider: editor\n ? {\n resolveProvider: false,\n }\n : undefined,\n workspace: {\n workspaceFolders: {\n supported: true,\n changeNotifications: true,\n },\n },\n },\n serverInfo: {\n name: \"Stillwind\",\n },\n };\n });\n connection.onInitialized(async () => {\n if (foldersSupported) {\n connection.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {\n const deleted = new Set(removed.map((folder) => folder.uri));\n roots = [\n ...roots.filter((root) => !deleted.has(root)),\n ...added.map((folder) => folder.uri),\n ];\n control(() => open(\"a workspace folder change\"));\n schedule();\n });\n }\n if (dynamicWatch) {\n await connection.client.register(DidChangeWatchedFilesNotification.type, {\n watchers: [\n {\n globPattern: \"**/*\",\n },\n ],\n });\n }\n schedule();\n });\n documents.onDidChangeContent(({ document }) => {\n control(async () => {\n if (documents.get(document.uri)?.version !== document.version) {\n return;\n }\n for (const workspace of workspaces.values()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n });\n if (!pull) {\n schedule();\n }\n });\n documents.onDidClose(({ document }) => {\n pullReports.delete(document.uri);\n control(async () => {\n for (const workspace of workspaces.values()) {\n await workspace.closeDocument(document.uri);\n }\n });\n schedule();\n });\n /**\n * Reopens the workspaces if any service cannot reuse its current buffers after a save or file\n * change. Without services, reopening lets a new or corrected configuration take effect.\n *\n * @param uris - Document URIs from the save or watch notification. The list must not be empty.\n * @param event - Notification kind for the log, such as `save`.\n * @returns Completion of the checks and any required workspace replacement.\n * @throws If a service check or workspace replacement fails.\n */\n const refresh = async (uris: readonly string[], event: string) => {\n const others = uris.length > 1 ? ` and ${uris.length - 1} other files` : \"\";\n const reason = `the ${event} of ${uris[0]}${others}`;\n if (!workspaces.size || (errors.size && uris.some(isConfigurationUri))) {\n await open(reason);\n return;\n }\n for (const workspace of workspaces.values()) {\n if (!(await workspace.refresh?.(uris))) {\n await open(reason);\n break;\n }\n }\n };\n documents.onDidSave(({ document }) => {\n control(() => refresh([document.uri], \"save\"));\n schedule();\n });\n /**\n * Decides whether watched changes need work. Starting that work cancels running analysis, so\n * changes to unrelated files must not reach it.\n *\n * @param uris - Document URIs from the watch notification.\n * @returns True for a configuration file while a service is missing or failed, and when a service\n * reports that the changes affect it. A service without an `affects` check counts as affected.\n * @throws If a service check fails.\n */\n const affected = async (uris: readonly string[]) => {\n if ((!workspaces.size || errors.size) && uris.some(isConfigurationUri)) {\n return true;\n }\n for (const workspace of workspaces.values()) {\n if ((await workspace.affects?.(uris)) ?? true) {\n return true;\n }\n }\n return false;\n };\n connection.onDidChangeWatchedFiles(({ changes }) => {\n const uris = changes.map((change) => change.uri);\n void affected(uris)\n .then((result) => {\n if (result) {\n control(() => refresh(uris, \"change\"));\n schedule();\n }\n })\n .catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n });\n connection.languages.diagnostics.on((params, token) => {\n const task = pulls.then(() =>\n pullDiagnostics(params.textDocument.uri, params.previousResultId, token),\n );\n pulls = task.then(\n () => undefined,\n () => undefined,\n );\n return task;\n });\n connection.onDidChangeConfiguration(({ settings }) => {\n control(async () => {\n registryDirectives =\n completionRegistrySetting(settings?.stillwind ?? settings) ?? registryDirectives;\n await open(\"a configuration change\");\n });\n schedule();\n });\n connection.onCodeAction(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n const result: CodeAction[] = document\n ? await sourceActions(document, params.context.only, token, query)\n : [];\n if (\n params.context.only &&\n !params.context.only.some(\n (kind) =>\n CodeActionKind.QuickFix === kind || CodeActionKind.QuickFix.startsWith(`${kind}.`),\n )\n ) {\n return result;\n }\n if (token.isCancellationRequested) {\n return result;\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n if (token.isCancellationRequested) {\n return result;\n }\n for (const entries of cache.values()) {\n for (const entry of entries) {\n for (const report of entry.result.reports) {\n const primary = report.primary.location;\n if (\n uriKey(primary.uri) !== uriKey(params.textDocument.uri) ||\n primary.endLine < params.range.start.line ||\n primary.startLine > params.range.end.line\n ) {\n continue;\n }\n if (\n document &&\n (primary.endUtf16 < document.offsetAt(params.range.start) ||\n primary.startUtf16 > document.offsetAt(params.range.end))\n ) {\n continue;\n }\n for (const action of report.actions) {\n const changes = new Map<string, TextDocumentEdit>();\n let valid = true;\n for (const edit of action.edits) {\n const key = uriKey(edit.location.uri);\n const document = documents.all().find(({ uri }) => uriKey(uri) === key);\n if (!document || fingerprint(document.getText()) !== edit.location.revision) {\n valid = false;\n break;\n }\n const change = changes.get(document.uri) ?? {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: [],\n };\n change.edits.push({\n range: range(edit.location),\n newText: edit.replacement,\n });\n changes.set(document.uri, change);\n }\n if (valid && changes.size) {\n result.push({\n title: action.title,\n kind: CodeActionKind.QuickFix,\n edit: {\n documentChanges: [...changes.values()],\n },\n });\n }\n }\n }\n }\n }\n return result.filter(\n (action, index) =>\n result.findIndex((candidate) => JSON.stringify(candidate) === JSON.stringify(action)) ===\n index,\n );\n });\n /**\n * Stops publication and closes all services after the control queue settles.\n *\n * @returns A shared cleanup promise, including on repeated calls.\n * @throws An AggregateError containing every service closure failure.\n */\n const dispose = (): Promise<void> => {\n disposal ??= (async () => {\n shutdown = true;\n active?.abort();\n generation++;\n cache.clear();\n if (timer) {\n clearTimeout(timer);\n }\n await controls;\n const closed = await Promise.allSettled(\n [...workspaces.values()].map((workspace) => workspace.close()),\n );\n workspaces.clear();\n const failed = closed.filter((result) => result.status === \"rejected\");\n if (failed.length) {\n throw new AggregateError(\n failed.map((result) => result.reason),\n \"Failed to close language server analysis services\",\n );\n }\n })();\n return disposal;\n };\n connection.onShutdown(dispose);\n connection.onExit(() => {\n options.onExit?.(shutdown);\n });\n documents.listen(connection);\n return {\n ready: () => controls,\n reload: async () => {\n control(() => open(\"a reload request\"));\n schedule();\n await controls;\n },\n dispose,\n };\n}\n\n/**\n * Creates a comparison key for spellings of one file URI. Editors and Node encode characters and\n * spell Windows drive letters differently, for example `file:///f%3A/a` and `file:///F:/a`.\n *\n * @param uri - Document URI. Do not send the result to a client.\n * @returns The decoded URI with a lowercase drive letter, or the input if it cannot be decoded.\n */\nexport function uriKey(uri: string): string {\n try {\n uri = decodeURIComponent(uri);\n } catch {\n return uri;\n }\n return uri.replace(/^file:\\/\\/\\/[a-z]:/i, (drive) => drive.toLowerCase());\n}\n\n/**\n * Formats an unexpected failure for the log.\n *\n * @param error - Thrown value.\n * @returns The stack trace of an `Error`, which includes its message, or the string form of other\n * values.\n */\nfunction errorText(error: unknown): string {\n return error instanceof Error && error.stack ? error.stack : String(error);\n}\n\n/**\n * Recognizes a Stillwind configuration file by name.\n *\n * @param uri - Document URI.\n * @returns Whether the file name is `stillwind.config` with any extension.\n */\nfunction isConfigurationUri(uri: string): boolean {\n return /\\/stillwind\\.config\\.[^/]+$/.test(uri);\n}\n\n/**\n * Reads the editor-only completion field from initialization options or configuration settings.\n *\n * @param value - A protocol object that may contain `completion.registryDirectives`.\n * @returns The boolean setting, or undefined when the field is absent or invalid.\n */\nfunction completionRegistrySetting(value: unknown): boolean | undefined {\n if (!value || typeof value !== \"object\") {\n return undefined;\n }\n const completion = (value as Record<string, unknown>).completion;\n if (!completion || typeof completion !== \"object\") {\n return undefined;\n }\n const registry = (completion as Record<string, unknown>).registryDirectives;\n return typeof registry === \"boolean\" ? registry : undefined;\n}\n\n/**\n * Copies a native diagnostic location into LSP positions.\n *\n * @param location - Original document positions with zero-based lines and UTF-16 columns.\n * @returns The half-open range, or an empty range at document start when no location is supplied.\n */\nfunction range(location?: {\n /** Zero-based line containing the inclusive start. */\n startLine: number;\n /** UTF-16 column of the inclusive start. */\n startColumn: number;\n /** Zero-based line containing the exclusive end. */\n endLine: number;\n /** UTF-16 column of the exclusive end. */\n endColumn: number;\n}) {\n return {\n start: {\n line: location?.startLine ?? 0,\n character: location?.startColumn ?? 0,\n },\n end: {\n line: location?.endLine ?? 0,\n character: location?.endColumn ?? 0,\n },\n };\n}\n"],"mappings":";;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;AAGnB,MAAa,wBAAwB,CAAC,YAAY,QAAQ;;;;;;;;AAuB1D,SAAgB,uBACd,YACA,WACA,OACM;CACN,WAAW,aAAa,OAAO,QAAQ,UAAU;EAC/C,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa,GAAG;EACtD,IAAI,CAAC,UACH,OAAO,CAAC;EAUV,MAAM,eAAc,MARE,MACpB,SAAS,KACT;GACE,MAAM;GACN,QAAQ,SAAS,SAAS,OAAO,QAAQ;EAC3C,GACA,KACF,EAAA,CAC4B,SAAS,UAAU,MAAM,OAAO,eAAe,CAAC,CAAC;EAC7E,OAAO,YACJ,QACE,YAAY,UACX,YAAY,WAAW,UAAU,KAAK,UAAU,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,MACrF,KACJ,CAAC,CACA,KAAK,gBAAgB;GACpB,KAAK,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8BAA8B,KAAK,GAAG;AAC/C;;;;;;;AAQA,SAAS,0BAA0B,OAAqC;CACtE,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B;CAEF,MAAM,aAAc,MAAkC;CACtD,IAAI,CAAC,cAAc,OAAO,eAAe,UACvC;CAEF,MAAM,WAAY,WAAuC;CACzD,OAAO,OAAO,aAAa,YAAY,WAAW,KAAA;AACpD;;;;;;;AAQA,SAAS,MAAM,UASZ;CACD,OAAO;EACL,OAAO;GACL,MAAM,UAAU,aAAa;GAC7B,WAAW,UAAU,eAAe;EACtC;EACA,KAAK;GACH,MAAM,UAAU,WAAW;GAC3B,WAAW,UAAU,aAAa;EACpC;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stillwind/language-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Stillwind language server for Node and browser transports",
|
|
5
5
|
"homepage": "https://stillwind.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@stillwind/analysis": "0.
|
|
39
|
-
"@stillwind/native": "0.
|
|
38
|
+
"@stillwind/analysis": "0.5.0",
|
|
39
|
+
"@stillwind/native": "0.5.0",
|
|
40
40
|
"vscode-languageserver": "^11.0.0",
|
|
41
41
|
"vscode-languageserver-textdocument": "^1.0.16"
|
|
42
42
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@stillwind-internal/tools-workspace": "0.0.0",
|
|
45
45
|
"@types/node": "^26.6.6",
|
|
46
46
|
"rolldown": "^1.2.16",
|
|
47
|
-
"stillwind": "0.
|
|
47
|
+
"stillwind": "0.5.0",
|
|
48
48
|
"typescript": "^6.0.3",
|
|
49
49
|
"vite-plus": "1.4.0"
|
|
50
50
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-GjZU1QxS.js","names":[],"sources":["../src/editor.ts","../src/server.ts"],"sourcesContent":["import type { EditorRequest, WorkspaceEditorResult } from \"@stillwind/analysis\";\nimport {\n CompletionItemKind,\n InsertTextFormat,\n MarkupKind,\n type CancellationToken,\n type CodeAction,\n type CompletionItem,\n type Connection,\n type TextDocuments,\n} from \"vscode-languageserver\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\n\nconst sortKind = \"source.sort.stillwind\";\nconst fixAllKind = \"source.fixAll.stillwind\";\n\n/** Source actions advertised in fix-all order followed by utility sorting. */\nexport const editorCodeActionKinds = [fixAllKind, sortKind];\n\n/**\n * Queries the current original buffer and discards results after a document change or cancellation.\n *\n * @param uri - URI of an open original document.\n * @param request - Editor operation with offsets in that document's UTF-16 text.\n * @param token - Cancellation for this request.\n * @returns Results whose source fingerprints match the current document.\n */\nexport type EditorQuery = (\n uri: string,\n request: EditorRequest,\n token: CancellationToken,\n) => Promise<WorkspaceEditorResult[]>;\n\n/**\n * Registers hover, definitions, completion, colors, plugin links, and source actions.\n *\n * @param connection - Caller-owned connection on which handlers are installed.\n * @param documents - Open original buffers used to convert UTF-16 offsets to LSP positions.\n * @param query - Query implementation that rejects obsolete results and honors cancellation.\n */\nexport function registerEditorFeatures(\n connection: Connection,\n documents: TextDocuments<TextDocument>,\n query: EditorQuery,\n): void {\n connection.onDefinition(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"definition\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const definitions = entries.flatMap((entry) => entry.result.definitions ?? []);\n return definitions\n .filter(\n (definition, index) =>\n definitions.findIndex((other) => JSON.stringify(other) === JSON.stringify(definition)) ===\n index,\n )\n .map((definition) => ({\n uri: definition.uri,\n range: {\n start: {\n line: definition.startLine,\n character: definition.startColumn,\n },\n end: {\n line: definition.endLine,\n character: definition.endColumn,\n },\n },\n }));\n });\n connection.onDocumentLinks(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"links\",\n },\n token,\n );\n const links = entries.flatMap((entry) => entry.result.links ?? []);\n return links\n .filter(\n (link, index) =>\n link.target &&\n links.findIndex(\n (other) =>\n other.start === link.start && other.end === link.end && other.target === link.target,\n ) === index &&\n !links.some(\n (other) =>\n other.start === link.start && other.end === link.end && other.target !== link.target,\n ),\n )\n .map((link) => ({\n range: offsets(document, link),\n target: link.target,\n }));\n });\n connection.onHover(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"hover\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const answers = entries.filter((entry) => entry.result.hover);\n if (!answers.length) {\n return null;\n }\n\n const seen = new Set<string>();\n const contents = answers\n .flatMap((entry) => {\n const hover = entry.result.hover!;\n const key = JSON.stringify(hover);\n if (seen.has(key)) {\n return [];\n }\n seen.add(key);\n return [\n `${answers.length > 1 ? `${entry.config} · project ${entry.project + 1}\\n\\n` : \"\"}${hoverMarkdown(hover)}`,\n ];\n })\n .join(\"\\n\\n\");\n return {\n contents: {\n kind: MarkupKind.Markdown,\n value: contents,\n },\n range: offsets(document, answers[0].result.hover!),\n };\n });\n\n connection.onCompletion(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const version = document.version;\n const entries = await query(\n document.uri,\n {\n kind: \"completion\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const items: CompletionItem[] = entries.flatMap((entry) =>\n (entry.result.completions ?? []).map((item) => ({\n label: item.label,\n detail: item.detail,\n sortText: item.sortText,\n insertTextFormat: item.snippet ? InsertTextFormat.Snippet : undefined,\n command: item.retrigger\n ? { title: \"Continue completion\", command: \"editor.action.triggerSuggest\" }\n : undefined,\n kind: item.keyword\n ? CompletionItemKind.Keyword\n : item.category === \"directory\"\n ? CompletionItemKind.Folder\n : item.category === \"file\"\n ? CompletionItemKind.File\n : item.category === \"module\" || item.variant || item.candidate.endsWith(\":\")\n ? CompletionItemKind.Module\n : item.marker\n ? CompletionItemKind.Class\n : CompletionItemKind.Value,\n textEdit: {\n range: offsets(document, item),\n newText: item.snippet ?? item.newText,\n },\n data: {\n uri: document.uri,\n version,\n revision: entry.result.revision,\n candidate: item.candidate,\n input: item.input,\n snapshot: item.snapshot,\n project: entry.project,\n config: entry.config,\n },\n })),\n );\n return items.filter(\n (item, index) =>\n items.findIndex(\n (other) =>\n other.label === item.label &&\n JSON.stringify(other.textEdit) === JSON.stringify(item.textEdit),\n ) === index,\n );\n });\n\n connection.onCompletionResolve(async (item, token) => {\n const detail = item.detail;\n delete item.documentation;\n delete item.detail;\n const data = item.data as\n | {\n /** Original document URI captured when completion was requested. */\n uri?: unknown;\n /** Document version that must still match the open buffer. */\n version?: unknown;\n /** Full completion candidate, including surrounding variants. */\n candidate?: unknown;\n /** Configuration identity used to select the same project result. */\n config?: unknown;\n /** Zero-based project index within the configuration. */\n project?: unknown;\n /** Source fingerprint that must match the resolved result. */\n revision?: unknown;\n /** Original UTF-16 offset that identifies the completion's utility input. */\n input?: unknown;\n /** Graph and configuration fingerprint required by the resolve request. */\n snapshot?: unknown;\n }\n | undefined;\n if (\n !data ||\n typeof data.uri !== \"string\" ||\n typeof data.candidate !== \"string\" ||\n typeof data.input !== \"number\" ||\n typeof data.snapshot !== \"string\" ||\n documents.get(data.uri)?.version !== data.version\n ) {\n return item;\n }\n\n const entries = await query(\n data.uri,\n {\n kind: \"resolve\",\n candidate: data.candidate,\n input: data.input,\n snapshot: data.snapshot,\n },\n token,\n );\n const answer = entries.find(\n (entry) =>\n entry.project === data.project &&\n entry.config === data.config &&\n entry.result.revision === data.revision,\n )?.result.hover;\n if (answer) {\n item.detail = answer.detail ?? detail;\n item.documentation = {\n kind: MarkupKind.Markdown,\n value: hoverMarkdown(answer),\n };\n }\n return item;\n });\n\n connection.onDocumentColor(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colors\",\n },\n token,\n );\n const colors = entries.flatMap((entry) => entry.result.colors ?? []);\n return colors\n .filter(\n (color, index) =>\n colors.findIndex((other) => JSON.stringify(other) === JSON.stringify(color)) === index &&\n !colors.some(\n (other) =>\n other.start === color.start &&\n other.end === color.end &&\n JSON.stringify(other) !== JSON.stringify(color),\n ),\n )\n .map((color) => ({\n range: offsets(document, color),\n color: {\n red: color.red,\n green: color.green,\n blue: color.blue,\n alpha: color.alpha,\n },\n }));\n });\n\n connection.onColorPresentation(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colorPresentation\",\n start: document.offsetAt(params.range.start),\n end: document.offsetAt(params.range.end),\n color: params.color,\n },\n token,\n );\n return entries\n .flatMap((entry) =>\n (entry.result.edits ?? []).map((edit) => ({\n label: edit.newText,\n textEdit: {\n range: offsets(document, edit),\n newText: edit.newText,\n },\n })),\n )\n .filter(\n (item, index, items) =>\n items.findIndex((other) => JSON.stringify(item) === JSON.stringify(other)) === index,\n );\n });\n}\n\n/**\n * Formats CSS previews and dialect documentation, and explains authored runtime key expressions.\n * Expression line breaks become spaces, and code-span delimiters exceed every authored\n * backtick run so expressions remain literal Markdown. The supplied hover remains unchanged.\n *\n * @param hover - CSS preview and optional authored expressions for runtime view-transition names.\n * @returns Markdown with CSS first and expression notes in their supplied order.\n */\nfunction hoverMarkdown(hover: {\n /** Formatted generated CSS included verbatim inside the CSS fence. */\n css: string;\n /** Markdown describing authored CSS syntax or theme semantics. */\n documentation?: string;\n /** Authored expressions in the order in which their notes should appear. */\n runtimeNames?: string[];\n}): string {\n const notes = (hover.runtimeNames ?? []).map((expression) => {\n const text = expression.replace(/\\r\\n?|\\n/g, \" \");\n const ticks = \"`\".repeat(\n Math.max(0, ...[...text.matchAll(/`+/g)].map((match) => match[0].length)) + 1,\n );\n return `view-transition-name is computed at runtime from ${ticks} ${text} ${ticks}.`;\n });\n return [hover.css ? `\\`\\`\\`css\\n${hover.css}\\n\\`\\`\\`` : undefined, hover.documentation, ...notes]\n .filter(Boolean)\n .join(\"\\n\\n\");\n}\n\n/**\n * Builds versioned source actions for each project and removes actions with identical edits.\n * Each action contains one project's edits, so differing project results remain separate.\n *\n * @param document - Open original buffer that the query reads and the returned edits target.\n * @param only - Requested source kinds or their prefixes. Omission or an empty list produces no actions.\n * @param token - Cancellation forwarded to each query.\n * @param query - Query implementation that discards changed buffers and cancelled requests.\n * @returns Fix-all actions followed by sort actions, preserving project order within each kind.\n * @throws If a query rejects.\n */\nexport async function sourceActions(\n document: TextDocument,\n only: readonly string[] | undefined,\n token: CancellationToken,\n query: EditorQuery,\n): Promise<CodeAction[]> {\n const actions: CodeAction[] = [];\n for (const [kind, operation, title] of [\n [fixAllKind, \"fixes\", \"Fix all Stillwind lint findings\"],\n [sortKind, \"sort\", \"Sort Stillwind utilities\"],\n ] as const) {\n if (!only?.some((requested) => kind === requested || kind.startsWith(`${requested}.`))) {\n continue;\n }\n const entries = await query(\n document.uri,\n {\n kind: operation,\n },\n token,\n );\n for (const entry of entries) {\n if (!entry.result.edits?.length) {\n continue;\n }\n const edit = {\n documentChanges: [\n {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: entry.result.edits.map((edit) => ({\n range: offsets(document, edit),\n newText: edit.newText,\n })),\n },\n ],\n };\n if (\n actions.some(\n (action) => action.kind === kind && JSON.stringify(action.edit) === JSON.stringify(edit),\n )\n ) {\n continue;\n }\n actions.push({\n title: `${title}${entries.length > 1 ? ` (${entry.config}, project ${entry.project + 1})` : \"\"}`,\n kind,\n edit,\n });\n }\n }\n return actions;\n}\n\n/**\n * Converts original UTF-16 offsets to positions using the open document's line table.\n *\n * @param document - Document containing the text from which the offsets were measured.\n * @param range - Half-open UTF-16 range. TextDocument clamps offsets outside the document.\n * @returns LSP positions with zero-based lines and UTF-16 character offsets.\n */\nfunction offsets(\n document: TextDocument,\n range: {\n /** Inclusive UTF-16 offset in the original document. */\n start: number;\n /** Exclusive UTF-16 offset in the original document. */\n end: number;\n },\n) {\n return {\n start: document.positionAt(range.start),\n end: document.positionAt(range.end),\n };\n}\n","import type {\n AnalysisWorkspaceService,\n DiscoverWorkspace,\n OpenAnalysisWorkspaces,\n OpenWorkspaces,\n WorkspaceEditorResult,\n WorkspaceResult,\n} from \"@stillwind/analysis\";\nimport {\n CodeActionKind,\n DiagnosticSeverity,\n DidChangeWatchedFilesNotification,\n MessageType,\n ShowMessageNotification,\n TextDocuments,\n TextDocumentSyncKind,\n type CancellationToken,\n type CodeAction,\n type Connection,\n type Diagnostic,\n type InitializeParams,\n type TextDocumentEdit,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\n\nimport {\n editorCodeActionKinds,\n registerEditorFeatures,\n sourceActions,\n type EditorQuery,\n} from \"./editor.ts\";\n\n/** Supplies analysis services and delegates transport exit to the embedding application. */\nexport interface LanguageServerOptions {\n /**\n * Opens services at initialization and after saves, watched file changes, configuration changes,\n * or workspace folder changes. Previous services are closed first. Open buffers are replayed.\n */\n openWorkspaces: OpenWorkspaces;\n /**\n * Opens a configuration for an open document that no service analyzes. The server calls this once\n * for each document until services reopen. Supplying it advertises editor features before any\n * service exists. Omission leaves such documents without analysis.\n */\n discoverWorkspace?: DiscoverWorkspace;\n /**\n * Converts a service identity to the URI of its configuration file, where the server publishes\n * that service's errors.\n *\n * @param id - Key from a workspace map or an error map.\n * @param folders - Current workspace directory URIs.\n * @returns The file URI, or undefined when the identity names no file. The server then only logs\n * the error and notifies the user. Omitting this option has the same effect.\n */\n configurationUri?(id: string, folders: readonly string[]): string | undefined;\n /**\n * Handles the LSP exit notification using the embedding's transport or process policy.\n *\n * @param shutdown - Whether shutdown or explicit disposal was requested before exit.\n */\n onExit?(shutdown: boolean): void;\n}\n\n/**\n * Registers synchronization, diagnostics, fixes, hover, completion, colors, and sorting.\n * Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited\n * document to be open and to match the report's source fingerprint.\n *\n * @param connection - Caller-owned connection. Call listen after registration and dispose the\n * transport when finished. Diagnostic locations must use original documents and UTF-16 positions.\n * @param options - Workspace factory and optional exit handler. This server owns the opened services.\n * @returns Cleanup for the analysis services. It does not dispose the connection or its transport.\n */\nexport function createLanguageServer(\n connection: Connection,\n options: LanguageServerOptions,\n): {\n /**\n * Waits for document and workspace changes already queued by the server.\n *\n * @returns The current control queue's completion promise. Queued failures are logged.\n */\n ready(): Promise<void>;\n /**\n * Reopens workspace configuration and files, replays current buffers, and schedules analysis.\n *\n * @returns Completion of the queued reload. Reload failures are logged, and analysis runs separately.\n */\n reload(): Promise<void>;\n /**\n * Stops scheduling analysis, cancels publication, and closes services after queued control work.\n *\n * @returns The same cleanup promise on repeated calls.\n * @throws An AggregateError if any service fails to close.\n */\n dispose(): Promise<void>;\n} {\n const documents = new TextDocuments(TextDocument);\n const workspaces = new Map<string, AnalysisWorkspaceService>();\n const errors = new Map<string, string>();\n const cache = new Map<string, WorkspaceResult[]>();\n const published = new Set<string>();\n /** Documents already passed to discovery, which keeps later analysis passes from searching again. */\n const discovered = new Set<string>();\n /** Current error messages that the user has seen, which keeps each from notifying again. */\n const reported = new Set<string>();\n\n let roots: string[] = [];\n let initializationOptions: unknown;\n let registryDirectives = false;\n let snippets = false;\n let generation = 0;\n let controls = Promise.resolve();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let shutdown = false;\n let foldersSupported = false;\n let dynamicWatch = false;\n let active: AbortController | undefined;\n let disposal: Promise<void> | undefined;\n\n /**\n * Invalidates current results and serializes a workspace or document mutation.\n * Callback failures are logged and absorbed so subsequent mutations can run.\n *\n * @param action - Mutation to execute after previous control work. Shutdown skips registration.\n */\n const control = (action: () => Promise<void>) => {\n if (shutdown) {\n return;\n }\n active?.abort();\n generation++;\n cache.clear();\n controls = controls.then(action).catch((error: unknown) => {\n connection.console.error(String(error));\n });\n };\n\n /**\n * Takes ownership of opened services and replays every open buffer into them.\n *\n * @param opened - Services and initialization errors from the workspace factory or discovery.\n * @returns Completion of buffer replay.\n * @throws If buffer replay fails.\n */\n const adopt = async (opened: OpenAnalysisWorkspaces) => {\n for (const [id, error] of opened.errors ?? []) {\n errors.set(id, error);\n }\n for (const [id, workspace] of opened.workspaces) {\n workspaces.set(id, workspace);\n for (const document of documents.all()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n }\n };\n\n /**\n * Closes existing services, opens the current roots, and replays every open buffer.\n *\n * @returns Completion of service replacement and buffer replay.\n * @throws If service closure, the workspace factory, or buffer replay fails.\n */\n const open = async () => {\n await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));\n workspaces.clear();\n errors.clear();\n discovered.clear();\n await adopt(\n await options.openWorkspaces({\n workspaceFolders: roots,\n initializationOptions,\n }),\n );\n };\n\n /**\n * Opens configurations for documents that the last analysis pass left without results.\n *\n * @param uris - Document URIs. A document closed in the meantime is skipped.\n * @returns Completion of discovery and buffer replay.\n * @throws If discovery or buffer replay fails.\n */\n const discover = async (uris: readonly string[]) => {\n for (const uri of uris) {\n if (!documents.get(uri)) {\n continue;\n }\n const opened = await options.discoverWorkspace?.(\n uri,\n {\n workspaceFolders: roots,\n initializationOptions,\n },\n new Set([...workspaces.keys(), ...errors.keys()]),\n );\n if (opened) {\n await adopt(opened);\n }\n }\n };\n\n /**\n * Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.\n * Empty notifications clear diagnostics for previously published or currently open documents.\n */\n const publish = () => {\n const grouped = new Map<string, Diagnostic[]>();\n const seen = new Set<string>();\n /**\n * Appends a diagnostic only once for its document and complete serialized value.\n *\n * @param uri - Original document URI used to group publication.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (uri: string, diagnostic: Diagnostic) => {\n const key = JSON.stringify([uri, diagnostic]);\n if (!seen.has(key)) {\n seen.add(key);\n const list = grouped.get(uri) ?? [];\n list.push(diagnostic);\n grouped.set(uri, list);\n }\n };\n for (const [uri, results] of cache) {\n for (const entry of results) {\n const source = `stillwind:${entry.config}:${entry.project + 1}`;\n for (const report of entry.result.reports) {\n const location = report.primary.location;\n add(location.uri, {\n range: range(location),\n severity:\n report.severity === \"error\" ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,\n source,\n code: report.code,\n message: [report.message, ...report.notes].join(\"\\n\"),\n relatedInformation: report.related.map((label) => ({\n location: {\n uri: label.location.uri,\n range: range(label.location),\n },\n message: label.message ?? report.message,\n })),\n });\n }\n if (entry.result.status === \"incomplete\") {\n const missing =\n entry.result.dependencies\n ?.filter(\n (dependency) =>\n dependency.status === \"unresolved\" || dependency.status === \"unsupported\",\n )\n .map(\n (dependency) =>\n `${dependency.status}: ${dependency.specifier} from ${dependency.importer}`,\n ) ?? [];\n add(uri, {\n range: range(),\n severity: entry.result.error\n ? DiagnosticSeverity.Error\n : DiagnosticSeverity.Information,\n source,\n code: entry.result.error ? \"SW_HOST\" : \"SW_UNVERIFIED\",\n message: [\n entry.result.error ?? \"Stillwind analysis is incomplete\",\n ...missing,\n ...(entry.result.unverified ?? []).map((item) => `${item.moduleId}: ${item.reason}`),\n ].join(\"\\n\"),\n });\n }\n }\n }\n const current = new Set<string>();\n for (const [file, error] of errors) {\n const message = `${file}: ${error}`;\n const uri = options.configurationUri?.(file, roots);\n if (uri) {\n add(uri, {\n range: range(),\n severity: DiagnosticSeverity.Error,\n source: \"stillwind\",\n code: \"SW_HOST\",\n message: error,\n });\n }\n current.add(message);\n if (!reported.has(message)) {\n reported.add(message);\n connection.console.error(message);\n void connection.sendNotification(ShowMessageNotification.type, {\n type: MessageType.Warning,\n message: `Stillwind: ${message}`,\n });\n }\n }\n for (const message of reported) {\n if (!current.has(message)) {\n reported.delete(message);\n }\n }\n for (const uri of new Set([\n ...published,\n ...grouped.keys(),\n ...documents.all().map((document) => document.uri),\n ])) {\n void connection.sendDiagnostics({\n uri,\n version: documents.get(uri)?.version,\n diagnostics: grouped.get(uri) ?? [],\n });\n }\n published.clear();\n for (const uri of grouped.keys()) {\n published.add(uri);\n }\n };\n\n /**\n * Analyzes open buffers after queued mutations and publishes only a current, non-stale batch.\n * Service failures become workspace errors. An obsolete or cancelled batch leaves the cache unchanged.\n *\n * @param revision - Control generation captured when analysis was scheduled.\n * @returns Completion of the analysis pass or its early discard.\n */\n const analyze = async (revision: number) => {\n await controls;\n if (shutdown || revision !== generation) {\n return;\n }\n const cancellation = new AbortController();\n active = cancellation;\n const next = new Map<string, WorkspaceResult[]>();\n for (const [file, workspace] of workspaces) {\n try {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n } catch (error) {\n errors.set(file, String(error));\n }\n if (revision !== generation || shutdown) {\n return;\n }\n }\n for (const document of documents.all()) {\n const results: WorkspaceResult[] = [];\n for (const [file, workspace] of workspaces) {\n try {\n results.push(...(await workspace.analyze(document.uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n if (revision !== generation || shutdown) {\n return;\n }\n if (\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n return;\n }\n next.set(document.uri, results);\n }\n if (revision === generation) {\n cache.clear();\n for (const [uri, result] of next) {\n cache.set(uri, result);\n }\n publish();\n const uncovered = options.discoverWorkspace\n ? [...next].flatMap(([uri, results]) =>\n results.length || discovered.has(uri) ? [] : [uri],\n )\n : [];\n if (uncovered.length) {\n for (const uri of uncovered) {\n discovered.add(uri);\n }\n control(() => discover(uncovered));\n schedule();\n }\n }\n };\n\n /** Replaces the pending 40 ms timer with an analysis pass for the current control generation. */\n const schedule = () => {\n if (timer) {\n clearTimeout(timer);\n }\n const revision = generation;\n timer = setTimeout(() => {\n void analyze(revision).catch((error: unknown) => {\n connection.console.error(String(error));\n });\n }, 40);\n };\n\n /**\n * Queries services after queued mutations and checks document versions and source fingerprints.\n * Query failures are logged, and the cancellation subscription is released after the request.\n *\n * @param uri - URI of the open original document.\n * @param request - Editor operation expressed in that document's UTF-16 coordinates.\n * @param token - LSP cancellation forwarded through an AbortSignal.\n * @returns Current project results, or an empty list after changes, cancellation, or failure.\n */\n const query: EditorQuery = async (uri, request, token: CancellationToken) => {\n await controls;\n if (request.kind === \"completion\" || request.kind === \"resolve\") {\n request = {\n ...request,\n registryDirectives,\n snippets,\n };\n }\n const document = documents.get(uri);\n if (!document || shutdown || token.isCancellationRequested) {\n return [];\n }\n const version = document.version;\n const revision = generation;\n const controller = new AbortController();\n const subscription = token.onCancellationRequested(() => controller.abort());\n const results: WorkspaceEditorResult[] = [];\n try {\n for (const workspace of workspaces.values()) {\n if (workspace.query) {\n results.push(...(await workspace.query(uri, request, controller.signal)));\n }\n }\n if (\n token.isCancellationRequested ||\n revision !== generation ||\n documents.get(uri)?.version !== version\n ) {\n return [];\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n return results.filter((entry) => entry.result.revision === fingerprint(document.getText()));\n } catch (error) {\n connection.console.error(String(error));\n return [];\n } finally {\n subscription.dispose();\n }\n };\n registerEditorFeatures(connection, documents, query);\n\n connection.onInitialize(async (params: InitializeParams) => {\n initializationOptions = params.initializationOptions;\n registryDirectives = completionRegistrySetting(initializationOptions) ?? false;\n snippets =\n params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;\n foldersSupported = params.capabilities.workspace?.workspaceFolders === true;\n dynamicWatch =\n params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;\n roots =\n params.workspaceFolders?.map((folder) => folder.uri) ??\n (params.rootUri ? [params.rootUri] : []);\n await open();\n const editor =\n options.discoverWorkspace != null ||\n [...workspaces.values()].some((workspace) => workspace.query != null);\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n codeActionProvider: {\n codeActionKinds: [CodeActionKind.QuickFix, ...(editor ? editorCodeActionKinds : [])],\n },\n hoverProvider: editor,\n definitionProvider: editor,\n completionProvider: editor\n ? {\n resolveProvider: true,\n triggerCharacters: [\"@\", \":\", \"-\", \"/\", \"[\", \"(\", \" \"],\n }\n : undefined,\n colorProvider: editor,\n documentLinkProvider: editor\n ? {\n resolveProvider: false,\n }\n : undefined,\n workspace: {\n workspaceFolders: {\n supported: true,\n changeNotifications: true,\n },\n },\n },\n serverInfo: {\n name: \"Stillwind\",\n },\n };\n });\n connection.onInitialized(async () => {\n if (foldersSupported) {\n connection.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {\n const deleted = new Set(removed.map((folder) => folder.uri));\n roots = [\n ...roots.filter((root) => !deleted.has(root)),\n ...added.map((folder) => folder.uri),\n ];\n control(open);\n schedule();\n });\n }\n if (dynamicWatch) {\n await connection.client.register(DidChangeWatchedFilesNotification.type, {\n watchers: [\n {\n globPattern: \"**/*\",\n },\n ],\n });\n }\n schedule();\n });\n documents.onDidChangeContent(({ document }) => {\n control(async () => {\n if (documents.get(document.uri)?.version !== document.version) {\n return;\n }\n for (const workspace of workspaces.values()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n });\n schedule();\n });\n documents.onDidClose(({ document }) => {\n control(async () => {\n for (const workspace of workspaces.values()) {\n await workspace.closeDocument(document.uri);\n }\n });\n schedule();\n });\n /**\n * Reopens the workspaces if any service cannot reuse its current buffers after a save or file\n * change. Without services, reopening lets a new or corrected configuration take effect.\n *\n * @param uris - Document URIs from the save or watch notification.\n * @returns Completion of the checks and any required workspace replacement.\n * @throws If a service check or workspace replacement fails.\n */\n const refresh = async (uris: readonly string[]) => {\n if (!workspaces.size) {\n await open();\n return;\n }\n for (const workspace of workspaces.values()) {\n if (!(await workspace.refresh?.(uris))) {\n await open();\n break;\n }\n }\n };\n documents.onDidSave(({ document }) => {\n control(() => refresh([document.uri]));\n schedule();\n });\n connection.onDidChangeWatchedFiles(({ changes }) => {\n control(() => refresh(changes.map((change) => change.uri)));\n schedule();\n });\n connection.onDidChangeConfiguration(({ settings }) => {\n control(async () => {\n registryDirectives =\n completionRegistrySetting(settings?.stillwind ?? settings) ?? registryDirectives;\n await open();\n });\n schedule();\n });\n connection.onCodeAction(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n const result: CodeAction[] = document\n ? await sourceActions(document, params.context.only, token, query)\n : [];\n if (\n params.context.only &&\n !params.context.only.some(\n (kind) =>\n CodeActionKind.QuickFix === kind || CodeActionKind.QuickFix.startsWith(`${kind}.`),\n )\n ) {\n return result;\n }\n if (token.isCancellationRequested) {\n return result;\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n if (token.isCancellationRequested) {\n return result;\n }\n for (const entries of cache.values()) {\n for (const entry of entries) {\n for (const report of entry.result.reports) {\n const primary = report.primary.location;\n if (\n primary.uri !== params.textDocument.uri ||\n primary.endLine < params.range.start.line ||\n primary.startLine > params.range.end.line\n ) {\n continue;\n }\n if (\n document &&\n (primary.endUtf16 < document.offsetAt(params.range.start) ||\n primary.startUtf16 > document.offsetAt(params.range.end))\n ) {\n continue;\n }\n for (const action of report.actions) {\n const changes = new Map<string, TextDocumentEdit>();\n let valid = true;\n for (const edit of action.edits) {\n const document = documents.get(edit.location.uri);\n if (!document || fingerprint(document.getText()) !== edit.location.revision) {\n valid = false;\n break;\n }\n const change = changes.get(document.uri) ?? {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: [],\n };\n change.edits.push({\n range: range(edit.location),\n newText: edit.replacement,\n });\n changes.set(document.uri, change);\n }\n if (valid && changes.size) {\n result.push({\n title: action.title,\n kind: CodeActionKind.QuickFix,\n edit: {\n documentChanges: [...changes.values()],\n },\n });\n }\n }\n }\n }\n }\n return result.filter(\n (action, index) =>\n result.findIndex((candidate) => JSON.stringify(candidate) === JSON.stringify(action)) ===\n index,\n );\n });\n /**\n * Stops publication and closes all services after the control queue settles.\n *\n * @returns A shared cleanup promise, including on repeated calls.\n * @throws An AggregateError containing every service closure failure.\n */\n const dispose = (): Promise<void> => {\n disposal ??= (async () => {\n shutdown = true;\n active?.abort();\n generation++;\n cache.clear();\n if (timer) {\n clearTimeout(timer);\n }\n await controls;\n const closed = await Promise.allSettled(\n [...workspaces.values()].map((workspace) => workspace.close()),\n );\n workspaces.clear();\n const failed = closed.filter((result) => result.status === \"rejected\");\n if (failed.length) {\n throw new AggregateError(\n failed.map((result) => result.reason),\n \"Failed to close language server analysis services\",\n );\n }\n })();\n return disposal;\n };\n connection.onShutdown(dispose);\n connection.onExit(() => {\n options.onExit?.(shutdown);\n });\n documents.listen(connection);\n return {\n ready: () => controls,\n reload: async () => {\n control(open);\n schedule();\n await controls;\n },\n dispose,\n };\n}\n\n/**\n * Reads the editor-only completion field from initialization options or configuration settings.\n *\n * @param value - A protocol object that may contain `completion.registryDirectives`.\n * @returns The boolean setting, or undefined when the field is absent or invalid.\n */\nfunction completionRegistrySetting(value: unknown): boolean | undefined {\n if (!value || typeof value !== \"object\") {\n return undefined;\n }\n const completion = (value as Record<string, unknown>).completion;\n if (!completion || typeof completion !== \"object\") {\n return undefined;\n }\n const registry = (completion as Record<string, unknown>).registryDirectives;\n return typeof registry === \"boolean\" ? registry : undefined;\n}\n\n/**\n * Copies a native diagnostic location into LSP positions.\n *\n * @param location - Original document positions with zero-based lines and UTF-16 columns.\n * @returns The half-open range, or an empty range at document start when no location is supplied.\n */\nfunction range(location?: {\n /** Zero-based line containing the inclusive start. */\n startLine: number;\n /** UTF-16 column of the inclusive start. */\n startColumn: number;\n /** Zero-based line containing the exclusive end. */\n endLine: number;\n /** UTF-16 column of the exclusive end. */\n endColumn: number;\n}) {\n return {\n start: {\n line: location?.startLine ?? 0,\n character: location?.startColumn ?? 0,\n },\n end: {\n line: location?.endLine ?? 0,\n character: location?.endColumn ?? 0,\n },\n };\n}\n"],"mappings":";;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;AAGnB,MAAa,wBAAwB,CAAC,YAAY,QAAQ;;;;;;;;AAuB1D,SAAgB,uBACd,YACA,WACA,OACM;CACN,WAAW,aAAa,OAAO,QAAQ,UAAU;EAC/C,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa,G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