@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/src/protocol.ts CHANGED
@@ -40,6 +40,13 @@ export interface LspTransport {
40
40
  export interface RequestOptions {
41
41
  signal?: AbortSignal;
42
42
  timeoutMs?: number;
43
+ /*
44
+ * Asks the server to stream the result: each part arrives here before the answer, which then holds only what
45
+ * is left, often nothing. The caller joins the parts, since how depends on the method. Needs object params.
46
+ */
47
+ onPartialResult?: (value: unknown) => void;
48
+ /* Asks the server to report the progress of the work under a token of the client. Needs object params. */
49
+ onWorkDoneProgress?: (progress: WorkDoneProgress) => void;
43
50
  }
44
51
 
45
52
  export interface DocumentRequestOptions extends RequestOptions {
@@ -452,6 +459,12 @@ export interface ProviderOptions {
452
459
  filters?: FileOperationFilter[];
453
460
  range?: boolean | object;
454
461
  full?: boolean | { delta?: boolean };
462
+ /* Of a formatting registration: the server formats several ranges in one request. */
463
+ rangesSupport?: boolean;
464
+ /* Of a diagnostic registration: the server answers `workspace/diagnostic`. */
465
+ workspaceDiagnostics?: boolean;
466
+ /* Of a `workspace/textDocumentContent` registration. */
467
+ schemes?: string[];
455
468
  [option: string]: unknown;
456
469
  }
457
470
 
@@ -489,7 +502,20 @@ export interface ServerCapabilities {
489
502
  inlayHintProvider?: boolean | ProviderOptions;
490
503
  callHierarchyProvider?: boolean | ProviderOptions;
491
504
  documentOnTypeFormattingProvider?: ProviderOptions;
492
- diagnosticProvider?: ProviderOptions;
505
+ diagnosticProvider?: ProviderOptions & { interFileDependencies?: boolean; workspaceDiagnostics?: boolean };
506
+ documentLinkProvider?: ProviderOptions;
507
+ colorProvider?: boolean | ProviderOptions;
508
+ linkedEditingRangeProvider?: boolean | ProviderOptions;
509
+ monikerProvider?: boolean | ProviderOptions;
510
+ typeHierarchyProvider?: boolean | ProviderOptions;
511
+ inlineValueProvider?: boolean | ProviderOptions;
512
+ inlineCompletionProvider?: boolean | ProviderOptions;
513
+ notebookDocumentSync?: NotebookDocumentSyncOptions;
514
+ workspace?: {
515
+ workspaceFolders?: { supported?: boolean; changeNotifications?: boolean | string };
516
+ fileOperations?: Partial<Record<FileOperation, { filters: FileOperationFilter[] }>>;
517
+ textDocumentContent?: { schemes: string[] };
518
+ };
493
519
  [capability: string]: unknown;
494
520
  }
495
521
 
@@ -519,3 +545,201 @@ export interface ProgressParams {
519
545
  token: string | number;
520
546
  value: unknown;
521
547
  }
548
+
549
+ export type ProgressToken = string | number;
550
+
551
+ /* The values of `$/progress` for a work-done token: a begin, any number of reports, and an end. */
552
+ export type WorkDoneProgress =
553
+ | { kind: 'begin'; title: string; cancellable?: boolean; message?: string; percentage?: number }
554
+ | { kind: 'report'; cancellable?: boolean; message?: string; percentage?: number }
555
+ | { kind: 'end'; message?: string };
556
+
557
+ export type TraceValue = 'off' | 'messages' | 'verbose';
558
+
559
+ export interface LogTraceParams {
560
+ message: string;
561
+ verbose?: string;
562
+ }
563
+
564
+ /* 1 error, 2 warning, 3 info, 4 log, 5 debug (3.18). */
565
+ export type MessageType = 1 | 2 | 3 | 4 | 5;
566
+
567
+ export interface ShowMessageParams {
568
+ type: MessageType;
569
+ message: string;
570
+ }
571
+
572
+ export interface MessageActionItem {
573
+ title: string;
574
+ [property: string]: unknown;
575
+ }
576
+
577
+ export interface ShowMessageRequestParams extends ShowMessageParams {
578
+ actions?: MessageActionItem[];
579
+ }
580
+
581
+ export interface LogMessageParams {
582
+ type: MessageType;
583
+ message: string;
584
+ }
585
+
586
+ /* A document or a web address a server asks to have shown; `external` opens it outside the editor. */
587
+ export interface ShowDocumentParams {
588
+ uri: string;
589
+ external?: boolean;
590
+ takeFocus?: boolean;
591
+ selection?: Range;
592
+ }
593
+
594
+ export interface ShowDocumentResult {
595
+ success: boolean;
596
+ }
597
+
598
+ export interface WorkspaceFoldersChangeEvent {
599
+ added: WorkspaceFolder[];
600
+ removed: WorkspaceFolder[];
601
+ }
602
+
603
+ /* 1 when a person saved, 2 after a delay, 3 when the editor lost focus. */
604
+ export type TextDocumentSaveReason = 1 | 2 | 3;
605
+
606
+ export interface DocumentLink {
607
+ range: Range;
608
+ target?: string;
609
+ tooltip?: string;
610
+ data?: unknown;
611
+ }
612
+
613
+ /* Each part from 0 to 1. */
614
+ export interface Color {
615
+ red: number;
616
+ green: number;
617
+ blue: number;
618
+ alpha: number;
619
+ }
620
+
621
+ export interface ColorInformation {
622
+ range: Range;
623
+ color: Color;
624
+ }
625
+
626
+ /* One way to write a color: its label is what the picker shows, `textEdit` what replaces the color in the text. */
627
+ export interface ColorPresentation {
628
+ label: string;
629
+ textEdit?: TextEdit;
630
+ additionalTextEdits?: TextEdit[];
631
+ }
632
+
633
+ /* Ranges that are edited together, such as the names of a start and an end tag; `wordPattern` limits what they may become. */
634
+ export interface LinkedEditingRanges {
635
+ ranges: Range[];
636
+ wordPattern?: string;
637
+ }
638
+
639
+ export type UniquenessLevel = 'document' | 'project' | 'group' | 'scheme' | 'global';
640
+ export type MonikerKind = 'import' | 'export' | 'local';
641
+
642
+ export interface Moniker {
643
+ scheme: string;
644
+ identifier: string;
645
+ unique: UniquenessLevel;
646
+ kind?: MonikerKind;
647
+ }
648
+
649
+ /* A class, interface or other type whose super and sub types are traced; `data` goes back to the server untouched. */
650
+ export interface TypeHierarchyItem {
651
+ name: string;
652
+ kind: SymbolKind;
653
+ tags?: 1[];
654
+ detail?: string;
655
+ uri: string;
656
+ range: Range;
657
+ selectionRange: Range;
658
+ data?: unknown;
659
+ }
660
+
661
+ /* Where a debugger stopped, which a server reads inline values for. */
662
+ export interface InlineValueContext {
663
+ frameId: number;
664
+ stoppedLocation: Range;
665
+ }
666
+
667
+ export type InlineValue =
668
+ | { range: Range; text: string }
669
+ | { range: Range; variableName?: string; caseSensitiveLookup: boolean }
670
+ | { range: Range; expression?: string };
671
+
672
+ /* 1 when a person asked, 2 while typing. */
673
+ export interface InlineCompletionContext {
674
+ triggerKind: 1 | 2;
675
+ selectedCompletionInfo?: { range: Range; text: string };
676
+ }
677
+
678
+ export interface InlineCompletionItem {
679
+ insertText: string | { kind: 'snippet'; value: string };
680
+ filterText?: string;
681
+ range?: Range;
682
+ command?: Command;
683
+ }
684
+
685
+ export type InlineCompletionResult = InlineCompletionItem[] | { items: InlineCompletionItem[] } | null;
686
+
687
+ export type WorkspaceDocumentDiagnosticReport =
688
+ | { kind: 'full'; uri: string; version: number | null; resultId?: string; items: Diagnostic[] }
689
+ | { kind: 'unchanged'; uri: string; version: number | null; resultId: string };
690
+
691
+ export interface WorkspaceDiagnosticReport {
692
+ items: WorkspaceDocumentDiagnosticReport[];
693
+ }
694
+
695
+ /* What the client last heard for a document, so the server can answer `unchanged`. */
696
+ export interface PreviousResultId {
697
+ uri: string;
698
+ value: string;
699
+ }
700
+
701
+ export interface TextDocumentContentResult {
702
+ text: string;
703
+ }
704
+
705
+ export interface NotebookCell {
706
+ /* 1 markup, 2 code. */
707
+ kind: 1 | 2;
708
+ document: string;
709
+ metadata?: Record<string, unknown>;
710
+ executionSummary?: { executionOrder: number; success?: boolean };
711
+ }
712
+
713
+ export interface NotebookDocument {
714
+ uri: string;
715
+ notebookType: string;
716
+ version: number;
717
+ metadata?: Record<string, unknown>;
718
+ cells: NotebookCell[];
719
+ }
720
+
721
+ export interface NotebookCellArrayChange {
722
+ start: number;
723
+ deleteCount: number;
724
+ cells?: NotebookCell[];
725
+ }
726
+
727
+ export interface NotebookDocumentChangeEvent {
728
+ metadata?: Record<string, unknown>;
729
+ cells?: {
730
+ structure?: { array: NotebookCellArrayChange; didOpen?: DocumentItem[]; didClose?: { uri: string }[] };
731
+ data?: NotebookCell[];
732
+ textContent?: { document: { uri: string; version: number }; changes: ContentChange[] }[];
733
+ };
734
+ }
735
+
736
+ export interface NotebookDocumentFilter {
737
+ notebookType?: string;
738
+ scheme?: string;
739
+ pattern?: string;
740
+ }
741
+
742
+ export interface NotebookDocumentSyncOptions {
743
+ notebookSelector: { notebook?: string | NotebookDocumentFilter; cells?: { language: string }[] }[];
744
+ save?: boolean;
745
+ }
package/src/service.ts CHANGED
@@ -5,6 +5,9 @@ import type {
5
5
  CodeAction,
6
6
  CodeActionContext,
7
7
  CodeLens,
8
+ Color,
9
+ ColorInformation,
10
+ ColorPresentation,
8
11
  Command,
9
12
  CompletionContext,
10
13
  CompletionItem,
@@ -13,23 +16,37 @@ import type {
13
16
  Diagnostic,
14
17
  Disposable,
15
18
  DocumentHighlight,
19
+ DocumentLink,
16
20
  DocumentSymbolResult,
17
21
  FoldingRange,
18
22
  FormattingOptions,
19
23
  Hover,
20
24
  InlayHint,
25
+ InlineCompletionContext,
26
+ InlineCompletionResult,
27
+ InlineValue,
28
+ InlineValueContext,
29
+ LinkedEditingRanges,
21
30
  Location,
31
+ MessageType,
32
+ Moniker,
22
33
  NavigationResult,
23
34
  Position,
24
35
  PrepareRenameResult,
36
+ PreviousResultId,
25
37
  ProviderOptions,
26
38
  Range,
27
39
  SelectionRange,
28
40
  SemanticTokens,
29
41
  SemanticTokensDelta,
42
+ ShowDocumentParams,
43
+ ShowDocumentResult,
30
44
  SignatureHelp,
31
45
  SignatureHelpContext,
46
+ TextDocumentSaveReason,
32
47
  TextEdit,
48
+ TypeHierarchyItem,
49
+ WorkspaceDiagnosticReport,
33
50
  WorkspaceEdit,
34
51
  WorkspaceSymbolResult
35
52
  } from './protocol.ts';
@@ -128,4 +145,42 @@ export interface LanguageService {
128
145
  didDeleteFiles?(files: readonly DeletedFile[]): Promise<void>;
129
146
  codeLenses(uri: string, options?: LanguageRequestOptions): Promise<CodeLens[] | null>;
130
147
  resolveCodeLens(uri: string, lens: CodeLens, options?: LanguageRequestOptions): Promise<CodeLens>;
148
+
149
+ /*
150
+ * The methods below are optional so a service from before them still fits; `supports(method, uri)` says
151
+ * whether a server answers each. They follow the LSP methods their names point at.
152
+ */
153
+ documentLinks?(uri: string, options?: LanguageRequestOptions): Promise<DocumentLink[] | null>;
154
+ resolveDocumentLink?(uri: string, link: DocumentLink, options?: LanguageRequestOptions): Promise<DocumentLink>;
155
+ documentColors?(uri: string, options?: LanguageRequestOptions): Promise<ColorInformation[] | null>;
156
+ colorPresentations?(uri: string, color: Color, range: Range, options?: LanguageRequestOptions): Promise<ColorPresentation[] | null>;
157
+ linkedEditingRanges?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<LinkedEditingRanges | null>;
158
+ monikers?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<Moniker[] | null>;
159
+ prepareTypeHierarchy?(uri: string, position: Position, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
160
+ /* `uri` is the document the hierarchy was prepared in, which names the server to ask. */
161
+ supertypes?(uri: string, item: TypeHierarchyItem, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
162
+ subtypes?(uri: string, item: TypeHierarchyItem, options?: LanguageRequestOptions): Promise<TypeHierarchyItem[] | null>;
163
+ inlineValues?(uri: string, range: Range, context: InlineValueContext, options?: LanguageRequestOptions): Promise<InlineValue[] | null>;
164
+ inlineCompletions?(uri: string, position: Position, context: InlineCompletionContext, options?: LanguageRequestOptions): Promise<InlineCompletionResult>;
165
+ rangesFormatting?(uri: string, ranges: readonly Range[], formatting: FormattingOptions, options?: LanguageRequestOptions): Promise<TextEdit[] | null>;
166
+ /* Tells the servers a save is coming; `willSaveWaitUntil` answers the edits they want in the text first, null when none asked. */
167
+ willSave?(uri: string, reason?: TextDocumentSaveReason): Promise<void>;
168
+ willSaveWaitUntil?(uri: string, reason?: TextDocumentSaveReason, options?: LanguageRequestOptions): Promise<TextEdit[] | null>;
169
+ /* The diagnostics of every file the server of `uri` knows, the answer for each document a full or an unchanged report. */
170
+ workspaceDiagnostics?(uri: string, previousResultIds?: readonly PreviousResultId[], options?: LanguageRequestOptions): Promise<WorkspaceDiagnosticReport>;
171
+ /* The text of a document of a scheme a server owns, such as a decompiled class; null when no server serves the scheme. */
172
+ textDocumentContent?(uri: string, options?: LanguageRequestOptions): Promise<string | null>;
173
+ /* What the servers want a person to read or have logged (`window/showMessage`, `window/logMessage`). */
174
+ onServerMessage?(listener: (message: ServerMessage) => void): Disposable;
175
+ /* Answers `window/showDocument`: the handler shows the document or web address and says whether it did. One handler at a time. */
176
+ onShowDocument?(handler: (params: ShowDocumentParams) => Promise<ShowDocumentResult>): Disposable;
177
+ }
178
+
179
+ /* A message of a server: one to show a person, or a line for its log. */
180
+ export interface ServerMessage {
181
+ readonly kind: 'show' | 'log';
182
+ readonly type: MessageType;
183
+ readonly message: string;
184
+ /* The server that sent it, as the service names servers. */
185
+ readonly source?: string;
131
186
  }