Skip to content

Commit 26ecf77

Browse files
authored
feat(types): introduce new completion API for edits suggestion (#635)
## Problem ## Solution <!--- REMINDER: - Read CONTRIBUTING.md first. - Add test coverage for your changes. - Link to related issues/commits. - Testing: how did you test your changes? - Screenshots if applicable --> ## License By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent ec6fefa commit 26ecf77

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {
2+
InlineCompletionItem,
3+
InlineCompletionList,
4+
InlineCompletionParams,
5+
InlineCompletionRegistrationOptions,
6+
} from './lsp'
7+
8+
import { ProtocolRequestType } from 'vscode-languageserver-protocol'
9+
10+
export const editCompletionRequestType = new ProtocolRequestType<
11+
InlineCompletionParams,
12+
InlineCompletionList | InlineCompletionItem[] | null,
13+
InlineCompletionItem[],
14+
void,
15+
InlineCompletionRegistrationOptions
16+
>('aws/textDocument/editCompletion')

runtimes/protocol/lsp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export * from 'vscode-languageserver-protocol'
2828
// Custom Runtimes LSP extensions
2929
export * from './inlineCompletionWithReferences'
3030
export * from './inlineCompletions'
31+
export * from './editCompletions'
3132

3233
// AutoParameterStructuresProtocolRequestType allows ParameterStructures both by-name and by-position
3334
export class AutoParameterStructuresProtocolRequestType<P, R, PR, E, RO>

runtimes/runtimes/base-runtime.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import { getClientInitializeParamsHandlerFactory } from './util/lspCacheUtil'
104104
import { newAgent } from './agent'
105105
import { ShowSaveFileDialogRequestType } from '../protocol/window'
106106
import { joinUnixPaths } from './util/pathUtil'
107+
import { editCompletionRequestType } from '../protocol/editCompletions'
107108

108109
declare const self: WindowOrWorkerGlobalScope
109110

@@ -253,6 +254,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
253254
getClientInitializeParams: getClientInitializeParamsHandlerFactory(lspRouter),
254255
onCompletion: handler => lspConnection.onCompletion(handler),
255256
onInlineCompletion: handler => lspConnection.onRequest(inlineCompletionRequestType, handler),
257+
onEditCompletion: handler => lspConnection.onRequest(editCompletionRequestType, handler),
256258
didChangeConfiguration: lspServer.setDidChangeConfigurationHandler,
257259
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler),
258260
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler),
@@ -289,6 +291,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
289291
onGetConfigurationFromServer: lspServer.setServerConfigurationHandler,
290292
onInlineCompletionWithReferences: handler =>
291293
lspConnection.onRequest(inlineCompletionWithReferencesRequestType, handler),
294+
onEditCompletion: handler => lspConnection.onRequest(editCompletionRequestType, handler),
292295
onLogInlineCompletionSessionResults: handler => {
293296
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
294297
},

runtimes/runtimes/standalone.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import { ShowSaveFileDialogRequestType } from '../protocol/window'
9595
import { getTelemetryReasonDesc } from './util/shared'
9696
import { writeSync } from 'fs'
9797
import { format } from 'util'
98+
import { editCompletionRequestType } from '../protocol/editCompletions'
9899

99100
// Honor shared aws config file
100101
if (checkAWSConfigFile()) {
@@ -379,6 +380,7 @@ export const standalone = (props: RuntimeProps) => {
379380
getClientInitializeParams: getClientInitializeParamsHandlerFactory(lspRouter),
380381
onCompletion: handler => lspConnection.onCompletion(handler),
381382
onInlineCompletion: handler => lspConnection.onRequest(inlineCompletionRequestType, handler),
383+
onEditCompletion: handler => lspConnection.onRequest(editCompletionRequestType, handler),
382384
didChangeConfiguration: lspServer.setDidChangeConfigurationHandler,
383385
onDidFormatDocument: handler => lspConnection.onDocumentFormatting(handler),
384386
onDidOpenTextDocument: handler => documentsObserver.callbacks.onDidOpenTextDocument(handler),
@@ -424,6 +426,7 @@ export const standalone = (props: RuntimeProps) => {
424426
onGetConfigurationFromServer: lspServer.setServerConfigurationHandler,
425427
onInlineCompletionWithReferences: handler =>
426428
lspConnection.onRequest(inlineCompletionWithReferencesRequestType, handler),
429+
onEditCompletion: handler => lspConnection.onRequest(editCompletionRequestType, handler),
427430
onLogInlineCompletionSessionResults: handler => {
428431
lspConnection.onNotification(logInlineCompletionSessionResultsNotificationType, handler)
429432
},

runtimes/server-interface/lsp.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ export type Lsp = {
118118
void
119119
>
120120
) => void
121+
onEditCompletion: (
122+
handler: RequestHandler<
123+
InlineCompletionParams,
124+
InlineCompletionItem[] | InlineCompletionList | undefined | null,
125+
void
126+
>
127+
) => void
121128
onCompletion: (
122129
handler: RequestHandler<CompletionParams, CompletionItem[] | CompletionList | undefined | null, void>
123130
) => void
@@ -163,6 +170,13 @@ export type Lsp = {
163170
void
164171
>
165172
) => void
173+
onEditCompletion: (
174+
handler: RequestHandler<
175+
InlineCompletionWithReferencesParams,
176+
InlineCompletionItemWithReferences[] | InlineCompletionListWithReferences | undefined | null,
177+
void
178+
>
179+
) => void
166180
onLogInlineCompletionSessionResults: (
167181
handler: NotificationHandler<LogInlineCompletionSessionResultsParams>
168182
) => void

0 commit comments

Comments
 (0)