@adecore/lsp 0.42.0 → 0.44.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/connection.d.ts +1 -0
- package/dist/connection.js +29 -1
- package/dist/document.d.ts +15 -1
- package/dist/document.js +60 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/protocol.d.ts +234 -1
- package/dist/service.d.ts +25 -1
- package/dist/session.d.ts +20 -12
- package/dist/session.js +169 -12
- package/dist/unserved.d.ts +2 -0
- package/dist/unserved.js +53 -0
- package/package.json +1 -1
- package/src/connection.ts +30 -3
- package/src/document.ts +86 -1
- package/src/index.ts +2 -1
- package/src/protocol.ts +225 -1
- package/src/service.ts +55 -0
- package/src/session.ts +221 -18
- package/src/unserved.ts +60 -0
package/dist/connection.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare class JsonRpcConnection {
|
|
|
34
34
|
constructor(transport: LspTransport, timeoutMs?: number);
|
|
35
35
|
get isClosed(): boolean;
|
|
36
36
|
request<T = unknown>(method: string, params?: unknown, options?: RequestOptions): Promise<T>;
|
|
37
|
+
private progressOf;
|
|
37
38
|
notify(method: string, params?: unknown): Promise<void>;
|
|
38
39
|
onRequest(method: string, handler: RequestHandler): Disposable;
|
|
39
40
|
onNotification(method: string, listener: NotificationHandler): Disposable;
|
package/dist/connection.js
CHANGED
|
@@ -66,6 +66,7 @@ export class JsonRpcConnection {
|
|
|
66
66
|
return Promise.reject(cancelledError());
|
|
67
67
|
}
|
|
68
68
|
const id = ++this.nextId;
|
|
69
|
+
const progress = this.progressOf(id, params, options);
|
|
69
70
|
return new Promise((resolve, reject) => {
|
|
70
71
|
let timer;
|
|
71
72
|
const cancel = (error) => {
|
|
@@ -82,6 +83,7 @@ export class JsonRpcConnection {
|
|
|
82
83
|
cleanup: () => {
|
|
83
84
|
clearTimeout(timer);
|
|
84
85
|
options.signal?.removeEventListener('abort', abort);
|
|
86
|
+
progress.listening?.dispose();
|
|
85
87
|
}
|
|
86
88
|
});
|
|
87
89
|
options.signal?.addEventListener('abort', abort, { once: true });
|
|
@@ -89,9 +91,35 @@ export class JsonRpcConnection {
|
|
|
89
91
|
if (timeout > 0) {
|
|
90
92
|
timer = setTimeout(() => cancel(new LspError(`LSP request timed out: ${method}`, ErrorCodes.RequestCancelled)), timeout);
|
|
91
93
|
}
|
|
92
|
-
void this.send({ jsonrpc: '2.0', id, method, params }).catch((error) => this.settle(id, undefined, error));
|
|
94
|
+
void this.send({ jsonrpc: '2.0', id, method, params: progress.params }).catch((error) => this.settle(id, undefined, error));
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
/* Adds the tokens of partial results and work-done progress to the params of a request, and hears `$/progress` for them. */
|
|
98
|
+
progressOf(id, params, options) {
|
|
99
|
+
const { onPartialResult, onWorkDoneProgress } = options;
|
|
100
|
+
if ((onPartialResult === undefined && onWorkDoneProgress === undefined) || params === null || typeof params !== 'object' || Array.isArray(params)) {
|
|
101
|
+
return { params };
|
|
102
|
+
}
|
|
103
|
+
const partialResultToken = onPartialResult === undefined ? undefined : `adecore-partial-${id}`;
|
|
104
|
+
const workDoneToken = onWorkDoneProgress === undefined ? undefined : `adecore-work-${id}`;
|
|
105
|
+
const listening = this.onNotification('$/progress', (value) => {
|
|
106
|
+
const { token, value: report } = value;
|
|
107
|
+
if (token === partialResultToken) {
|
|
108
|
+
onPartialResult?.(report);
|
|
109
|
+
}
|
|
110
|
+
else if (token === workDoneToken) {
|
|
111
|
+
onWorkDoneProgress?.(report);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
params: {
|
|
116
|
+
...params,
|
|
117
|
+
...(partialResultToken === undefined ? {} : { partialResultToken }),
|
|
118
|
+
...(workDoneToken === undefined ? {} : { workDoneToken })
|
|
119
|
+
},
|
|
120
|
+
listening
|
|
121
|
+
};
|
|
122
|
+
}
|
|
95
123
|
notify(method, params) {
|
|
96
124
|
return this.send({ jsonrpc: '2.0', method, params });
|
|
97
125
|
}
|
package/dist/document.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LspSession } from './session.ts';
|
|
2
|
-
import type { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CodeAction, CodeActionContext, CodeLens, Command, CompletionContext, CompletionItem, CompletionResult, ContentChange, DocumentDiagnosticReport, DocumentHighlight, DocumentItem, DocumentRequestOptions, DocumentSymbolResult, FoldingRange, FormattingOptions, Hover, InlayHint, Location, NavigationResult, Position, PrepareRenameResult, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, SignatureHelp, SignatureHelpContext, TextEdit, WorkspaceEdit } from './protocol.ts';
|
|
2
|
+
import type { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CodeAction, CodeActionContext, CodeLens, Color, ColorInformation, ColorPresentation, Command, CompletionContext, CompletionItem, CompletionResult, ContentChange, DocumentDiagnosticReport, DocumentHighlight, DocumentItem, DocumentLink, DocumentRequestOptions, DocumentSymbolResult, FoldingRange, FormattingOptions, Hover, InlayHint, InlineCompletionContext, InlineCompletionResult, InlineValue, InlineValueContext, LinkedEditingRanges, Location, Moniker, NavigationResult, Position, PrepareRenameResult, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, SignatureHelp, SignatureHelpContext, TextDocumentSaveReason, TextEdit, TypeHierarchyItem, WorkspaceEdit } from './protocol.ts';
|
|
3
3
|
export declare class LspDocument {
|
|
4
4
|
readonly session: LspSession;
|
|
5
5
|
readonly uri: string;
|
|
@@ -52,6 +52,20 @@ export declare class LspDocument {
|
|
|
52
52
|
incomingCalls(item: CallHierarchyItem, options?: DocumentRequestOptions): Promise<CallHierarchyIncomingCall[] | null>;
|
|
53
53
|
outgoingCalls(item: CallHierarchyItem, options?: DocumentRequestOptions): Promise<CallHierarchyOutgoingCall[] | null>;
|
|
54
54
|
diagnostics(previousResultId?: string, identifier?: string, options?: DocumentRequestOptions): Promise<DocumentDiagnosticReport>;
|
|
55
|
+
documentLinks(options?: DocumentRequestOptions): Promise<DocumentLink[] | null>;
|
|
56
|
+
resolveDocumentLink(link: DocumentLink, options?: DocumentRequestOptions): Promise<DocumentLink>;
|
|
57
|
+
documentColors(options?: DocumentRequestOptions): Promise<ColorInformation[] | null>;
|
|
58
|
+
colorPresentations(color: Color, range: Range, options?: DocumentRequestOptions): Promise<ColorPresentation[] | null>;
|
|
59
|
+
linkedEditingRanges(position: Position, options?: DocumentRequestOptions): Promise<LinkedEditingRanges | null>;
|
|
60
|
+
monikers(position: Position, options?: DocumentRequestOptions): Promise<Moniker[] | null>;
|
|
61
|
+
prepareTypeHierarchy(position: Position, options?: DocumentRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
62
|
+
supertypes(item: TypeHierarchyItem, options?: DocumentRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
63
|
+
subtypes(item: TypeHierarchyItem, options?: DocumentRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
64
|
+
inlineValues(range: Range, context: InlineValueContext, options?: DocumentRequestOptions): Promise<InlineValue[] | null>;
|
|
65
|
+
inlineCompletions(position: Position, context: InlineCompletionContext, options?: DocumentRequestOptions): Promise<InlineCompletionResult>;
|
|
66
|
+
rangesFormatting(ranges: readonly Range[], formatting: FormattingOptions, options?: DocumentRequestOptions): Promise<TextEdit[] | null>;
|
|
67
|
+
willSave(reason?: TextDocumentSaveReason): Promise<void>;
|
|
68
|
+
willSaveWaitUntil(reason?: TextDocumentSaveReason, options?: DocumentRequestOptions): Promise<TextEdit[] | null>;
|
|
55
69
|
request<T = unknown>(method: string, params: object, options?: DocumentRequestOptions): Promise<T>;
|
|
56
70
|
close(): Promise<void>;
|
|
57
71
|
disconnect(): void;
|
package/dist/document.js
CHANGED
|
@@ -195,6 +195,58 @@ export class LspDocument {
|
|
|
195
195
|
diagnostics(previousResultId, identifier, options) {
|
|
196
196
|
return this.feature('textDocument/diagnostic', { previousResultId, identifier }, options);
|
|
197
197
|
}
|
|
198
|
+
documentLinks(options) {
|
|
199
|
+
return this.feature('textDocument/documentLink', {}, options);
|
|
200
|
+
}
|
|
201
|
+
resolveDocumentLink(link, options) {
|
|
202
|
+
return this.resolve('documentLink/resolve', link, options);
|
|
203
|
+
}
|
|
204
|
+
documentColors(options) {
|
|
205
|
+
return this.feature('textDocument/documentColor', {}, options);
|
|
206
|
+
}
|
|
207
|
+
colorPresentations(color, range, options) {
|
|
208
|
+
return this.feature('textDocument/colorPresentation', { color, range }, options);
|
|
209
|
+
}
|
|
210
|
+
linkedEditingRanges(position, options) {
|
|
211
|
+
return this.feature('textDocument/linkedEditingRange', { position }, options);
|
|
212
|
+
}
|
|
213
|
+
monikers(position, options) {
|
|
214
|
+
return this.feature('textDocument/moniker', { position }, options);
|
|
215
|
+
}
|
|
216
|
+
prepareTypeHierarchy(position, options) {
|
|
217
|
+
return this.feature('textDocument/prepareTypeHierarchy', { position }, options);
|
|
218
|
+
}
|
|
219
|
+
/* Like the calls of a call hierarchy, expansions of the tree run beside each other unless `cancelPrevious` says otherwise. */
|
|
220
|
+
supertypes(item, options) {
|
|
221
|
+
return this.perform('typeHierarchy/supertypes', { item }, { cancelPrevious: false, ...options });
|
|
222
|
+
}
|
|
223
|
+
subtypes(item, options) {
|
|
224
|
+
return this.perform('typeHierarchy/subtypes', { item }, { cancelPrevious: false, ...options });
|
|
225
|
+
}
|
|
226
|
+
inlineValues(range, context, options) {
|
|
227
|
+
return this.feature('textDocument/inlineValue', { range, context }, options);
|
|
228
|
+
}
|
|
229
|
+
inlineCompletions(position, context, options) {
|
|
230
|
+
return this.feature('textDocument/inlineCompletion', { position, context }, options);
|
|
231
|
+
}
|
|
232
|
+
rangesFormatting(ranges, formatting, options) {
|
|
233
|
+
return this.feature('textDocument/rangesFormatting', { ranges: [...ranges], options: formatting }, options);
|
|
234
|
+
}
|
|
235
|
+
/* Tells the server a save is coming, when it asked to hear it. */
|
|
236
|
+
async willSave(reason = 1) {
|
|
237
|
+
this.assertOpen();
|
|
238
|
+
if (this.session.syncOptions.willSave) {
|
|
239
|
+
await this.session.notify('textDocument/willSave', { textDocument: { uri: this.uri }, reason });
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/* The edits the server wants in the text before it is saved, or null when it did not ask to be told. Apply them, then save. */
|
|
243
|
+
async willSaveWaitUntil(reason = 1, options) {
|
|
244
|
+
this.assertOpen();
|
|
245
|
+
if (!this.session.syncOptions.willSaveWaitUntil) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
return this.perform('textDocument/willSaveWaitUntil', { textDocument: { uri: this.uri }, reason }, options);
|
|
249
|
+
}
|
|
198
250
|
/* Any feature by its LSP method, for a caller that gets the method from elsewhere. `params` leave out `textDocument`; a resolve method takes the item. */
|
|
199
251
|
request(method, params, options) {
|
|
200
252
|
return method.endsWith('/resolve') ? this.resolve(method, params, options) : this.feature(method, params, options);
|
|
@@ -257,7 +309,14 @@ export class LspDocument {
|
|
|
257
309
|
this.sendFullText?.();
|
|
258
310
|
await this.synced;
|
|
259
311
|
this.assertCurrent(version);
|
|
260
|
-
const
|
|
312
|
+
const { onPartialResult, onWorkDoneProgress } = options;
|
|
313
|
+
const result = await this.session.request(method, params, {
|
|
314
|
+
signal: controller.signal,
|
|
315
|
+
timeoutMs: options.timeoutMs,
|
|
316
|
+
// A part for a text that moved on is as stale as the answer would be.
|
|
317
|
+
onPartialResult: onPartialResult && ((value) => this.version === version && !this.closed && onPartialResult(value)),
|
|
318
|
+
onWorkDoneProgress
|
|
319
|
+
});
|
|
261
320
|
this.assertCurrent(version);
|
|
262
321
|
this.remember(result, version);
|
|
263
322
|
return result;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export { type CreatedFile, type DeletedFile, type RenamedFile } from './file-ope
|
|
|
7
7
|
export { watchesFile, type FileChangeType } from './watched-files.ts';
|
|
8
8
|
export { LspSession, type LspSessionOptions, type SessionState } from './session.ts';
|
|
9
9
|
export { TextMirror } from './text-mirror.ts';
|
|
10
|
-
export type { DiagnosticsReport, LanguageDocument, LanguageRequestOptions, LanguageService } from './service.ts';
|
|
10
|
+
export type { DiagnosticsReport, LanguageDocument, LanguageRequestOptions, LanguageService, ServerMessage } from './service.ts';
|
|
11
|
+
export { unservedLanguageService } from './unserved.ts';
|
|
11
12
|
export { connectWebSocket, createStreamTransport, type ByteStream, type WebSocketTransportOptions } from './transport.ts';
|
|
12
13
|
export { fileUriToPath, pathToFileUri } from './uris.ts';
|
|
13
14
|
export { bridgeVueTypeScript, vueServerOrder, type VueServer } from './vue.ts';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export {} from './file-operations.js';
|
|
|
7
7
|
export { watchesFile } from './watched-files.js';
|
|
8
8
|
export { LspSession } from './session.js';
|
|
9
9
|
export { TextMirror } from './text-mirror.js';
|
|
10
|
+
export { unservedLanguageService } from './unserved.js';
|
|
10
11
|
export { connectWebSocket, createStreamTransport } from './transport.js';
|
|
11
12
|
export { fileUriToPath, pathToFileUri } from './uris.js';
|
|
12
13
|
export { bridgeVueTypeScript, vueServerOrder } from './vue.js';
|
package/dist/protocol.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface LspTransport {
|
|
|
33
33
|
export interface RequestOptions {
|
|
34
34
|
signal?: AbortSignal;
|
|
35
35
|
timeoutMs?: number;
|
|
36
|
+
onPartialResult?: (value: unknown) => void;
|
|
37
|
+
onWorkDoneProgress?: (progress: WorkDoneProgress) => void;
|
|
36
38
|
}
|
|
37
39
|
export interface DocumentRequestOptions extends RequestOptions {
|
|
38
40
|
cancelPrevious?: boolean;
|
|
@@ -430,6 +432,9 @@ export interface ProviderOptions {
|
|
|
430
432
|
full?: boolean | {
|
|
431
433
|
delta?: boolean;
|
|
432
434
|
};
|
|
435
|
+
rangesSupport?: boolean;
|
|
436
|
+
workspaceDiagnostics?: boolean;
|
|
437
|
+
schemes?: string[];
|
|
433
438
|
[option: string]: unknown;
|
|
434
439
|
}
|
|
435
440
|
export interface TextDocumentSyncOptions {
|
|
@@ -469,7 +474,30 @@ export interface ServerCapabilities {
|
|
|
469
474
|
inlayHintProvider?: boolean | ProviderOptions;
|
|
470
475
|
callHierarchyProvider?: boolean | ProviderOptions;
|
|
471
476
|
documentOnTypeFormattingProvider?: ProviderOptions;
|
|
472
|
-
diagnosticProvider?: ProviderOptions
|
|
477
|
+
diagnosticProvider?: ProviderOptions & {
|
|
478
|
+
interFileDependencies?: boolean;
|
|
479
|
+
workspaceDiagnostics?: boolean;
|
|
480
|
+
};
|
|
481
|
+
documentLinkProvider?: ProviderOptions;
|
|
482
|
+
colorProvider?: boolean | ProviderOptions;
|
|
483
|
+
linkedEditingRangeProvider?: boolean | ProviderOptions;
|
|
484
|
+
monikerProvider?: boolean | ProviderOptions;
|
|
485
|
+
typeHierarchyProvider?: boolean | ProviderOptions;
|
|
486
|
+
inlineValueProvider?: boolean | ProviderOptions;
|
|
487
|
+
inlineCompletionProvider?: boolean | ProviderOptions;
|
|
488
|
+
notebookDocumentSync?: NotebookDocumentSyncOptions;
|
|
489
|
+
workspace?: {
|
|
490
|
+
workspaceFolders?: {
|
|
491
|
+
supported?: boolean;
|
|
492
|
+
changeNotifications?: boolean | string;
|
|
493
|
+
};
|
|
494
|
+
fileOperations?: Partial<Record<FileOperation, {
|
|
495
|
+
filters: FileOperationFilter[];
|
|
496
|
+
}>>;
|
|
497
|
+
textDocumentContent?: {
|
|
498
|
+
schemes: string[];
|
|
499
|
+
};
|
|
500
|
+
};
|
|
473
501
|
[capability: string]: unknown;
|
|
474
502
|
}
|
|
475
503
|
export interface InitializeResult {
|
|
@@ -497,3 +525,208 @@ export interface ProgressParams {
|
|
|
497
525
|
token: string | number;
|
|
498
526
|
value: unknown;
|
|
499
527
|
}
|
|
528
|
+
export type ProgressToken = string | number;
|
|
529
|
+
export type WorkDoneProgress = {
|
|
530
|
+
kind: 'begin';
|
|
531
|
+
title: string;
|
|
532
|
+
cancellable?: boolean;
|
|
533
|
+
message?: string;
|
|
534
|
+
percentage?: number;
|
|
535
|
+
} | {
|
|
536
|
+
kind: 'report';
|
|
537
|
+
cancellable?: boolean;
|
|
538
|
+
message?: string;
|
|
539
|
+
percentage?: number;
|
|
540
|
+
} | {
|
|
541
|
+
kind: 'end';
|
|
542
|
+
message?: string;
|
|
543
|
+
};
|
|
544
|
+
export type TraceValue = 'off' | 'messages' | 'verbose';
|
|
545
|
+
export interface LogTraceParams {
|
|
546
|
+
message: string;
|
|
547
|
+
verbose?: string;
|
|
548
|
+
}
|
|
549
|
+
export type MessageType = 1 | 2 | 3 | 4 | 5;
|
|
550
|
+
export interface ShowMessageParams {
|
|
551
|
+
type: MessageType;
|
|
552
|
+
message: string;
|
|
553
|
+
}
|
|
554
|
+
export interface MessageActionItem {
|
|
555
|
+
title: string;
|
|
556
|
+
[property: string]: unknown;
|
|
557
|
+
}
|
|
558
|
+
export interface ShowMessageRequestParams extends ShowMessageParams {
|
|
559
|
+
actions?: MessageActionItem[];
|
|
560
|
+
}
|
|
561
|
+
export interface LogMessageParams {
|
|
562
|
+
type: MessageType;
|
|
563
|
+
message: string;
|
|
564
|
+
}
|
|
565
|
+
export interface ShowDocumentParams {
|
|
566
|
+
uri: string;
|
|
567
|
+
external?: boolean;
|
|
568
|
+
takeFocus?: boolean;
|
|
569
|
+
selection?: Range;
|
|
570
|
+
}
|
|
571
|
+
export interface ShowDocumentResult {
|
|
572
|
+
success: boolean;
|
|
573
|
+
}
|
|
574
|
+
export interface WorkspaceFoldersChangeEvent {
|
|
575
|
+
added: WorkspaceFolder[];
|
|
576
|
+
removed: WorkspaceFolder[];
|
|
577
|
+
}
|
|
578
|
+
export type TextDocumentSaveReason = 1 | 2 | 3;
|
|
579
|
+
export interface DocumentLink {
|
|
580
|
+
range: Range;
|
|
581
|
+
target?: string;
|
|
582
|
+
tooltip?: string;
|
|
583
|
+
data?: unknown;
|
|
584
|
+
}
|
|
585
|
+
export interface Color {
|
|
586
|
+
red: number;
|
|
587
|
+
green: number;
|
|
588
|
+
blue: number;
|
|
589
|
+
alpha: number;
|
|
590
|
+
}
|
|
591
|
+
export interface ColorInformation {
|
|
592
|
+
range: Range;
|
|
593
|
+
color: Color;
|
|
594
|
+
}
|
|
595
|
+
export interface ColorPresentation {
|
|
596
|
+
label: string;
|
|
597
|
+
textEdit?: TextEdit;
|
|
598
|
+
additionalTextEdits?: TextEdit[];
|
|
599
|
+
}
|
|
600
|
+
export interface LinkedEditingRanges {
|
|
601
|
+
ranges: Range[];
|
|
602
|
+
wordPattern?: string;
|
|
603
|
+
}
|
|
604
|
+
export type UniquenessLevel = 'document' | 'project' | 'group' | 'scheme' | 'global';
|
|
605
|
+
export type MonikerKind = 'import' | 'export' | 'local';
|
|
606
|
+
export interface Moniker {
|
|
607
|
+
scheme: string;
|
|
608
|
+
identifier: string;
|
|
609
|
+
unique: UniquenessLevel;
|
|
610
|
+
kind?: MonikerKind;
|
|
611
|
+
}
|
|
612
|
+
export interface TypeHierarchyItem {
|
|
613
|
+
name: string;
|
|
614
|
+
kind: SymbolKind;
|
|
615
|
+
tags?: 1[];
|
|
616
|
+
detail?: string;
|
|
617
|
+
uri: string;
|
|
618
|
+
range: Range;
|
|
619
|
+
selectionRange: Range;
|
|
620
|
+
data?: unknown;
|
|
621
|
+
}
|
|
622
|
+
export interface InlineValueContext {
|
|
623
|
+
frameId: number;
|
|
624
|
+
stoppedLocation: Range;
|
|
625
|
+
}
|
|
626
|
+
export type InlineValue = {
|
|
627
|
+
range: Range;
|
|
628
|
+
text: string;
|
|
629
|
+
} | {
|
|
630
|
+
range: Range;
|
|
631
|
+
variableName?: string;
|
|
632
|
+
caseSensitiveLookup: boolean;
|
|
633
|
+
} | {
|
|
634
|
+
range: Range;
|
|
635
|
+
expression?: string;
|
|
636
|
+
};
|
|
637
|
+
export interface InlineCompletionContext {
|
|
638
|
+
triggerKind: 1 | 2;
|
|
639
|
+
selectedCompletionInfo?: {
|
|
640
|
+
range: Range;
|
|
641
|
+
text: string;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
export interface InlineCompletionItem {
|
|
645
|
+
insertText: string | {
|
|
646
|
+
kind: 'snippet';
|
|
647
|
+
value: string;
|
|
648
|
+
};
|
|
649
|
+
filterText?: string;
|
|
650
|
+
range?: Range;
|
|
651
|
+
command?: Command;
|
|
652
|
+
}
|
|
653
|
+
export type InlineCompletionResult = InlineCompletionItem[] | {
|
|
654
|
+
items: InlineCompletionItem[];
|
|
655
|
+
} | null;
|
|
656
|
+
export type WorkspaceDocumentDiagnosticReport = {
|
|
657
|
+
kind: 'full';
|
|
658
|
+
uri: string;
|
|
659
|
+
version: number | null;
|
|
660
|
+
resultId?: string;
|
|
661
|
+
items: Diagnostic[];
|
|
662
|
+
} | {
|
|
663
|
+
kind: 'unchanged';
|
|
664
|
+
uri: string;
|
|
665
|
+
version: number | null;
|
|
666
|
+
resultId: string;
|
|
667
|
+
};
|
|
668
|
+
export interface WorkspaceDiagnosticReport {
|
|
669
|
+
items: WorkspaceDocumentDiagnosticReport[];
|
|
670
|
+
}
|
|
671
|
+
export interface PreviousResultId {
|
|
672
|
+
uri: string;
|
|
673
|
+
value: string;
|
|
674
|
+
}
|
|
675
|
+
export interface TextDocumentContentResult {
|
|
676
|
+
text: string;
|
|
677
|
+
}
|
|
678
|
+
export interface NotebookCell {
|
|
679
|
+
kind: 1 | 2;
|
|
680
|
+
document: string;
|
|
681
|
+
metadata?: Record<string, unknown>;
|
|
682
|
+
executionSummary?: {
|
|
683
|
+
executionOrder: number;
|
|
684
|
+
success?: boolean;
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
export interface NotebookDocument {
|
|
688
|
+
uri: string;
|
|
689
|
+
notebookType: string;
|
|
690
|
+
version: number;
|
|
691
|
+
metadata?: Record<string, unknown>;
|
|
692
|
+
cells: NotebookCell[];
|
|
693
|
+
}
|
|
694
|
+
export interface NotebookCellArrayChange {
|
|
695
|
+
start: number;
|
|
696
|
+
deleteCount: number;
|
|
697
|
+
cells?: NotebookCell[];
|
|
698
|
+
}
|
|
699
|
+
export interface NotebookDocumentChangeEvent {
|
|
700
|
+
metadata?: Record<string, unknown>;
|
|
701
|
+
cells?: {
|
|
702
|
+
structure?: {
|
|
703
|
+
array: NotebookCellArrayChange;
|
|
704
|
+
didOpen?: DocumentItem[];
|
|
705
|
+
didClose?: {
|
|
706
|
+
uri: string;
|
|
707
|
+
}[];
|
|
708
|
+
};
|
|
709
|
+
data?: NotebookCell[];
|
|
710
|
+
textContent?: {
|
|
711
|
+
document: {
|
|
712
|
+
uri: string;
|
|
713
|
+
version: number;
|
|
714
|
+
};
|
|
715
|
+
changes: ContentChange[];
|
|
716
|
+
}[];
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
export interface NotebookDocumentFilter {
|
|
720
|
+
notebookType?: string;
|
|
721
|
+
scheme?: string;
|
|
722
|
+
pattern?: string;
|
|
723
|
+
}
|
|
724
|
+
export interface NotebookDocumentSyncOptions {
|
|
725
|
+
notebookSelector: {
|
|
726
|
+
notebook?: string | NotebookDocumentFilter;
|
|
727
|
+
cells?: {
|
|
728
|
+
language: string;
|
|
729
|
+
}[];
|
|
730
|
+
}[];
|
|
731
|
+
save?: boolean;
|
|
732
|
+
}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CodeAction, CodeActionContext, CodeLens, Command, CompletionContext, CompletionItem, CompletionResult, ContentChange, Diagnostic, Disposable, DocumentHighlight, DocumentSymbolResult, FoldingRange, FormattingOptions, Hover, InlayHint, Location, NavigationResult, Position, PrepareRenameResult, ProviderOptions, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, SignatureHelp, SignatureHelpContext, TextEdit, WorkspaceEdit, WorkspaceSymbolResult } from './protocol.ts';
|
|
1
|
+
import type { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CodeAction, CodeActionContext, CodeLens, Color, ColorInformation, ColorPresentation, Command, CompletionContext, CompletionItem, CompletionResult, ContentChange, Diagnostic, Disposable, DocumentHighlight, DocumentLink, DocumentSymbolResult, FoldingRange, FormattingOptions, Hover, InlayHint, InlineCompletionContext, InlineCompletionResult, InlineValue, InlineValueContext, LinkedEditingRanges, Location, MessageType, Moniker, NavigationResult, Position, PrepareRenameResult, PreviousResultId, ProviderOptions, Range, SelectionRange, SemanticTokens, SemanticTokensDelta, ShowDocumentParams, ShowDocumentResult, SignatureHelp, SignatureHelpContext, TextDocumentSaveReason, TextEdit, TypeHierarchyItem, WorkspaceDiagnosticReport, WorkspaceEdit, WorkspaceSymbolResult } from './protocol.ts';
|
|
2
2
|
import type { CreatedFile, DeletedFile } from './file-operations.ts';
|
|
3
3
|
export interface LanguageDocument {
|
|
4
4
|
uri: string;
|
|
@@ -60,4 +60,28 @@ export interface LanguageService {
|
|
|
60
60
|
didDeleteFiles?(files: readonly DeletedFile[]): Promise<void>;
|
|
61
61
|
codeLenses(uri: string, options?: LanguageRequestOptions): Promise<CodeLens[] | null>;
|
|
62
62
|
resolveCodeLens(uri: string, lens: CodeLens, options?: LanguageRequestOptions): Promise<CodeLens>;
|
|
63
|
+
documentLinks?(uri: string, options?: LanguageRequestOptions): Promise<DocumentLink[] | null>;
|
|
64
|
+
resolveDocumentLink?(uri: string, link: DocumentLink, options?: LanguageRequestOptions): Promise<DocumentLink>;
|
|
65
|
+
documentColors?(uri: string, options?: LanguageRequestOptions): Promise<ColorInformation[] | null>;
|
|
66
|
+
colorPresentations?(uri: string, color: Color, range: Range, options?: LanguageRequestOptions): Promise<ColorPresentation[] | null>;
|
|
67
|
+
linkedEditingRanges?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<LinkedEditingRanges | null>;
|
|
68
|
+
monikers?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<Moniker[] | null>;
|
|
69
|
+
prepareTypeHierarchy?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
70
|
+
supertypes?(uri: string, item: TypeHierarchyItem, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
71
|
+
subtypes?(uri: string, item: TypeHierarchyItem, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
|
|
72
|
+
inlineValues?(uri: string, range: Range, context: InlineValueContext, options?: LanguageRequestOptions): Promise<InlineValue[] | null>;
|
|
73
|
+
inlineCompletions?(uri: string, position: Position, context: InlineCompletionContext, options?: LanguageRequestOptions): Promise<InlineCompletionResult>;
|
|
74
|
+
rangesFormatting?(uri: string, ranges: readonly Range[], formatting: FormattingOptions, options?: LanguageRequestOptions): Promise<TextEdit[] | null>;
|
|
75
|
+
willSave?(uri: string, reason?: TextDocumentSaveReason): Promise<void>;
|
|
76
|
+
willSaveWaitUntil?(uri: string, reason?: TextDocumentSaveReason, options?: LanguageRequestOptions): Promise<TextEdit[] | null>;
|
|
77
|
+
workspaceDiagnostics?(uri: string, previousResultIds?: readonly PreviousResultId[], options?: LanguageRequestOptions): Promise<WorkspaceDiagnosticReport>;
|
|
78
|
+
textDocumentContent?(uri: string, options?: LanguageRequestOptions): Promise<string | null>;
|
|
79
|
+
onServerMessage?(listener: (message: ServerMessage) => void): Disposable;
|
|
80
|
+
onShowDocument?(handler: (params: ShowDocumentParams) => Promise<ShowDocumentResult>): Disposable;
|
|
81
|
+
}
|
|
82
|
+
export interface ServerMessage {
|
|
83
|
+
readonly kind: 'show' | 'log';
|
|
84
|
+
readonly type: MessageType;
|
|
85
|
+
readonly message: string;
|
|
86
|
+
readonly source?: string;
|
|
63
87
|
}
|
package/dist/session.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { JsonRpcConnection, type RequestHandler } from './connection.ts';
|
|
|
2
2
|
import { LspDocument } from './document.ts';
|
|
3
3
|
import { type CreatedFile, type DeletedFile, type RenamedFile } from './file-operations.ts';
|
|
4
4
|
import type { ResourceOperationKind } from './workspace-operations.ts';
|
|
5
|
-
import type { ApplyWorkspaceEditParams, ApplyWorkspaceEditResult, Command, ConfigurationItem, Disposable, DocumentItem, FileEvent, FileOperation, FileOperationFilter, FileSystemWatcher, InitializeResult, LspTransport, ProgressParams, ProviderOptions, PublishDiagnosticsParams, RequestOptions, ServerCapabilities, TextDocumentSyncOptions, WorkspaceEdit, WorkspaceFolder, WorkspaceSymbol, WorkspaceSymbolResult } from './protocol.ts';
|
|
5
|
+
import type { ApplyWorkspaceEditParams, ApplyWorkspaceEditResult, Command, ConfigurationItem, Disposable, DocumentItem, FileEvent, FileOperation, FileOperationFilter, FileSystemWatcher, InitializeResult, LogMessageParams, LogTraceParams, LspTransport, MessageActionItem, NotebookDocument, NotebookDocumentChangeEvent, PreviousResultId, ProgressParams, ProgressToken, ProviderOptions, PublishDiagnosticsParams, RequestOptions, ServerCapabilities, ShowDocumentParams, ShowDocumentResult, ShowMessageParams, ShowMessageRequestParams, TextDocumentContentResult, TextDocumentSyncOptions, TraceValue, WorkspaceDiagnosticReport, WorkspaceEdit, WorkspaceFolder, WorkspaceFoldersChangeEvent, WorkspaceSymbol, WorkspaceSymbolResult } from './protocol.ts';
|
|
6
6
|
export type SessionState = 'new' | 'initializing' | 'ready' | 'closing' | 'closed';
|
|
7
7
|
export interface LspSessionOptions {
|
|
8
8
|
rootUri?: string | null;
|
|
@@ -21,17 +21,14 @@ export interface LspSessionOptions {
|
|
|
21
21
|
resourceOperations?: readonly ResourceOperationKind[];
|
|
22
22
|
onConfiguration?: (item: ConfigurationItem) => unknown | Promise<unknown>;
|
|
23
23
|
onApplyEdit?: (params: ApplyWorkspaceEditParams) => ApplyWorkspaceEditResult | Promise<ApplyWorkspaceEditResult>;
|
|
24
|
-
onShowMessage?: (params:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} | null | Promise<{
|
|
33
|
-
title: string;
|
|
34
|
-
} | null>;
|
|
24
|
+
onShowMessage?: (params: ShowMessageRequestParams) => MessageActionItem | null | Promise<MessageActionItem | null>;
|
|
25
|
+
onMessage?: (params: ShowMessageParams) => void;
|
|
26
|
+
onLog?: (params: LogMessageParams) => void;
|
|
27
|
+
onTrace?: (params: LogTraceParams) => void;
|
|
28
|
+
onTelemetry?: (data: unknown) => void;
|
|
29
|
+
onShowDocument?: (params: ShowDocumentParams) => ShowDocumentResult | Promise<ShowDocumentResult>;
|
|
30
|
+
trace?: TraceValue;
|
|
31
|
+
locale?: string;
|
|
35
32
|
}
|
|
36
33
|
export declare class LspSession {
|
|
37
34
|
readonly connection: JsonRpcConnection;
|
|
@@ -46,6 +43,7 @@ export declare class LspSession {
|
|
|
46
43
|
private readonly diagnosticListeners;
|
|
47
44
|
private readonly capabilityListeners;
|
|
48
45
|
private configuration;
|
|
46
|
+
private folders;
|
|
49
47
|
constructor(transport: LspTransport, options?: LspSessionOptions);
|
|
50
48
|
get state(): SessionState;
|
|
51
49
|
get capabilities(): Readonly<ServerCapabilities>;
|
|
@@ -61,6 +59,16 @@ export declare class LspSession {
|
|
|
61
59
|
executeCommand<T = unknown>(command: Command | string, args?: unknown[], options?: RequestOptions): Promise<T>;
|
|
62
60
|
workspaceSymbols(query: string, options?: RequestOptions): Promise<WorkspaceSymbolResult>;
|
|
63
61
|
resolveWorkspaceSymbol(symbol: WorkspaceSymbol, options?: RequestOptions): Promise<WorkspaceSymbol>;
|
|
62
|
+
workspaceDiagnostics(previousResultIds?: readonly PreviousResultId[], identifier?: string, options?: RequestOptions): Promise<WorkspaceDiagnosticReport>;
|
|
63
|
+
textDocumentContent(uri: string, options?: RequestOptions): Promise<TextDocumentContentResult>;
|
|
64
|
+
setTrace(value: TraceValue): Promise<void>;
|
|
65
|
+
cancelWorkDoneProgress(token: ProgressToken): Promise<void>;
|
|
66
|
+
changeWorkspaceFolders(event: WorkspaceFoldersChangeEvent): Promise<void>;
|
|
67
|
+
syncsNotebook(notebook: Pick<NotebookDocument, 'uri' | 'notebookType'>): boolean;
|
|
68
|
+
openNotebook(notebook: NotebookDocument, cellTextDocuments: readonly DocumentItem[]): Promise<void>;
|
|
69
|
+
changeNotebook(notebook: Pick<NotebookDocument, 'uri' | 'notebookType' | 'version'>, change: NotebookDocumentChangeEvent): Promise<void>;
|
|
70
|
+
saveNotebook(notebook: Pick<NotebookDocument, 'uri' | 'notebookType'>): Promise<void>;
|
|
71
|
+
closeNotebook(notebook: Pick<NotebookDocument, 'uri' | 'notebookType'>, cellUris: readonly string[]): Promise<void>;
|
|
64
72
|
setConfiguration(settings: Record<string, unknown>): Promise<void>;
|
|
65
73
|
onRequest(method: string, handler: RequestHandler): Disposable;
|
|
66
74
|
onNotification(method: string, listener: (params: unknown) => void | Promise<void>): Disposable;
|