@stillwind/language-server 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as LanguageServerOptions } from "./server-Bp6CUeN4.js";
1
+ import { t as LanguageServerOptions } from "./server-CEF3Ha9S.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-ZB6y2ShG.js";
1
+ import { t as createLanguageServer } from "./server-BSF6RYru.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-Bp6CUeN4.js";
1
+ import { n as createLanguageServer, t as LanguageServerOptions } from "./server-CEF3Ha9S.js";
2
2
  export { type LanguageServerOptions, createLanguageServer };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as createLanguageServer } from "./server-ZB6y2ShG.js";
1
+ export { t as createLanguageServer } from "./server-BSF6RYru.js";
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createLanguageServer } from "./server-ZB6y2ShG.js";
1
+ import { t as createLanguageServer } from "./server-BSF6RYru.js";
2
2
  import path from "node:path";
3
3
  import process from "node:process";
4
4
  import { pathToFileURL } from "node:url";
@@ -1,3 +1,4 @@
1
+ import { documentationUrl } from "@stillwind/analysis";
1
2
  import { CodeActionKind, CompletionItemKind, DiagnosticSeverity, DidChangeWatchedFilesNotification, InsertTextFormat, LSPErrorCodes, MarkupKind, MessageType, ResponseError, ShowMessageNotification, TextDocumentSyncKind, TextDocuments } from "vscode-languageserver";
2
3
  import { TextDocument } from "vscode-languageserver-textdocument";
3
4
  // src/editor.ts
@@ -372,11 +373,13 @@ function createLanguageServer(connection, options) {
372
373
  const source = `stillwind:${entry.config}:${entry.project + 1}`;
373
374
  for (const report of entry.result.reports) {
374
375
  const location = report.primary.location;
376
+ const href = documentationUrl(report.code);
375
377
  add(location.uri, {
376
378
  range: range(location),
377
379
  severity: report.severity === "error" ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,
378
380
  source,
379
381
  code: report.code,
382
+ ...href ? { codeDescription: { href } } : {},
380
383
  message: [report.message, ...report.notes].join("\n"),
381
384
  relatedInformation: report.related.map((label) => ({
382
385
  location: {
@@ -964,4 +967,4 @@ function range(location) {
964
967
  }
965
968
  export { createLanguageServer as t };
966
969
 
967
- //# sourceMappingURL=server-ZB6y2ShG.js.map
970
+ //# sourceMappingURL=server-BSF6RYru.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-BSF6RYru.js","names":[],"sources":["../src/editor.ts","../src/server.ts"],"sourcesContent":["import type { EditorRequest, WorkspaceEditorResult } from \"@stillwind/analysis\";\nimport {\n CompletionItemKind,\n InsertTextFormat,\n MarkupKind,\n type CancellationToken,\n type CodeAction,\n type CompletionItem,\n type Connection,\n type TextDocuments,\n} from \"vscode-languageserver\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\n\nconst sortKind = \"source.sort.stillwind\";\nconst fixAllKind = \"source.fixAll.stillwind\";\n\n/** Source actions advertised in fix-all order followed by utility sorting. */\nexport const editorCodeActionKinds = [fixAllKind, sortKind];\n\n/**\n * Queries the current original buffer and discards results after a document change or cancellation.\n *\n * @param uri - URI of an open original document.\n * @param request - Editor operation with offsets in that document's UTF-16 text.\n * @param token - Cancellation for this request.\n * @returns Results whose source fingerprints match the current document.\n */\nexport type EditorQuery = (\n uri: string,\n request: EditorRequest,\n token: CancellationToken,\n) => Promise<WorkspaceEditorResult[]>;\n\n/**\n * Registers hover, definitions, completion, colors, plugin links, and source actions.\n *\n * @param connection - Caller-owned connection on which handlers are installed.\n * @param documents - Open original buffers used to convert UTF-16 offsets to LSP positions.\n * @param query - Query implementation that rejects obsolete results and honors cancellation.\n */\nexport function registerEditorFeatures(\n connection: Connection,\n documents: TextDocuments<TextDocument>,\n query: EditorQuery,\n): void {\n connection.onDefinition(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"definition\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const definitions = entries.flatMap((entry) => entry.result.definitions ?? []);\n return definitions\n .filter(\n (definition, index) =>\n definitions.findIndex((other) => JSON.stringify(other) === JSON.stringify(definition)) ===\n index,\n )\n .map((definition) => ({\n uri: definition.uri,\n range: {\n start: {\n line: definition.startLine,\n character: definition.startColumn,\n },\n end: {\n line: definition.endLine,\n character: definition.endColumn,\n },\n },\n }));\n });\n connection.onDocumentLinks(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"links\",\n },\n token,\n );\n const links = entries.flatMap((entry) => entry.result.links ?? []);\n return links\n .filter(\n (link, index) =>\n link.target &&\n links.findIndex(\n (other) =>\n other.start === link.start && other.end === link.end && other.target === link.target,\n ) === index &&\n !links.some(\n (other) =>\n other.start === link.start && other.end === link.end && other.target !== link.target,\n ),\n )\n .map((link) => ({\n range: offsets(document, link),\n target: link.target,\n }));\n });\n connection.onHover(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"hover\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const answers = entries.filter((entry) => entry.result.hover);\n if (!answers.length) {\n return null;\n }\n\n const seen = new Set<string>();\n const contents = answers\n .flatMap((entry) => {\n const hover = entry.result.hover!;\n const key = JSON.stringify(hover);\n if (seen.has(key)) {\n return [];\n }\n seen.add(key);\n return [\n `${answers.length > 1 ? `${entry.config} · project ${entry.project + 1}\\n\\n` : \"\"}${hoverMarkdown(hover)}`,\n ];\n })\n .join(\"\\n\\n\");\n return {\n contents: {\n kind: MarkupKind.Markdown,\n value: contents,\n },\n range: offsets(document, answers[0].result.hover!),\n };\n });\n\n connection.onCompletion(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const version = document.version;\n const entries = await query(\n document.uri,\n {\n kind: \"completion\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const items: CompletionItem[] = entries.flatMap((entry) =>\n (entry.result.completions ?? []).map((item) => ({\n label: item.label,\n detail: item.detail,\n sortText: item.sortText,\n insertTextFormat: item.snippet ? InsertTextFormat.Snippet : undefined,\n command: item.retrigger\n ? { title: \"Continue completion\", command: \"editor.action.triggerSuggest\" }\n : undefined,\n kind: item.keyword\n ? CompletionItemKind.Keyword\n : item.category === \"directory\"\n ? CompletionItemKind.Folder\n : item.category === \"file\"\n ? CompletionItemKind.File\n : item.category === \"module\" || item.variant || item.candidate.endsWith(\":\")\n ? CompletionItemKind.Module\n : item.marker\n ? CompletionItemKind.Class\n : CompletionItemKind.Value,\n textEdit: {\n range: offsets(document, item),\n newText: item.snippet ?? item.newText,\n },\n data: {\n uri: document.uri,\n version,\n revision: entry.result.revision,\n candidate: item.candidate,\n input: item.input,\n snapshot: item.snapshot,\n project: entry.project,\n config: entry.config,\n },\n })),\n );\n return items.filter(\n (item, index) =>\n items.findIndex(\n (other) =>\n other.label === item.label &&\n JSON.stringify(other.textEdit) === JSON.stringify(item.textEdit),\n ) === index,\n );\n });\n\n connection.onCompletionResolve(async (item, token) => {\n const detail = item.detail;\n delete item.documentation;\n delete item.detail;\n const data = item.data as\n | {\n /** Original document URI captured when completion was requested. */\n uri?: unknown;\n /** Document version that must still match the open buffer. */\n version?: unknown;\n /** Full completion candidate, including surrounding variants. */\n candidate?: unknown;\n /** Configuration identity used to select the same project result. */\n config?: unknown;\n /** Zero-based project index within the configuration. */\n project?: unknown;\n /** Source fingerprint that must match the resolved result. */\n revision?: unknown;\n /** Original UTF-16 offset that identifies the completion's utility input. */\n input?: unknown;\n /** Graph and configuration fingerprint required by the resolve request. */\n snapshot?: unknown;\n }\n | undefined;\n if (\n !data ||\n typeof data.uri !== \"string\" ||\n typeof data.candidate !== \"string\" ||\n typeof data.input !== \"number\" ||\n typeof data.snapshot !== \"string\" ||\n documents.get(data.uri)?.version !== data.version\n ) {\n return item;\n }\n\n const entries = await query(\n data.uri,\n {\n kind: \"resolve\",\n candidate: data.candidate,\n input: data.input,\n snapshot: data.snapshot,\n },\n token,\n );\n const answer = entries.find(\n (entry) =>\n entry.project === data.project &&\n entry.config === data.config &&\n entry.result.revision === data.revision,\n )?.result.hover;\n if (answer) {\n item.detail = answer.detail ?? detail;\n item.documentation = {\n kind: MarkupKind.Markdown,\n value: hoverMarkdown(answer),\n };\n }\n return item;\n });\n\n connection.onDocumentColor(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colors\",\n },\n token,\n );\n const colors = entries\n .flatMap((entry) => entry.result.colors ?? [])\n .filter(\n (color, index, colors) =>\n colors.findIndex((other) => JSON.stringify(other) === JSON.stringify(color)) === index,\n );\n // Projects that disagree on a range omit it. A range may show one light and one dark color.\n return colors\n .filter((color) => {\n const range = colors.filter(\n (other) => other.start === color.start && other.end === color.end,\n );\n return (\n range.length === 1 ||\n (range.length === 2 &&\n range.some((other) => other.scheme === \"light\") &&\n range.some((other) => other.scheme === \"dark\"))\n );\n })\n .map((color) => ({\n range: offsets(document, color),\n color: {\n red: color.red,\n green: color.green,\n blue: color.blue,\n alpha: color.alpha,\n },\n }));\n });\n\n connection.onColorPresentation(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colorPresentation\",\n start: document.offsetAt(params.range.start),\n end: document.offsetAt(params.range.end),\n color: params.color,\n },\n token,\n );\n return entries\n .flatMap((entry) =>\n (entry.result.edits ?? []).map((edit) => ({\n label: edit.newText,\n textEdit: {\n range: offsets(document, edit),\n newText: edit.newText,\n },\n })),\n )\n .filter(\n (item, index, items) =>\n items.findIndex((other) => JSON.stringify(item) === JSON.stringify(other)) === index,\n );\n });\n}\n\n/**\n * Formats CSS previews and dialect documentation, and explains authored runtime key expressions.\n * Expression line breaks become spaces, and code-span delimiters exceed every authored\n * backtick run so expressions remain literal Markdown. The supplied hover remains unchanged.\n *\n * @param hover - CSS preview and optional authored expressions for runtime view-transition names.\n * @returns Markdown with CSS first and expression notes in their supplied order.\n */\nfunction hoverMarkdown(hover: {\n /** Formatted generated CSS included verbatim inside the CSS fence. */\n css: string;\n /** Markdown describing authored CSS syntax or theme semantics. */\n documentation?: string;\n /** Authored expressions in the order in which their notes should appear. */\n runtimeNames?: string[];\n}): string {\n const notes = (hover.runtimeNames ?? []).map((expression) => {\n const text = expression.replace(/\\r\\n?|\\n/g, \" \");\n const ticks = \"`\".repeat(\n Math.max(0, ...[...text.matchAll(/`+/g)].map((match) => match[0].length)) + 1,\n );\n return `view-transition-name is computed at runtime from ${ticks} ${text} ${ticks}.`;\n });\n return [hover.css ? `\\`\\`\\`css\\n${hover.css}\\n\\`\\`\\`` : undefined, hover.documentation, ...notes]\n .filter(Boolean)\n .join(\"\\n\\n\");\n}\n\n/**\n * Builds versioned source actions for each project and removes actions with identical edits.\n * Each action contains one project's edits, so differing project results remain separate.\n *\n * @param document - Open original buffer that the query reads and the returned edits target.\n * @param only - Requested source kinds or their prefixes. Omission or an empty list produces no actions.\n * @param token - Cancellation forwarded to each query.\n * @param query - Query implementation that discards changed buffers and cancelled requests.\n * @returns Fix-all actions followed by sort actions, preserving project order within each kind.\n * @throws If a query rejects.\n */\nexport async function sourceActions(\n document: TextDocument,\n only: readonly string[] | undefined,\n token: CancellationToken,\n query: EditorQuery,\n): Promise<CodeAction[]> {\n const actions: CodeAction[] = [];\n for (const [kind, operation, title] of [\n [fixAllKind, \"fixes\", \"Fix all Stillwind lint findings\"],\n [sortKind, \"sort\", \"Sort Stillwind utilities\"],\n ] as const) {\n if (!only?.some((requested) => kind === requested || kind.startsWith(`${requested}.`))) {\n continue;\n }\n const entries = await query(\n document.uri,\n {\n kind: operation,\n },\n token,\n );\n for (const entry of entries) {\n if (!entry.result.edits?.length) {\n continue;\n }\n const edit = {\n documentChanges: [\n {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: entry.result.edits.map((edit) => ({\n range: offsets(document, edit),\n newText: edit.newText,\n })),\n },\n ],\n };\n if (\n actions.some(\n (action) => action.kind === kind && JSON.stringify(action.edit) === JSON.stringify(edit),\n )\n ) {\n continue;\n }\n actions.push({\n title: `${title}${entries.length > 1 ? ` (${entry.config}, project ${entry.project + 1})` : \"\"}`,\n kind,\n edit,\n });\n }\n }\n return actions;\n}\n\n/**\n * Converts original UTF-16 offsets to positions using the open document's line table.\n *\n * @param document - Document containing the text from which the offsets were measured.\n * @param range - Half-open UTF-16 range. TextDocument clamps offsets outside the document.\n * @returns LSP positions with zero-based lines and UTF-16 character offsets.\n */\nfunction offsets(\n document: TextDocument,\n range: {\n /** Inclusive UTF-16 offset in the original document. */\n start: number;\n /** Exclusive UTF-16 offset in the original document. */\n end: number;\n },\n) {\n return {\n start: document.positionAt(range.start),\n end: document.positionAt(range.end),\n };\n}\n","import {\n documentationUrl,\n type AnalysisWorkspaceService,\n type DiscoverWorkspace,\n type OpenAnalysisWorkspaces,\n type OpenWorkspaces,\n type WorkspaceEditorResult,\n type WorkspaceResult,\n} from \"@stillwind/analysis\";\nimport {\n CodeActionKind,\n DiagnosticSeverity,\n DidChangeWatchedFilesNotification,\n LSPErrorCodes,\n MessageType,\n ResponseError,\n ShowMessageNotification,\n TextDocuments,\n TextDocumentSyncKind,\n type CancellationToken,\n type CodeAction,\n type Connection,\n type Diagnostic,\n type DiagnosticServerCancellationData,\n type DocumentDiagnosticReport,\n type InitializeParams,\n type TextDocumentEdit,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\n\nimport {\n editorCodeActionKinds,\n registerEditorFeatures,\n sourceActions,\n type EditorQuery,\n} from \"./editor.ts\";\n\n/** Supplies analysis services and delegates transport exit to the embedding application. */\nexport interface LanguageServerOptions {\n /**\n * Opens services at initialization and after saves, watched file changes, configuration changes,\n * or workspace folder changes. Previous services are closed first. Open buffers are replayed.\n */\n openWorkspaces: OpenWorkspaces;\n /**\n * Opens a configuration for an open document that no service analyzes. The server calls this once\n * for each document until services reopen. Supplying it advertises editor features before any\n * service exists. Omission leaves such documents without analysis. A client with pull diagnostics\n * decides which documents reach this call, because only a diagnostic request starts discovery.\n * Editors open documents in the background, and each configuration starts a process that runs\n * its code.\n */\n discoverWorkspace?: DiscoverWorkspace;\n /**\n * Converts a service identity to the URI of its configuration file, where the server publishes\n * that service's errors.\n *\n * @param id - Key from a workspace map or an error map.\n * @param folders - Current workspace directory URIs.\n * @returns The file URI, or undefined when the identity names no file. The server then only logs\n * the error and notifies the user. Omitting this option has the same effect.\n */\n configurationUri?(id: string, folders: readonly string[]): string | undefined;\n /**\n * Handles the LSP exit notification using the embedding's transport or process policy.\n *\n * @param shutdown - Whether shutdown or explicit disposal was requested before exit.\n */\n onExit?(shutdown: boolean): void;\n}\n\n/**\n * Registers synchronization, diagnostics, fixes, hover, completion, colors, and sorting.\n * Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited\n * document to be open and to match the report's source fingerprint.\n *\n * A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the\n * server reports only the findings located in that document. Other clients receive every open\n * document's findings through `textDocument/publishDiagnostics`.\n *\n * @param connection - Caller-owned connection. Call listen after registration and dispose the\n * transport when finished. Diagnostic locations must use original documents and UTF-16 positions.\n * @param options - Workspace factory and optional exit handler. This server owns the opened services.\n * @returns Cleanup for the analysis services. It does not dispose the connection or its transport.\n */\nexport function createLanguageServer(\n connection: Connection,\n options: LanguageServerOptions,\n): {\n /**\n * Waits for document and workspace changes already queued by the server.\n *\n * @returns The current control queue's completion promise. Queued failures are logged.\n */\n ready(): Promise<void>;\n /**\n * Reopens workspace configuration and files, replays current buffers, and schedules analysis.\n *\n * @returns Completion of the queued reload. Reload failures are logged, and analysis runs separately.\n */\n reload(): Promise<void>;\n /**\n * Stops scheduling analysis, cancels publication, and closes services after queued control work.\n *\n * @returns The same cleanup promise on repeated calls.\n * @throws An AggregateError if any service fails to close.\n */\n dispose(): Promise<void>;\n} {\n const documents = new TextDocuments(TextDocument);\n const workspaces = new Map<string, AnalysisWorkspaceService>();\n const errors = new Map<string, string>();\n const cache = new Map<string, WorkspaceResult[]>();\n const published = new Set<string>();\n /** Documents already passed to discovery, which keeps later analysis passes from searching again. */\n const discovered = new Set<string>();\n /** Identities whose current error the user has seen, which keeps each from notifying again. */\n const reported = new Set<string>();\n /** Last logged error message of each identity, which keeps an unchanged error from repeating. */\n const logged = new Map<string, string>();\n /** Editor query failures already logged since services opened, which keeps each from repeating. */\n const queryFailures = new Set<string>();\n\n let roots: string[] = [];\n let initializationOptions: unknown;\n let registryDirectives = false;\n let snippets = false;\n /** Whether the client requests diagnostics instead of receiving published ones. */\n let pull = false;\n /** Whether the client accepts `workspace/diagnostic/refresh`. */\n let pullRefresh = false;\n /** Control generation whose open documents were prepared together for pull diagnostics. */\n let prepared: number | undefined;\n /** Serializes pull diagnostics, because a worker analyzes one document at a time. */\n let pulls = Promise.resolve();\n /** Last report for each pulled document. Its identity lets the client keep unchanged results. */\n const pullReports = new Map<string, { id: string; text: string }>();\n let nextReport = 0;\n let generation = 0;\n let controls = Promise.resolve();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let shutdown = false;\n let foldersSupported = false;\n let dynamicWatch = false;\n let active: AbortController | undefined;\n let disposal: Promise<void> | undefined;\n\n /**\n * Invalidates current results and serializes a workspace or document mutation.\n * Callback failures are logged and absorbed so subsequent mutations can run.\n *\n * @param action - Mutation to execute after previous control work. Shutdown skips registration.\n */\n const control = (action: () => Promise<void>) => {\n if (shutdown) {\n return;\n }\n active?.abort();\n generation++;\n cache.clear();\n controls = controls.then(action).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n };\n\n /**\n * Takes ownership of opened services and replays every open buffer into them.\n *\n * @param opened - Services and initialization errors from the workspace factory or discovery.\n * @returns Completion of buffer replay.\n * @throws If buffer replay fails.\n */\n const adopt = async (opened: OpenAnalysisWorkspaces) => {\n for (const [id, error] of opened.errors ?? []) {\n errors.set(id, error);\n }\n for (const [id, workspace] of opened.workspaces) {\n connection.console.info(`Opened the Stillwind workspace ${id}`);\n workspaces.set(id, workspace);\n for (const document of documents.all()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n }\n };\n\n /**\n * Closes existing services, opens the current roots, replays every open buffer, and logs the\n * outcome.\n *\n * @param reason - Event that requires the services, logged at debug level.\n * @returns Completion of service replacement and buffer replay.\n * @throws If service closure, the workspace factory, or buffer replay fails.\n */\n const open = async (reason: string) => {\n connection.console.debug(`Opening Stillwind workspaces after ${reason}`);\n const start = performance.now();\n await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));\n workspaces.clear();\n errors.clear();\n discovered.clear();\n queryFailures.clear();\n await adopt(\n await options.openWorkspaces({\n workspaceFolders: roots,\n initializationOptions,\n }),\n );\n const elapsed = Math.round(performance.now() - start);\n if (workspaces.size) {\n const count = `${workspaces.size} Stillwind workspace${workspaces.size === 1 ? \"\" : \"s\"}`;\n connection.console.info(`Opened ${count} in ${elapsed} ms`);\n } else if (!errors.size) {\n connection.console.info(\n [\n roots.length\n ? `No Stillwind configuration was found in ${roots.join(\", \")}.`\n : \"No workspace folder is open.\",\n ...(options.discoverWorkspace\n ? [\"A configuration in a subdirectory opens when a document in that directory opens.\"]\n : []),\n ].join(\" \"),\n );\n }\n };\n\n /**\n * Opens configurations for documents that the last analysis pass left without results.\n *\n * @param uris - Document URIs. A document closed in the meantime is skipped.\n * @returns Completion of discovery and buffer replay.\n * @throws If discovery or buffer replay fails.\n */\n const discover = async (uris: readonly string[]) => {\n for (const uri of uris) {\n if (!documents.get(uri)) {\n continue;\n }\n const opened = await options.discoverWorkspace?.(\n uri,\n {\n workspaceFolders: roots,\n initializationOptions,\n },\n new Set([...workspaces.keys(), ...errors.keys()]),\n );\n if (opened) {\n await adopt(opened);\n }\n }\n };\n\n /**\n * Converts one document's analysis results to diagnostics.\n *\n * @param uri - Analyzed document, which receives the note about an incomplete analysis.\n * @param results - Results of each project that analyzed the document.\n * @param add - Receives each diagnostic with the URI of its location.\n */\n const collect = (\n uri: string,\n results: readonly WorkspaceResult[],\n add: (uri: string, diagnostic: Diagnostic) => void,\n ) => {\n for (const entry of results) {\n const source = `stillwind:${entry.config}:${entry.project + 1}`;\n for (const report of entry.result.reports) {\n const location = report.primary.location;\n const href = documentationUrl(report.code);\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 ...(href ? { codeDescription: { href } } : {}),\n message: [report.message, ...report.notes].join(\"\\n\"),\n relatedInformation: report.related.map((label) => ({\n location: {\n uri: label.location.uri,\n range: range(label.location),\n },\n message: label.message ?? report.message,\n })),\n });\n }\n if (entry.result.status === \"incomplete\") {\n const missing =\n entry.result.dependencies\n ?.filter(\n (dependency) =>\n dependency.status === \"unresolved\" || dependency.status === \"unsupported\",\n )\n .map(\n (dependency) =>\n `${dependency.status}: ${dependency.specifier} from ${dependency.importer}`,\n ) ?? [];\n add(uri, {\n range: range(),\n severity: entry.result.error ? DiagnosticSeverity.Error : DiagnosticSeverity.Information,\n source,\n code: entry.result.error ? \"SW_HOST\" : \"SW_UNVERIFIED\",\n message: [\n entry.result.error ?? \"Stillwind analysis is incomplete\",\n ...missing,\n ...(entry.result.unverified ?? []).map((item) => `${item.moduleId}: ${item.reason}`),\n ].join(\"\\n\"),\n });\n }\n }\n };\n\n /**\n * Converts workspace errors to diagnostics on their configuration files.\n *\n * @param add - Receives each diagnostic with the URI of its configuration file.\n */\n const collectErrors = (add: (uri: string, diagnostic: Diagnostic) => void) => {\n for (const [file, error] of errors) {\n const uri = options.configurationUri?.(file, roots);\n if (uri) {\n add(uri, {\n range: range(),\n severity: DiagnosticSeverity.Error,\n source: \"stillwind\",\n code: \"SW_HOST\",\n message: error,\n });\n }\n }\n };\n\n /**\n * Logs each new or changed workspace error and forgets errors that ended. The user receives one\n * notification for each identity until its error ends, because the message of a configuration\n * error can change with each edit of the configuration.\n */\n const notifyErrors = () => {\n for (const [file, error] of errors) {\n const message = `${file}: ${error}`;\n if (logged.get(file) !== message) {\n logged.set(file, message);\n connection.console.error(message);\n }\n if (!reported.has(file)) {\n reported.add(file);\n void connection.sendNotification(ShowMessageNotification.type, {\n type: MessageType.Error,\n message: `Stillwind: ${message}`,\n });\n }\n }\n for (const file of reported) {\n if (!errors.has(file)) {\n reported.delete(file);\n logged.delete(file);\n }\n }\n };\n\n /**\n * Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.\n * Empty notifications clear diagnostics for previously published or currently open documents.\n */\n const publish = () => {\n const open = new Map(documents.all().map((document) => [uriKey(document.uri), document.uri]));\n const grouped = new Map<string, Diagnostic[]>();\n const seen = new Set<string>();\n /**\n * Appends a diagnostic only once for its document and complete serialized value.\n *\n * @param reported - Original document URI, in any spelling of that document.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (reported: string, diagnostic: Diagnostic) => {\n const uri = open.get(uriKey(reported)) ?? reported;\n const key = JSON.stringify([uri, diagnostic]);\n if (!seen.has(key)) {\n seen.add(key);\n const list = grouped.get(uri) ?? [];\n list.push(diagnostic);\n grouped.set(uri, list);\n }\n };\n for (const [uri, results] of cache) {\n collect(uri, results, add);\n }\n collectErrors(add);\n notifyErrors();\n // Clients treat spellings of one file as one resource, so a second notification for another\n // spelling would replace the first.\n const targets = new Map(\n [...published, ...grouped.keys(), ...open.values()].map((uri) => [uriKey(uri), uri]),\n );\n for (const uri of targets.values()) {\n void connection.sendDiagnostics({\n uri,\n version: documents.get(uri)?.version,\n diagnostics: grouped.get(uri) ?? [],\n });\n }\n published.clear();\n for (const uri of grouped.keys()) {\n published.add(uri);\n }\n };\n\n /**\n * Analyzes open buffers after queued mutations and publishes only a current, non-stale batch.\n * Service failures become workspace errors. An obsolete or cancelled batch leaves the cache unchanged.\n *\n * @param revision - Control generation captured when analysis was scheduled.\n * @returns Completion of the analysis pass or its early discard.\n */\n const analyze = async (revision: number) => {\n await controls;\n if (shutdown || revision !== generation) {\n return;\n }\n const cancellation = new AbortController();\n active = cancellation;\n const next = new Map<string, WorkspaceResult[]>();\n for (const [file, workspace] of workspaces) {\n try {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n } catch (error) {\n errors.set(file, String(error));\n }\n if (revision !== generation || shutdown) {\n return;\n }\n }\n for (const document of documents.all()) {\n const results: WorkspaceResult[] = [];\n for (const [file, workspace] of workspaces) {\n try {\n results.push(...(await workspace.analyze(document.uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n if (revision !== generation || shutdown) {\n return;\n }\n if (\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n return;\n }\n next.set(document.uri, results);\n }\n if (revision === generation) {\n cache.clear();\n for (const [uri, result] of next) {\n cache.set(uri, result);\n }\n publish();\n discoverUncovered();\n }\n };\n\n /**\n * Starts discovery for documents that the last analysis pass left without results. Each document\n * is passed to discovery once until services reopen.\n */\n const discoverUncovered = () => {\n const uncovered = options.discoverWorkspace\n ? [...cache].flatMap(([uri, results]) => (results.length || discovered.has(uri) ? [] : [uri]))\n : [];\n if (uncovered.length) {\n for (const uri of uncovered) {\n discovered.add(uri);\n }\n control(() => discover(uncovered));\n schedule();\n }\n };\n\n /**\n * Replaces the pending 40 ms timer with an analysis pass for the current control generation. A\n * pull client instead receives a request to pull its documents again, without a pass here.\n */\n const schedule = () => {\n if (timer) {\n clearTimeout(timer);\n }\n if (pull) {\n timer = setTimeout(() => {\n notifyErrors();\n if (pullRefresh) {\n void connection.languages.diagnostics.refresh().catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }\n }, 40);\n return;\n }\n const revision = generation;\n timer = setTimeout(() => {\n void analyze(revision).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }, 40);\n };\n\n /**\n * Analyzes one document for a pull request, and retries once after discovery opens a service.\n * Results stay cached until the next control generation. Open documents are prepared together\n * once per generation, because the checker then loads them in one batch.\n *\n * @param uri - Requested document URI.\n * @param token - Client cancellation.\n * @returns Results of each project, or an empty list for a closed document or after shutdown.\n * @throws A `ResponseError` with `RequestCancelled` after client cancellation, or with\n * `ServerCancelled` and `retriggerRequest` after a change makes the analysis obsolete.\n */\n const pullResults = async (uri: string, token: CancellationToken): Promise<WorkspaceResult[]> => {\n for (;;) {\n await controls;\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (shutdown || !documents.get(uri)) {\n return [];\n }\n const cached = cache.get(uri);\n if (cached) {\n return cached;\n }\n const revision = generation;\n const cancellation = new AbortController();\n active = cancellation;\n const subscription = token.onCancellationRequested(() => cancellation.abort());\n const results: WorkspaceResult[] = [];\n try {\n for (const [file, workspace] of workspaces) {\n try {\n if (prepared !== revision) {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n }\n results.push(...(await workspace.analyze(uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n } finally {\n subscription.dispose();\n }\n if (shutdown) {\n return [];\n }\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (\n revision !== generation ||\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n throw new ResponseError<DiagnosticServerCancellationData>(\n LSPErrorCodes.ServerCancelled,\n \"Stillwind analysis became obsolete\",\n { retriggerRequest: true },\n );\n }\n prepared = revision;\n cache.set(uri, results);\n if (results.length || discovered.has(uri) || !options.discoverWorkspace) {\n return results;\n }\n discovered.add(uri);\n control(() => discover([uri]));\n }\n };\n\n /**\n * Answers a pull request with the findings located in one document and in its configuration\n * errors. Findings in other documents appear when the client pulls those documents.\n *\n * @param uri - Requested document URI.\n * @param previous - Report identity that the client retains.\n * @param token - Client cancellation.\n * @returns An unchanged report when the content matches the retained report, otherwise a full one.\n * @throws The errors of `pullResults`.\n */\n const pullDiagnostics = async (\n uri: string,\n previous: string | undefined,\n token: CancellationToken,\n ): Promise<DocumentDiagnosticReport> => {\n const results = await pullResults(uri, token);\n const key = uriKey(uri);\n const items = new Map<string, Diagnostic>();\n /**\n * Keeps a diagnostic only when it belongs to the requested document.\n *\n * @param location - URI of the diagnostic, in any spelling.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (location: string, diagnostic: Diagnostic) => {\n if (uriKey(location) === key) {\n items.set(JSON.stringify(diagnostic), diagnostic);\n }\n };\n collect(uri, results, add);\n collectErrors(add);\n notifyErrors();\n const text = [...items.keys()].join(\"\\n\");\n let report = pullReports.get(uri);\n if (report?.text !== text) {\n report = { id: String(++nextReport), text };\n pullReports.set(uri, report);\n }\n return previous === report.id\n ? { kind: \"unchanged\", resultId: report.id }\n : { kind: \"full\", resultId: report.id, items: [...items.values()] };\n };\n\n /**\n * Queries services after queued mutations and checks document versions and source fingerprints.\n * Each distinct query failure is logged once until services reopen. The cancellation subscription\n * is released after the request.\n *\n * @param uri - URI of the open original document.\n * @param request - Editor operation expressed in that document's UTF-16 coordinates.\n * @param token - LSP cancellation forwarded through an AbortSignal.\n * @returns Current project results, or an empty list after changes, cancellation, or failure.\n */\n const query: EditorQuery = async (uri, request, token: CancellationToken) => {\n await controls;\n if (request.kind === \"completion\" || request.kind === \"resolve\") {\n request = {\n ...request,\n registryDirectives,\n snippets,\n };\n }\n const document = documents.get(uri);\n if (!document || shutdown || token.isCancellationRequested) {\n return [];\n }\n const version = document.version;\n const revision = generation;\n const controller = new AbortController();\n const subscription = token.onCancellationRequested(() => controller.abort());\n const results: WorkspaceEditorResult[] = [];\n try {\n for (const workspace of workspaces.values()) {\n if (workspace.query) {\n results.push(...(await workspace.query(uri, request, controller.signal)));\n }\n }\n if (\n token.isCancellationRequested ||\n revision !== generation ||\n documents.get(uri)?.version !== version\n ) {\n return [];\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n return results.filter((entry) => entry.result.revision === fingerprint(document.getText()));\n } catch (error) {\n const message = errorText(error);\n if (!queryFailures.has(message)) {\n queryFailures.add(message);\n connection.console.error(message);\n }\n return [];\n } finally {\n subscription.dispose();\n }\n };\n registerEditorFeatures(connection, documents, query);\n\n connection.onInitialize(async (params: InitializeParams) => {\n initializationOptions = params.initializationOptions;\n registryDirectives = completionRegistrySetting(initializationOptions) ?? false;\n pull = params.capabilities.textDocument?.diagnostic !== undefined;\n pullRefresh = params.capabilities.workspace?.diagnostics?.refreshSupport === true;\n snippets =\n params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;\n foldersSupported = params.capabilities.workspace?.workspaceFolders === true;\n dynamicWatch =\n params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;\n roots =\n params.workspaceFolders?.map((folder) => folder.uri) ??\n (params.rootUri ? [params.rootUri] : []);\n await open(\"initialization\");\n const editor =\n options.discoverWorkspace != null ||\n [...workspaces.values()].some((workspace) => workspace.query != null);\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n codeActionProvider: {\n codeActionKinds: [CodeActionKind.QuickFix, ...(editor ? editorCodeActionKinds : [])],\n },\n ...(pull\n ? {\n diagnosticProvider: {\n identifier: \"stillwind\",\n interFileDependencies: true,\n workspaceDiagnostics: false,\n },\n }\n : {}),\n hoverProvider: editor,\n definitionProvider: editor,\n completionProvider: editor\n ? {\n resolveProvider: true,\n triggerCharacters: [\"@\", \":\", \"-\", \"/\", \"[\", \"(\", \" \"],\n }\n : undefined,\n colorProvider: editor,\n documentLinkProvider: editor\n ? {\n resolveProvider: false,\n }\n : undefined,\n workspace: {\n workspaceFolders: {\n supported: true,\n changeNotifications: true,\n },\n },\n },\n serverInfo: {\n name: \"Stillwind\",\n },\n };\n });\n connection.onInitialized(async () => {\n if (foldersSupported) {\n connection.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {\n const deleted = new Set(removed.map((folder) => folder.uri));\n roots = [\n ...roots.filter((root) => !deleted.has(root)),\n ...added.map((folder) => folder.uri),\n ];\n control(() => open(\"a workspace folder change\"));\n schedule();\n });\n }\n if (dynamicWatch) {\n await connection.client.register(DidChangeWatchedFilesNotification.type, {\n watchers: [\n {\n globPattern: \"**/*\",\n },\n ],\n });\n }\n schedule();\n });\n documents.onDidChangeContent(({ document }) => {\n control(async () => {\n if (documents.get(document.uri)?.version !== document.version) {\n return;\n }\n for (const workspace of workspaces.values()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n });\n if (!pull) {\n schedule();\n }\n });\n documents.onDidClose(({ document }) => {\n pullReports.delete(document.uri);\n control(async () => {\n for (const workspace of workspaces.values()) {\n await workspace.closeDocument(document.uri);\n }\n });\n schedule();\n });\n /**\n * Reopens the workspaces if any service cannot reuse its current buffers after a save or file\n * change. Without services, reopening lets a new or corrected configuration take effect.\n *\n * @param uris - Document URIs from the save or watch notification. The list must not be empty.\n * @param event - Notification kind for the log, such as `save`.\n * @returns Completion of the checks and any required workspace replacement.\n * @throws If a service check or workspace replacement fails.\n */\n const refresh = async (uris: readonly string[], event: string) => {\n const others = uris.length > 1 ? ` and ${uris.length - 1} other files` : \"\";\n const reason = `the ${event} of ${uris[0]}${others}`;\n if (!workspaces.size || (errors.size && uris.some(isConfigurationUri))) {\n await open(reason);\n return;\n }\n for (const workspace of workspaces.values()) {\n if (!(await workspace.refresh?.(uris))) {\n await open(reason);\n break;\n }\n }\n };\n documents.onDidSave(({ document }) => {\n control(() => refresh([document.uri], \"save\"));\n schedule();\n });\n /**\n * Decides whether watched changes need work. Starting that work cancels running analysis, so\n * changes to unrelated files must not reach it.\n *\n * @param uris - Document URIs from the watch notification.\n * @returns True for a configuration file while a service is missing or failed, and when a service\n * reports that the changes affect it. A service without an `affects` check counts as affected.\n * @throws If a service check fails.\n */\n const affected = async (uris: readonly string[]) => {\n if ((!workspaces.size || errors.size) && uris.some(isConfigurationUri)) {\n return true;\n }\n for (const workspace of workspaces.values()) {\n if ((await workspace.affects?.(uris)) ?? true) {\n return true;\n }\n }\n return false;\n };\n connection.onDidChangeWatchedFiles(({ changes }) => {\n const uris = changes.map((change) => change.uri);\n void affected(uris)\n .then((result) => {\n if (result) {\n control(() => refresh(uris, \"change\"));\n schedule();\n }\n })\n .catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n });\n connection.languages.diagnostics.on((params, token) => {\n const task = pulls.then(() =>\n pullDiagnostics(params.textDocument.uri, params.previousResultId, token),\n );\n pulls = task.then(\n () => undefined,\n () => undefined,\n );\n return task;\n });\n connection.onDidChangeConfiguration(({ settings }) => {\n control(async () => {\n registryDirectives =\n completionRegistrySetting(settings?.stillwind ?? settings) ?? registryDirectives;\n await open(\"a configuration change\");\n });\n schedule();\n });\n connection.onCodeAction(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n const result: CodeAction[] = document\n ? await sourceActions(document, params.context.only, token, query)\n : [];\n if (\n params.context.only &&\n !params.context.only.some(\n (kind) =>\n CodeActionKind.QuickFix === kind || CodeActionKind.QuickFix.startsWith(`${kind}.`),\n )\n ) {\n return result;\n }\n if (token.isCancellationRequested) {\n return result;\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n if (token.isCancellationRequested) {\n return result;\n }\n for (const entries of cache.values()) {\n for (const entry of entries) {\n for (const report of entry.result.reports) {\n const primary = report.primary.location;\n if (\n uriKey(primary.uri) !== uriKey(params.textDocument.uri) ||\n primary.endLine < params.range.start.line ||\n primary.startLine > params.range.end.line\n ) {\n continue;\n }\n if (\n document &&\n (primary.endUtf16 < document.offsetAt(params.range.start) ||\n primary.startUtf16 > document.offsetAt(params.range.end))\n ) {\n continue;\n }\n for (const action of report.actions) {\n const changes = new Map<string, TextDocumentEdit>();\n let valid = true;\n for (const edit of action.edits) {\n const key = uriKey(edit.location.uri);\n const document = documents.all().find(({ uri }) => uriKey(uri) === key);\n if (!document || fingerprint(document.getText()) !== edit.location.revision) {\n valid = false;\n break;\n }\n const change = changes.get(document.uri) ?? {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: [],\n };\n change.edits.push({\n range: range(edit.location),\n newText: edit.replacement,\n });\n changes.set(document.uri, change);\n }\n if (valid && changes.size) {\n result.push({\n title: action.title,\n kind: CodeActionKind.QuickFix,\n edit: {\n documentChanges: [...changes.values()],\n },\n });\n }\n }\n }\n }\n }\n return result.filter(\n (action, index) =>\n result.findIndex((candidate) => JSON.stringify(candidate) === JSON.stringify(action)) ===\n index,\n );\n });\n /**\n * Stops publication and closes all services after the control queue settles.\n *\n * @returns A shared cleanup promise, including on repeated calls.\n * @throws An AggregateError containing every service closure failure.\n */\n const dispose = (): Promise<void> => {\n disposal ??= (async () => {\n shutdown = true;\n active?.abort();\n generation++;\n cache.clear();\n if (timer) {\n clearTimeout(timer);\n }\n await controls;\n const closed = await Promise.allSettled(\n [...workspaces.values()].map((workspace) => workspace.close()),\n );\n workspaces.clear();\n const failed = closed.filter((result) => result.status === \"rejected\");\n if (failed.length) {\n throw new AggregateError(\n failed.map((result) => result.reason),\n \"Failed to close language server analysis services\",\n );\n }\n })();\n return disposal;\n };\n connection.onShutdown(dispose);\n connection.onExit(() => {\n options.onExit?.(shutdown);\n });\n documents.listen(connection);\n return {\n ready: () => controls,\n reload: async () => {\n control(() => open(\"a reload request\"));\n schedule();\n await controls;\n },\n dispose,\n };\n}\n\n/**\n * Creates a comparison key for spellings of one file URI. Editors and Node encode characters and\n * spell Windows drive letters differently, for example `file:///f%3A/a` and `file:///F:/a`.\n *\n * @param uri - Document URI. Do not send the result to a client.\n * @returns The decoded URI with a lowercase drive letter, or the input if it cannot be decoded.\n */\nexport function uriKey(uri: string): string {\n try {\n uri = decodeURIComponent(uri);\n } catch {\n return uri;\n }\n return uri.replace(/^file:\\/\\/\\/[a-z]:/i, (drive) => drive.toLowerCase());\n}\n\n/**\n * Formats an unexpected failure for the log.\n *\n * @param error - Thrown value.\n * @returns The stack trace of an `Error`, which includes its message, or the string form of other\n * values.\n */\nfunction errorText(error: unknown): string {\n return error instanceof Error && error.stack ? error.stack : String(error);\n}\n\n/**\n * Recognizes a Stillwind configuration file by name.\n *\n * @param uri - Document URI.\n * @returns Whether the file name is `stillwind.config` with any extension.\n */\nfunction isConfigurationUri(uri: string): boolean {\n return /\\/stillwind\\.config\\.[^/]+$/.test(uri);\n}\n\n/**\n * Reads the editor-only completion field from initialization options or configuration settings.\n *\n * @param value - A protocol object that may contain `completion.registryDirectives`.\n * @returns The boolean setting, or undefined when the field is absent or invalid.\n */\nfunction completionRegistrySetting(value: unknown): boolean | undefined {\n if (!value || typeof value !== \"object\") {\n return undefined;\n }\n const completion = (value as Record<string, unknown>).completion;\n if (!completion || typeof completion !== \"object\") {\n return undefined;\n }\n const registry = (completion as Record<string, unknown>).registryDirectives;\n return typeof registry === \"boolean\" ? registry : undefined;\n}\n\n/**\n * Copies a native diagnostic location into LSP positions.\n *\n * @param location - Original document positions with zero-based lines and UTF-16 columns.\n * @returns The half-open range, or an empty range at document start when no location is supplied.\n */\nfunction range(location?: {\n /** Zero-based line containing the inclusive start. */\n startLine: number;\n /** UTF-16 column of the inclusive start. */\n startColumn: number;\n /** Zero-based line containing the exclusive end. */\n endLine: number;\n /** UTF-16 column of the exclusive end. */\n endColumn: number;\n}) {\n return {\n start: {\n line: location?.startLine ?? 0,\n character: location?.startColumn ?? 0,\n },\n end: {\n line: location?.endLine ?? 0,\n character: location?.endColumn ?? 0,\n },\n };\n}\n"],"mappings":";;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;AAGnB,MAAa,wBAAwB,CAAC,YAAY,QAAQ;;;;;;;;AAuB1D,SAAgB,uBACd,Y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O;CACT;CACA,WAAW,WAAW,OAAO;CAC7B,WAAW,aAAa;EACtB,QAAQ,SAAS,QAAQ;CAC3B,CAAC;CACD,UAAU,OAAO,UAAU;CAC3B,OAAO;EACL,aAAa;EACb,QAAQ,YAAY;GAClB,cAAc,KAAK,kBAAkB,CAAC;GACtC,SAAS;GACT,MAAM;EACR;EACA;CACF;AACF;;;;;;;;AASA,SAAgB,OAAO,KAAqB;CAC1C,IAAI;EACF,MAAM,mBAAmB,GAAG;CAC9B,QAAQ;EACN,OAAO;CACT;CACA,OAAO,IAAI,QAAQ,wBAAwB,UAAU,MAAM,YAAY,CAAC;AAC1E;;;;;;;;AASA,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,SAAS,MAAM,QAAQ,MAAM,QAAQ,OAAO,KAAK;AAC3E;;;;;;;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"}
@@ -1,5 +1,5 @@
1
- import { Connection } from "vscode-languageserver";
2
1
  import { DiscoverWorkspace, OpenWorkspaces } from "@stillwind/analysis";
2
+ import { Connection } from "vscode-languageserver";
3
3
  /** Supplies analysis services and delegates transport exit to the embedding application. */
4
4
  interface LanguageServerOptions {
5
5
  /**
@@ -69,4 +69,4 @@ declare function createLanguageServer(connection: Connection, options: LanguageS
69
69
  dispose(): Promise<void>;
70
70
  };
71
71
  export { createLanguageServer as n, LanguageServerOptions as t };
72
- //# sourceMappingURL=server-Bp6CUeN4.d.ts.map
72
+ //# sourceMappingURL=server-CEF3Ha9S.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stillwind/language-server",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Stillwind Language Server Protocol handlers with Node and browser transports",
5
5
  "keywords": [
6
6
  "language-server",
@@ -21,6 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "type": "module",
24
+ "types": "./dist/index.d.ts",
24
25
  "exports": {
25
26
  ".": {
26
27
  "types": "./dist/index.d.ts",
@@ -40,8 +41,8 @@
40
41
  "access": "public"
41
42
  },
42
43
  "dependencies": {
43
- "@stillwind/analysis": "0.6.0",
44
- "@stillwind/native": "0.6.0",
44
+ "@stillwind/analysis": "0.8.0",
45
+ "@stillwind/native": "0.8.0",
45
46
  "vscode-languageserver": "^11.0.0",
46
47
  "vscode-languageserver-textdocument": "^1.0.16"
47
48
  },
@@ -49,7 +50,7 @@
49
50
  "@stillwind-internal/tools-workspace": "0.0.0",
50
51
  "@types/node": "^26.6.6",
51
52
  "rolldown": "^1.2.16",
52
- "stillwind": "0.6.0",
53
+ "stillwind": "0.8.0",
53
54
  "typescript": "^6.0.3",
54
55
  "vite-plus": "1.4.0"
55
56
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-ZB6y2ShG.js","names":[],"sources":["../src/editor.ts","../src/server.ts"],"sourcesContent":["import type { EditorRequest, WorkspaceEditorResult } from \"@stillwind/analysis\";\nimport {\n CompletionItemKind,\n InsertTextFormat,\n MarkupKind,\n type CancellationToken,\n type CodeAction,\n type CompletionItem,\n type Connection,\n type TextDocuments,\n} from \"vscode-languageserver\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\n\nconst sortKind = \"source.sort.stillwind\";\nconst fixAllKind = \"source.fixAll.stillwind\";\n\n/** Source actions advertised in fix-all order followed by utility sorting. */\nexport const editorCodeActionKinds = [fixAllKind, sortKind];\n\n/**\n * Queries the current original buffer and discards results after a document change or cancellation.\n *\n * @param uri - URI of an open original document.\n * @param request - Editor operation with offsets in that document's UTF-16 text.\n * @param token - Cancellation for this request.\n * @returns Results whose source fingerprints match the current document.\n */\nexport type EditorQuery = (\n uri: string,\n request: EditorRequest,\n token: CancellationToken,\n) => Promise<WorkspaceEditorResult[]>;\n\n/**\n * Registers hover, definitions, completion, colors, plugin links, and source actions.\n *\n * @param connection - Caller-owned connection on which handlers are installed.\n * @param documents - Open original buffers used to convert UTF-16 offsets to LSP positions.\n * @param query - Query implementation that rejects obsolete results and honors cancellation.\n */\nexport function registerEditorFeatures(\n connection: Connection,\n documents: TextDocuments<TextDocument>,\n query: EditorQuery,\n): void {\n connection.onDefinition(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"definition\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const definitions = entries.flatMap((entry) => entry.result.definitions ?? []);\n return definitions\n .filter(\n (definition, index) =>\n definitions.findIndex((other) => JSON.stringify(other) === JSON.stringify(definition)) ===\n index,\n )\n .map((definition) => ({\n uri: definition.uri,\n range: {\n start: {\n line: definition.startLine,\n character: definition.startColumn,\n },\n end: {\n line: definition.endLine,\n character: definition.endColumn,\n },\n },\n }));\n });\n connection.onDocumentLinks(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n const entries = await query(\n document.uri,\n {\n kind: \"links\",\n },\n token,\n );\n const links = entries.flatMap((entry) => entry.result.links ?? []);\n return links\n .filter(\n (link, index) =>\n link.target &&\n links.findIndex(\n (other) =>\n other.start === link.start && other.end === link.end && other.target === link.target,\n ) === index &&\n !links.some(\n (other) =>\n other.start === link.start && other.end === link.end && other.target !== link.target,\n ),\n )\n .map((link) => ({\n range: offsets(document, link),\n target: link.target,\n }));\n });\n connection.onHover(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return null;\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"hover\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const answers = entries.filter((entry) => entry.result.hover);\n if (!answers.length) {\n return null;\n }\n\n const seen = new Set<string>();\n const contents = answers\n .flatMap((entry) => {\n const hover = entry.result.hover!;\n const key = JSON.stringify(hover);\n if (seen.has(key)) {\n return [];\n }\n seen.add(key);\n return [\n `${answers.length > 1 ? `${entry.config} · project ${entry.project + 1}\\n\\n` : \"\"}${hoverMarkdown(hover)}`,\n ];\n })\n .join(\"\\n\\n\");\n return {\n contents: {\n kind: MarkupKind.Markdown,\n value: contents,\n },\n range: offsets(document, answers[0].result.hover!),\n };\n });\n\n connection.onCompletion(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const version = document.version;\n const entries = await query(\n document.uri,\n {\n kind: \"completion\",\n offset: document.offsetAt(params.position),\n },\n token,\n );\n const items: CompletionItem[] = entries.flatMap((entry) =>\n (entry.result.completions ?? []).map((item) => ({\n label: item.label,\n detail: item.detail,\n sortText: item.sortText,\n insertTextFormat: item.snippet ? InsertTextFormat.Snippet : undefined,\n command: item.retrigger\n ? { title: \"Continue completion\", command: \"editor.action.triggerSuggest\" }\n : undefined,\n kind: item.keyword\n ? CompletionItemKind.Keyword\n : item.category === \"directory\"\n ? CompletionItemKind.Folder\n : item.category === \"file\"\n ? CompletionItemKind.File\n : item.category === \"module\" || item.variant || item.candidate.endsWith(\":\")\n ? CompletionItemKind.Module\n : item.marker\n ? CompletionItemKind.Class\n : CompletionItemKind.Value,\n textEdit: {\n range: offsets(document, item),\n newText: item.snippet ?? item.newText,\n },\n data: {\n uri: document.uri,\n version,\n revision: entry.result.revision,\n candidate: item.candidate,\n input: item.input,\n snapshot: item.snapshot,\n project: entry.project,\n config: entry.config,\n },\n })),\n );\n return items.filter(\n (item, index) =>\n items.findIndex(\n (other) =>\n other.label === item.label &&\n JSON.stringify(other.textEdit) === JSON.stringify(item.textEdit),\n ) === index,\n );\n });\n\n connection.onCompletionResolve(async (item, token) => {\n const detail = item.detail;\n delete item.documentation;\n delete item.detail;\n const data = item.data as\n | {\n /** Original document URI captured when completion was requested. */\n uri?: unknown;\n /** Document version that must still match the open buffer. */\n version?: unknown;\n /** Full completion candidate, including surrounding variants. */\n candidate?: unknown;\n /** Configuration identity used to select the same project result. */\n config?: unknown;\n /** Zero-based project index within the configuration. */\n project?: unknown;\n /** Source fingerprint that must match the resolved result. */\n revision?: unknown;\n /** Original UTF-16 offset that identifies the completion's utility input. */\n input?: unknown;\n /** Graph and configuration fingerprint required by the resolve request. */\n snapshot?: unknown;\n }\n | undefined;\n if (\n !data ||\n typeof data.uri !== \"string\" ||\n typeof data.candidate !== \"string\" ||\n typeof data.input !== \"number\" ||\n typeof data.snapshot !== \"string\" ||\n documents.get(data.uri)?.version !== data.version\n ) {\n return item;\n }\n\n const entries = await query(\n data.uri,\n {\n kind: \"resolve\",\n candidate: data.candidate,\n input: data.input,\n snapshot: data.snapshot,\n },\n token,\n );\n const answer = entries.find(\n (entry) =>\n entry.project === data.project &&\n entry.config === data.config &&\n entry.result.revision === data.revision,\n )?.result.hover;\n if (answer) {\n item.detail = answer.detail ?? detail;\n item.documentation = {\n kind: MarkupKind.Markdown,\n value: hoverMarkdown(answer),\n };\n }\n return item;\n });\n\n connection.onDocumentColor(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colors\",\n },\n token,\n );\n const colors = entries\n .flatMap((entry) => entry.result.colors ?? [])\n .filter(\n (color, index, colors) =>\n colors.findIndex((other) => JSON.stringify(other) === JSON.stringify(color)) === index,\n );\n // Projects that disagree on a range omit it. A range may show one light and one dark color.\n return colors\n .filter((color) => {\n const range = colors.filter(\n (other) => other.start === color.start && other.end === color.end,\n );\n return (\n range.length === 1 ||\n (range.length === 2 &&\n range.some((other) => other.scheme === \"light\") &&\n range.some((other) => other.scheme === \"dark\"))\n );\n })\n .map((color) => ({\n range: offsets(document, color),\n color: {\n red: color.red,\n green: color.green,\n blue: color.blue,\n alpha: color.alpha,\n },\n }));\n });\n\n connection.onColorPresentation(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n if (!document) {\n return [];\n }\n\n const entries = await query(\n document.uri,\n {\n kind: \"colorPresentation\",\n start: document.offsetAt(params.range.start),\n end: document.offsetAt(params.range.end),\n color: params.color,\n },\n token,\n );\n return entries\n .flatMap((entry) =>\n (entry.result.edits ?? []).map((edit) => ({\n label: edit.newText,\n textEdit: {\n range: offsets(document, edit),\n newText: edit.newText,\n },\n })),\n )\n .filter(\n (item, index, items) =>\n items.findIndex((other) => JSON.stringify(item) === JSON.stringify(other)) === index,\n );\n });\n}\n\n/**\n * Formats CSS previews and dialect documentation, and explains authored runtime key expressions.\n * Expression line breaks become spaces, and code-span delimiters exceed every authored\n * backtick run so expressions remain literal Markdown. The supplied hover remains unchanged.\n *\n * @param hover - CSS preview and optional authored expressions for runtime view-transition names.\n * @returns Markdown with CSS first and expression notes in their supplied order.\n */\nfunction hoverMarkdown(hover: {\n /** Formatted generated CSS included verbatim inside the CSS fence. */\n css: string;\n /** Markdown describing authored CSS syntax or theme semantics. */\n documentation?: string;\n /** Authored expressions in the order in which their notes should appear. */\n runtimeNames?: string[];\n}): string {\n const notes = (hover.runtimeNames ?? []).map((expression) => {\n const text = expression.replace(/\\r\\n?|\\n/g, \" \");\n const ticks = \"`\".repeat(\n Math.max(0, ...[...text.matchAll(/`+/g)].map((match) => match[0].length)) + 1,\n );\n return `view-transition-name is computed at runtime from ${ticks} ${text} ${ticks}.`;\n });\n return [hover.css ? `\\`\\`\\`css\\n${hover.css}\\n\\`\\`\\`` : undefined, hover.documentation, ...notes]\n .filter(Boolean)\n .join(\"\\n\\n\");\n}\n\n/**\n * Builds versioned source actions for each project and removes actions with identical edits.\n * Each action contains one project's edits, so differing project results remain separate.\n *\n * @param document - Open original buffer that the query reads and the returned edits target.\n * @param only - Requested source kinds or their prefixes. Omission or an empty list produces no actions.\n * @param token - Cancellation forwarded to each query.\n * @param query - Query implementation that discards changed buffers and cancelled requests.\n * @returns Fix-all actions followed by sort actions, preserving project order within each kind.\n * @throws If a query rejects.\n */\nexport async function sourceActions(\n document: TextDocument,\n only: readonly string[] | undefined,\n token: CancellationToken,\n query: EditorQuery,\n): Promise<CodeAction[]> {\n const actions: CodeAction[] = [];\n for (const [kind, operation, title] of [\n [fixAllKind, \"fixes\", \"Fix all Stillwind lint findings\"],\n [sortKind, \"sort\", \"Sort Stillwind utilities\"],\n ] as const) {\n if (!only?.some((requested) => kind === requested || kind.startsWith(`${requested}.`))) {\n continue;\n }\n const entries = await query(\n document.uri,\n {\n kind: operation,\n },\n token,\n );\n for (const entry of entries) {\n if (!entry.result.edits?.length) {\n continue;\n }\n const edit = {\n documentChanges: [\n {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: entry.result.edits.map((edit) => ({\n range: offsets(document, edit),\n newText: edit.newText,\n })),\n },\n ],\n };\n if (\n actions.some(\n (action) => action.kind === kind && JSON.stringify(action.edit) === JSON.stringify(edit),\n )\n ) {\n continue;\n }\n actions.push({\n title: `${title}${entries.length > 1 ? ` (${entry.config}, project ${entry.project + 1})` : \"\"}`,\n kind,\n edit,\n });\n }\n }\n return actions;\n}\n\n/**\n * Converts original UTF-16 offsets to positions using the open document's line table.\n *\n * @param document - Document containing the text from which the offsets were measured.\n * @param range - Half-open UTF-16 range. TextDocument clamps offsets outside the document.\n * @returns LSP positions with zero-based lines and UTF-16 character offsets.\n */\nfunction offsets(\n document: TextDocument,\n range: {\n /** Inclusive UTF-16 offset in the original document. */\n start: number;\n /** Exclusive UTF-16 offset in the original document. */\n end: number;\n },\n) {\n return {\n start: document.positionAt(range.start),\n end: document.positionAt(range.end),\n };\n}\n","import type {\n AnalysisWorkspaceService,\n DiscoverWorkspace,\n OpenAnalysisWorkspaces,\n OpenWorkspaces,\n WorkspaceEditorResult,\n WorkspaceResult,\n} from \"@stillwind/analysis\";\nimport {\n CodeActionKind,\n DiagnosticSeverity,\n DidChangeWatchedFilesNotification,\n LSPErrorCodes,\n MessageType,\n ResponseError,\n ShowMessageNotification,\n TextDocuments,\n TextDocumentSyncKind,\n type CancellationToken,\n type CodeAction,\n type Connection,\n type Diagnostic,\n type DiagnosticServerCancellationData,\n type DocumentDiagnosticReport,\n type InitializeParams,\n type TextDocumentEdit,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\n\nimport {\n editorCodeActionKinds,\n registerEditorFeatures,\n sourceActions,\n type EditorQuery,\n} from \"./editor.ts\";\n\n/** Supplies analysis services and delegates transport exit to the embedding application. */\nexport interface LanguageServerOptions {\n /**\n * Opens services at initialization and after saves, watched file changes, configuration changes,\n * or workspace folder changes. Previous services are closed first. Open buffers are replayed.\n */\n openWorkspaces: OpenWorkspaces;\n /**\n * Opens a configuration for an open document that no service analyzes. The server calls this once\n * for each document until services reopen. Supplying it advertises editor features before any\n * service exists. Omission leaves such documents without analysis. A client with pull diagnostics\n * decides which documents reach this call, because only a diagnostic request starts discovery.\n * Editors open documents in the background, and each configuration starts a process that runs\n * its code.\n */\n discoverWorkspace?: DiscoverWorkspace;\n /**\n * Converts a service identity to the URI of its configuration file, where the server publishes\n * that service's errors.\n *\n * @param id - Key from a workspace map or an error map.\n * @param folders - Current workspace directory URIs.\n * @returns The file URI, or undefined when the identity names no file. The server then only logs\n * the error and notifies the user. Omitting this option has the same effect.\n */\n configurationUri?(id: string, folders: readonly string[]): string | undefined;\n /**\n * Handles the LSP exit notification using the embedding's transport or process policy.\n *\n * @param shutdown - Whether shutdown or explicit disposal was requested before exit.\n */\n onExit?(shutdown: boolean): void;\n}\n\n/**\n * Registers synchronization, diagnostics, fixes, hover, completion, colors, and sorting.\n * Analysis uses captured buffers and suppresses obsolete results. Quick fixes require every edited\n * document to be open and to match the report's source fingerprint.\n *\n * A client that declares `textDocument.diagnostic` requests diagnostics for each document, and the\n * server reports only the findings located in that document. Other clients receive every open\n * document's findings through `textDocument/publishDiagnostics`.\n *\n * @param connection - Caller-owned connection. Call listen after registration and dispose the\n * transport when finished. Diagnostic locations must use original documents and UTF-16 positions.\n * @param options - Workspace factory and optional exit handler. This server owns the opened services.\n * @returns Cleanup for the analysis services. It does not dispose the connection or its transport.\n */\nexport function createLanguageServer(\n connection: Connection,\n options: LanguageServerOptions,\n): {\n /**\n * Waits for document and workspace changes already queued by the server.\n *\n * @returns The current control queue's completion promise. Queued failures are logged.\n */\n ready(): Promise<void>;\n /**\n * Reopens workspace configuration and files, replays current buffers, and schedules analysis.\n *\n * @returns Completion of the queued reload. Reload failures are logged, and analysis runs separately.\n */\n reload(): Promise<void>;\n /**\n * Stops scheduling analysis, cancels publication, and closes services after queued control work.\n *\n * @returns The same cleanup promise on repeated calls.\n * @throws An AggregateError if any service fails to close.\n */\n dispose(): Promise<void>;\n} {\n const documents = new TextDocuments(TextDocument);\n const workspaces = new Map<string, AnalysisWorkspaceService>();\n const errors = new Map<string, string>();\n const cache = new Map<string, WorkspaceResult[]>();\n const published = new Set<string>();\n /** Documents already passed to discovery, which keeps later analysis passes from searching again. */\n const discovered = new Set<string>();\n /** Identities whose current error the user has seen, which keeps each from notifying again. */\n const reported = new Set<string>();\n /** Last logged error message of each identity, which keeps an unchanged error from repeating. */\n const logged = new Map<string, string>();\n /** Editor query failures already logged since services opened, which keeps each from repeating. */\n const queryFailures = new Set<string>();\n\n let roots: string[] = [];\n let initializationOptions: unknown;\n let registryDirectives = false;\n let snippets = false;\n /** Whether the client requests diagnostics instead of receiving published ones. */\n let pull = false;\n /** Whether the client accepts `workspace/diagnostic/refresh`. */\n let pullRefresh = false;\n /** Control generation whose open documents were prepared together for pull diagnostics. */\n let prepared: number | undefined;\n /** Serializes pull diagnostics, because a worker analyzes one document at a time. */\n let pulls = Promise.resolve();\n /** Last report for each pulled document. Its identity lets the client keep unchanged results. */\n const pullReports = new Map<string, { id: string; text: string }>();\n let nextReport = 0;\n let generation = 0;\n let controls = Promise.resolve();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let shutdown = false;\n let foldersSupported = false;\n let dynamicWatch = false;\n let active: AbortController | undefined;\n let disposal: Promise<void> | undefined;\n\n /**\n * Invalidates current results and serializes a workspace or document mutation.\n * Callback failures are logged and absorbed so subsequent mutations can run.\n *\n * @param action - Mutation to execute after previous control work. Shutdown skips registration.\n */\n const control = (action: () => Promise<void>) => {\n if (shutdown) {\n return;\n }\n active?.abort();\n generation++;\n cache.clear();\n controls = controls.then(action).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n };\n\n /**\n * Takes ownership of opened services and replays every open buffer into them.\n *\n * @param opened - Services and initialization errors from the workspace factory or discovery.\n * @returns Completion of buffer replay.\n * @throws If buffer replay fails.\n */\n const adopt = async (opened: OpenAnalysisWorkspaces) => {\n for (const [id, error] of opened.errors ?? []) {\n errors.set(id, error);\n }\n for (const [id, workspace] of opened.workspaces) {\n connection.console.info(`Opened the Stillwind workspace ${id}`);\n workspaces.set(id, workspace);\n for (const document of documents.all()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n }\n };\n\n /**\n * Closes existing services, opens the current roots, replays every open buffer, and logs the\n * outcome.\n *\n * @param reason - Event that requires the services, logged at debug level.\n * @returns Completion of service replacement and buffer replay.\n * @throws If service closure, the workspace factory, or buffer replay fails.\n */\n const open = async (reason: string) => {\n connection.console.debug(`Opening Stillwind workspaces after ${reason}`);\n const start = performance.now();\n await Promise.all([...workspaces.values()].map((workspace) => workspace.close()));\n workspaces.clear();\n errors.clear();\n discovered.clear();\n queryFailures.clear();\n await adopt(\n await options.openWorkspaces({\n workspaceFolders: roots,\n initializationOptions,\n }),\n );\n const elapsed = Math.round(performance.now() - start);\n if (workspaces.size) {\n const count = `${workspaces.size} Stillwind workspace${workspaces.size === 1 ? \"\" : \"s\"}`;\n connection.console.info(`Opened ${count} in ${elapsed} ms`);\n } else if (!errors.size) {\n connection.console.info(\n [\n roots.length\n ? `No Stillwind configuration was found in ${roots.join(\", \")}.`\n : \"No workspace folder is open.\",\n ...(options.discoverWorkspace\n ? [\"A configuration in a subdirectory opens when a document in that directory opens.\"]\n : []),\n ].join(\" \"),\n );\n }\n };\n\n /**\n * Opens configurations for documents that the last analysis pass left without results.\n *\n * @param uris - Document URIs. A document closed in the meantime is skipped.\n * @returns Completion of discovery and buffer replay.\n * @throws If discovery or buffer replay fails.\n */\n const discover = async (uris: readonly string[]) => {\n for (const uri of uris) {\n if (!documents.get(uri)) {\n continue;\n }\n const opened = await options.discoverWorkspace?.(\n uri,\n {\n workspaceFolders: roots,\n initializationOptions,\n },\n new Set([...workspaces.keys(), ...errors.keys()]),\n );\n if (opened) {\n await adopt(opened);\n }\n }\n };\n\n /**\n * Converts one document's analysis results to diagnostics.\n *\n * @param uri - Analyzed document, which receives the note about an incomplete analysis.\n * @param results - Results of each project that analyzed the document.\n * @param add - Receives each diagnostic with the URI of its location.\n */\n const collect = (\n uri: string,\n results: readonly WorkspaceResult[],\n add: (uri: string, diagnostic: Diagnostic) => void,\n ) => {\n for (const entry of results) {\n const source = `stillwind:${entry.config}:${entry.project + 1}`;\n for (const report of entry.result.reports) {\n const location = report.primary.location;\n add(location.uri, {\n range: range(location),\n severity:\n report.severity === \"error\" ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning,\n source,\n code: report.code,\n message: [report.message, ...report.notes].join(\"\\n\"),\n relatedInformation: report.related.map((label) => ({\n location: {\n uri: label.location.uri,\n range: range(label.location),\n },\n message: label.message ?? report.message,\n })),\n });\n }\n if (entry.result.status === \"incomplete\") {\n const missing =\n entry.result.dependencies\n ?.filter(\n (dependency) =>\n dependency.status === \"unresolved\" || dependency.status === \"unsupported\",\n )\n .map(\n (dependency) =>\n `${dependency.status}: ${dependency.specifier} from ${dependency.importer}`,\n ) ?? [];\n add(uri, {\n range: range(),\n severity: entry.result.error ? DiagnosticSeverity.Error : DiagnosticSeverity.Information,\n source,\n code: entry.result.error ? \"SW_HOST\" : \"SW_UNVERIFIED\",\n message: [\n entry.result.error ?? \"Stillwind analysis is incomplete\",\n ...missing,\n ...(entry.result.unverified ?? []).map((item) => `${item.moduleId}: ${item.reason}`),\n ].join(\"\\n\"),\n });\n }\n }\n };\n\n /**\n * Converts workspace errors to diagnostics on their configuration files.\n *\n * @param add - Receives each diagnostic with the URI of its configuration file.\n */\n const collectErrors = (add: (uri: string, diagnostic: Diagnostic) => void) => {\n for (const [file, error] of errors) {\n const uri = options.configurationUri?.(file, roots);\n if (uri) {\n add(uri, {\n range: range(),\n severity: DiagnosticSeverity.Error,\n source: \"stillwind\",\n code: \"SW_HOST\",\n message: error,\n });\n }\n }\n };\n\n /**\n * Logs each new or changed workspace error and forgets errors that ended. The user receives one\n * notification for each identity until its error ends, because the message of a configuration\n * error can change with each edit of the configuration.\n */\n const notifyErrors = () => {\n for (const [file, error] of errors) {\n const message = `${file}: ${error}`;\n if (logged.get(file) !== message) {\n logged.set(file, message);\n connection.console.error(message);\n }\n if (!reported.has(file)) {\n reported.add(file);\n void connection.sendNotification(ShowMessageNotification.type, {\n type: MessageType.Error,\n message: `Stillwind: ${message}`,\n });\n }\n }\n for (const file of reported) {\n if (!errors.has(file)) {\n reported.delete(file);\n logged.delete(file);\n }\n }\n };\n\n /**\n * Sends deduplicated cached diagnostics and workspace errors, then records their document URIs.\n * Empty notifications clear diagnostics for previously published or currently open documents.\n */\n const publish = () => {\n const open = new Map(documents.all().map((document) => [uriKey(document.uri), document.uri]));\n const grouped = new Map<string, Diagnostic[]>();\n const seen = new Set<string>();\n /**\n * Appends a diagnostic only once for its document and complete serialized value.\n *\n * @param reported - Original document URI, in any spelling of that document.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (reported: string, diagnostic: Diagnostic) => {\n const uri = open.get(uriKey(reported)) ?? reported;\n const key = JSON.stringify([uri, diagnostic]);\n if (!seen.has(key)) {\n seen.add(key);\n const list = grouped.get(uri) ?? [];\n list.push(diagnostic);\n grouped.set(uri, list);\n }\n };\n for (const [uri, results] of cache) {\n collect(uri, results, add);\n }\n collectErrors(add);\n notifyErrors();\n // Clients treat spellings of one file as one resource, so a second notification for another\n // spelling would replace the first.\n const targets = new Map(\n [...published, ...grouped.keys(), ...open.values()].map((uri) => [uriKey(uri), uri]),\n );\n for (const uri of targets.values()) {\n void connection.sendDiagnostics({\n uri,\n version: documents.get(uri)?.version,\n diagnostics: grouped.get(uri) ?? [],\n });\n }\n published.clear();\n for (const uri of grouped.keys()) {\n published.add(uri);\n }\n };\n\n /**\n * Analyzes open buffers after queued mutations and publishes only a current, non-stale batch.\n * Service failures become workspace errors. An obsolete or cancelled batch leaves the cache unchanged.\n *\n * @param revision - Control generation captured when analysis was scheduled.\n * @returns Completion of the analysis pass or its early discard.\n */\n const analyze = async (revision: number) => {\n await controls;\n if (shutdown || revision !== generation) {\n return;\n }\n const cancellation = new AbortController();\n active = cancellation;\n const next = new Map<string, WorkspaceResult[]>();\n for (const [file, workspace] of workspaces) {\n try {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n } catch (error) {\n errors.set(file, String(error));\n }\n if (revision !== generation || shutdown) {\n return;\n }\n }\n for (const document of documents.all()) {\n const results: WorkspaceResult[] = [];\n for (const [file, workspace] of workspaces) {\n try {\n results.push(...(await workspace.analyze(document.uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n if (revision !== generation || shutdown) {\n return;\n }\n if (\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n return;\n }\n next.set(document.uri, results);\n }\n if (revision === generation) {\n cache.clear();\n for (const [uri, result] of next) {\n cache.set(uri, result);\n }\n publish();\n discoverUncovered();\n }\n };\n\n /**\n * Starts discovery for documents that the last analysis pass left without results. Each document\n * is passed to discovery once until services reopen.\n */\n const discoverUncovered = () => {\n const uncovered = options.discoverWorkspace\n ? [...cache].flatMap(([uri, results]) => (results.length || discovered.has(uri) ? [] : [uri]))\n : [];\n if (uncovered.length) {\n for (const uri of uncovered) {\n discovered.add(uri);\n }\n control(() => discover(uncovered));\n schedule();\n }\n };\n\n /**\n * Replaces the pending 40 ms timer with an analysis pass for the current control generation. A\n * pull client instead receives a request to pull its documents again, without a pass here.\n */\n const schedule = () => {\n if (timer) {\n clearTimeout(timer);\n }\n if (pull) {\n timer = setTimeout(() => {\n notifyErrors();\n if (pullRefresh) {\n void connection.languages.diagnostics.refresh().catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }\n }, 40);\n return;\n }\n const revision = generation;\n timer = setTimeout(() => {\n void analyze(revision).catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n }, 40);\n };\n\n /**\n * Analyzes one document for a pull request, and retries once after discovery opens a service.\n * Results stay cached until the next control generation. Open documents are prepared together\n * once per generation, because the checker then loads them in one batch.\n *\n * @param uri - Requested document URI.\n * @param token - Client cancellation.\n * @returns Results of each project, or an empty list for a closed document or after shutdown.\n * @throws A `ResponseError` with `RequestCancelled` after client cancellation, or with\n * `ServerCancelled` and `retriggerRequest` after a change makes the analysis obsolete.\n */\n const pullResults = async (uri: string, token: CancellationToken): Promise<WorkspaceResult[]> => {\n for (;;) {\n await controls;\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (shutdown || !documents.get(uri)) {\n return [];\n }\n const cached = cache.get(uri);\n if (cached) {\n return cached;\n }\n const revision = generation;\n const cancellation = new AbortController();\n active = cancellation;\n const subscription = token.onCancellationRequested(() => cancellation.abort());\n const results: WorkspaceResult[] = [];\n try {\n for (const [file, workspace] of workspaces) {\n try {\n if (prepared !== revision) {\n await workspace.prepare?.(\n documents.all().map((document) => document.uri),\n cancellation.signal,\n );\n }\n results.push(...(await workspace.analyze(uri, cancellation.signal)));\n errors.delete(file);\n } catch (error) {\n errors.set(file, String(error));\n }\n }\n } finally {\n subscription.dispose();\n }\n if (shutdown) {\n return [];\n }\n if (token.isCancellationRequested) {\n throw new ResponseError(LSPErrorCodes.RequestCancelled, \"Diagnostics request cancelled\");\n }\n if (\n revision !== generation ||\n results.some(({ result }) => result.status === \"stale\" || result.status === \"cancelled\")\n ) {\n throw new ResponseError<DiagnosticServerCancellationData>(\n LSPErrorCodes.ServerCancelled,\n \"Stillwind analysis became obsolete\",\n { retriggerRequest: true },\n );\n }\n prepared = revision;\n cache.set(uri, results);\n if (results.length || discovered.has(uri) || !options.discoverWorkspace) {\n return results;\n }\n discovered.add(uri);\n control(() => discover([uri]));\n }\n };\n\n /**\n * Answers a pull request with the findings located in one document and in its configuration\n * errors. Findings in other documents appear when the client pulls those documents.\n *\n * @param uri - Requested document URI.\n * @param previous - Report identity that the client retains.\n * @param token - Client cancellation.\n * @returns An unchanged report when the content matches the retained report, otherwise a full one.\n * @throws The errors of `pullResults`.\n */\n const pullDiagnostics = async (\n uri: string,\n previous: string | undefined,\n token: CancellationToken,\n ): Promise<DocumentDiagnosticReport> => {\n const results = await pullResults(uri, token);\n const key = uriKey(uri);\n const items = new Map<string, Diagnostic>();\n /**\n * Keeps a diagnostic only when it belongs to the requested document.\n *\n * @param location - URI of the diagnostic, in any spelling.\n * @param diagnostic - Diagnostic with original LSP positions.\n */\n const add = (location: string, diagnostic: Diagnostic) => {\n if (uriKey(location) === key) {\n items.set(JSON.stringify(diagnostic), diagnostic);\n }\n };\n collect(uri, results, add);\n collectErrors(add);\n notifyErrors();\n const text = [...items.keys()].join(\"\\n\");\n let report = pullReports.get(uri);\n if (report?.text !== text) {\n report = { id: String(++nextReport), text };\n pullReports.set(uri, report);\n }\n return previous === report.id\n ? { kind: \"unchanged\", resultId: report.id }\n : { kind: \"full\", resultId: report.id, items: [...items.values()] };\n };\n\n /**\n * Queries services after queued mutations and checks document versions and source fingerprints.\n * Each distinct query failure is logged once until services reopen. The cancellation subscription\n * is released after the request.\n *\n * @param uri - URI of the open original document.\n * @param request - Editor operation expressed in that document's UTF-16 coordinates.\n * @param token - LSP cancellation forwarded through an AbortSignal.\n * @returns Current project results, or an empty list after changes, cancellation, or failure.\n */\n const query: EditorQuery = async (uri, request, token: CancellationToken) => {\n await controls;\n if (request.kind === \"completion\" || request.kind === \"resolve\") {\n request = {\n ...request,\n registryDirectives,\n snippets,\n };\n }\n const document = documents.get(uri);\n if (!document || shutdown || token.isCancellationRequested) {\n return [];\n }\n const version = document.version;\n const revision = generation;\n const controller = new AbortController();\n const subscription = token.onCancellationRequested(() => controller.abort());\n const results: WorkspaceEditorResult[] = [];\n try {\n for (const workspace of workspaces.values()) {\n if (workspace.query) {\n results.push(...(await workspace.query(uri, request, controller.signal)));\n }\n }\n if (\n token.isCancellationRequested ||\n revision !== generation ||\n documents.get(uri)?.version !== version\n ) {\n return [];\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n return results.filter((entry) => entry.result.revision === fingerprint(document.getText()));\n } catch (error) {\n const message = errorText(error);\n if (!queryFailures.has(message)) {\n queryFailures.add(message);\n connection.console.error(message);\n }\n return [];\n } finally {\n subscription.dispose();\n }\n };\n registerEditorFeatures(connection, documents, query);\n\n connection.onInitialize(async (params: InitializeParams) => {\n initializationOptions = params.initializationOptions;\n registryDirectives = completionRegistrySetting(initializationOptions) ?? false;\n pull = params.capabilities.textDocument?.diagnostic !== undefined;\n pullRefresh = params.capabilities.workspace?.diagnostics?.refreshSupport === true;\n snippets =\n params.capabilities.textDocument?.completion?.completionItem?.snippetSupport === true;\n foldersSupported = params.capabilities.workspace?.workspaceFolders === true;\n dynamicWatch =\n params.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration === true;\n roots =\n params.workspaceFolders?.map((folder) => folder.uri) ??\n (params.rootUri ? [params.rootUri] : []);\n await open(\"initialization\");\n const editor =\n options.discoverWorkspace != null ||\n [...workspaces.values()].some((workspace) => workspace.query != null);\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n codeActionProvider: {\n codeActionKinds: [CodeActionKind.QuickFix, ...(editor ? editorCodeActionKinds : [])],\n },\n ...(pull\n ? {\n diagnosticProvider: {\n identifier: \"stillwind\",\n interFileDependencies: true,\n workspaceDiagnostics: false,\n },\n }\n : {}),\n hoverProvider: editor,\n definitionProvider: editor,\n completionProvider: editor\n ? {\n resolveProvider: true,\n triggerCharacters: [\"@\", \":\", \"-\", \"/\", \"[\", \"(\", \" \"],\n }\n : undefined,\n colorProvider: editor,\n documentLinkProvider: editor\n ? {\n resolveProvider: false,\n }\n : undefined,\n workspace: {\n workspaceFolders: {\n supported: true,\n changeNotifications: true,\n },\n },\n },\n serverInfo: {\n name: \"Stillwind\",\n },\n };\n });\n connection.onInitialized(async () => {\n if (foldersSupported) {\n connection.workspace.onDidChangeWorkspaceFolders(({ added, removed }) => {\n const deleted = new Set(removed.map((folder) => folder.uri));\n roots = [\n ...roots.filter((root) => !deleted.has(root)),\n ...added.map((folder) => folder.uri),\n ];\n control(() => open(\"a workspace folder change\"));\n schedule();\n });\n }\n if (dynamicWatch) {\n await connection.client.register(DidChangeWatchedFilesNotification.type, {\n watchers: [\n {\n globPattern: \"**/*\",\n },\n ],\n });\n }\n schedule();\n });\n documents.onDidChangeContent(({ document }) => {\n control(async () => {\n if (documents.get(document.uri)?.version !== document.version) {\n return;\n }\n for (const workspace of workspaces.values()) {\n await workspace.update(document.uri, document.getText(), document.version);\n }\n });\n if (!pull) {\n schedule();\n }\n });\n documents.onDidClose(({ document }) => {\n pullReports.delete(document.uri);\n control(async () => {\n for (const workspace of workspaces.values()) {\n await workspace.closeDocument(document.uri);\n }\n });\n schedule();\n });\n /**\n * Reopens the workspaces if any service cannot reuse its current buffers after a save or file\n * change. Without services, reopening lets a new or corrected configuration take effect.\n *\n * @param uris - Document URIs from the save or watch notification. The list must not be empty.\n * @param event - Notification kind for the log, such as `save`.\n * @returns Completion of the checks and any required workspace replacement.\n * @throws If a service check or workspace replacement fails.\n */\n const refresh = async (uris: readonly string[], event: string) => {\n const others = uris.length > 1 ? ` and ${uris.length - 1} other files` : \"\";\n const reason = `the ${event} of ${uris[0]}${others}`;\n if (!workspaces.size || (errors.size && uris.some(isConfigurationUri))) {\n await open(reason);\n return;\n }\n for (const workspace of workspaces.values()) {\n if (!(await workspace.refresh?.(uris))) {\n await open(reason);\n break;\n }\n }\n };\n documents.onDidSave(({ document }) => {\n control(() => refresh([document.uri], \"save\"));\n schedule();\n });\n /**\n * Decides whether watched changes need work. Starting that work cancels running analysis, so\n * changes to unrelated files must not reach it.\n *\n * @param uris - Document URIs from the watch notification.\n * @returns True for a configuration file while a service is missing or failed, and when a service\n * reports that the changes affect it. A service without an `affects` check counts as affected.\n * @throws If a service check fails.\n */\n const affected = async (uris: readonly string[]) => {\n if ((!workspaces.size || errors.size) && uris.some(isConfigurationUri)) {\n return true;\n }\n for (const workspace of workspaces.values()) {\n if ((await workspace.affects?.(uris)) ?? true) {\n return true;\n }\n }\n return false;\n };\n connection.onDidChangeWatchedFiles(({ changes }) => {\n const uris = changes.map((change) => change.uri);\n void affected(uris)\n .then((result) => {\n if (result) {\n control(() => refresh(uris, \"change\"));\n schedule();\n }\n })\n .catch((error: unknown) => {\n connection.console.error(errorText(error));\n });\n });\n connection.languages.diagnostics.on((params, token) => {\n const task = pulls.then(() =>\n pullDiagnostics(params.textDocument.uri, params.previousResultId, token),\n );\n pulls = task.then(\n () => undefined,\n () => undefined,\n );\n return task;\n });\n connection.onDidChangeConfiguration(({ settings }) => {\n control(async () => {\n registryDirectives =\n completionRegistrySetting(settings?.stillwind ?? settings) ?? registryDirectives;\n await open(\"a configuration change\");\n });\n schedule();\n });\n connection.onCodeAction(async (params, token) => {\n const document = documents.get(params.textDocument.uri);\n const result: CodeAction[] = document\n ? await sourceActions(document, params.context.only, token, query)\n : [];\n if (\n params.context.only &&\n !params.context.only.some(\n (kind) =>\n CodeActionKind.QuickFix === kind || CodeActionKind.QuickFix.startsWith(`${kind}.`),\n )\n ) {\n return result;\n }\n if (token.isCancellationRequested) {\n return result;\n }\n const { fingerprint } = await import(\"@stillwind/native\");\n if (token.isCancellationRequested) {\n return result;\n }\n for (const entries of cache.values()) {\n for (const entry of entries) {\n for (const report of entry.result.reports) {\n const primary = report.primary.location;\n if (\n uriKey(primary.uri) !== uriKey(params.textDocument.uri) ||\n primary.endLine < params.range.start.line ||\n primary.startLine > params.range.end.line\n ) {\n continue;\n }\n if (\n document &&\n (primary.endUtf16 < document.offsetAt(params.range.start) ||\n primary.startUtf16 > document.offsetAt(params.range.end))\n ) {\n continue;\n }\n for (const action of report.actions) {\n const changes = new Map<string, TextDocumentEdit>();\n let valid = true;\n for (const edit of action.edits) {\n const key = uriKey(edit.location.uri);\n const document = documents.all().find(({ uri }) => uriKey(uri) === key);\n if (!document || fingerprint(document.getText()) !== edit.location.revision) {\n valid = false;\n break;\n }\n const change = changes.get(document.uri) ?? {\n textDocument: {\n uri: document.uri,\n version: document.version,\n },\n edits: [],\n };\n change.edits.push({\n range: range(edit.location),\n newText: edit.replacement,\n });\n changes.set(document.uri, change);\n }\n if (valid && changes.size) {\n result.push({\n title: action.title,\n kind: CodeActionKind.QuickFix,\n edit: {\n documentChanges: [...changes.values()],\n },\n });\n }\n }\n }\n }\n }\n return result.filter(\n (action, index) =>\n result.findIndex((candidate) => JSON.stringify(candidate) === JSON.stringify(action)) ===\n index,\n );\n });\n /**\n * Stops publication and closes all services after the control queue settles.\n *\n * @returns A shared cleanup promise, including on repeated calls.\n * @throws An AggregateError containing every service closure failure.\n */\n const dispose = (): Promise<void> => {\n disposal ??= (async () => {\n shutdown = true;\n active?.abort();\n generation++;\n cache.clear();\n if (timer) {\n clearTimeout(timer);\n }\n await controls;\n const closed = await Promise.allSettled(\n [...workspaces.values()].map((workspace) => workspace.close()),\n );\n workspaces.clear();\n const failed = closed.filter((result) => result.status === \"rejected\");\n if (failed.length) {\n throw new AggregateError(\n failed.map((result) => result.reason),\n \"Failed to close language server analysis services\",\n );\n }\n })();\n return disposal;\n };\n connection.onShutdown(dispose);\n connection.onExit(() => {\n options.onExit?.(shutdown);\n });\n documents.listen(connection);\n return {\n ready: () => controls,\n reload: async () => {\n control(() => open(\"a reload request\"));\n schedule();\n await controls;\n },\n dispose,\n };\n}\n\n/**\n * Creates a comparison key for spellings of one file URI. Editors and Node encode characters and\n * spell Windows drive letters differently, for example `file:///f%3A/a` and `file:///F:/a`.\n *\n * @param uri - Document URI. Do not send the result to a client.\n * @returns The decoded URI with a lowercase drive letter, or the input if it cannot be decoded.\n */\nexport function uriKey(uri: string): string {\n try {\n uri = decodeURIComponent(uri);\n } catch {\n return uri;\n }\n return uri.replace(/^file:\\/\\/\\/[a-z]:/i, (drive) => drive.toLowerCase());\n}\n\n/**\n * Formats an unexpected failure for the log.\n *\n * @param error - Thrown value.\n * @returns The stack trace of an `Error`, which includes its message, or the string form of other\n * values.\n */\nfunction errorText(error: unknown): string {\n return error instanceof Error && error.stack ? error.stack : String(error);\n}\n\n/**\n * Recognizes a Stillwind configuration file by name.\n *\n * @param uri - Document URI.\n * @returns Whether the file name is `stillwind.config` with any extension.\n */\nfunction isConfigurationUri(uri: string): boolean {\n return /\\/stillwind\\.config\\.[^/]+$/.test(uri);\n}\n\n/**\n * Reads the editor-only completion field from initialization options or configuration settings.\n *\n * @param value - A protocol object that may contain `completion.registryDirectives`.\n * @returns The boolean setting, or undefined when the field is absent or invalid.\n */\nfunction completionRegistrySetting(value: unknown): boolean | undefined {\n if (!value || typeof value !== \"object\") {\n return undefined;\n }\n const completion = (value as Record<string, unknown>).completion;\n if (!completion || typeof completion !== \"object\") {\n return undefined;\n }\n const registry = (completion as Record<string, unknown>).registryDirectives;\n return typeof registry === \"boolean\" ? registry : undefined;\n}\n\n/**\n * Copies a native diagnostic location into LSP positions.\n *\n * @param location - Original document positions with zero-based lines and UTF-16 columns.\n * @returns The half-open range, or an empty range at document start when no location is supplied.\n */\nfunction range(location?: {\n /** Zero-based line containing the inclusive start. */\n startLine: number;\n /** UTF-16 column of the inclusive start. */\n startColumn: number;\n /** Zero-based line containing the exclusive end. */\n endLine: number;\n /** UTF-16 column of the exclusive end. */\n endColumn: number;\n}) {\n return {\n start: {\n line: location?.startLine ?? 0,\n character: location?.startColumn ?? 0,\n },\n end: {\n line: location?.endLine ?? 0,\n character: location?.endColumn ?? 0,\n },\n };\n}\n"],"mappings":";;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;AAGnB,MAAa,wBAAwB,CAAC,YAAY,QAAQ;;;;;;;;AAuB1D,SAAgB,uBACd,YACA,WACA,OACM;CACN,WAAW,aAAa,OAAO,QAAQ,UAAU;EAC/C,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa,GAAG;EACtD,IAAI,CAAC,UACH,OAAO,CAAC;EAUV,MAAM,eAAc,MARE,MACpB,SAAS,KACT;GACE,MAAM;GACN,QAAQ,SAAS,SAAS,OAAO,QAAQ;EAC3C,GACA,KACF,EAAA,CAC4B,SAAS,UAAU,MAAM,OAAO,eAAe,CAAC,CAAC;EAC7E,OAAO,YACJ,QACE,YAAY,UACX,YAAY,WAAW,UAAU,KAAK,UAAU,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC,MACrF,KACJ,CAAC,CACA,KAAK,gBAAgB;GACpB,KAAK,WAAW;GAChB,OAAO;IACL,OAAO;KACL,MAAM,WAAW;KACjB,WAAW,WAAW;IACxB;IACA,KAAK;KACH,MAAM,WAAW;KACjB,WAAW,WAAW;IACxB;GACF;EACF,EAAE;CACN,CAAC;CACD,WAAW,gBAAgB,OAAO,QAAQ,UAAU;EAClD,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa,GAAG;EACtD,IAAI,CAAC,UACH,OAAO,CAAC;EASV,MAAM,SAAQ,MAPQ,MACpB,SAAS,KACT,EACE,MAAM,QACR,GACA,KACF,EAAA,CACsB,SAAS,UAAU,MAAM,OAAO,SAAS,CAAC,CAAC;EACjE,OAAO,MACJ,QACE,MAAM,UACL,KAAK,UACL,MAAM,WACH,UACC,MAAM,UAAU,KAAK,SAAS,MAAM,QAAQ,KAAK,OAAO,MAAM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