UNPKG

@stacksjs/dtsx

Version:

A modern, fast .d.ts generation tool, powered by Bun.

318 lines (317 loc) 7.49 kB
/** * Start LSP server on stdio */ export declare function startLSPServer(): void; /** * Create a simple file watcher that emits diagnostics */ export declare function createFileWatcher(server: DtsxLanguageServer, onDiagnostics: (uri: string, diagnostics: Diagnostic[]) => void): (filePath: string) => void; /** * LSP message types */ export declare interface LSPMessage { jsonrpc: '2.0' id?: number | string method?: string params?: unknown result?: unknown error?: LSPError } export declare interface LSPError { code: number message: string data?: unknown } /** * LSP initialization params */ export declare interface InitializeParams { processId: number | null rootUri: string | null capabilities: ClientCapabilities } export declare interface ClientCapabilities { textDocument?: { synchronization?: { dynamicRegistration?: boolean willSave?: boolean didSave?: boolean } hover?: { dynamicRegistration?: boolean contentFormat?: string[] } completion?: { dynamicRegistration?: boolean completionItem?: { snippetSupport?: boolean documentationFormat?: string[] } } definition?: { dynamicRegistration?: boolean } diagnostic?: { dynamicRegistration?: boolean } } workspace?: { workspaceFolders?: boolean configuration?: boolean } } export declare interface ServerCapabilities { textDocumentSync?: number hoverProvider?: boolean completionProvider?: { triggerCharacters?: string[] resolveProvider?: boolean } definitionProvider?: boolean referencesProvider?: boolean renameProvider?: boolean | { prepareProvider?: boolean } documentSymbolProvider?: boolean workspaceSymbolProvider?: boolean codeActionProvider?: boolean | { codeActionKinds?: string[] } signatureHelpProvider?: { triggerCharacters?: string[] retriggerCharacters?: string[] } documentHighlightProvider?: boolean documentFormattingProvider?: boolean diagnosticProvider?: { interFileDependencies: boolean workspaceDiagnostics: boolean } } /** * Text document item */ export declare interface TextDocumentItem { uri: string languageId: string version: number text: string } /** * Position in a text document */ export declare interface Position { line: number character: number } /** * Range in a text document */ export declare interface Range { start: Position end: Position } /** * Diagnostic message */ export declare interface Diagnostic { range: Range severity?: LspDiagnosticSeverity code?: string | number source?: string message: string } /** * Hover response */ export declare interface Hover { contents: string | { kind: string, value: string } range?: Range } /** * Location for go-to-definition */ export declare interface Location { uri: string range: Range } /** * Document symbol */ export declare interface DocumentSymbol { name: string detail?: string kind: SymbolKind range: Range selectionRange: Range children?: DocumentSymbol[] } /** * Workspace symbol */ export declare interface WorkspaceSymbol { name: string kind: SymbolKind location: Location containerName?: string } /** * Code action */ export declare interface CodeAction { title: string kind?: string diagnostics?: Diagnostic[] isPreferred?: boolean edit?: WorkspaceEdit command?: Command } /** * Workspace edit */ export declare interface WorkspaceEdit { changes?: Record<string, TextEdit[]> } /** * Text edit */ export declare interface TextEdit { range: Range newText: string } /** * Command */ export declare interface Command { title: string command: string arguments?: unknown[] } /** * Signature help */ export declare interface SignatureHelp { signatures: SignatureInformation[] activeSignature?: number activeParameter?: number } /** * Signature information */ export declare interface SignatureInformation { label: string documentation?: string | { kind: string, value: string } parameters?: ParameterInformation[] } /** * Parameter information */ export declare interface ParameterInformation { label: string | [number, number] documentation?: string | { kind: string, value: string } } /** * Document highlight */ export declare interface DocumentHighlight { range: Range kind?: DocumentHighlightKind } /** * LSP Server for dtsx */ export declare class DtsxLanguageServer { initialize(params: InitializeParams): { capabilities: ServerCapabilities }; didOpen(params: { textDocument: TextDocumentItem }): void; didChange(params: { textDocument: { uri: string, version: number }, contentChanges: Array<{ text: string }> }): void; didClose(params: { textDocument: { uri: string } }): void; getDiagnostics(uri: string): Diagnostic[]; hover(params: { textDocument: { uri: string }, position: Position }): Hover | null; completion(params: { textDocument: { uri: string }, position: Position }): Array<{ label: string, kind: number, detail?: string, documentation?: string }>; definition(params: { textDocument: { uri: string }, position: Position }): Location | null; references(params: { textDocument: { uri: string }, position: Position, context: { includeDeclaration: boolean } }): Location[]; prepareRename(params: { textDocument: { uri: string }, position: Position }): { range: Range, placeholder: string } | null; rename(params: { textDocument: { uri: string }, position: Position, newName: string }): WorkspaceEdit | null; documentSymbols(params: { textDocument: { uri: string } }): DocumentSymbol[]; workspaceSymbols(params: { query: string }): WorkspaceSymbol[]; codeActions(params: { textDocument: { uri: string }, range: Range, context: { diagnostics: Diagnostic[] } }): CodeAction[]; signatureHelp(params: { textDocument: { uri: string }, position: Position }): SignatureHelp | null; documentHighlight(params: { textDocument: { uri: string }, position: Position }): DocumentHighlight[]; formatting(params: { textDocument: { uri: string }, options: { tabSize: number, insertSpaces: boolean } }): Promise<TextEdit[]>; generateDts(uri: string): string | null; handleMessage(message: LSPMessage): LSPMessage | null; } /** * LSP Diagnostic severity (matches LSP specification) */ export declare enum LspDiagnosticSeverity { Error = 1, Warning = 2, Information = 3, Hint = 4, } /** * Symbol kind enum (LSP spec) */ export declare enum SymbolKind { File = 1, Module = 2, Namespace = 3, Package = 4, Class = 5, Method = 6, Property = 7, Field = 8, Constructor = 9, Enum = 10, Interface = 11, Function = 12, Variable = 13, Constant = 14, String = 15, Number = 16, Boolean = 17, Array = 18, Object = 19, Key = 20, Null = 21, EnumMember = 22, Struct = 23, Event = 24, Operator = 25, TypeParameter = 26, } /** * Completion item kind enum */ export declare enum CompletionItemKind { Text = 1, Method = 2, Function = 3, Constructor = 4, Field = 5, Variable = 6, Class = 7, Interface = 8, Module = 9, Property = 10, Unit = 11, Value = 12, Enum = 13, Keyword = 14, Snippet = 15, Color = 16, File = 17, Reference = 18, Folder = 19, EnumMember = 20, Constant = 21, Struct = 22, Event = 23, Operator = 24, TypeParameter = 25, } /** * Document highlight kind */ export declare enum DocumentHighlightKind { Text = 1, Read = 2, Write = 3, }