-
Notifications
You must be signed in to change notification settings - Fork 40.3k
Expand file tree
/
Copy pathvscode.proposed.inlineCompletionsAdditions.d.ts
More file actions
290 lines (235 loc) · 9.15 KB
/
vscode.proposed.inlineCompletionsAdditions.d.ts
File metadata and controls
290 lines (235 loc) · 9.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/124024 @hediet
export namespace languages {
/**
* Registers an inline completion provider.
*
* Multiple providers can be registered for a language. In that case providers are asked in
* parallel and the results are merged. A failing provider (rejected promise or exception) will
* not cause a failure of the whole operation.
*
* @param selector A selector that defines the documents this provider is applicable to.
* @param provider An inline completion provider.
* @param metadata Metadata about the provider.
* @return A {@link Disposable} that unregisters this provider when being disposed.
*/
export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider, metadata: InlineCompletionItemProviderMetadata): Disposable;
/**
* temporary: to be removed
*/
export const inlineCompletionsUnificationState: InlineCompletionsUnificationState;
/**
* temporary: to be removed
*/
export const onDidChangeCompletionsUnificationState: Event<void>;
}
export interface InlineCompletionItem {
// insertText: string | SnippetString | undefined;
/** If set to `true`, this item is treated as inline edit. */
isInlineEdit?: boolean;
/**
* A range specifying when the edit can be shown based on the cursor position.
* If the cursor is within this range, the inline edit can be displayed.
*/
showRange?: Range;
showInlineEditMenu?: boolean;
/**
* If set, specifies where insertText, filterText, range, jumpToPosition apply to.
*/
uri?: Uri;
// TODO: rename to gutterMenuLinkAction
action?: Command;
displayLocation?: InlineCompletionDisplayLocation;
/** Used for telemetry. Can be an arbitrary string. */
correlationId?: string;
/**
* If set to `true`, unopened closing brackets are removed and unclosed opening brackets are closed.
* Defaults to `false`.
*/
completeBracketPairs?: boolean;
warning?: InlineCompletionWarning;
supportsRename?: boolean;
jumpToPosition?: Position;
}
export interface InlineCompletionDisplayLocation {
range: Range;
kind: InlineCompletionDisplayLocationKind;
label: string;
}
export enum InlineCompletionDisplayLocationKind {
Code = 1,
Label = 2
}
export interface InlineCompletionWarning {
message: MarkdownString | string;
icon?: ThemeIcon;
}
export interface InlineCompletionItemProviderMetadata {
/**
* Specifies a list of extension ids that this provider yields to if they return a result.
* If some inline completion provider registered by such an extension returns a result, this provider is not asked.
*/
yieldTo?: string[];
/**
* Can override the extension id for the yieldTo mechanism. Used for testing, so that yieldTo can be tested within one extension.
*/
groupId?: string;
debounceDelayMs?: number;
displayName?: string;
excludes?: string[];
}
export interface InlineCompletionItemProvider {
/**
* @param completionItem The completion item that was shown.
* @param updatedInsertText The actual insert text (after brackets were fixed).
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidShowCompletionItem?(completionItem: InlineCompletionItem, updatedInsertText: string): void;
/**
* Is called when an inline completion item was accepted partially.
* @param info Additional info for the partial accepted trigger.
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidPartiallyAcceptCompletionItem?(completionItem: InlineCompletionItem, info: PartialAcceptInfo): void;
/**
* Is called when an inline completion item is no longer being used.
* Provides a reason of why it is not used anymore.
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleEndOfLifetime?(completionItem: InlineCompletionItem, reason: InlineCompletionEndOfLifeReason): void;
/**
* Is called when an inline completion list is no longer being used (same reference as the list returned by provideInlineEditsForRange).
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleListEndOfLifetime?(list: InlineCompletionList, reason: InlineCompletionsDisposeReason): void;
/**
* Fired when the provider wants to trigger a new completion request.
* Can optionally pass a {@link InlineCompletionChangeHint} which will be
* included in the {@link InlineCompletionContext.changeHint} of the subsequent request.
*/
readonly onDidChange?: Event<InlineCompletionChangeHint | void>;
readonly modelInfo?: InlineCompletionModelInfo;
readonly onDidChangeModelInfo?: Event<void>;
// eslint-disable-next-line local/vscode-dts-provider-naming
setCurrentModelId?(modelId: string): Thenable<void>;
readonly providerOptions?: readonly InlineCompletionProviderOption[];
readonly onDidChangeProviderOptions?: Event<void>;
// eslint-disable-next-line local/vscode-dts-provider-naming
setProviderOptionValue?(optionId: string, valueId: string): Thenable<void>;
// #region Deprecated methods
/**
* Is called when an inline completion item was accepted partially.
* @param acceptedLength The length of the substring of the inline completion that was accepted already.
* @deprecated Use `handleDidPartiallyAcceptCompletionItem` with `PartialAcceptInfo` instead.
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidPartiallyAcceptCompletionItem?(completionItem: InlineCompletionItem, acceptedLength: number): void;
/**
* @param completionItem The completion item that was rejected.
* @deprecated Use {@link handleEndOfLifetime} instead.
*/
// eslint-disable-next-line local/vscode-dts-provider-naming
handleDidRejectCompletionItem?(completionItem: InlineCompletionItem): void;
// #endregion
}
export interface InlineCompletionModelInfo {
readonly models: InlineCompletionModel[];
readonly currentModelId: string;
}
export interface InlineCompletionModel {
readonly id: string;
readonly name: string;
}
export interface InlineCompletionProviderOption {
readonly id: string;
readonly label: string;
readonly values: readonly InlineCompletionProviderOptionValue[];
readonly currentValueId: string;
}
export interface InlineCompletionProviderOptionValue {
readonly id: string;
readonly label: string;
}
export enum InlineCompletionEndOfLifeReasonKind {
Accepted = 0,
Rejected = 1,
Ignored = 2,
}
export type InlineCompletionEndOfLifeReason = {
kind: InlineCompletionEndOfLifeReasonKind.Accepted; // User did an explicit action to accept
} | {
kind: InlineCompletionEndOfLifeReasonKind.Rejected; // User did an explicit action to reject
} | {
kind: InlineCompletionEndOfLifeReasonKind.Ignored;
supersededBy?: InlineCompletionItem;
userTypingDisagreed: boolean;
};
export enum InlineCompletionsDisposeReasonKind {
Other = 0,
Empty = 1,
TokenCancellation = 2,
LostRace = 3,
NotTaken = 4,
}
export type InlineCompletionsDisposeReason = { kind: InlineCompletionsDisposeReasonKind };
/**
* Arbitrary data that the provider can pass when firing {@link InlineCompletionItemProvider.onDidChange}.
* This data is passed back to the provider in {@link InlineCompletionContext.changeHint}.
*/
export interface InlineCompletionChangeHint {
/**
* Arbitrary data that the provider can use to identify what triggered the change.
* This data must be JSON serializable.
*/
readonly data?: unknown;
}
export interface InlineCompletionContext {
readonly userPrompt?: string;
readonly requestUuid: string;
readonly requestIssuedDateTime: number;
readonly earliestShownDateTime: number;
/**
* The change hint that was passed to {@link InlineCompletionItemProvider.onDidChange}.
* Only set if this request was triggered by such an event.
*/
readonly changeHint?: InlineCompletionChangeHint;
}
export interface PartialAcceptInfo {
kind: PartialAcceptTriggerKind;
/**
* The length of the substring of the provided inline completion text that was accepted already.
*/
acceptedLength: number;
}
export enum PartialAcceptTriggerKind {
Unknown = 0,
Word = 1,
Line = 2,
Suggest = 3,
}
// When finalizing `commands`, make sure to add a corresponding constructor parameter.
export interface InlineCompletionList {
/**
* A list of commands associated with the inline completions of this list.
*/
commands?: Array<Command | { command: Command; icon: ThemeIcon }>;
/**
* When set and the user types a suggestion without deviating from it, the inline suggestion is not updated.
* Defaults to false (might change).
*/
enableForwardStability?: boolean;
}
/**
* temporary: to be removed
*/
export interface InlineCompletionsUnificationState {
codeUnification: boolean;
modelUnification: boolean;
extensionUnification: boolean;
expAssignments: string[];
}
}