@stillwind/language-server 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-GjZU1QxS.js → server-BIfF_XGK.js} +249 -41
- package/dist/server-BIfF_XGK.js.map +1 -0
- package/dist/{server-D7Wg5GbT.d.ts → server-Bp6CUeN4.d.ts} +9 -2
- 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-BIfF_XGK.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-BIfF_XGK.js";
|
package/dist/node.js
CHANGED
|
@@ -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";
|
|
@@ -238,6 +238,10 @@ function offsets(document, range) {
|
|
|
238
238
|
* Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited
|
|
239
239
|
* document to be open and to match the report's source fingerprint.
|
|
240
240
|
*
|
|
241
|
+
* A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the
|
|
242
|
+
* server reports only the findings located in that document. Other clients receive every open
|
|
243
|
+
* document's findings through `textDocument/publishDiagnostics`.
|
|
244
|
+
*
|
|
241
245
|
* @param connection - Caller-owned connection. Call listen after registration and dispose the
|
|
242
246
|
* transport when finished. Diagnostic locations must use original documents and UTF-16 positions.
|
|
243
247
|
* @param options - Workspace factory and optional exit handler. This server owns the opened services.
|
|
@@ -257,6 +261,17 @@ function createLanguageServer(connection, options) {
|
|
|
257
261
|
let initializationOptions;
|
|
258
262
|
let registryDirectives = false;
|
|
259
263
|
let snippets = false;
|
|
264
|
+
/** Whether the client requests diagnostics instead of receiving published ones. */
|
|
265
|
+
let pull = false;
|
|
266
|
+
/** Whether the client accepts `workspace/diagnostic/refresh`. */
|
|
267
|
+
let pullRefresh = false;
|
|
268
|
+
/** Control generation whose open documents were prepared together for pull diagnostics. */
|
|
269
|
+
let prepared;
|
|
270
|
+
/** Serializes pull diagnostics, because a worker analyzes one document at a time. */
|
|
271
|
+
let pulls = Promise.resolve();
|
|
272
|
+
/** Last report for each pulled document. Its identity lets the client keep unchanged results. */
|
|
273
|
+
const pullReports = /* @__PURE__ */ new Map();
|
|
274
|
+
let nextReport = 0;
|
|
260
275
|
let generation = 0;
|
|
261
276
|
let controls = Promise.resolve();
|
|
262
277
|
let timer;
|
|
@@ -328,28 +343,14 @@ function createLanguageServer(connection, options) {
|
|
|
328
343
|
}
|
|
329
344
|
};
|
|
330
345
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
346
|
+
* Converts one document's analysis results to diagnostics.
|
|
347
|
+
*
|
|
348
|
+
* @param uri - Analyzed document, which receives the note about an incomplete analysis.
|
|
349
|
+
* @param results - Results of each project that analyzed the document.
|
|
350
|
+
* @param add - Receives each diagnostic with the URI of its location.
|
|
333
351
|
*/
|
|
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) {
|
|
352
|
+
const collect = (uri, results, add) => {
|
|
353
|
+
for (const entry of results) {
|
|
353
354
|
const source = `stillwind:${entry.config}:${entry.project + 1}`;
|
|
354
355
|
for (const report of entry.result.reports) {
|
|
355
356
|
const location = report.primary.location;
|
|
@@ -383,9 +384,14 @@ function createLanguageServer(connection, options) {
|
|
|
383
384
|
});
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
|
-
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Converts workspace errors to diagnostics on their configuration files.
|
|
390
|
+
*
|
|
391
|
+
* @param add - Receives each diagnostic with the URI of its configuration file.
|
|
392
|
+
*/
|
|
393
|
+
const collectErrors = (add) => {
|
|
387
394
|
for (const [file, error] of errors) {
|
|
388
|
-
const message = `${file}: ${error}`;
|
|
389
395
|
const uri = options.configurationUri?.(file, roots);
|
|
390
396
|
if (uri) add(uri, {
|
|
391
397
|
range: range(),
|
|
@@ -394,6 +400,13 @@ function createLanguageServer(connection, options) {
|
|
|
394
400
|
code: "SW_HOST",
|
|
395
401
|
message: error
|
|
396
402
|
});
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
/** Logs each new workspace error, notifies the user once, and forgets errors that ended. */
|
|
406
|
+
const notifyErrors = () => {
|
|
407
|
+
const current = /* @__PURE__ */ new Set();
|
|
408
|
+
for (const [file, error] of errors) {
|
|
409
|
+
const message = `${file}: ${error}`;
|
|
397
410
|
current.add(message);
|
|
398
411
|
if (!reported.has(message)) {
|
|
399
412
|
reported.add(message);
|
|
@@ -405,11 +418,40 @@ function createLanguageServer(connection, options) {
|
|
|
405
418
|
}
|
|
406
419
|
}
|
|
407
420
|
for (const message of reported) if (!current.has(message)) reported.delete(message);
|
|
408
|
-
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.
|
|
424
|
+
* Empty notifications clear diagnostics for previously published or currently open documents.
|
|
425
|
+
*/
|
|
426
|
+
const publish = () => {
|
|
427
|
+
const open = new Map(documents.all().map((document) => [uriKey(document.uri), document.uri]));
|
|
428
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
429
|
+
const seen = /* @__PURE__ */ new Set();
|
|
430
|
+
/**
|
|
431
|
+
* Appends a diagnostic only once for its document and complete serialized value.
|
|
432
|
+
*
|
|
433
|
+
* @param reported - Original document URI, in any spelling of that document.
|
|
434
|
+
* @param diagnostic - Diagnostic with original LSP positions.
|
|
435
|
+
*/
|
|
436
|
+
const add = (reported, diagnostic) => {
|
|
437
|
+
const uri = open.get(uriKey(reported)) ?? reported;
|
|
438
|
+
const key = JSON.stringify([uri, diagnostic]);
|
|
439
|
+
if (!seen.has(key)) {
|
|
440
|
+
seen.add(key);
|
|
441
|
+
const list = grouped.get(uri) ?? [];
|
|
442
|
+
list.push(diagnostic);
|
|
443
|
+
grouped.set(uri, list);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
for (const [uri, results] of cache) collect(uri, results, add);
|
|
447
|
+
collectErrors(add);
|
|
448
|
+
notifyErrors();
|
|
449
|
+
const targets = new Map([
|
|
409
450
|
...published,
|
|
410
451
|
...grouped.keys(),
|
|
411
|
-
...
|
|
412
|
-
]))
|
|
452
|
+
...open.values()
|
|
453
|
+
].map((uri) => [uriKey(uri), uri]));
|
|
454
|
+
for (const uri of targets.values()) connection.sendDiagnostics({
|
|
413
455
|
uri,
|
|
414
456
|
version: documents.get(uri)?.version,
|
|
415
457
|
diagnostics: grouped.get(uri) ?? []
|
|
@@ -454,17 +496,36 @@ function createLanguageServer(connection, options) {
|
|
|
454
496
|
cache.clear();
|
|
455
497
|
for (const [uri, result] of next) cache.set(uri, result);
|
|
456
498
|
publish();
|
|
457
|
-
|
|
458
|
-
if (uncovered.length) {
|
|
459
|
-
for (const uri of uncovered) discovered.add(uri);
|
|
460
|
-
control(() => discover(uncovered));
|
|
461
|
-
schedule();
|
|
462
|
-
}
|
|
499
|
+
discoverUncovered();
|
|
463
500
|
}
|
|
464
501
|
};
|
|
465
|
-
/**
|
|
502
|
+
/**
|
|
503
|
+
* Starts discovery for documents that the last analysis pass left without results. Each document
|
|
504
|
+
* is passed to discovery once until services reopen.
|
|
505
|
+
*/
|
|
506
|
+
const discoverUncovered = () => {
|
|
507
|
+
const uncovered = options.discoverWorkspace ? [...cache].flatMap(([uri, results]) => results.length || discovered.has(uri) ? [] : [uri]) : [];
|
|
508
|
+
if (uncovered.length) {
|
|
509
|
+
for (const uri of uncovered) discovered.add(uri);
|
|
510
|
+
control(() => discover(uncovered));
|
|
511
|
+
schedule();
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* Replaces the pending 40 ms timer with an analysis pass for the current control generation. A
|
|
516
|
+
* pull client instead receives a request to pull its documents again, without a pass here.
|
|
517
|
+
*/
|
|
466
518
|
const schedule = () => {
|
|
467
519
|
if (timer) clearTimeout(timer);
|
|
520
|
+
if (pull) {
|
|
521
|
+
timer = setTimeout(() => {
|
|
522
|
+
notifyErrors();
|
|
523
|
+
if (pullRefresh) connection.languages.diagnostics.refresh().catch((error) => {
|
|
524
|
+
connection.console.error(String(error));
|
|
525
|
+
});
|
|
526
|
+
}, 40);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
468
529
|
const revision = generation;
|
|
469
530
|
timer = setTimeout(() => {
|
|
470
531
|
analyze(revision).catch((error) => {
|
|
@@ -473,6 +534,94 @@ function createLanguageServer(connection, options) {
|
|
|
473
534
|
}, 40);
|
|
474
535
|
};
|
|
475
536
|
/**
|
|
537
|
+
* Analyzes one document for a pull request, and retries once after discovery opens a service.
|
|
538
|
+
* Results stay cached until the next control generation. Open documents are prepared together
|
|
539
|
+
* once per generation, because the checker then loads them in one batch.
|
|
540
|
+
*
|
|
541
|
+
* @param uri - Requested document URI.
|
|
542
|
+
* @param token - Client cancellation.
|
|
543
|
+
* @returns Results of each project, or an empty list for a closed document or after shutdown.
|
|
544
|
+
* @throws A `ResponseError` with `RequestCancelled` after client cancellation, or with
|
|
545
|
+
* `ServerCancelled` and `retriggerRequest` after a change makes the analysis obsolete.
|
|
546
|
+
*/
|
|
547
|
+
const pullResults = async (uri, token) => {
|
|
548
|
+
for (;;) {
|
|
549
|
+
await controls;
|
|
550
|
+
if (token.isCancellationRequested) throw new ResponseError(LSPErrorCodes.RequestCancelled, "Diagnostics request cancelled");
|
|
551
|
+
if (shutdown || !documents.get(uri)) return [];
|
|
552
|
+
const cached = cache.get(uri);
|
|
553
|
+
if (cached) return cached;
|
|
554
|
+
const revision = generation;
|
|
555
|
+
const cancellation = new AbortController();
|
|
556
|
+
active = cancellation;
|
|
557
|
+
const subscription = token.onCancellationRequested(() => cancellation.abort());
|
|
558
|
+
const results = [];
|
|
559
|
+
try {
|
|
560
|
+
for (const [file, workspace] of workspaces) try {
|
|
561
|
+
if (prepared !== revision) await workspace.prepare?.(documents.all().map((document) => document.uri), cancellation.signal);
|
|
562
|
+
results.push(...await workspace.analyze(uri, cancellation.signal));
|
|
563
|
+
errors.delete(file);
|
|
564
|
+
} catch (error) {
|
|
565
|
+
errors.set(file, String(error));
|
|
566
|
+
}
|
|
567
|
+
} finally {
|
|
568
|
+
subscription.dispose();
|
|
569
|
+
}
|
|
570
|
+
if (shutdown) return [];
|
|
571
|
+
if (token.isCancellationRequested) throw new ResponseError(LSPErrorCodes.RequestCancelled, "Diagnostics request cancelled");
|
|
572
|
+
if (revision !== generation || results.some(({ result }) => result.status === "stale" || result.status === "cancelled")) throw new ResponseError(LSPErrorCodes.ServerCancelled, "Stillwind analysis became obsolete", { retriggerRequest: true });
|
|
573
|
+
prepared = revision;
|
|
574
|
+
cache.set(uri, results);
|
|
575
|
+
if (results.length || discovered.has(uri) || !options.discoverWorkspace) return results;
|
|
576
|
+
discovered.add(uri);
|
|
577
|
+
control(() => discover([uri]));
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Answers a pull request with the findings located in one document and in its configuration
|
|
582
|
+
* errors. Findings in other documents appear when the client pulls those documents.
|
|
583
|
+
*
|
|
584
|
+
* @param uri - Requested document URI.
|
|
585
|
+
* @param previous - Report identity that the client retains.
|
|
586
|
+
* @param token - Client cancellation.
|
|
587
|
+
* @returns An unchanged report when the content matches the retained report, otherwise a full one.
|
|
588
|
+
* @throws The errors of `pullResults`.
|
|
589
|
+
*/
|
|
590
|
+
const pullDiagnostics = async (uri, previous, token) => {
|
|
591
|
+
const results = await pullResults(uri, token);
|
|
592
|
+
const key = uriKey(uri);
|
|
593
|
+
const items = /* @__PURE__ */ new Map();
|
|
594
|
+
/**
|
|
595
|
+
* Keeps a diagnostic only when it belongs to the requested document.
|
|
596
|
+
*
|
|
597
|
+
* @param location - URI of the diagnostic, in any spelling.
|
|
598
|
+
* @param diagnostic - Diagnostic with original LSP positions.
|
|
599
|
+
*/
|
|
600
|
+
const add = (location, diagnostic) => {
|
|
601
|
+
if (uriKey(location) === key) items.set(JSON.stringify(diagnostic), diagnostic);
|
|
602
|
+
};
|
|
603
|
+
collect(uri, results, add);
|
|
604
|
+
collectErrors(add);
|
|
605
|
+
notifyErrors();
|
|
606
|
+
const text = [...items.keys()].join("\n");
|
|
607
|
+
let report = pullReports.get(uri);
|
|
608
|
+
if (report?.text !== text) {
|
|
609
|
+
report = {
|
|
610
|
+
id: String(++nextReport),
|
|
611
|
+
text
|
|
612
|
+
};
|
|
613
|
+
pullReports.set(uri, report);
|
|
614
|
+
}
|
|
615
|
+
return previous === report.id ? {
|
|
616
|
+
kind: "unchanged",
|
|
617
|
+
resultId: report.id
|
|
618
|
+
} : {
|
|
619
|
+
kind: "full",
|
|
620
|
+
resultId: report.id,
|
|
621
|
+
items: [...items.values()]
|
|
622
|
+
};
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
476
625
|
* Queries services after queued mutations and checks document versions and source fingerprints.
|
|
477
626
|
* Query failures are logged, and the cancellation subscription is released after the request.
|
|
478
627
|
*
|
|
@@ -511,6 +660,8 @@ function createLanguageServer(connection, options) {
|
|
|
511
660
|
connection.onInitialize(async (params) => {
|
|
512
661
|
initializationOptions = params.initializationOptions;
|
|
513
662
|
registryDirectives = completionRegistrySetting(initializationOptions) ?? false;
|
|
663
|
+
pull = params.capabilities.textDocument?.diagnostic !== void 0;
|
|
664
|
+
pullRefresh = params.capabilities.workspace?.diagnostics?.refreshSupport === true;
|
|
514
665
|
snippets = params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;
|
|
515
666
|
foldersSupported = params.capabilities.workspace?.workspaceFolders === true;
|
|
516
667
|
dynamicWatch = params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;
|
|
@@ -521,6 +672,11 @@ function createLanguageServer(connection, options) {
|
|
|
521
672
|
capabilities: {
|
|
522
673
|
textDocumentSync: TextDocumentSyncKind.Incremental,
|
|
523
674
|
codeActionProvider: { codeActionKinds: [CodeActionKind.QuickFix, ...editor ? editorCodeActionKinds : []] },
|
|
675
|
+
...pull ? { diagnosticProvider: {
|
|
676
|
+
identifier: "stillwind",
|
|
677
|
+
interFileDependencies: true,
|
|
678
|
+
workspaceDiagnostics: false
|
|
679
|
+
} } : {},
|
|
524
680
|
hoverProvider: editor,
|
|
525
681
|
definitionProvider: editor,
|
|
526
682
|
completionProvider: editor ? {
|
|
@@ -560,9 +716,10 @@ function createLanguageServer(connection, options) {
|
|
|
560
716
|
if (documents.get(document.uri)?.version !== document.version) return;
|
|
561
717
|
for (const workspace of workspaces.values()) await workspace.update(document.uri, document.getText(), document.version);
|
|
562
718
|
});
|
|
563
|
-
schedule();
|
|
719
|
+
if (!pull) schedule();
|
|
564
720
|
});
|
|
565
721
|
documents.onDidClose(({ document }) => {
|
|
722
|
+
pullReports.delete(document.uri);
|
|
566
723
|
control(async () => {
|
|
567
724
|
for (const workspace of workspaces.values()) await workspace.closeDocument(document.uri);
|
|
568
725
|
});
|
|
@@ -577,7 +734,7 @@ function createLanguageServer(connection, options) {
|
|
|
577
734
|
* @throws If a service check or workspace replacement fails.
|
|
578
735
|
*/
|
|
579
736
|
const refresh = async (uris) => {
|
|
580
|
-
if (!workspaces.size) {
|
|
737
|
+
if (!workspaces.size || errors.size && uris.some(isConfigurationUri)) {
|
|
581
738
|
await open();
|
|
582
739
|
return;
|
|
583
740
|
}
|
|
@@ -590,9 +747,35 @@ function createLanguageServer(connection, options) {
|
|
|
590
747
|
control(() => refresh([document.uri]));
|
|
591
748
|
schedule();
|
|
592
749
|
});
|
|
750
|
+
/**
|
|
751
|
+
* Decides whether watched changes need work. Starting that work cancels running analysis, so
|
|
752
|
+
* changes to unrelated files must not reach it.
|
|
753
|
+
*
|
|
754
|
+
* @param uris - Document URIs from the watch notification.
|
|
755
|
+
* @returns True for a configuration file while a service is missing or failed, and when a service
|
|
756
|
+
* reports that the changes affect it. A service without an `affects` check counts as affected.
|
|
757
|
+
* @throws If a service check fails.
|
|
758
|
+
*/
|
|
759
|
+
const affected = async (uris) => {
|
|
760
|
+
if ((!workspaces.size || errors.size) && uris.some(isConfigurationUri)) return true;
|
|
761
|
+
for (const workspace of workspaces.values()) if (await workspace.affects?.(uris) ?? true) return true;
|
|
762
|
+
return false;
|
|
763
|
+
};
|
|
593
764
|
connection.onDidChangeWatchedFiles(({ changes }) => {
|
|
594
|
-
|
|
595
|
-
|
|
765
|
+
const uris = changes.map((change) => change.uri);
|
|
766
|
+
affected(uris).then((result) => {
|
|
767
|
+
if (result) {
|
|
768
|
+
control(() => refresh(uris));
|
|
769
|
+
schedule();
|
|
770
|
+
}
|
|
771
|
+
}).catch((error) => {
|
|
772
|
+
connection.console.error(String(error));
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
connection.languages.diagnostics.on((params, token) => {
|
|
776
|
+
const task = pulls.then(() => pullDiagnostics(params.textDocument.uri, params.previousResultId, token));
|
|
777
|
+
pulls = task.then(() => void 0, () => void 0);
|
|
778
|
+
return task;
|
|
596
779
|
});
|
|
597
780
|
connection.onDidChangeConfiguration(({ settings }) => {
|
|
598
781
|
control(async () => {
|
|
@@ -610,13 +793,14 @@ function createLanguageServer(connection, options) {
|
|
|
610
793
|
if (token.isCancellationRequested) return result;
|
|
611
794
|
for (const entries of cache.values()) for (const entry of entries) for (const report of entry.result.reports) {
|
|
612
795
|
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;
|
|
796
|
+
if (uriKey(primary.uri) !== uriKey(params.textDocument.uri) || primary.endLine < params.range.start.line || primary.startLine > params.range.end.line) continue;
|
|
614
797
|
if (document && (primary.endUtf16 < document.offsetAt(params.range.start) || primary.startUtf16 > document.offsetAt(params.range.end))) continue;
|
|
615
798
|
for (const action of report.actions) {
|
|
616
799
|
const changes = /* @__PURE__ */ new Map();
|
|
617
800
|
let valid = true;
|
|
618
801
|
for (const edit of action.edits) {
|
|
619
|
-
const
|
|
802
|
+
const key = uriKey(edit.location.uri);
|
|
803
|
+
const document = documents.all().find(({ uri }) => uriKey(uri) === key);
|
|
620
804
|
if (!document || fingerprint(document.getText()) !== edit.location.revision) {
|
|
621
805
|
valid = false;
|
|
622
806
|
break;
|
|
@@ -680,6 +864,30 @@ function createLanguageServer(connection, options) {
|
|
|
680
864
|
};
|
|
681
865
|
}
|
|
682
866
|
/**
|
|
867
|
+
* Creates a comparison key for spellings of one file URI. Editors and Node encode characters and
|
|
868
|
+
* spell Windows drive letters differently, for example `file:///f%3A/a` and `file:///F:/a`.
|
|
869
|
+
*
|
|
870
|
+
* @param uri - Document URI. Do not send the result to a client.
|
|
871
|
+
* @returns The decoded URI with a lowercase drive letter, or the input if it cannot be decoded.
|
|
872
|
+
*/
|
|
873
|
+
function uriKey(uri) {
|
|
874
|
+
try {
|
|
875
|
+
uri = decodeURIComponent(uri);
|
|
876
|
+
} catch {
|
|
877
|
+
return uri;
|
|
878
|
+
}
|
|
879
|
+
return uri.replace(/^file:\/\/\/[a-z]:/i, (drive) => drive.toLowerCase());
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Recognizes a Stillwind configuration file by name.
|
|
883
|
+
*
|
|
884
|
+
* @param uri - Document URI.
|
|
885
|
+
* @returns Whether the file name is `stillwind.config` with any extension.
|
|
886
|
+
*/
|
|
887
|
+
function isConfigurationUri(uri) {
|
|
888
|
+
return /\/stillwind\.config\.[^/]+$/.test(uri);
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
683
891
|
* Reads the editor-only completion field from initialization options or configuration settings.
|
|
684
892
|
*
|
|
685
893
|
* @param value - A protocol object that may contain `completion.registryDirectives`.
|
|
@@ -712,4 +920,4 @@ function range(location) {
|
|
|
712
920
|
}
|
|
713
921
|
export { createLanguageServer as t };
|
|
714
922
|
|
|
715
|
-
//# sourceMappingURL=server-
|
|
923
|
+
//# sourceMappingURL=server-BIfF_XGK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-BIfF_XGK.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 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 /** 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 /** 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(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 * 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 /** Logs each new workspace error, notifies the user once, and forgets errors that ended. */\n const notifyErrors = () => {\n const current = new Set<string>();\n for (const [file, error] of errors) {\n const message = `${file}: ${error}`;\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 };\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(String(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(String(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 * 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 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();\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);\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.\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 || (errors.size && uris.some(isConfigurationUri))) {\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 /**\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));\n schedule();\n }\n })\n .catch((error: unknown) => {\n connection.console.error(String(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();\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);\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 * 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,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AqB;CAC1C,IAAI;EACF,MAAM,mBAAmB,GAAG;CAC9B,QAAQ;EACN,OAAO;CACT;CACA,OAAO,IAAI,QAAQ,wBAAwB,UAAU,MAAM,YAAY,CAAC;AAC1E;;;;;;;AAQA,SAAS,mBAAmB,KAAsB;CAChD,OAAO,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"}
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stillwind/language-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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.4.1",
|
|
39
|
+
"@stillwind/native": "0.4.1",
|
|
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.4.1",
|
|
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,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