@stillwind/language-server 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- 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.d.ts +2 -1
- package/dist/node.js +8 -3
- package/dist/node.js.map +1 -1
- package/dist/{server-pVyUFO88.d.ts → server-D7Wg5GbT.d.ts} +18 -2
- package/dist/{server-p2n04Evx.js → server-GjZU1QxS.js} +74 -17
- package/dist/server-GjZU1QxS.js.map +1 -0
- package/package.json +7 -7
- package/dist/server-p2n04Evx.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# @stillwind/language-server
|
|
2
2
|
|
|
3
|
-
Stillwind compiles Tailwind CSS v4 utilities into component props and static CSS.
|
|
4
|
-
It uses theme rules and compiler checks to keep styling code in order, even when
|
|
5
|
-
AI agents write much of it.
|
|
3
|
+
[Stillwind](https://stillwind.dev/) compiles Tailwind CSS v4 utilities into component props and static CSS.
|
|
4
|
+
It uses theme rules and compiler checks to keep styling code in order, even when AI agents write much of it.
|
|
6
5
|
|
|
7
|
-
`@stillwind/language-server` provides Stillwind's Language Server Protocol
|
|
8
|
-
|
|
9
|
-
services for diagnostics and editor queries.
|
|
6
|
+
`@stillwind/language-server` provides Stillwind's Language Server Protocol handlers and Node/browser transports.
|
|
7
|
+
The CLI and VS Code extension use these services for diagnostics and editor queries.
|
|
10
8
|
|
|
11
9
|
See [Embedding the language server](https://github.com/SegaraRai/stillwind/blob/main/docs/standalone-analysis.md#embedding-the-language-server)
|
|
12
10
|
for connection ownership and analysis providers.
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as LanguageServerOptions } from "./server-
|
|
1
|
+
import { t as LanguageServerOptions } from "./server-D7Wg5GbT.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-GjZU1QxS.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-D7Wg5GbT.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-GjZU1QxS.js";
|
package/dist/node.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Starts a stdio LSP connection with isolated Node analysis processes.
|
|
3
3
|
*
|
|
4
4
|
* @param config - Explicit configuration path, resolved from the process working directory.
|
|
5
|
-
* Omission discovers configurations from client workspace folders, or the working directory
|
|
5
|
+
* Omission discovers configurations from client workspace folders, or the working directory, and
|
|
6
|
+
* from the documents that the client opens in them.
|
|
6
7
|
* The process exits with code 0 after shutdown followed by exit, or code 1 after exit alone.
|
|
7
8
|
*/
|
|
8
9
|
export declare function startLanguageServer(config?: string): void;
|
package/dist/node.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { t as createLanguageServer } from "./server-
|
|
1
|
+
import { t as createLanguageServer } from "./server-GjZU1QxS.js";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import process from "node:process";
|
|
3
|
-
import {
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { discoverNodeWorkspace, openNodeWorkspaces } from "@stillwind/analysis/node";
|
|
4
6
|
import { ProposedFeatures, createConnection } from "vscode-languageserver/node";
|
|
5
7
|
// src/node.ts
|
|
6
8
|
/**
|
|
7
9
|
* Starts a stdio LSP connection with isolated Node analysis processes.
|
|
8
10
|
*
|
|
9
11
|
* @param config - Explicit configuration path, resolved from the process working directory.
|
|
10
|
-
* Omission discovers configurations from client workspace folders, or the working directory
|
|
12
|
+
* Omission discovers configurations from client workspace folders, or the working directory, and
|
|
13
|
+
* from the documents that the client opens in them.
|
|
11
14
|
* The process exits with code 0 after shutdown followed by exit, or code 1 after exit alone.
|
|
12
15
|
*/
|
|
13
16
|
function startLanguageServer(config) {
|
|
14
17
|
const connection = createConnection(ProposedFeatures.all, process.stdin, process.stdout);
|
|
15
18
|
createLanguageServer(connection, {
|
|
19
|
+
...config ? {} : { discoverWorkspace: discoverNodeWorkspace },
|
|
16
20
|
openWorkspaces: (context) => openNodeWorkspaces(context, config),
|
|
21
|
+
configurationUri: (id) => path.isAbsolute(id) ? pathToFileURL(id).href : void 0,
|
|
17
22
|
onExit: (shutdown) => {
|
|
18
23
|
process.exit(shutdown ? 0 : 1);
|
|
19
24
|
}
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":[],"sources":["../src/node.ts"],"sourcesContent":["import process from \"node:process\";\n\nimport { openNodeWorkspaces } from \"@stillwind/analysis/node\";\nimport { createConnection, ProposedFeatures } from \"vscode-languageserver/node\";\n\nimport { createLanguageServer } from \"./server.ts\";\n\n/**\n * Starts a stdio LSP connection with isolated Node analysis processes.\n *\n * @param config - Explicit configuration path, resolved from the process working directory.\n * Omission discovers configurations from client workspace folders, or the working directory.\n * The process exits with code 0 after shutdown followed by exit, or code 1 after exit alone.\n */\nexport function startLanguageServer(config?: string): void {\n const connection = createConnection(ProposedFeatures.all, process.stdin, process.stdout);\n createLanguageServer(connection, {\n openWorkspaces: (context) => openNodeWorkspaces(context, config),\n onExit: (shutdown) => {\n process.exit(shutdown ? 0 : 1);\n },\n });\n connection.listen();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../src/node.ts"],"sourcesContent":["import path from \"node:path\";\nimport process from \"node:process\";\nimport { pathToFileURL } from \"node:url\";\n\nimport { discoverNodeWorkspace, openNodeWorkspaces } from \"@stillwind/analysis/node\";\nimport { createConnection, ProposedFeatures } from \"vscode-languageserver/node\";\n\nimport { createLanguageServer } from \"./server.ts\";\n\n/**\n * Starts a stdio LSP connection with isolated Node analysis processes.\n *\n * @param config - Explicit configuration path, resolved from the process working directory.\n * Omission discovers configurations from client workspace folders, or the working directory, and\n * from the documents that the client opens in them.\n * The process exits with code 0 after shutdown followed by exit, or code 1 after exit alone.\n */\nexport function startLanguageServer(config?: string): void {\n const connection = createConnection(ProposedFeatures.all, process.stdin, process.stdout);\n createLanguageServer(connection, {\n ...(config ? {} : { discoverWorkspace: discoverNodeWorkspace }),\n openWorkspaces: (context) => openNodeWorkspaces(context, config),\n configurationUri: (id) => (path.isAbsolute(id) ? pathToFileURL(id).href : undefined),\n onExit: (shutdown) => {\n process.exit(shutdown ? 0 : 1);\n },\n });\n connection.listen();\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,oBAAoB,QAAuB;CACzD,MAAM,aAAa,iBAAiB,iBAAiB,KAAK,QAAQ,OAAO,QAAQ,MAAM;CACvF,qBAAqB,YAAY;EAC/B,GAAI,SAAS,CAAC,IAAI,EAAE,mBAAmB,sBAAsB;EAC7D,iBAAiB,YAAY,mBAAmB,SAAS,MAAM;EAC/D,mBAAmB,OAAQ,KAAK,WAAW,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC,OAAO,KAAA;EAC1E,SAAS,aAAa;GACpB,QAAQ,KAAK,WAAW,IAAI,CAAC;EAC/B;CACF,CAAC;CACD,WAAW,OAAO;AACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from "vscode-languageserver";
|
|
2
|
-
import { OpenWorkspaces } from "@stillwind/analysis";
|
|
2
|
+
import { DiscoverWorkspace, OpenWorkspaces } from "@stillwind/analysis";
|
|
3
3
|
/** Supplies analysis services and delegates transport exit to the embedding application. */
|
|
4
4
|
interface LanguageServerOptions {
|
|
5
5
|
/**
|
|
@@ -7,6 +7,22 @@ interface LanguageServerOptions {
|
|
|
7
7
|
* or workspace folder changes. Previous services are closed first. Open buffers are replayed.
|
|
8
8
|
*/
|
|
9
9
|
openWorkspaces: OpenWorkspaces;
|
|
10
|
+
/**
|
|
11
|
+
* Opens a configuration for an open document that no service analyzes. The server calls this once
|
|
12
|
+
* for each document until services reopen. Supplying it advertises editor features before any
|
|
13
|
+
* service exists. Omission leaves such documents without analysis.
|
|
14
|
+
*/
|
|
15
|
+
discoverWorkspace?: DiscoverWorkspace;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a service identity to the URI of its configuration file, where the server publishes
|
|
18
|
+
* that service's errors.
|
|
19
|
+
*
|
|
20
|
+
* @param id - Key from a workspace map or an error map.
|
|
21
|
+
* @param folders - Current workspace directory URIs.
|
|
22
|
+
* @returns The file URI, or undefined when the identity names no file. The server then only logs
|
|
23
|
+
* the error and notifies the user. Omitting this option has the same effect.
|
|
24
|
+
*/
|
|
25
|
+
configurationUri?(id: string, folders: readonly string[]): string | undefined;
|
|
10
26
|
/**
|
|
11
27
|
* Handles the LSP exit notification using the embedding's transport or process policy.
|
|
12
28
|
*
|
|
@@ -46,4 +62,4 @@ declare function createLanguageServer(connection: Connection, options: LanguageS
|
|
|
46
62
|
dispose(): Promise<void>;
|
|
47
63
|
};
|
|
48
64
|
export { createLanguageServer as n, LanguageServerOptions as t };
|
|
49
|
-
//# sourceMappingURL=server-
|
|
65
|
+
//# sourceMappingURL=server-D7Wg5GbT.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeActionKind, CompletionItemKind, DiagnosticSeverity, DidChangeWatchedFilesNotification, InsertTextFormat, MarkupKind, TextDocumentSyncKind, TextDocuments } from "vscode-languageserver";
|
|
1
|
+
import { CodeActionKind, CompletionItemKind, DiagnosticSeverity, DidChangeWatchedFilesNotification, InsertTextFormat, MarkupKind, MessageType, 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";
|
|
@@ -249,6 +249,10 @@ function createLanguageServer(connection, options) {
|
|
|
249
249
|
const errors = /* @__PURE__ */ new Map();
|
|
250
250
|
const cache = /* @__PURE__ */ new Map();
|
|
251
251
|
const published = /* @__PURE__ */ new Set();
|
|
252
|
+
/** Documents already passed to discovery, which keeps later analysis passes from searching again. */
|
|
253
|
+
const discovered = /* @__PURE__ */ new Set();
|
|
254
|
+
/** Current error messages that the user has seen, which keeps each from notifying again. */
|
|
255
|
+
const reported = /* @__PURE__ */ new Set();
|
|
252
256
|
let roots = [];
|
|
253
257
|
let initializationOptions;
|
|
254
258
|
let registryDirectives = false;
|
|
@@ -277,6 +281,20 @@ function createLanguageServer(connection, options) {
|
|
|
277
281
|
});
|
|
278
282
|
};
|
|
279
283
|
/**
|
|
284
|
+
* Takes ownership of opened services and replays every open buffer into them.
|
|
285
|
+
*
|
|
286
|
+
* @param opened - Services and initialization errors from the workspace factory or discovery.
|
|
287
|
+
* @returns Completion of buffer replay.
|
|
288
|
+
* @throws If buffer replay fails.
|
|
289
|
+
*/
|
|
290
|
+
const adopt = async (opened) => {
|
|
291
|
+
for (const [id, error] of opened.errors ?? []) errors.set(id, error);
|
|
292
|
+
for (const [id, workspace] of opened.workspaces) {
|
|
293
|
+
workspaces.set(id, workspace);
|
|
294
|
+
for (const document of documents.all()) await workspace.update(document.uri, document.getText(), document.version);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
280
298
|
* Closes existing services, opens the current roots, and replays every open buffer.
|
|
281
299
|
*
|
|
282
300
|
* @returns Completion of service replacement and buffer replay.
|
|
@@ -286,14 +304,27 @@ function createLanguageServer(connection, options) {
|
|
|
286
304
|
await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));
|
|
287
305
|
workspaces.clear();
|
|
288
306
|
errors.clear();
|
|
289
|
-
|
|
307
|
+
discovered.clear();
|
|
308
|
+
await adopt(await options.openWorkspaces({
|
|
290
309
|
workspaceFolders: roots,
|
|
291
310
|
initializationOptions
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
311
|
+
}));
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Opens configurations for documents that the last analysis pass left without results.
|
|
315
|
+
*
|
|
316
|
+
* @param uris - Document URIs. A document closed in the meantime is skipped.
|
|
317
|
+
* @returns Completion of discovery and buffer replay.
|
|
318
|
+
* @throws If discovery or buffer replay fails.
|
|
319
|
+
*/
|
|
320
|
+
const discover = async (uris) => {
|
|
321
|
+
for (const uri of uris) {
|
|
322
|
+
if (!documents.get(uri)) continue;
|
|
323
|
+
const opened = await options.discoverWorkspace?.(uri, {
|
|
324
|
+
workspaceFolders: roots,
|
|
325
|
+
initializationOptions
|
|
326
|
+
}, /* @__PURE__ */ new Set([...workspaces.keys(), ...errors.keys()]));
|
|
327
|
+
if (opened) await adopt(opened);
|
|
297
328
|
}
|
|
298
329
|
};
|
|
299
330
|
/**
|
|
@@ -352,13 +383,28 @@ function createLanguageServer(connection, options) {
|
|
|
352
383
|
});
|
|
353
384
|
}
|
|
354
385
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
386
|
+
const current = /* @__PURE__ */ new Set();
|
|
387
|
+
for (const [file, error] of errors) {
|
|
388
|
+
const message = `${file}: ${error}`;
|
|
389
|
+
const uri = options.configurationUri?.(file, roots);
|
|
390
|
+
if (uri) add(uri, {
|
|
391
|
+
range: range(),
|
|
392
|
+
severity: DiagnosticSeverity.Error,
|
|
393
|
+
source: "stillwind",
|
|
394
|
+
code: "SW_HOST",
|
|
395
|
+
message: error
|
|
396
|
+
});
|
|
397
|
+
current.add(message);
|
|
398
|
+
if (!reported.has(message)) {
|
|
399
|
+
reported.add(message);
|
|
400
|
+
connection.console.error(message);
|
|
401
|
+
connection.sendNotification(ShowMessageNotification.type, {
|
|
402
|
+
type: MessageType.Warning,
|
|
403
|
+
message: `Stillwind: ${message}`
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
for (const message of reported) if (!current.has(message)) reported.delete(message);
|
|
362
408
|
for (const uri of /* @__PURE__ */ new Set([
|
|
363
409
|
...published,
|
|
364
410
|
...grouped.keys(),
|
|
@@ -408,6 +454,12 @@ function createLanguageServer(connection, options) {
|
|
|
408
454
|
cache.clear();
|
|
409
455
|
for (const [uri, result] of next) cache.set(uri, result);
|
|
410
456
|
publish();
|
|
457
|
+
const uncovered = options.discoverWorkspace ? [...next].flatMap(([uri, results]) => results.length || discovered.has(uri) ? [] : [uri]) : [];
|
|
458
|
+
if (uncovered.length) {
|
|
459
|
+
for (const uri of uncovered) discovered.add(uri);
|
|
460
|
+
control(() => discover(uncovered));
|
|
461
|
+
schedule();
|
|
462
|
+
}
|
|
411
463
|
}
|
|
412
464
|
};
|
|
413
465
|
/** Replaces the pending 40 ms timer with an analysis pass for the current control generation. */
|
|
@@ -464,7 +516,7 @@ function createLanguageServer(connection, options) {
|
|
|
464
516
|
dynamicWatch = params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;
|
|
465
517
|
roots = params.workspaceFolders?.map((folder) => folder.uri) ?? (params.rootUri ? [params.rootUri] : []);
|
|
466
518
|
await open();
|
|
467
|
-
const editor = [...workspaces.values()].some((workspace) => workspace.query != null);
|
|
519
|
+
const editor = options.discoverWorkspace != null || [...workspaces.values()].some((workspace) => workspace.query != null);
|
|
468
520
|
return {
|
|
469
521
|
capabilities: {
|
|
470
522
|
textDocumentSync: TextDocumentSyncKind.Incremental,
|
|
@@ -517,13 +569,18 @@ function createLanguageServer(connection, options) {
|
|
|
517
569
|
schedule();
|
|
518
570
|
});
|
|
519
571
|
/**
|
|
520
|
-
* Reopens the workspaces if any service cannot reuse its current buffers after a save or file
|
|
572
|
+
* Reopens the workspaces if any service cannot reuse its current buffers after a save or file
|
|
573
|
+
* change. Without services, reopening lets a new or corrected configuration take effect.
|
|
521
574
|
*
|
|
522
575
|
* @param uris - Document URIs from the save or watch notification.
|
|
523
576
|
* @returns Completion of the checks and any required workspace replacement.
|
|
524
577
|
* @throws If a service check or workspace replacement fails.
|
|
525
578
|
*/
|
|
526
579
|
const refresh = async (uris) => {
|
|
580
|
+
if (!workspaces.size) {
|
|
581
|
+
await open();
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
527
584
|
for (const workspace of workspaces.values()) if (!await workspace.refresh?.(uris)) {
|
|
528
585
|
await open();
|
|
529
586
|
break;
|
|
@@ -655,4 +712,4 @@ function range(location) {
|
|
|
655
712
|
}
|
|
656
713
|
export { createLanguageServer as t };
|
|
657
714
|
|
|
658
|
-
//# sourceMappingURL=server-
|
|
715
|
+
//# sourceMappingURL=server-GjZU1QxS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,GAAG;EACtD,IAAI,CAAC,UACH,OAAO,CAAC;EAUV,MAAM,eAAc,MARE,MACpB,SAAS,KACT;GACE,MAAM;GACN,QAAQ,SAAS,SAAS,OAAO,QAAQ;EAC3C,GACA,KACF,EAAA,CAC4B,SAAS,UAAU,MAAM,OAAO,eAAe,CAAC,CAAC;EAC7E,OAAO,YACJ,QACE,YAAY,UACX,YAAY,WAAW,UAAU,KAAK,UAAU,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,MACrF,KACJ,CAAC,CACA,KAAK,gBAAgB;GACpB,KAAK,WAAW;GAChB,OAAO;IACL,OAAO;KACL,MAAM,WAAW;KACjB,WAAW,WAAW;IACxB;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EACA,KAAK;GACH,MAAM,UAAU,WAAW;GAC3B,WAAW,UAAU,aAAa;EACpC;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stillwind/language-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Stillwind language server for Node and browser transports",
|
|
5
|
-
"homepage": "https://stillwind.dev
|
|
5
|
+
"homepage": "https://stillwind.dev",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/SegaraRai/stillwind/issues"
|
|
8
8
|
},
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@stillwind/analysis": "0.
|
|
39
|
-
"@stillwind/native": "0.
|
|
38
|
+
"@stillwind/analysis": "0.3.0",
|
|
39
|
+
"@stillwind/native": "0.3.0",
|
|
40
40
|
"vscode-languageserver": "^11.0.0",
|
|
41
41
|
"vscode-languageserver-textdocument": "^1.0.16"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@stillwind-internal/tools-workspace": "0.0.0",
|
|
45
|
-
"@types/node": "^26.6.
|
|
46
|
-
"rolldown": "^1.2.
|
|
47
|
-
"stillwind": "0.
|
|
45
|
+
"@types/node": "^26.6.6",
|
|
46
|
+
"rolldown": "^1.2.16",
|
|
47
|
+
"stillwind": "0.3.0",
|
|
48
48
|
"typescript": "^6.0.3",
|
|
49
49
|
"vite-plus": "1.4.0"
|
|
50
50
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-p2n04Evx.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 OpenWorkspaces,\n WorkspaceEditorResult,\n WorkspaceResult,\n} from \"@stillwind/analysis\";\nimport {\n CodeActionKind,\n DiagnosticSeverity,\n DidChangeWatchedFilesNotification,\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 * 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\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 * 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 const opened = await options.openWorkspaces({\n workspaceFolders: roots,\n initializationOptions,\n });\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 * 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 for (const document of documents.all()) {\n for (const [file, error] of errors) {\n add(document.uri, {\n range: range(),\n severity: DiagnosticSeverity.Error,\n source: \"stillwind\",\n code: \"SW_HOST\",\n message: `${file}: ${error}`,\n });\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 }\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 = [...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 change.\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 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,GAAG;EACtD,IAAI,CAAC,UACH,OAAO,CAAC;EAUV,MAAM,eAAc,MARE,MACpB,SAAS,KACT;GACE,MAAM;GACN,QAAQ,SAAS,SAAS,OAAO,QAAQ;EAC3C,GACA,KACF,EAAA,CAC4B,SAAS,UAAU,MAAM,OAAO,eAAe,CAAC,CAAC;EAC7E,OAAO,YACJ,QACE,YAAY,UACX,YAAY,WAAW,UAAU,KAAK,UAAU,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,MACrF,KACJ,CAAC,CACA,KAAK,gBAAgB;GACpB,KAAK,WAAW;GAChB,OAAO;IACL,OAAO;KACL,MAAM,WAAW;KACjB,WAAW,WAAW;IACxB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