From d61638e6efba3c61dd30c3d91eb06279a1cb87ac Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 15 Feb 2023 20:10:21 +0100 Subject: [PATCH 1/8] Add support for textdocument/inlineCompletions --- client-node-tests/src/converter.test.ts | 20 ++ client-node-tests/src/integration.test.ts | 22 ++ client-node-tests/src/servers/testServer.ts | 9 +- client/package-lock.json | 16 +- client/package.json | 4 +- client/src/common/client.ts | 10 +- client/src/common/codeConverter.ts | 10 +- client/src/common/inlineCompletion.ts | 80 +++++ client/src/common/protocolConverter.ts | 46 ++- client/src/node/main.ts | 2 +- protocol/metaModel.json | 309 ++++++++++++++++-- .../src/common/protocol.inlineCompletion.ts | 65 ++++ protocol/src/common/protocol.ts | 20 +- server/src/common/inlineCompletion.ts | 39 +++ server/src/common/server.ts | 7 +- types/src/main.ts | 119 +++++++ 16 files changed, 733 insertions(+), 45 deletions(-) create mode 100644 client/src/common/inlineCompletion.ts create mode 100644 protocol/src/common/protocol.inlineCompletion.ts create mode 100644 server/src/common/inlineCompletion.ts diff --git a/client-node-tests/src/converter.test.ts b/client-node-tests/src/converter.test.ts index a4354d1ff..01f65cd3a 100644 --- a/client-node-tests/src/converter.test.ts +++ b/client-node-tests/src/converter.test.ts @@ -1244,6 +1244,26 @@ suite('Protocol Converter', () => { strictEqual((result[1] as ProtocolInlayHint).data, '2'); }); + test('InlineCompletions', async () => { + const items: proto.InlineCompletionItem[] = [ + proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7)), + proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined, proto.InsertTextFormat.PlainText), + proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined, proto.InsertTextFormat.Snippet), + ]; + + const result = await p2c.asInlineCompletionResult(items); + ok(result.every((r) => r.range instanceof vscode.InlineCompletionItem)); + for (const r of result) { + rangeEqual(r.range!, proto.Range.create(1, 2, 6, 7)); + } + + ok(result[0] instanceof vscode.InlineCompletionItem && result[0].insertText === 'insert text'); + ok(result[0] instanceof vscode.InlineCompletionItem && result[0].filterText === 'in'); + ok(typeof result[0].insertText === 'string'); + ok(typeof result[1].insertText === 'string'); + ok(result[2].insertText instanceof vscode.SnippetString); + }); + test('Bug #361', () => { const item: proto.CompletionItem = { 'label': 'MyLabel', diff --git a/client-node-tests/src/integration.test.ts b/client-node-tests/src/integration.test.ts index 59818806d..962405ca3 100644 --- a/client-node-tests/src/integration.test.ts +++ b/client-node-tests/src/integration.test.ts @@ -273,6 +273,7 @@ suite('Client integration', () => { delta: true } }, + inlineCompletionProvider: {}, workspace: { fileOperations: { didCreate: { filters: [{ scheme: fsProvider.scheme, pattern: { glob: '**/created-static/**{/,/*.txt}' } }] }, @@ -1445,6 +1446,27 @@ suite('Client integration', () => { assert.strictEqual(edit.newText, 'number'); }); + test('Inline Completions', async () => { + const providerData = client.getFeature(lsclient.InlineCompletionRequest.method).getProvider(document); + isDefined(providerData); + const results = (await providerData.provideInlineCompletionItems(document, position, { triggerKind: 1, selectedCompletionInfo: {range, text: 'text'} }, tokenSource.token)) as vscode.InlineCompletionItem[]; + + isArray(results, vscode.InlineCompletionItem, 1); + + rangeEqual(results[0].range!, 1, 2, 3, 4); + assert.strictEqual(results[0].filterText!, 'te'); + assert.strictEqual(results[0].insertText, 'text inline'); + + let middlewareCalled: boolean = false; + middleware.provideInlineCompletionItems = (d, r, c, t, n) => { + middlewareCalled = true; + return n(d, r, c, t); + }; + await providerData.provideInlineCompletionItems(document, position, { triggerKind: 0, selectedCompletionInfo: undefined }, tokenSource.token); + middleware.provideInlineCompletionItems = undefined; + assert.strictEqual(middlewareCalled, true); + }); + test('Workspace symbols', async () => { const providers = client.getFeature(lsclient.WorkspaceSymbolRequest.method).getProviders(); isDefined(providers); diff --git a/client-node-tests/src/servers/testServer.ts b/client-node-tests/src/servers/testServer.ts index 6feb0b56b..57ab4d9ff 100644 --- a/client-node-tests/src/servers/testServer.ts +++ b/client-node-tests/src/servers/testServer.ts @@ -11,7 +11,7 @@ import { ColorInformation, Color, ColorPresentation, FoldingRange, SelectionRange, SymbolKind, ProtocolRequestType, WorkDoneProgress, InlineValueText, InlineValueVariableLookup, InlineValueEvaluatableExpression, WorkDoneProgressCreateRequest, WillCreateFilesRequest, WillRenameFilesRequest, WillDeleteFilesRequest, DidDeleteFilesNotification, DidRenameFilesNotification, DidCreateFilesNotification, - ProposedFeatures, Diagnostic, DiagnosticSeverity, TypeHierarchyItem, InlayHint, InlayHintLabelPart, InlayHintKind, DocumentDiagnosticReportKind, DocumentSymbol + ProposedFeatures, Diagnostic, DiagnosticSeverity, TypeHierarchyItem, InlayHint, InlayHintLabelPart, InlayHintKind, DocumentDiagnosticReportKind, DocumentSymbol, InlineCompletionItem } from 'vscode-languageserver/node'; import { URI } from 'vscode-uri'; @@ -105,6 +105,7 @@ connection.onInitialize((params: InitializeParams): any => { delta: true } }, + inlineCompletionProvider: {}, workspace: { fileOperations: { // Static reg is folders + .txt files with operation kind in the path @@ -513,6 +514,12 @@ connection.languages.inlayHint.resolve((hint) => { return hint; }); +connection.languages.inlineCompletion.on((_params) => { + return [ + InlineCompletionItem.create('text inline', 'te', Range.create(1,2,3,4)) + ]; +}); + connection.onRequest( new ProtocolRequestType('testing/sendSampleProgress'), async (_, __) => { diff --git a/client/package-lock.json b/client/package-lock.json index 4e27725ef..0b2ea52aa 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -16,11 +16,11 @@ "devDependencies": { "@types/minimatch": "^3.0.5", "@types/semver": "^7.3.10", - "@types/vscode": "1.67.0", + "@types/vscode": "1.68.0", "shx": "^0.3.4" }, "engines": { - "vscode": "^1.67.0" + "vscode": "^1.68.0" } }, "node_modules/@types/minimatch": { @@ -36,9 +36,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.67.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.67.0.tgz", - "integrity": "sha512-GH8BDf8cw9AC9080uneJfulhSa7KHSMI2s/CyKePXoGNos9J486w2V4YKoeNUqIEkW4hKoEAWp6/cXTwyGj47g==", + "version": "1.68.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", + "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", "dev": true }, "node_modules/balanced-match": { @@ -335,9 +335,9 @@ "dev": true }, "@types/vscode": { - "version": "1.67.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.67.0.tgz", - "integrity": "sha512-GH8BDf8cw9AC9080uneJfulhSa7KHSMI2s/CyKePXoGNos9J486w2V4YKoeNUqIEkW4hKoEAWp6/cXTwyGj47g==", + "version": "1.68.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", + "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", "dev": true }, "balanced-match": { diff --git a/client/package.json b/client/package.json index efe0d80cc..6a16b2326 100644 --- a/client/package.json +++ b/client/package.json @@ -5,7 +5,7 @@ "author": "Microsoft Corporation", "license": "MIT", "engines": { - "vscode": "^1.67.0" + "vscode": "^1.68.0" }, "repository": { "type": "git", @@ -24,7 +24,7 @@ "devDependencies": { "@types/minimatch": "^3.0.5", "@types/semver": "^7.3.10", - "@types/vscode": "1.67.0", + "@types/vscode": "1.68.0", "shx": "^0.3.4" }, "dependencies": { diff --git a/client/src/common/client.ts b/client/src/common/client.ts index 2d85843bd..273b46a9c 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -11,7 +11,7 @@ import { DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, - ProviderResult, TextEdit as VTextEdit + ProviderResult, TextEdit as VTextEdit, InlineCompletionItemProvider } from 'vscode'; import { @@ -36,7 +36,7 @@ import { TypeHierarchyPrepareRequest, InlineValueRequest, InlayHintRequest, WorkspaceSymbolRequest, TextDocumentRegistrationOptions, FileOperationRegistrationOptions, ConnectionOptions, PositionEncodingKind, DocumentDiagnosticRequest, NotebookDocumentSyncRegistrationType, NotebookDocumentSyncRegistrationOptions, ErrorCodes, MessageStrategy, DidOpenTextDocumentParams, CodeLensResolveRequest, CompletionResolveRequest, CodeActionResolveRequest, InlayHintResolveRequest, DocumentLinkResolveRequest, WorkspaceSymbolResolveRequest, - CancellationToken as ProtocolCancellationToken + CancellationToken as ProtocolCancellationToken, InlineCompletionRequest, InlineCompletionRegistrationOptions } from 'vscode-languageserver-protocol'; import * as c2p from './codeConverter'; @@ -90,6 +90,7 @@ import { InlineValueMiddleware, InlineValueProviderShape } from './inlineValue'; import { InlayHintsMiddleware, InlayHintsProviderShape } from './inlayHint'; import { WorkspaceFolderMiddleware } from './workspaceFolder'; import { FileOperationsMiddleware } from './fileOperations'; +import { InlineCompletionMiddleware } from './inlineCompletion'; import { FileSystemWatcherFeature } from './fileSystemWatcher'; import { ColorProviderFeature } from './colorProvider'; import { ImplementationFeature } from './implementation'; @@ -106,6 +107,7 @@ import { LinkedEditingFeature } from './linkedEditingRange'; import { TypeHierarchyFeature } from './typeHierarchy'; import { InlineValueFeature } from './inlineValue'; import { InlayHintsFeature } from './inlayHint'; +import { InlineCompletionItemFeature } from './inlineCompletion'; /** * Controls when the output channel is revealed. @@ -346,7 +348,7 @@ export type Middleware = _Middleware & TextDocumentSynchronizationMiddleware & C DocumentHighlightMiddleware & DocumentSymbolMiddleware & WorkspaceSymbolMiddleware & ReferencesMiddleware & TypeDefinitionMiddleware & ImplementationMiddleware & ColorProviderMiddleware & CodeActionMiddleware & CodeLensMiddleware & FormattingMiddleware & RenameMiddleware & DocumentLinkMiddleware & ExecuteCommandMiddleware & FoldingRangeProviderMiddleware & DeclarationMiddleware & SelectionRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware & -LinkedEditingRangeMiddleware & TypeHierarchyMiddleware & InlineValueMiddleware & InlayHintsMiddleware & NotebookDocumentMiddleware & DiagnosticProviderMiddleware & GeneralMiddleware; +LinkedEditingRangeMiddleware & TypeHierarchyMiddleware & InlineValueMiddleware & InlayHintsMiddleware & NotebookDocumentMiddleware & DiagnosticProviderMiddleware & InlineCompletionMiddleware & GeneralMiddleware; export type LanguageClientOptions = { documentSelector?: DocumentSelector | string[]; @@ -1734,6 +1736,7 @@ export abstract class BaseLanguageClient implements FeatureClient & WorkspaceProviderFeature; getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature & TextDocumentProviderFeature | undefined; getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature & NotebookDocumentProviderShape | undefined; + getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature & TextDocumentProviderFeature; public getFeature(request: string): DynamicFeature | undefined { return this._dynamicFeatures.get(request); } @@ -1803,6 +1806,7 @@ export abstract class BaseLanguageClient implements FeatureClient; +} + +export interface InlineCompletionMiddleware { + provideInlineCompletionItems?: (this: void, document: TextDocument, position: VPosition, context: VInlineCompletionContext, token: CancellationToken, next: ProvideInlineCompletionItemsSignature) => ProviderResult; +} + +export type InlineCompletionProviderShape = { + provider: InlineCompletionItemProvider; +}; + +export class InlineCompletionItemFeature extends TextDocumentLanguageFeature { + + constructor(client: FeatureClient) { + super(client, InlineCompletionRequest.type); + } + + public fillClientCapabilities(capabilities: ClientCapabilities): void { + let inlineCompletion = ensure(ensure(capabilities, 'textDocument')!, 'inlineCompletion')!; + inlineCompletion.dynamicRegistration = true; + } + + public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void { + const options = this.getRegistrationOptions(documentSelector, capabilities.inlineCompletionProvider); + if (!options) { + return; + } + + this.register({ + id: UUID.generateUuid(), + registerOptions: options + }); + } + + protected registerLanguageProvider(options: InlineCompletionRegistrationOptions): [Disposable, InlineCompletionItemProvider] { + const selector = options.documentSelector!; + const provider: InlineCompletionItemProvider = { + provideInlineCompletionItems: (document: TextDocument, position: VPosition, context: VInlineCompletionContext, token: CancellationToken): ProviderResult => { + const client = this._client; + const middleware = this._client.middleware; + const provideInlineCompletionItems: ProvideInlineCompletionItemsSignature = (document, position, context, token) => { + return client.sendRequest(InlineCompletionRequest.type, client.code2ProtocolConverter.asInlineCompletionParams(document, position, context), token).then((result) => { + if (token.isCancellationRequested) { + return null; + } + return client.protocol2CodeConverter.asInlineCompletionResult(result, token); + }, (error) => { + return client.handleFailedRequest(InlineCompletionRequest.type, token, error, null); + }); + }; + return middleware.provideInlineCompletionItems + ? middleware.provideInlineCompletionItems(document, position, context, token, provideInlineCompletionItems) + : provideInlineCompletionItems(document, position, context, token); + } + }; + return [Languages.registerInlineCompletionItemProvider(this._client.protocol2CodeConverter.asDocumentSelector(selector), provider), provider]; + } +} \ No newline at end of file diff --git a/client/src/common/protocolConverter.ts b/client/src/common/protocolConverter.ts index 0fce53ee2..fd1d9f54d 100644 --- a/client/src/common/protocolConverter.ts +++ b/client/src/common/protocolConverter.ts @@ -247,6 +247,13 @@ export interface Converter { asTypeHierarchyItems(items: ls.TypeHierarchyItem[] | null, token?: code.CancellationToken): Promise; asGlobPattern(pattern: ls.GlobPattern): code.GlobPattern | undefined; + + asInlineCompletionResult(value: undefined | null, token?: code.CancellationToken): Promise; + asInlineCompletionResult(value: ls.InlineCompletionList, token?: code.CancellationToken): Promise; + asInlineCompletionResult(value: ls.InlineCompletionItem[], token?: code.CancellationToken): Promise; + asInlineCompletionResult(value: ls.InlineCompletionItem[] | ls.InlineCompletionList | undefined | null, token?: code.CancellationToken): Promise; + + asInlineCompletionItem(item: ls.InlineCompletionItem): code.InlineCompletionItem; } export interface URIConverter { @@ -1420,6 +1427,41 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar return undefined; } + function asInlineCompletionResult(value: undefined | null, token?: code.CancellationToken): Promise; + function asInlineCompletionResult(value: ls.InlineCompletionList, token?: code.CancellationToken): Promise; + function asInlineCompletionResult(value: ls.InlineCompletionItem[], token?: code.CancellationToken): Promise; + function asInlineCompletionResult(value: ls.InlineCompletionItem[] | ls.InlineCompletionList | undefined | null, token?: code.CancellationToken): Promise; + async function asInlineCompletionResult(value: ls.InlineCompletionItem[] | ls.InlineCompletionList | undefined | null, token?: code.CancellationToken): Promise { + if (!value) { + return undefined; + } + if (Array.isArray(value)) { + return async.map(value, (item) => asInlineCompletionItem(item), token); + } + const list = value; + const converted = await async.map(list.items, (item) => { + return asInlineCompletionItem(item); + }, token); + return new code.InlineCompletionList(converted); + } + + function asInlineCompletionItem(item: ls.InlineCompletionItem): code.InlineCompletionItem { + let insertText: string | code.SnippetString; + if (item.insertTextFormat === ls.InsertTextFormat.Snippet) { + insertText = new code.SnippetString(item.insertText); + } else { + insertText = item.insertText; + } + + let command: code.Command | undefined = undefined; + if (item.command) {command = asCommand(item.command);} + + const inlineCompletionItem = new code.InlineCompletionItem(insertText, asRange(item.range), command); + + if (item.filterText) {inlineCompletionItem.filterText = item.filterText;} + + return inlineCompletionItem; + } return { asUri, @@ -1493,6 +1535,8 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar asLinkedEditingRanges: asLinkedEditingRanges, asTypeHierarchyItem, asTypeHierarchyItems, - asGlobPattern + asGlobPattern, + asInlineCompletionResult, + asInlineCompletionItem }; } diff --git a/client/src/node/main.ts b/client/src/node/main.ts index d4a6ed35f..dac300f3a 100644 --- a/client/src/node/main.ts +++ b/client/src/node/main.ts @@ -23,7 +23,7 @@ import semverSatisfies = require('semver/functions/satisfies'); export * from 'vscode-languageserver-protocol/node'; export * from '../common/api'; -const REQUIRED_VSCODE_VERSION = '^1.67.0'; // do not change format, updated by `updateVSCode` script +const REQUIRED_VSCODE_VERSION = '^1.68.0'; // do not change format, updated by `updateVSCode` script export enum TransportKind { stdio, diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 52f71da3a..52a0338ca 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -1,6 +1,6 @@ { "metaData": { - "version": "3.17.0" + "version": "3.18.0" }, "requests": [ { @@ -566,7 +566,7 @@ "kind": "reference", "name": "ShowDocumentParams" }, - "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", + "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example, a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", "since": "3.16.0" }, { @@ -846,6 +846,40 @@ "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "method": "textDocument/inlineCompletion", + "result": { + "kind": "or", + "items": [ + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + { + "kind": "reference", + "name": "InlineCompletionList" + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineCompletionParams" + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineCompletionRegistrationOptions" + }, + "documentation": "The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing.", + "since": "3.18.0" + }, { "method": "workspace/inlineValue/refresh", "result": { @@ -1633,7 +1667,7 @@ "kind": "reference", "name": "DocumentFormattingRegistrationOptions" }, - "documentation": "A request to to format a whole document." + "documentation": "A request to format a whole document." }, { "method": "textDocument/rangeFormatting", @@ -1662,7 +1696,7 @@ "kind": "reference", "name": "DocumentRangeFormattingRegistrationOptions" }, - "documentation": "A request to to format a range in a document." + "documentation": "A request to format a range in a document." }, { "method": "textDocument/onTypeFormatting", @@ -3070,7 +3104,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Indicates to show the resource in an external program.\nTo show for example `https://code.visualstudio.com/`\nin the default WEB browser set `external` to `true`." + "documentation": "Indicates to show the resource in an external program.\nTo show, for example, `https://code.visualstudio.com/`\nin the default WEB browser set `external` to `true`." }, { "name": "takeFocus", @@ -3259,7 +3293,7 @@ "since": "3.16.0" } ], - "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit for example can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" + "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit, for example, can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" }, { "name": "FileOperationRegistrationOptions", @@ -3344,7 +3378,7 @@ "kind": "base", "name": "string" }, - "documentation": "The scheme of the moniker. For example tsc or .Net" + "documentation": "The scheme of the moniker. For example, `tsc` or `.Net`" }, { "name": "identifier", @@ -4639,7 +4673,7 @@ "name": "string" }, "optional": true, - "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." + "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example,\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." }, { "name": "insertTextFormat", @@ -4699,7 +4733,7 @@ } }, "optional": true, - "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." + "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example, adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." }, { "name": "commitCharacters", @@ -5991,7 +6025,7 @@ "name": "string" }, "optional": true, - "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface for example on an undo\nstack to undo the workspace edit." + "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface, for example, on an undo\nstack to undo the workspace edit." }, { "name": "edit", @@ -6002,7 +6036,7 @@ "documentation": "The edits to apply." } ], - "documentation": "The parameters passed via a apply workspace edit request." + "documentation": "The parameters passed via an apply workspace edit request." }, { "name": "ApplyWorkspaceEditResult", @@ -6140,7 +6174,7 @@ "name": "string" }, "optional": true, - "documentation": "Optional, a final message indicating to for example indicate the outcome\nof the operation." + "documentation": "Optional, a final message indicating to, for example, indicate the outcome\nof the operation." } ] }, @@ -6295,7 +6329,7 @@ "kind": "reference", "name": "Range" }, - "documentation": "The full target range of this link. If the target for example is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." + "documentation": "The full target range of this link. If the target, for example, is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." }, { "name": "targetSelectionRange", @@ -7623,7 +7657,7 @@ "documentation": "Options necessary for the registration." } ], - "documentation": "General parameters to to register for an notification or to register a provider." + "documentation": "General parameters to register for a notification or to register a provider." }, { "name": "Unregistration", @@ -8438,6 +8472,25 @@ }, "optional": true, "documentation": "Experimental server capabilities." + }, + { + "name": "InlineCompletionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ] + }, + "optional": true, + "documentation": "The server provides inline completions.", + "since": "3.18.0" } ], "documentation": "Defines the capabilities provided by a language\nserver." @@ -8717,7 +8770,7 @@ } }, "optional": true, - "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example `.` in JavaScript) list them in `triggerCharacters`." + "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example, if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example, `.` in JavaScript) list them in `triggerCharacters`." }, { "name": "allCommitCharacters", @@ -10606,6 +10659,16 @@ "optional": true, "documentation": "Capabilities specific to the diagnostic pull model.\n\n@since 3.17.0", "since": "3.17.0" + }, + { + "name": "inlineCompletion", + "type": { + "kind": "reference", + "name": "InlineCompletionClientCapabilities" + }, + "optional": true, + "documentation": "Capabilities specific to the `textDocument/inlineCompletion` request.", + "since": "3.18.0" } ], "documentation": "Text document specific client capabilities." @@ -10984,7 +11047,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server for example detects a project\nwide change that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server, for example, detects a project\nwide change that requires such a calculation." } ], "documentation": "@since 3.16.0", @@ -11000,7 +11063,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detect a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server, for example, detect a project wide\nchange that requires such a calculation." } ], "documentation": "@since 3.16.0", @@ -11086,7 +11149,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." } ], "documentation": "Client workspace capabilities specific to inline values.\n\n@since 3.17.0", @@ -11102,7 +11165,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." } ], "documentation": "Client workspace capabilities specific to inlay hints.\n\n@since 3.17.0", @@ -11118,7 +11181,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." } ], "documentation": "Workspace client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", @@ -11826,7 +11889,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by, for example, presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", "since": "3.16.0" } ], @@ -11970,7 +12033,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by, for example, presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", "since": "3.16.0" } ] @@ -12225,7 +12288,7 @@ ] } }, - "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If for example the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." + "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If, for example, the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." }, { "name": "tokenTypes", @@ -12557,6 +12620,183 @@ ], "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", "since": "3.16.0" + }, + { + "name": "InlineCompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineCompletionContext" + }, + "documentation": "Additional information about the context in which inline completions were requested." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "Inline completion parameters", + "since": "3.18.0" + }, + { + "name": "InlineCompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "InlineCompletionTriggerKind" + }, + "documentation": "Describes how the inline completion was triggered." + }, + { + "name": "selectedCompletionInfo", + "type": { + "kind": "reference", + "name": "SelectedCompletionInfo" + }, + "optional": true, + "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." + } + ], + "documentation": "Provides information about the context in which an inline completion was requested.", + "since": "3.18.0" + }, + { + "name": "SelectedCompletionInfo", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that will be replaced if this completion item is accepted." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text the range will be replaced with if this completion is accepted." + } + ], + "documentation": "Describes the currently selected completion item.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + }, + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline completion options used during static or dynamic registration.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "documentation": "Inline completion options used during static registration.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionItem", + "properties": [ + { + "name": "insertText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text to replace the range with. Must be set." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "The range to replace. Must begin and end on the same line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command} that is executed *after* inserting this completion." + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." + } + ], + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.", + "since": "3.18.0" + }, + { + "name": "InlineCompletionList", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "documentation": "The inline completion items" + } + ], + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.", + "since": "3.18.0" } ], "enumerations": [ @@ -13745,6 +13985,27 @@ "value": "relative" } ] + }, + { + "name": "InlineCompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoke", + "value": 0, + "documentation": "Completion was triggered explicitly by a user gesture." + }, + { + "name": "Automatic", + "value": 1, + "documentation": "Completion was triggered automatically while editing." + } + ], + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.", + "since": "3.18.0" } ], "typeAliases": [ @@ -14370,4 +14631,4 @@ "since": "3.17.0" } ] -} +} \ No newline at end of file diff --git a/protocol/src/common/protocol.inlineCompletion.ts b/protocol/src/common/protocol.inlineCompletion.ts new file mode 100644 index 000000000..9c9b46f8c --- /dev/null +++ b/protocol/src/common/protocol.inlineCompletion.ts @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { InlineCompletionItem, InlineCompletionContext, InlineCompletionList } from 'vscode-languageserver-types'; +import { RequestHandler } from 'vscode-jsonrpc'; + +import { MessageDirection, ProtocolRequestType } from './messages'; +import type { TextDocumentRegistrationOptions, WorkDoneProgressOptions, StaticRegistrationOptions, WorkDoneProgressParams, TextDocumentPositionParams } from './protocol'; + +// ---- capabilities + +/** + * Client capabilities specific to inline completions. + * + * @since 3.18.0 + */ +export type InlineCompletionClientCapabilities = { + /** + * Whether implementation supports dynamic registration for inline completion providers. + */ + dynamicRegistration?: boolean; +}; + +/** + * Inline completion options used during static registration. + * + * @since 3.18.0 + */ +export type InlineCompletionOptions = WorkDoneProgressOptions; + +/** + * Inline completion options used during static or dynamic registration. + * + * @since 3.18.0 + */ +export type InlineCompletionRegistrationOptions = InlineCompletionOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions; + +/** + * A parameter literal used in inline completion requests. + * + * @since 3.18.0 + */ +export type InlineCompletionParams = WorkDoneProgressParams & TextDocumentPositionParams & { + /** + * Additional information about the context in which inline completions were + * requested. + */ + context: InlineCompletionContext; +}; + +/** + * A request to provide inline completions in a document. The request's parameter is of + * type {@link InlineCompletionParams}, the response is of type + * {@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such. + * + * @since 3.18.0 + */ +export namespace InlineCompletionRequest { + export const method: 'textDocument/inlineCompletion' = 'textDocument/inlineCompletion'; + export const messageDirection: MessageDirection = MessageDirection.clientToServer; + export const type = new ProtocolRequestType(method); + export type HandlerSignature = RequestHandler; +} diff --git a/protocol/src/common/protocol.ts b/protocol/src/common/protocol.ts index ed031b4e7..a3e25bbaf 100644 --- a/protocol/src/common/protocol.ts +++ b/protocol/src/common/protocol.ts @@ -121,6 +121,8 @@ import { DidCloseNotebookDocumentNotification } from './protocol.notebook'; +import {InlineCompletionClientCapabilities, InlineCompletionOptions, InlineCompletionParams, InlineCompletionRegistrationOptions, InlineCompletionRequest} from './protocol.inlineCompletion'; + // @ts-ignore: to avoid inlining LocationLink as dynamic import let __noDynamicImport: LocationLink | undefined; @@ -740,6 +742,13 @@ export interface TextDocumentClientCapabilities { * @since 3.17.0 */ diagnostic?: DiagnosticClientCapabilities; + + /** + * Client capabilities specific to inline completions. + * + * @since 3.18.0 + */ + inlineCompletion?: InlineCompletionClientCapabilities; } export interface WindowClientCapabilities { @@ -1247,6 +1256,13 @@ export interface ServerCapabilities { */ diagnosticProvider?: DiagnosticOptions | DiagnosticRegistrationOptions; + /** + * Inline completion options used during static registration. + * + * @since 3.18.0 + */ + inlineCompletionProvider?: boolean | InlineCompletionOptions; + /** * Workspace specific server capabilities. */ @@ -3847,7 +3863,9 @@ export { VersionedNotebookDocumentIdentifier, NotebookDocumentSyncOptions, NotebookDocumentSyncRegistrationOptions, NotebookDocumentSyncRegistrationType, DidOpenNotebookDocumentParams, DidOpenNotebookDocumentNotification, NotebookCellArrayChange, NotebookDocumentChangeEvent, DidChangeNotebookDocumentParams, DidChangeNotebookDocumentNotification, DidSaveNotebookDocumentParams, DidSaveNotebookDocumentNotification, DidCloseNotebookDocumentParams, - DidCloseNotebookDocumentNotification + DidCloseNotebookDocumentNotification, + // Inline Completions + InlineCompletionClientCapabilities, InlineCompletionOptions, InlineCompletionParams, InlineCompletionRegistrationOptions, InlineCompletionRequest }; // To be backwards compatible diff --git a/server/src/common/inlineCompletion.ts b/server/src/common/inlineCompletion.ts new file mode 100644 index 000000000..d1b9f7d8f --- /dev/null +++ b/server/src/common/inlineCompletion.ts @@ -0,0 +1,39 @@ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ +'use strict'; + +import { InlineCompletionItem, Disposable, InlineCompletionParams, InlineCompletionList, InlineCompletionRequest } from 'vscode-languageserver-protocol'; + +import type { Feature, _Languages, ServerRequestHandler } from './server'; + +/** + * Shape of the inline completions feature + * + * @since 3.18.0 + */ +export interface InlineCompletionFeatureShape { + inlineCompletion: { + /** + * Installs a handler for the inline completions request. + * + * @param handler The corresponding handler. + */ + on(handler: ServerRequestHandler): Disposable; + }; +} + +export const InlineCompletionFeature: Feature<_Languages, InlineCompletionFeatureShape> = (Base) => { + return class extends Base implements InlineCompletionFeatureShape { + public get inlineCompletion() { + return { + on: (handler: ServerRequestHandler): Disposable => { + return this.connection.onRequest(InlineCompletionRequest.type, (params, cancel) => { + return handler(params, cancel, this.attachWorkDoneProgress(params)); + }); + } + }; + } + }; +}; \ No newline at end of file diff --git a/server/src/common/server.ts b/server/src/common/server.ts index 1a7058f23..3db337b01 100644 --- a/server/src/common/server.ts +++ b/server/src/common/server.ts @@ -24,7 +24,7 @@ import { DocumentSymbolRequest, WorkspaceSymbolRequest, CodeActionRequest, CodeLensRequest, CodeLensResolveRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, PrepareRenameRequest, DocumentLinkRequest, DocumentLinkResolveRequest, DocumentColorRequest, ColorPresentationRequest, FoldingRangeRequest, SelectionRangeRequest, ExecuteCommandRequest, InitializeRequest, ResponseError, RegistrationType, RequestType0, RequestType, - NotificationType0, NotificationType, CodeActionResolveRequest, RAL, WorkspaceSymbol, WorkspaceSymbolResolveRequest + NotificationType0, NotificationType, CodeActionResolveRequest, RAL, WorkspaceSymbol, WorkspaceSymbolResolveRequest, InlineCompletionParams, InlineCompletionItem, InlineCompletionRequest } from 'vscode-languageserver-protocol'; import * as Is from './utils/is'; @@ -39,6 +39,7 @@ import { FileOperationsFeature, FileOperationsFeatureShape } from './fileOperati import { LinkedEditingRangeFeature, LinkedEditingRangeFeatureShape } from './linkedEditingRange'; import { TypeHierarchyFeatureShape, TypeHierarchyFeature } from './typeHierarchy'; import { InlineValueFeatureShape, InlineValueFeature } from './inlineValue'; +import { InlineCompletionFeatureShape, InlineCompletionFeature } from './inlineCompletion'; import { InlayHintFeatureShape, InlayHintFeature } from './inlayHint'; import { DiagnosticFeatureShape, DiagnosticFeature } from './diagnostic'; import { NotebookSyncFeatureShape, NotebookSyncFeature } from './notebook'; @@ -814,8 +815,8 @@ export class _LanguagesImpl implements Remote, _Languages { } } -export type Languages = _Languages & CallHierarchy & SemanticTokensFeatureShape & LinkedEditingRangeFeatureShape & TypeHierarchyFeatureShape & InlineValueFeatureShape & InlayHintFeatureShape & DiagnosticFeatureShape & MonikerFeatureShape; -const LanguagesImpl: new () => Languages = MonikerFeature(DiagnosticFeature(InlayHintFeature(InlineValueFeature(TypeHierarchyFeature(LinkedEditingRangeFeature(SemanticTokensFeature(CallHierarchyFeature(_LanguagesImpl)))))))) as (new () => Languages); +export type Languages = _Languages & CallHierarchy & SemanticTokensFeatureShape & LinkedEditingRangeFeatureShape & TypeHierarchyFeatureShape & InlineValueFeatureShape & InlayHintFeatureShape & DiagnosticFeatureShape & MonikerFeatureShape & InlineCompletionFeatureShape; +const LanguagesImpl: new () => Languages = InlineCompletionFeature(MonikerFeature(DiagnosticFeature(InlayHintFeature(InlineValueFeature(TypeHierarchyFeature(LinkedEditingRangeFeature(SemanticTokensFeature(CallHierarchyFeature(_LanguagesImpl))))))))) as (new () => Languages); export interface _Notebooks extends FeatureBase { connection: Connection; diff --git a/types/src/main.ts b/types/src/main.ts index 4723bd2f1..34527fcfd 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -4087,6 +4087,125 @@ export namespace InlayHint { } } +/** + * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. + * + * @since 3.18.0 + */ +export interface InlineCompletionItem { + /** + * The text to replace the range with. Must be set. + */ + insertText: string; + + /** + * A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used. + */ + filterText?: string; + + /** + * The range to replace. Must begin and end on the same line. + */ + range?: Range; + + /** + * An optional {@link Command} that is executed *after* inserting this completion. + */ + command?: Command; + + /** + * The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`. + */ + insertTextFormat?: InsertTextFormat; +} + +export namespace InlineCompletionItem { + export function create(insertText: string, filterText?: string, range?: Range, command?: Command, insertTextFormat?: InsertTextFormat): InlineCompletionItem { + return {insertText, filterText, range, command, insertTextFormat}; + } +} + +/** + * Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor. + */ +export interface InlineCompletionList { + /** + * The inline completion items + */ + items: InlineCompletionItem[]; +} + +export namespace InlineCompletionList { + export function create(items: InlineCompletionItem[]): InlineCompletionList { + return {items}; + } +} + +/** + * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. + * + * @since 3.18.0 + */ +export namespace InlineCompletionTriggerKind { + /** + * Completion was triggered explicitly by a user gesture. + */ + export const Invoked: 0 = 0; + + /** + * Completion was triggered automatically while editing. + */ + export const Automatic: 1 = 1; +} + +export type InlineCompletionTriggerKind = 0 | 1; + +/** + * Describes the currently selected completion item. + * + * @since 3.18.0 + */ +export interface SelectedCompletionInfo { + /** + * The range that will be replaced if this completion item is accepted. + */ + range: Range; + + /** + * The text the range will be replaced with if this completion is accepted. + */ + text: string; +} + +export namespace SelectedCompletionInfo { + export function create(range: Range, text: string): SelectedCompletionInfo { + return {range, text}; + } +} + +/** + * Provides information about the context in which an inline completion was requested. + * + * @since 3.18.0 + */ +export interface InlineCompletionContext { + /** + * Describes how the inline completion was triggered. + */ + triggerKind: InlineCompletionTriggerKind; + + /** + * Provides information about the currently selected item in the autocomplete widget if it is visible. + */ + selectedCompletionInfo?: SelectedCompletionInfo; +} + +export namespace InlineCompletionContext{ + export function create(triggerKind: InlineCompletionTriggerKind, selectedCompletionInfo?: SelectedCompletionInfo): InlineCompletionContext { + return {triggerKind, selectedCompletionInfo}; + } +} + /** * A workspace folder inside a client. */ From 695905e0a5777ef0b100a93f6bad31f18bf99905 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Wed, 15 Feb 2023 20:14:13 +0100 Subject: [PATCH 2/8] Remove unused imports --- server/src/common/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/common/server.ts b/server/src/common/server.ts index 3db337b01..ec32714ba 100644 --- a/server/src/common/server.ts +++ b/server/src/common/server.ts @@ -24,7 +24,7 @@ import { DocumentSymbolRequest, WorkspaceSymbolRequest, CodeActionRequest, CodeLensRequest, CodeLensResolveRequest, DocumentFormattingRequest, DocumentRangeFormattingRequest, DocumentOnTypeFormattingRequest, RenameRequest, PrepareRenameRequest, DocumentLinkRequest, DocumentLinkResolveRequest, DocumentColorRequest, ColorPresentationRequest, FoldingRangeRequest, SelectionRangeRequest, ExecuteCommandRequest, InitializeRequest, ResponseError, RegistrationType, RequestType0, RequestType, - NotificationType0, NotificationType, CodeActionResolveRequest, RAL, WorkspaceSymbol, WorkspaceSymbolResolveRequest, InlineCompletionParams, InlineCompletionItem, InlineCompletionRequest + NotificationType0, NotificationType, CodeActionResolveRequest, RAL, WorkspaceSymbol, WorkspaceSymbolResolveRequest } from 'vscode-languageserver-protocol'; import * as Is from './utils/is'; From a67b94f43ccd5c6ad4c193eadae846ad514dfbce Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Fri, 17 Feb 2023 19:08:42 +0100 Subject: [PATCH 3/8] Address PR comments --- client/package-lock.json | 4 +- client/package.json | 2 +- client/src/common/protocolConverter.ts | 2 +- protocol/metaModel.json | 624 +++++++++++++------------ protocol/src/common/protocol.ts | 2 +- types/src/main.ts | 18 +- 6 files changed, 337 insertions(+), 315 deletions(-) diff --git a/client/package-lock.json b/client/package-lock.json index 0b2ea52aa..57da6bea8 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-languageclient", - "version": "8.1.0", + "version": "8.2.0-next.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-languageclient", - "version": "8.1.0", + "version": "8.2.0-next.1", "license": "MIT", "dependencies": { "minimatch": "^5.1.0", diff --git a/client/package.json b/client/package.json index 6a16b2326..5806848b8 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageclient", "description": "VSCode Language client implementation", - "version": "8.1.0", + "version": "8.2.0-next.1", "author": "Microsoft Corporation", "license": "MIT", "engines": { diff --git a/client/src/common/protocolConverter.ts b/client/src/common/protocolConverter.ts index fd1d9f54d..228e78fe7 100644 --- a/client/src/common/protocolConverter.ts +++ b/client/src/common/protocolConverter.ts @@ -1458,7 +1458,7 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar const inlineCompletionItem = new code.InlineCompletionItem(insertText, asRange(item.range), command); - if (item.filterText) {inlineCompletionItem.filterText = item.filterText;} + if (item.filterText) { inlineCompletionItem.filterText = item.filterText; } return inlineCompletionItem; } diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 52a0338ca..8dac72e90 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -1,6 +1,6 @@ { "metaData": { - "version": "3.18.0" + "version": "3.17.0" }, "requests": [ { @@ -566,7 +566,7 @@ "kind": "reference", "name": "ShowDocumentParams" }, - "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example, a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", + "documentation": "A request to show a document. This request might open an\nexternal program depending on the value of the URI to open.\nFor example a request to open `https://code.visualstudio.com/`\nwill very likely open the URI in a WEB browser.\n\n@since 3.16.0", "since": "3.16.0" }, { @@ -620,7 +620,7 @@ "kind": "reference", "name": "FileOperationRegistrationOptions" }, - "documentation": "The will create files request is sent from the client to the server before files are actually\ncreated as long as the creation is triggered from within the client.\n\n@since 3.16.0", + "documentation": "The will create files request is sent from the client to the server before files are actually\ncreated as long as the creation is triggered from within the client.\n\nThe request can return a `WorkspaceEdit` which will be applied to workspace before the\nfiles are created. Hence the `WorkspaceEdit` can not manipulate the content of the file\nto be created.\n\n@since 3.16.0", "since": "3.16.0" }, { @@ -846,40 +846,6 @@ "documentation": "A request to provide inline values in a document. The request's parameter is of\ntype {@link InlineValueParams}, the response is of type\n{@link InlineValue InlineValue[]} or a Thenable that resolves to such.\n\n@since 3.17.0", "since": "3.17.0" }, - { - "method": "textDocument/inlineCompletion", - "result": { - "kind": "or", - "items": [ - { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - { - "kind": "reference", - "name": "InlineCompletionList" - }, - { - "kind": "base", - "name": "null" - } - ] - }, - "messageDirection": "clientToServer", - "params": { - "kind": "reference", - "name": "InlineCompletionParams" - }, - "registrationOptions": { - "kind": "reference", - "name": "InlineCompletionRegistrationOptions" - }, - "documentation": "The inline completion request is sent from the client to the server to compute inline completions for a given text document either explicitly by a user gesture or implicitly when typing.", - "since": "3.18.0" - }, { "method": "workspace/inlineValue/refresh", "result": { @@ -1009,6 +975,47 @@ "documentation": "The diagnostic refresh request definition.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "method": "textDocument/inlineCompletion", + "result": { + "kind": "or", + "items": [ + { + "kind": "reference", + "name": "InlineCompletionList" + }, + { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + { + "kind": "base", + "name": "null" + } + ] + }, + "messageDirection": "clientToServer", + "params": { + "kind": "reference", + "name": "InlineCompletionParams" + }, + "partialResult": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "registrationOptions": { + "kind": "reference", + "name": "InlineCompletionRegistrationOptions" + }, + "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "method": "client/registerCapability", "result": { @@ -1667,7 +1674,7 @@ "kind": "reference", "name": "DocumentFormattingRegistrationOptions" }, - "documentation": "A request to format a whole document." + "documentation": "A request to to format a whole document." }, { "method": "textDocument/rangeFormatting", @@ -1696,7 +1703,7 @@ "kind": "reference", "name": "DocumentRangeFormattingRegistrationOptions" }, - "documentation": "A request to format a range in a document." + "documentation": "A request to to format a range in a document." }, { "method": "textDocument/onTypeFormatting", @@ -3095,7 +3102,7 @@ "kind": "base", "name": "URI" }, - "documentation": "The document uri to show." + "documentation": "The uri to show." }, { "name": "external", @@ -3125,7 +3132,7 @@ "documentation": "An optional selection range if the document is a text\ndocument. Clients might ignore the property if an\nexternal program is started or the file is not a text\nfile." } ], - "documentation": "Params to show a document.\n\n@since 3.16.0", + "documentation": "Params to show a resource in the UI.\n\n@since 3.16.0", "since": "3.16.0" }, { @@ -3293,7 +3300,7 @@ "since": "3.16.0" } ], - "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit, for example, can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" + "documentation": "A workspace edit represents changes to many resources managed in the workspace. The edit\nshould either provide `changes` or `documentChanges`. If documentChanges are present\nthey are preferred over `changes` if the client can handle versioned document edits.\n\nSince version 3.13.0 a workspace edit can contain resource operations as well. If resource\noperations are present clients need to execute the operations in the order in which they\nare provided. So a workspace edit for example can consist of the following two changes:\n(1) a create file a.txt and (2) a text document edit which insert text into file a.txt.\n\nAn invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will\ncause failure of the operation. How the client recovers from the failure is described by\nthe client capability: `workspace.workspaceEdit.failureHandling`" }, { "name": "FileOperationRegistrationOptions", @@ -3378,7 +3385,7 @@ "kind": "base", "name": "string" }, - "documentation": "The scheme of the moniker. For example, `tsc` or `.Net`" + "documentation": "The scheme of the moniker. For example tsc or .Net" }, { "name": "identifier", @@ -4069,6 +4076,123 @@ "documentation": "The params sent in a close notebook document notification.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionParams", + "properties": [ + { + "name": "context", + "type": { + "kind": "reference", + "name": "InlineCompletionContext" + }, + "documentation": "Additional information about the context in which inline completions were\nrequested." + } + ], + "extends": [ + { + "kind": "reference", + "name": "TextDocumentPositionParams" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressParams" + } + ], + "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionList", + "properties": [ + { + "name": "items", + "type": { + "kind": "array", + "element": { + "kind": "reference", + "name": "InlineCompletionItem" + } + }, + "documentation": "The inline completion items" + } + ], + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor." + }, + { + "name": "InlineCompletionItem", + "properties": [ + { + "name": "insertText", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text to replace the range with. Must be set." + }, + { + "name": "insertTextFormat", + "type": { + "kind": "reference", + "name": "InsertTextFormat" + }, + "optional": true, + "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." + }, + { + "name": "filterText", + "type": { + "kind": "base", + "name": "string" + }, + "optional": true, + "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." + }, + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "optional": true, + "documentation": "The range to replace. Must begin and end on the same line." + }, + { + "name": "command", + "type": { + "kind": "reference", + "name": "Command" + }, + "optional": true, + "documentation": "An optional {@link Command} that is executed *after* inserting this completion." + } + ], + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionRegistrationOptions", + "properties": [], + "extends": [ + { + "kind": "reference", + "name": "InlineCompletionOptions" + }, + { + "kind": "reference", + "name": "TextDocumentRegistrationOptions" + } + ], + "mixins": [ + { + "kind": "reference", + "name": "StaticRegistrationOptions" + } + ], + "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "RegistrationParams", "properties": [ @@ -4673,7 +4797,7 @@ "name": "string" }, "optional": true, - "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example,\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." + "documentation": "A string that should be inserted into a document when selecting\nthis completion. When `falsy` the {@link CompletionItem.label label}\nis used.\n\nThe `insertText` is subject to interpretation by the client side.\nSome tools might not take the string literally. For example\nVS Code when code complete is requested in this example\n`con` and a completion item with an `insertText` of\n`console` is provided it will only insert `sole`. Therefore it is\nrecommended to use `textEdit` instead since it avoids additional client\nside interpretation." }, { "name": "insertTextFormat", @@ -4733,7 +4857,7 @@ } }, "optional": true, - "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example, adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." + "documentation": "An optional array of additional {@link TextEdit text edits} that are applied when\nselecting this completion. Edits must not overlap (including the same insert position)\nwith the main {@link CompletionItem.textEdit edit} nor with themselves.\n\nAdditional text edits should be used to change text unrelated to the current cursor position\n(for example adding an import statement at the top of the file if the completion item will\ninsert an unqualified type)." }, { "name": "commitCharacters", @@ -5716,7 +5840,7 @@ "name": "target", "type": { "kind": "base", - "name": "string" + "name": "URI" }, "optional": true, "documentation": "The uri this link points to. If missing a resolve request is sent later." @@ -6025,7 +6149,7 @@ "name": "string" }, "optional": true, - "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface, for example, on an undo\nstack to undo the workspace edit." + "documentation": "An optional label of the workspace edit. This label is\npresented in the user interface for example on an undo\nstack to undo the workspace edit." }, { "name": "edit", @@ -6174,7 +6298,7 @@ "name": "string" }, "optional": true, - "documentation": "Optional, a final message indicating to, for example, indicate the outcome\nof the operation." + "documentation": "Optional, a final message indicating to for example indicate the outcome\nof the operation." } ] }, @@ -6329,7 +6453,7 @@ "kind": "reference", "name": "Range" }, - "documentation": "The full target range of this link. If the target, for example, is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." + "documentation": "The full target range of this link. If the target for example is a symbol then target range is the\nrange enclosing this symbol not including leading/trailing whitespace but everything else\nlike comments. This information is typically used to highlight the range in the editor." }, { "name": "targetSelectionRange", @@ -7628,6 +7752,42 @@ "documentation": "A literal to identify a notebook document in the client.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionContext", + "properties": [ + { + "name": "triggerKind", + "type": { + "kind": "reference", + "name": "InlineCompletionTriggerKind" + }, + "documentation": "Describes how the inline completion was triggered." + }, + { + "name": "selectedCompletionInfo", + "type": { + "kind": "reference", + "name": "SelectedCompletionInfo" + }, + "optional": true, + "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." + } + ], + "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "InlineCompletionOptions", + "mixins": [ + { + "kind": "reference", + "name": "WorkDoneProgressOptions" + } + ], + "properties": [], + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "Registration", "properties": [ @@ -7657,7 +7817,7 @@ "documentation": "Options necessary for the registration." } ], - "documentation": "General parameters to register for a notification or to register a provider." + "documentation": "General parameters to to register for an notification or to register a provider." }, { "name": "Unregistration", @@ -8432,6 +8592,25 @@ "documentation": "The server has support for pull model diagnostics.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "inlineCompletionProvider", + "type": { + "kind": "or", + "items": [ + { + "kind": "base", + "name": "boolean" + }, + { + "kind": "reference", + "name": "InlineCompletionOptions" + } + ] + }, + "optional": true, + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "workspace", "type": { @@ -8472,25 +8651,6 @@ }, "optional": true, "documentation": "Experimental server capabilities." - }, - { - "name": "InlineCompletionProvider", - "type": { - "kind": "or", - "items": [ - { - "kind": "base", - "name": "boolean" - }, - { - "kind": "reference", - "name": "InlineCompletionOptions" - } - ] - }, - "optional": true, - "documentation": "The server provides inline completions.", - "since": "3.18.0" } ], "documentation": "Defines the capabilities provided by a language\nserver." @@ -8770,7 +8930,7 @@ } }, "optional": true, - "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example, if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example, `.` in JavaScript) list them in `triggerCharacters`." + "documentation": "Most tools trigger completion request automatically without explicitly requesting\nit using a keyboard shortcut (e.g. Ctrl+Space). Typically they do so when the user\nstarts to type an identifier. For example if the user types `c` in a JavaScript file\ncode complete will automatically pop up present `console` besides others as a\ncompletion item. Characters that make up identifiers don't need to be listed here.\n\nIf code complete should automatically be trigger on characters not being valid inside\nan identifier (for example `.` in JavaScript) list them in `triggerCharacters`." }, { "name": "allCommitCharacters", @@ -9725,7 +9885,30 @@ "since": "3.17.0" }, { - "name": "ClientCapabilities", + "name": "SelectedCompletionInfo", + "properties": [ + { + "name": "range", + "type": { + "kind": "reference", + "name": "Range" + }, + "documentation": "The range that will be replaced if this completion item is accepted." + }, + { + "name": "text", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The text the range will be replaced with if this completion is accepted." + } + ], + "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0", + "since": "3.18.0" + }, + { + "name": "ClientCapabilities", "properties": [ { "name": "workspace", @@ -10667,7 +10850,7 @@ "name": "InlineCompletionClientCapabilities" }, "optional": true, - "documentation": "Capabilities specific to the `textDocument/inlineCompletion` request.", + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", "since": "3.18.0" } ], @@ -11047,7 +11230,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server, for example, detects a project\nwide change that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\nsemantic tokens currently shown. It should be used with absolute care\nand is useful for situation where a server for example detects a project\nwide change that requires such a calculation." } ], "documentation": "@since 3.16.0", @@ -11063,7 +11246,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server, for example, detect a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ncode lenses currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detect a project wide\nchange that requires such a calculation." } ], "documentation": "@since 3.16.0", @@ -11149,7 +11332,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from the\nserver to the client.\n\nNote that this event is global and will force the client to refresh all\ninline values currently shown. It should be used with absolute care and is\nuseful for situation where a server for example detects a project wide\nchange that requires such a calculation." } ], "documentation": "Client workspace capabilities specific to inline values.\n\n@since 3.17.0", @@ -11165,7 +11348,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\ninlay hints currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." } ], "documentation": "Client workspace capabilities specific to inlay hints.\n\n@since 3.17.0", @@ -11181,7 +11364,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server, for example, detects a project wide\nchange that requires such a calculation." + "documentation": "Whether the client implementation supports a refresh request sent from\nthe server to the client.\n\nNote that this event is global and will force the client to refresh all\npulled diagnostics currently shown. It should be used with absolute care and\nis useful for situation where a server for example detects a project wide\nchange that requires such a calculation." } ], "documentation": "Workspace client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", @@ -11889,7 +12072,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by, for example, presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", "since": "3.16.0" } ], @@ -12033,7 +12216,7 @@ "name": "boolean" }, "optional": true, - "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by, for example, presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", + "documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\nrename request's workspace edit by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0", "since": "3.16.0" } ] @@ -12288,7 +12471,7 @@ ] } }, - "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If, for example, the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." + "documentation": "Which requests the client supports and might send to the server\ndepending on the server's capability. Please note that clients might not\nshow semantic tokens or degrade some of the user experience if a range\nor full request is advertised by the client but not provided by the\nserver. If for example the client capability `requests.full` and\n`request.range` are both set to true but the server only provides a\nrange provider the client might not render a minimap correctly or might\neven decide to not show any semantic tokens at all." }, { "name": "tokenTypes", @@ -12493,6 +12676,22 @@ "documentation": "Client capabilities specific to diagnostic pull requests.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InlineCompletionClientCapabilities", + "properties": [ + { + "name": "dynamicRegistration", + "type": { + "kind": "base", + "name": "boolean" + }, + "optional": true, + "documentation": "Whether implementation supports dynamic registration for inline completion providers." + } + ], + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "NotebookDocumentSyncClientCapabilities", "properties": [ @@ -12620,183 +12819,6 @@ ], "documentation": "Client capabilities specific to the used markdown parser.\n\n@since 3.16.0", "since": "3.16.0" - }, - { - "name": "InlineCompletionParams", - "properties": [ - { - "name": "context", - "type": { - "kind": "reference", - "name": "InlineCompletionContext" - }, - "documentation": "Additional information about the context in which inline completions were requested." - } - ], - "extends": [ - { - "kind": "reference", - "name": "TextDocumentPositionParams" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "WorkDoneProgressParams" - } - ], - "documentation": "Inline completion parameters", - "since": "3.18.0" - }, - { - "name": "InlineCompletionContext", - "properties": [ - { - "name": "triggerKind", - "type": { - "kind": "reference", - "name": "InlineCompletionTriggerKind" - }, - "documentation": "Describes how the inline completion was triggered." - }, - { - "name": "selectedCompletionInfo", - "type": { - "kind": "reference", - "name": "SelectedCompletionInfo" - }, - "optional": true, - "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." - } - ], - "documentation": "Provides information about the context in which an inline completion was requested.", - "since": "3.18.0" - }, - { - "name": "SelectedCompletionInfo", - "properties": [ - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "documentation": "The range that will be replaced if this completion item is accepted." - }, - { - "name": "text", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text the range will be replaced with if this completion is accepted." - } - ], - "documentation": "Describes the currently selected completion item.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionRegistrationOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "InlineCompletionOptions" - } - ], - "mixins": [ - { - "kind": "reference", - "name": "TextDocumentRegistrationOptions" - }, - { - "kind": "reference", - "name": "StaticRegistrationOptions" - } - ], - "documentation": "Inline completion options used during static or dynamic registration.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionOptions", - "properties": [], - "extends": [ - { - "kind": "reference", - "name": "WorkDoneProgressOptions" - } - ], - "documentation": "Inline completion options used during static registration.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionItem", - "properties": [ - { - "name": "insertText", - "type": { - "kind": "base", - "name": "string" - }, - "documentation": "The text to replace the range with. Must be set." - }, - { - "name": "filterText", - "type": { - "kind": "base", - "name": "string" - }, - "optional": true, - "documentation": "A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used." - }, - { - "name": "range", - "type": { - "kind": "reference", - "name": "Range" - }, - "optional": true, - "documentation": "The range to replace. Must begin and end on the same line." - }, - { - "name": "command", - "type": { - "kind": "reference", - "name": "Command" - }, - "optional": true, - "documentation": "An optional {@link Command} that is executed *after* inserting this completion." - }, - { - "name": "insertTextFormat", - "type": { - "kind": "reference", - "name": "InsertTextFormat" - }, - "optional": true, - "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." - } - ], - "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.", - "since": "3.18.0" - }, - { - "name": "InlineCompletionList", - "properties": [ - { - "name": "items", - "type": { - "kind": "array", - "element": { - "kind": "reference", - "name": "InlineCompletionItem" - } - }, - "documentation": "The inline completion items" - } - ], - "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.", - "since": "3.18.0" } ], "enumerations": [ @@ -13291,6 +13313,26 @@ "documentation": "Inlay hint kinds.\n\n@since 3.17.0", "since": "3.17.0" }, + { + "name": "InsertTextFormat", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "PlainText", + "value": 1, + "documentation": "The primary text to be inserted is treated as a plain string." + }, + { + "name": "Snippet", + "value": 2, + "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" + } + ], + "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." + }, { "name": "MessageType", "type": { @@ -13497,26 +13539,6 @@ "documentation": "Completion item tags are extra annotations that tweak the rendering of a completion\nitem.\n\n@since 3.15.0", "since": "3.15.0" }, - { - "name": "InsertTextFormat", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "PlainText", - "value": 1, - "documentation": "The primary text to be inserted is treated as a plain string." - }, - { - "name": "Snippet", - "value": 2, - "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" - } - ], - "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." - }, { "name": "InsertTextMode", "type": { @@ -13664,6 +13686,27 @@ ], "documentation": "Describes the content type that a client supports in various\nresult literals like `Hover`, `ParameterInfo` or `CompletionItem`.\n\nPlease note that `MarkupKinds` must not start with a `$`. This kinds\nare reserved for internal usage." }, + { + "name": "InlineCompletionTriggerKind", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "Invoked", + "value": 0, + "documentation": "Completion was triggered explicitly by a user gesture." + }, + { + "name": "Automatic", + "value": 1, + "documentation": "Completion was triggered automatically while editing." + } + ], + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "PositionEncodingKind", "type": { @@ -13674,7 +13717,7 @@ { "name": "UTF8", "value": "utf-8", - "documentation": "Character offsets count UTF-8 code units." + "documentation": "Character offsets count UTF-8 code units (e.g. bytes)." }, { "name": "UTF16", @@ -13684,7 +13727,7 @@ { "name": "UTF32", "value": "utf-32", - "documentation": "Character offsets count UTF-32 code units.\n\nImplementation note: these are the same as Unicode code points,\nso this `PositionEncodingKind` may also be used for an\nencoding-agnostic representation of character offsets." + "documentation": "Character offsets count UTF-32 code units.\n\nImplementation note: these are the same as Unicode codepoints,\nso this `PositionEncodingKind` may also be used for an\nencoding-agnostic representation of character offsets." } ], "supportsCustomValues": true, @@ -13985,27 +14028,6 @@ "value": "relative" } ] - }, - { - "name": "InlineCompletionTriggerKind", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "Invoke", - "value": 0, - "documentation": "Completion was triggered explicitly by a user gesture." - }, - { - "name": "Automatic", - "value": 1, - "documentation": "Completion was triggered automatically while editing." - } - ], - "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.", - "since": "3.18.0" } ], "typeAliases": [ @@ -14631,4 +14653,4 @@ "since": "3.17.0" } ] -} \ No newline at end of file +} diff --git a/protocol/src/common/protocol.ts b/protocol/src/common/protocol.ts index a3e25bbaf..fa1902161 100644 --- a/protocol/src/common/protocol.ts +++ b/protocol/src/common/protocol.ts @@ -121,7 +121,7 @@ import { DidCloseNotebookDocumentNotification } from './protocol.notebook'; -import {InlineCompletionClientCapabilities, InlineCompletionOptions, InlineCompletionParams, InlineCompletionRegistrationOptions, InlineCompletionRequest} from './protocol.inlineCompletion'; +import { InlineCompletionClientCapabilities, InlineCompletionOptions, InlineCompletionParams, InlineCompletionRegistrationOptions, InlineCompletionRequest } from './protocol.inlineCompletion'; // @ts-ignore: to avoid inlining LocationLink as dynamic import let __noDynamicImport: LocationLink | undefined; diff --git a/types/src/main.ts b/types/src/main.ts index 34527fcfd..f6b912d34 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -4098,6 +4098,11 @@ export interface InlineCompletionItem { */ insertText: string; + /** + * The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`. + */ + insertTextFormat?: InsertTextFormat; + /** * A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used. */ @@ -4112,16 +4117,11 @@ export interface InlineCompletionItem { * An optional {@link Command} that is executed *after* inserting this completion. */ command?: Command; - - /** - * The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`. - */ - insertTextFormat?: InsertTextFormat; } export namespace InlineCompletionItem { export function create(insertText: string, filterText?: string, range?: Range, command?: Command, insertTextFormat?: InsertTextFormat): InlineCompletionItem { - return {insertText, filterText, range, command, insertTextFormat}; + return { insertText, filterText, range, command, insertTextFormat }; } } @@ -4137,7 +4137,7 @@ export interface InlineCompletionList { export namespace InlineCompletionList { export function create(items: InlineCompletionItem[]): InlineCompletionList { - return {items}; + return { items }; } } @@ -4179,7 +4179,7 @@ export interface SelectedCompletionInfo { export namespace SelectedCompletionInfo { export function create(range: Range, text: string): SelectedCompletionInfo { - return {range, text}; + return { range, text }; } } @@ -4202,7 +4202,7 @@ export interface InlineCompletionContext { export namespace InlineCompletionContext{ export function create(triggerKind: InlineCompletionTriggerKind, selectedCompletionInfo?: SelectedCompletionInfo): InlineCompletionContext { - return {triggerKind, selectedCompletionInfo}; + return { triggerKind, selectedCompletionInfo }; } } From 99332749d8d162efba7d2af08f48f04406c5697f Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Fri, 17 Feb 2023 21:04:10 +0100 Subject: [PATCH 4/8] Align client-node-tests VSC version with client --- client-node-tests/package-lock.json | 16 ++++++++-------- client-node-tests/package.json | 7 ++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/client-node-tests/package-lock.json b/client-node-tests/package-lock.json index d782618f6..f9f2a7e05 100644 --- a/client-node-tests/package-lock.json +++ b/client-node-tests/package-lock.json @@ -17,7 +17,7 @@ "@types/minimatch": "^3.0.5", "@types/sinon": "^10.0.2", "@types/uuid": "^8.3.1", - "@types/vscode": "1.67.0", + "@types/vscode": "1.68.0", "find-process": "^1.4.7", "glob": "^7.1.7", "sinon": "^11.1.2", @@ -25,7 +25,7 @@ "vscode-test": "^1.6.1" }, "engines": { - "vscode": "^1.67.0" + "vscode": "^1.68.0" } }, "node_modules/@sinonjs/commons": { @@ -110,9 +110,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.67.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.67.0.tgz", - "integrity": "sha512-GH8BDf8cw9AC9080uneJfulhSa7KHSMI2s/CyKePXoGNos9J486w2V4YKoeNUqIEkW4hKoEAWp6/cXTwyGj47g==", + "version": "1.68.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", + "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", "dev": true }, "node_modules/agent-base": { @@ -811,9 +811,9 @@ "dev": true }, "@types/vscode": { - "version": "1.67.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.67.0.tgz", - "integrity": "sha512-GH8BDf8cw9AC9080uneJfulhSa7KHSMI2s/CyKePXoGNos9J486w2V4YKoeNUqIEkW4hKoEAWp6/cXTwyGj47g==", + "version": "1.68.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.0.tgz", + "integrity": "sha512-duBwEK5ta/eBBMJMQ7ECMEsMvlE3XJdRGh3xoS1uOO4jl2Z4LPBl5vx8WvBP10ERAgDRmIt/FaSD4RHyBGbChw==", "dev": true }, "agent-base": { diff --git a/client-node-tests/package.json b/client-node-tests/package.json index 19be47dc3..0855dd5aa 100644 --- a/client-node-tests/package.json +++ b/client-node-tests/package.json @@ -6,7 +6,7 @@ "description": "", "version": "0.0.1", "engines": { - "vscode": "^1.67.0" + "vscode": "^1.68.0" }, "categories": [ "Other" @@ -14,9 +14,6 @@ "activationEvents": [ "*" ], - "enabledApiProposals": [ - "notebookContentProvider" - ], "main": "./extension.js", "contributes": {}, "scripts": { @@ -41,7 +38,7 @@ "@types/minimatch": "^3.0.5", "@types/sinon": "^10.0.2", "@types/uuid": "^8.3.1", - "@types/vscode": "1.67.0", + "@types/vscode": "1.68.0", "find-process": "^1.4.7", "glob": "^7.1.7", "sinon": "^11.1.2", From 13885ed1d4a7ddda9603c2443363929a3b70bb4d Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Thu, 2 Mar 2023 17:47:04 +0100 Subject: [PATCH 5/8] Change insert text, bump versions, make proposed --- client-node-tests/package.json | 2 +- client-node-tests/src/converter.test.ts | 6 +- client-node-tests/src/servers/testServer.ts | 2 +- client/package.json | 2 +- client/src/common/client.ts | 2 +- client/src/common/protocolConverter.ts | 6 +- protocol/metaModel.json | 77 +++++++++++-------- protocol/package.json | 4 +- server/package.json | 4 +- server/src/common/api.ts | 7 +- ...letion.ts => inlineCompletion.proposed.ts} | 0 server/src/common/server.ts | 6 +- types/package-lock.json | 4 +- types/package.json | 2 +- types/src/main.ts | 35 +++++++-- 15 files changed, 98 insertions(+), 61 deletions(-) rename server/src/common/{inlineCompletion.ts => inlineCompletion.proposed.ts} (100%) diff --git a/client-node-tests/package.json b/client-node-tests/package.json index 0855dd5aa..08c21c988 100644 --- a/client-node-tests/package.json +++ b/client-node-tests/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "minimatch": "^3.0.4", - "vscode-languageserver": "8.1.0", + "vscode-languageserver": "8.1.0-next.1", "vscode-uri": "3.0.3" }, "devDependencies": { diff --git a/client-node-tests/src/converter.test.ts b/client-node-tests/src/converter.test.ts index 01f65cd3a..acbe6d538 100644 --- a/client-node-tests/src/converter.test.ts +++ b/client-node-tests/src/converter.test.ts @@ -1247,12 +1247,12 @@ suite('Protocol Converter', () => { test('InlineCompletions', async () => { const items: proto.InlineCompletionItem[] = [ proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7)), - proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined, proto.InsertTextFormat.PlainText), - proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined, proto.InsertTextFormat.Snippet), + proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined), + proto.InlineCompletionItem.create(proto.SnippetString.create('insert text'), 'in', proto.Range.create(1, 2, 6, 7), undefined), ]; const result = await p2c.asInlineCompletionResult(items); - ok(result.every((r) => r.range instanceof vscode.InlineCompletionItem)); + ok(result.every((r) => r instanceof vscode.InlineCompletionItem)); for (const r of result) { rangeEqual(r.range!, proto.Range.create(1, 2, 6, 7)); } diff --git a/client-node-tests/src/servers/testServer.ts b/client-node-tests/src/servers/testServer.ts index 57ab4d9ff..958b0d93e 100644 --- a/client-node-tests/src/servers/testServer.ts +++ b/client-node-tests/src/servers/testServer.ts @@ -16,7 +16,7 @@ import { import { URI } from 'vscode-uri'; -const connection: ProposedFeatures.Connection = createConnection(); +const connection = createConnection() as ProposedFeatures.Connection; console.log = connection.console.log.bind(connection.console); console.error = connection.console.error.bind(connection.console); diff --git a/client/package.json b/client/package.json index 5806848b8..ef91f141a 100644 --- a/client/package.json +++ b/client/package.json @@ -30,7 +30,7 @@ "dependencies": { "minimatch": "^5.1.0", "semver": "^7.3.7", - "vscode-languageserver-protocol": "3.17.3" + "vscode-languageserver-protocol": "3.18.0-next.1" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/client/src/common/client.ts b/client/src/common/client.ts index 273b46a9c..2d96380d4 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -1806,7 +1806,6 @@ export abstract class BaseLanguageClient implements FeatureClient): (StaticFeature | DynamicFeature)[] { let result: (StaticFeature | DynamicFeature)[] = [ + new InlineCompletionItemFeature(_client) ]; return result; } diff --git a/client/src/common/protocolConverter.ts b/client/src/common/protocolConverter.ts index 228e78fe7..b344d4a80 100644 --- a/client/src/common/protocolConverter.ts +++ b/client/src/common/protocolConverter.ts @@ -1447,10 +1447,10 @@ export function createConverter(uriConverter: URIConverter | undefined, trustMar function asInlineCompletionItem(item: ls.InlineCompletionItem): code.InlineCompletionItem { let insertText: string | code.SnippetString; - if (item.insertTextFormat === ls.InsertTextFormat.Snippet) { - insertText = new code.SnippetString(item.insertText); - } else { + if (typeof item.insertText === 'string') { insertText = item.insertText; + } else { + insertText = new code.SnippetString(item.insertText.value); } let command: code.Command | undefined = undefined; diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 8dac72e90..3d2ed139f 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -4126,20 +4126,20 @@ { "name": "insertText", "type": { - "kind": "base", - "name": "string" + "kind": "or", + "items": [ + { + "kind": "base", + "name": "string" + }, + { + "kind": "reference", + "name": "SnippetString" + } + ] }, "documentation": "The text to replace the range with. Must be set." }, - { - "name": "insertTextFormat", - "type": { - "kind": "reference", - "name": "InsertTextFormat" - }, - "optional": true, - "documentation": "The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`." - }, { "name": "filterText", "type": { @@ -7776,6 +7776,21 @@ "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0", "since": "3.18.0" }, + { + "name": "SnippetString", + "properties": [ + { + "name": "value", + "type": { + "kind": "base", + "name": "string" + }, + "documentation": "The snippet string." + } + ], + "documentation": "A snippet string is a template which allows to insert text\nand to control the editor cursor when insertion happens.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Variables are defined with `$name` and\n`${name:default value}`.\n\n@since 3.18.0", + "since": "3.18.0" + }, { "name": "InlineCompletionOptions", "mixins": [ @@ -13313,26 +13328,6 @@ "documentation": "Inlay hint kinds.\n\n@since 3.17.0", "since": "3.17.0" }, - { - "name": "InsertTextFormat", - "type": { - "kind": "base", - "name": "uinteger" - }, - "values": [ - { - "name": "PlainText", - "value": 1, - "documentation": "The primary text to be inserted is treated as a plain string." - }, - { - "name": "Snippet", - "value": 2, - "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" - } - ], - "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." - }, { "name": "MessageType", "type": { @@ -13539,6 +13534,26 @@ "documentation": "Completion item tags are extra annotations that tweak the rendering of a completion\nitem.\n\n@since 3.15.0", "since": "3.15.0" }, + { + "name": "InsertTextFormat", + "type": { + "kind": "base", + "name": "uinteger" + }, + "values": [ + { + "name": "PlainText", + "value": 1, + "documentation": "The primary text to be inserted is treated as a plain string." + }, + { + "name": "Snippet", + "value": 2, + "documentation": "The primary text to be inserted is treated as a snippet.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Placeholders with equal identifiers are linked,\nthat is typing in one will update others too.\n\nSee also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax" + } + ], + "documentation": "Defines whether the insert text in a completion item should be interpreted as\nplain text or a snippet." + }, { "name": "InsertTextMode", "type": { diff --git a/protocol/package.json b/protocol/package.json index 4abf03826..ef970725b 100644 --- a/protocol/package.json +++ b/protocol/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver-protocol", "description": "VSCode Language Server Protocol implementation", - "version": "3.17.3", + "version": "3.18.0-next.1", "author": "Microsoft Corporation", "license": "MIT", "repository": { @@ -19,7 +19,7 @@ "typings": "./lib/common/api.d.ts", "dependencies": { "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.17.3" + "vscode-languageserver-types": "3.18.0-next.1" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/server/package.json b/server/package.json index 52485851a..de74d0992 100644 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver", "description": "Language server implementation for node", - "version": "8.1.0", + "version": "8.1.0-next.1", "author": "Microsoft Corporation", "license": "MIT", "repository": { @@ -24,7 +24,7 @@ "vscode-languageserver-textdocument": "1.0.9" }, "dependencies": { - "vscode-languageserver-protocol": "3.17.3" + "vscode-languageserver-protocol": "3.18.0-next.1" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/server/src/common/api.ts b/server/src/common/api.ts index a465f51cc..690b0c29b 100644 --- a/server/src/common/api.ts +++ b/server/src/common/api.ts @@ -7,6 +7,8 @@ import { _, Features, _Connection, _LanguagesImpl } from './server'; import { SemanticTokensBuilder } from './semanticTokens'; import type { WorkDoneProgressReporter, WorkDoneProgressServerReporter, ResultProgressReporter } from './progress'; +import * as ic from './inlineCompletion.proposed'; + export * from 'vscode-languageserver-protocol/'; export { WorkDoneProgressReporter, WorkDoneProgressServerReporter, ResultProgressReporter }; export { SemanticTokensBuilder }; @@ -17,9 +19,10 @@ export { NotebookDocuments }; export * from './server'; export namespace ProposedFeatures { - export const all: Features<_, _, _, _, _, _, _, _> = { + export const all: Features<_, _, _, _, _, _, ic.InlineCompletionFeatureShape, _> = { __brand: 'features', + languages: ic.InlineCompletionFeature }; - export type Connection = _Connection<_, _, _, _, _, _, _, _>; + export type Connection = _Connection<_, _, _, _, _, _, ic.InlineCompletionFeatureShape, _>; } \ No newline at end of file diff --git a/server/src/common/inlineCompletion.ts b/server/src/common/inlineCompletion.proposed.ts similarity index 100% rename from server/src/common/inlineCompletion.ts rename to server/src/common/inlineCompletion.proposed.ts diff --git a/server/src/common/server.ts b/server/src/common/server.ts index ec32714ba..9ae4cc745 100644 --- a/server/src/common/server.ts +++ b/server/src/common/server.ts @@ -39,7 +39,7 @@ import { FileOperationsFeature, FileOperationsFeatureShape } from './fileOperati import { LinkedEditingRangeFeature, LinkedEditingRangeFeatureShape } from './linkedEditingRange'; import { TypeHierarchyFeatureShape, TypeHierarchyFeature } from './typeHierarchy'; import { InlineValueFeatureShape, InlineValueFeature } from './inlineValue'; -import { InlineCompletionFeatureShape, InlineCompletionFeature } from './inlineCompletion'; +// import { InlineCompletionFeatureShape, InlineCompletionFeature } from './inlineCompletion.proposed'; import { InlayHintFeatureShape, InlayHintFeature } from './inlayHint'; import { DiagnosticFeatureShape, DiagnosticFeature } from './diagnostic'; import { NotebookSyncFeatureShape, NotebookSyncFeature } from './notebook'; @@ -815,8 +815,8 @@ export class _LanguagesImpl implements Remote, _Languages { } } -export type Languages = _Languages & CallHierarchy & SemanticTokensFeatureShape & LinkedEditingRangeFeatureShape & TypeHierarchyFeatureShape & InlineValueFeatureShape & InlayHintFeatureShape & DiagnosticFeatureShape & MonikerFeatureShape & InlineCompletionFeatureShape; -const LanguagesImpl: new () => Languages = InlineCompletionFeature(MonikerFeature(DiagnosticFeature(InlayHintFeature(InlineValueFeature(TypeHierarchyFeature(LinkedEditingRangeFeature(SemanticTokensFeature(CallHierarchyFeature(_LanguagesImpl))))))))) as (new () => Languages); +export type Languages = _Languages & CallHierarchy & SemanticTokensFeatureShape & LinkedEditingRangeFeatureShape & TypeHierarchyFeatureShape & InlineValueFeatureShape & InlayHintFeatureShape & DiagnosticFeatureShape & MonikerFeatureShape; +const LanguagesImpl: new () => Languages = MonikerFeature(DiagnosticFeature(InlayHintFeature(InlineValueFeature(TypeHierarchyFeature(LinkedEditingRangeFeature(SemanticTokensFeature(CallHierarchyFeature(_LanguagesImpl)))))))) as (new () => Languages); export interface _Notebooks extends FeatureBase { connection: Connection; diff --git a/types/package-lock.json b/types/package-lock.json index 0bdaea6d0..08a6e4ca8 100644 --- a/types/package-lock.json +++ b/types/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-languageserver-types", - "version": "3.17.3", + "version": "3.18.0-next.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-languageserver-types", - "version": "3.17.3", + "version": "3.18.0-next.1", "license": "MIT" } } diff --git a/types/package.json b/types/package.json index 811900130..2f1085ec6 100644 --- a/types/package.json +++ b/types/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver-types", "description": "Types used by the Language server for node", - "version": "3.17.3", + "version": "3.18.0-next.1", "author": "Microsoft Corporation", "license": "MIT", "repository": { diff --git a/types/src/main.ts b/types/src/main.ts index f6b912d34..7176b0169 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -4088,20 +4088,39 @@ export namespace InlayHint { } /** - * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. + * A snippet string is a template which allows to insert text + * and to control the editor cursor when insertion happens. + * + * A snippet can define tab stops and placeholders with `$1`, `$2` + * and `${3:foo}`. `$0` defines the final tab stop, it defaults to + * the end of the snippet. Variables are defined with `$name` and + * `${name:default value}`. * * @since 3.18.0 */ -export interface InlineCompletionItem { +export interface SnippetString { /** - * The text to replace the range with. Must be set. + * The snippet string. */ - insertText: string; + value: string; +} + +export namespace SnippetString { + export function create(value: string) { + return { value }; + } +} +/** + * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. + * + * @since 3.18.0 + */ +export interface InlineCompletionItem { /** - * The format of the insert text. The format applies to the `insertText`. If omitted defaults to `InsertTextFormat.PlainText`. + * The text to replace the range with. Must be set. */ - insertTextFormat?: InsertTextFormat; + insertText: string | SnippetString; /** * A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used. @@ -4120,8 +4139,8 @@ export interface InlineCompletionItem { } export namespace InlineCompletionItem { - export function create(insertText: string, filterText?: string, range?: Range, command?: Command, insertTextFormat?: InsertTextFormat): InlineCompletionItem { - return { insertText, filterText, range, command, insertTextFormat }; + export function create(insertText: string | SnippetString, filterText?: string, range?: Range, command?: Command): InlineCompletionItem { + return { insertText, filterText, range, command }; } } From 83248b8172bc1b10532fb88d24f5675759fee919 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Thu, 9 Mar 2023 13:43:28 +0100 Subject: [PATCH 6/8] Add proposed annot, rename StringValue, update meta --- client-node-tests/package-lock.json | 62 ++++++++-------- client-node-tests/src/converter.test.ts | 2 +- protocol/metaModel.json | 72 ++++++++++++------- .../src/common/protocol.inlineCompletion.ts | 5 ++ protocol/src/common/protocol.ts | 2 + types/src/main.ts | 23 ++++-- 6 files changed, 101 insertions(+), 65 deletions(-) diff --git a/client-node-tests/package-lock.json b/client-node-tests/package-lock.json index f9f2a7e05..7d1ab345f 100644 --- a/client-node-tests/package-lock.json +++ b/client-node-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "minimatch": "^3.0.4", - "vscode-languageserver": "8.1.0", + "vscode-languageserver": "8.1.0-next.1", "vscode-uri": "3.0.3" }, "devDependencies": { @@ -672,37 +672,37 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", - "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "version": "8.1.0-next.1", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.1.tgz", + "integrity": "sha512-FiPG+9TuMIga3t+kkalQytwqMtJu1djI+Pq+Ut2tvAJpcNHDJ0PYdjFv5mgEvTEJLujrYwjWHVkNe+XfHPBD/w==", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", - "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", + "version": "8.1.0-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.1.tgz", + "integrity": "sha512-u14Rk4JgXI+7iS6AEXI2pNc1dWh/5JEXtaqa4TeBECKJlN+5242mbGBBPaHMOE7sSI1Kh66XhEMZJhPYjUfjHw==", "dependencies": { - "vscode-languageserver-protocol": "3.17.3" + "vscode-languageserver-protocol": "3.17.3-next.1" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", - "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.1.tgz", + "integrity": "sha512-vgjvPE0zox+1Fi4ljsSFJ+B3g8wGNbuAEEdulueVdv+R2VHtc06+dgxhWiG4LKPqXwjPDmiuxCnvd2xk3fzTTw==", "dependencies": { - "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.17.3" + "vscode-jsonrpc": "8.1.0-next.1", + "vscode-languageserver-types": "3.17.2" } }, "node_modules/vscode-languageserver-types": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", - "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" + "version": "3.17.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", + "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" }, "node_modules/vscode-test": { "version": "1.6.1", @@ -1275,31 +1275,31 @@ "dev": true }, "vscode-jsonrpc": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", - "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==" + "version": "8.1.0-next.1", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.1.tgz", + "integrity": "sha512-FiPG+9TuMIga3t+kkalQytwqMtJu1djI+Pq+Ut2tvAJpcNHDJ0PYdjFv5mgEvTEJLujrYwjWHVkNe+XfHPBD/w==" }, "vscode-languageserver": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", - "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", + "version": "8.1.0-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.1.tgz", + "integrity": "sha512-u14Rk4JgXI+7iS6AEXI2pNc1dWh/5JEXtaqa4TeBECKJlN+5242mbGBBPaHMOE7sSI1Kh66XhEMZJhPYjUfjHw==", "requires": { - "vscode-languageserver-protocol": "3.17.3" + "vscode-languageserver-protocol": "3.17.3-next.1" } }, "vscode-languageserver-protocol": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", - "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "version": "3.17.3-next.1", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.1.tgz", + "integrity": "sha512-vgjvPE0zox+1Fi4ljsSFJ+B3g8wGNbuAEEdulueVdv+R2VHtc06+dgxhWiG4LKPqXwjPDmiuxCnvd2xk3fzTTw==", "requires": { - "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.17.3" + "vscode-jsonrpc": "8.1.0-next.1", + "vscode-languageserver-types": "3.17.2" } }, "vscode-languageserver-types": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", - "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" + "version": "3.17.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", + "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" }, "vscode-test": { "version": "1.6.1", diff --git a/client-node-tests/src/converter.test.ts b/client-node-tests/src/converter.test.ts index acbe6d538..3a645d59f 100644 --- a/client-node-tests/src/converter.test.ts +++ b/client-node-tests/src/converter.test.ts @@ -1248,7 +1248,7 @@ suite('Protocol Converter', () => { const items: proto.InlineCompletionItem[] = [ proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7)), proto.InlineCompletionItem.create('insert text', 'in', proto.Range.create(1, 2, 6, 7), undefined), - proto.InlineCompletionItem.create(proto.SnippetString.create('insert text'), 'in', proto.Range.create(1, 2, 6, 7), undefined), + proto.InlineCompletionItem.create(proto.StringValue.create('insert text'), 'in', proto.Range.create(1, 2, 6, 7), undefined), ]; const result = await p2c.asInlineCompletionResult(items); diff --git a/protocol/metaModel.json b/protocol/metaModel.json index 3d2ed139f..c6ead70e6 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -1013,8 +1013,9 @@ "kind": "reference", "name": "InlineCompletionRegistrationOptions" }, - "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "A request to provide inline completions in a document. The request's parameter is of\ntype {@link InlineCompletionParams}, the response is of type\n{@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "method": "client/registerCapability", @@ -4100,8 +4101,9 @@ "name": "WorkDoneProgressParams" } ], - "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "A parameter literal used in inline completion requests.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "InlineCompletionList", @@ -4134,7 +4136,7 @@ }, { "kind": "reference", - "name": "SnippetString" + "name": "StringValue" } ] }, @@ -4168,8 +4170,9 @@ "documentation": "An optional {@link Command} that is executed *after* inserting this completion." } ], - "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "InlineCompletionRegistrationOptions", @@ -4190,8 +4193,9 @@ "name": "StaticRegistrationOptions" } ], - "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Inline completion options used during static or dynamic registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "RegistrationParams", @@ -7773,12 +7777,21 @@ "documentation": "Provides information about the currently selected item in the autocomplete widget if it is visible." } ], - "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Provides information about the context in which an inline completion was requested.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { - "name": "SnippetString", + "name": "StringValue", "properties": [ + { + "name": "kind", + "type": { + "kind": "stringLiteral", + "value": "snippet" + }, + "documentation": "The kind of string value." + }, { "name": "value", "type": { @@ -7788,8 +7801,9 @@ "documentation": "The snippet string." } ], - "documentation": "A snippet string is a template which allows to insert text\nand to control the editor cursor when insertion happens.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Variables are defined with `$name` and\n`${name:default value}`.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "A string value used as a snippet is a template which allows to insert text\nand to control the editor cursor when insertion happens.\n\nA snippet can define tab stops and placeholders with `$1`, `$2`\nand `${3:foo}`. `$0` defines the final tab stop, it defaults to\nthe end of the snippet. Variables are defined with `$name` and\n`${name:default value}`.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "InlineCompletionOptions", @@ -7800,8 +7814,9 @@ } ], "properties": [], - "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "Registration", @@ -8623,8 +8638,9 @@ ] }, "optional": true, - "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Inline completion options used during static registration.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "workspace", @@ -9919,8 +9935,9 @@ "documentation": "The text the range will be replaced with if this completion is accepted." } ], - "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Describes the currently selected completion item.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "ClientCapabilities", @@ -10865,8 +10882,9 @@ "name": "InlineCompletionClientCapabilities" }, "optional": true, - "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true } ], "documentation": "Text document specific client capabilities." @@ -12704,8 +12722,9 @@ "documentation": "Whether implementation supports dynamic registration for inline completion providers." } ], - "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Client capabilities specific to inline completions.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "NotebookDocumentSyncClientCapabilities", @@ -13719,8 +13738,9 @@ "documentation": "Completion was triggered automatically while editing." } ], - "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0", - "since": "3.18.0" + "documentation": "Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "PositionEncodingKind", diff --git a/protocol/src/common/protocol.inlineCompletion.ts b/protocol/src/common/protocol.inlineCompletion.ts index 9c9b46f8c..d69d959c6 100644 --- a/protocol/src/common/protocol.inlineCompletion.ts +++ b/protocol/src/common/protocol.inlineCompletion.ts @@ -15,6 +15,7 @@ import type { TextDocumentRegistrationOptions, WorkDoneProgressOptions, StaticRe * Client capabilities specific to inline completions. * * @since 3.18.0 + * @proposed */ export type InlineCompletionClientCapabilities = { /** @@ -27,6 +28,7 @@ export type InlineCompletionClientCapabilities = { * Inline completion options used during static registration. * * @since 3.18.0 + * @proposed */ export type InlineCompletionOptions = WorkDoneProgressOptions; @@ -34,6 +36,7 @@ export type InlineCompletionOptions = WorkDoneProgressOptions; * Inline completion options used during static or dynamic registration. * * @since 3.18.0 + * @proposed */ export type InlineCompletionRegistrationOptions = InlineCompletionOptions & TextDocumentRegistrationOptions & StaticRegistrationOptions; @@ -41,6 +44,7 @@ export type InlineCompletionRegistrationOptions = InlineCompletionOptions & Text * A parameter literal used in inline completion requests. * * @since 3.18.0 + * @proposed */ export type InlineCompletionParams = WorkDoneProgressParams & TextDocumentPositionParams & { /** @@ -56,6 +60,7 @@ export type InlineCompletionParams = WorkDoneProgressParams & TextDocumentPositi * {@link InlineCompletion InlineCompletion[]} or a Thenable that resolves to such. * * @since 3.18.0 + * @proposed */ export namespace InlineCompletionRequest { export const method: 'textDocument/inlineCompletion' = 'textDocument/inlineCompletion'; diff --git a/protocol/src/common/protocol.ts b/protocol/src/common/protocol.ts index fa1902161..01420e14b 100644 --- a/protocol/src/common/protocol.ts +++ b/protocol/src/common/protocol.ts @@ -747,6 +747,7 @@ export interface TextDocumentClientCapabilities { * Client capabilities specific to inline completions. * * @since 3.18.0 + * @proposed */ inlineCompletion?: InlineCompletionClientCapabilities; } @@ -1260,6 +1261,7 @@ export interface ServerCapabilities { * Inline completion options used during static registration. * * @since 3.18.0 + * @proposed */ inlineCompletionProvider?: boolean | InlineCompletionOptions; diff --git a/types/src/main.ts b/types/src/main.ts index 7176b0169..361d87486 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -4088,7 +4088,7 @@ export namespace InlayHint { } /** - * A snippet string is a template which allows to insert text + * A string value used as a snippet is a template which allows to insert text * and to control the editor cursor when insertion happens. * * A snippet can define tab stops and placeholders with `$1`, `$2` @@ -4097,17 +4097,22 @@ export namespace InlayHint { * `${name:default value}`. * * @since 3.18.0 + * @proposed */ -export interface SnippetString { +export interface StringValue { + /** + * The kind of string value. + */ + kind: 'snippet'; /** * The snippet string. */ value: string; } -export namespace SnippetString { - export function create(value: string) { - return { value }; +export namespace StringValue { + export function create(value: string): StringValue { + return { value, kind: 'snippet' }; } } @@ -4115,12 +4120,13 @@ export namespace SnippetString { * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. * * @since 3.18.0 + * @proposed */ export interface InlineCompletionItem { /** * The text to replace the range with. Must be set. */ - insertText: string | SnippetString; + insertText: string | StringValue; /** * A text that is used to decide if this inline completion should be shown. When `falsy` the {@link InlineCompletionItem.insertText} is used. @@ -4139,7 +4145,7 @@ export interface InlineCompletionItem { } export namespace InlineCompletionItem { - export function create(insertText: string | SnippetString, filterText?: string, range?: Range, command?: Command): InlineCompletionItem { + export function create(insertText: string | StringValue, filterText?: string, range?: Range, command?: Command): InlineCompletionItem { return { insertText, filterText, range, command }; } } @@ -4164,6 +4170,7 @@ export namespace InlineCompletionList { * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. * * @since 3.18.0 + * @proposed */ export namespace InlineCompletionTriggerKind { /** @@ -4183,6 +4190,7 @@ export type InlineCompletionTriggerKind = 0 | 1; * Describes the currently selected completion item. * * @since 3.18.0 + * @proposed */ export interface SelectedCompletionInfo { /** @@ -4206,6 +4214,7 @@ export namespace SelectedCompletionInfo { * Provides information about the context in which an inline completion was requested. * * @since 3.18.0 + * @proposed */ export interface InlineCompletionContext { /** From e421956b718db83a09cc8a052a7bce782c40c289 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Tue, 14 Mar 2023 19:29:46 +0100 Subject: [PATCH 7/8] Adding missing tsdoc --- protocol/metaModel.json | 4 +++- types/src/main.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/protocol/metaModel.json b/protocol/metaModel.json index c6ead70e6..f081ee9a7 100644 --- a/protocol/metaModel.json +++ b/protocol/metaModel.json @@ -4120,7 +4120,9 @@ "documentation": "The inline completion items" } ], - "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor." + "documentation": "Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor.\n\n@since 3.18.0\n@proposed", + "since": "3.18.0", + "proposed": true }, { "name": "InlineCompletionItem", diff --git a/types/src/main.ts b/types/src/main.ts index 361d87486..eb3ebe455 100644 --- a/types/src/main.ts +++ b/types/src/main.ts @@ -4152,6 +4152,9 @@ export namespace InlineCompletionItem { /** * Represents a collection of {@link InlineCompletionItem inline completion items} to be presented in the editor. + * + * @since 3.18.0 + * @proposed */ export interface InlineCompletionList { /** From 59d676d3dc9cd772db26de2636c9783b149335d4 Mon Sep 17 00:00:00 2001 From: Cristopher Claeys Date: Fri, 31 Mar 2023 13:35:32 +0200 Subject: [PATCH 8/8] Undo eager version bumps --- client-node-tests/package-lock.json | 62 ++++++++++++++--------------- client-node-tests/package.json | 2 +- client/package-lock.json | 4 +- client/package.json | 4 +- protocol/package.json | 4 +- server/package.json | 4 +- types/package-lock.json | 4 +- types/package.json | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/client-node-tests/package-lock.json b/client-node-tests/package-lock.json index 7d1ab345f..f9f2a7e05 100644 --- a/client-node-tests/package-lock.json +++ b/client-node-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "minimatch": "^3.0.4", - "vscode-languageserver": "8.1.0-next.1", + "vscode-languageserver": "8.1.0", "vscode-uri": "3.0.3" }, "devDependencies": { @@ -672,37 +672,37 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.1.0-next.1", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.1.tgz", - "integrity": "sha512-FiPG+9TuMIga3t+kkalQytwqMtJu1djI+Pq+Ut2tvAJpcNHDJ0PYdjFv5mgEvTEJLujrYwjWHVkNe+XfHPBD/w==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", + "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", "engines": { "node": ">=14.0.0" } }, "node_modules/vscode-languageserver": { - "version": "8.1.0-next.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.1.tgz", - "integrity": "sha512-u14Rk4JgXI+7iS6AEXI2pNc1dWh/5JEXtaqa4TeBECKJlN+5242mbGBBPaHMOE7sSI1Kh66XhEMZJhPYjUfjHw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", + "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", "dependencies": { - "vscode-languageserver-protocol": "3.17.3-next.1" + "vscode-languageserver-protocol": "3.17.3" }, "bin": { "installServerIntoExtension": "bin/installServerIntoExtension" } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.3-next.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.1.tgz", - "integrity": "sha512-vgjvPE0zox+1Fi4ljsSFJ+B3g8wGNbuAEEdulueVdv+R2VHtc06+dgxhWiG4LKPqXwjPDmiuxCnvd2xk3fzTTw==", + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", + "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", "dependencies": { - "vscode-jsonrpc": "8.1.0-next.1", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0", + "vscode-languageserver-types": "3.17.3" } }, "node_modules/vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", + "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, "node_modules/vscode-test": { "version": "1.6.1", @@ -1275,31 +1275,31 @@ "dev": true }, "vscode-jsonrpc": { - "version": "8.1.0-next.1", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0-next.1.tgz", - "integrity": "sha512-FiPG+9TuMIga3t+kkalQytwqMtJu1djI+Pq+Ut2tvAJpcNHDJ0PYdjFv5mgEvTEJLujrYwjWHVkNe+XfHPBD/w==" + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", + "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==" }, "vscode-languageserver": { - "version": "8.1.0-next.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0-next.1.tgz", - "integrity": "sha512-u14Rk4JgXI+7iS6AEXI2pNc1dWh/5JEXtaqa4TeBECKJlN+5242mbGBBPaHMOE7sSI1Kh66XhEMZJhPYjUfjHw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz", + "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==", "requires": { - "vscode-languageserver-protocol": "3.17.3-next.1" + "vscode-languageserver-protocol": "3.17.3" } }, "vscode-languageserver-protocol": { - "version": "3.17.3-next.1", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3-next.1.tgz", - "integrity": "sha512-vgjvPE0zox+1Fi4ljsSFJ+B3g8wGNbuAEEdulueVdv+R2VHtc06+dgxhWiG4LKPqXwjPDmiuxCnvd2xk3fzTTw==", + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", + "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", "requires": { - "vscode-jsonrpc": "8.1.0-next.1", - "vscode-languageserver-types": "3.17.2" + "vscode-jsonrpc": "8.1.0", + "vscode-languageserver-types": "3.17.3" } }, "vscode-languageserver-types": { - "version": "3.17.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", - "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", + "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" }, "vscode-test": { "version": "1.6.1", diff --git a/client-node-tests/package.json b/client-node-tests/package.json index 08c21c988..0855dd5aa 100644 --- a/client-node-tests/package.json +++ b/client-node-tests/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "minimatch": "^3.0.4", - "vscode-languageserver": "8.1.0-next.1", + "vscode-languageserver": "8.1.0", "vscode-uri": "3.0.3" }, "devDependencies": { diff --git a/client/package-lock.json b/client/package-lock.json index 57da6bea8..0b2ea52aa 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-languageclient", - "version": "8.2.0-next.1", + "version": "8.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-languageclient", - "version": "8.2.0-next.1", + "version": "8.1.0", "license": "MIT", "dependencies": { "minimatch": "^5.1.0", diff --git a/client/package.json b/client/package.json index ef91f141a..6a16b2326 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageclient", "description": "VSCode Language client implementation", - "version": "8.2.0-next.1", + "version": "8.1.0", "author": "Microsoft Corporation", "license": "MIT", "engines": { @@ -30,7 +30,7 @@ "dependencies": { "minimatch": "^5.1.0", "semver": "^7.3.7", - "vscode-languageserver-protocol": "3.18.0-next.1" + "vscode-languageserver-protocol": "3.17.3" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/protocol/package.json b/protocol/package.json index ef970725b..4abf03826 100644 --- a/protocol/package.json +++ b/protocol/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver-protocol", "description": "VSCode Language Server Protocol implementation", - "version": "3.18.0-next.1", + "version": "3.17.3", "author": "Microsoft Corporation", "license": "MIT", "repository": { @@ -19,7 +19,7 @@ "typings": "./lib/common/api.d.ts", "dependencies": { "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.18.0-next.1" + "vscode-languageserver-types": "3.17.3" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/server/package.json b/server/package.json index de74d0992..52485851a 100644 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver", "description": "Language server implementation for node", - "version": "8.1.0-next.1", + "version": "8.1.0", "author": "Microsoft Corporation", "license": "MIT", "repository": { @@ -24,7 +24,7 @@ "vscode-languageserver-textdocument": "1.0.9" }, "dependencies": { - "vscode-languageserver-protocol": "3.18.0-next.1" + "vscode-languageserver-protocol": "3.17.3" }, "scripts": { "prepublishOnly": "echo \"⛔ Can only publish from a secure pipeline ⛔\" && node ../build/npm/fail", diff --git a/types/package-lock.json b/types/package-lock.json index 08a6e4ca8..0bdaea6d0 100644 --- a/types/package-lock.json +++ b/types/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-languageserver-types", - "version": "3.18.0-next.1", + "version": "3.17.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-languageserver-types", - "version": "3.18.0-next.1", + "version": "3.17.3", "license": "MIT" } } diff --git a/types/package.json b/types/package.json index 2f1085ec6..811900130 100644 --- a/types/package.json +++ b/types/package.json @@ -1,7 +1,7 @@ { "name": "vscode-languageserver-types", "description": "Types used by the Language server for node", - "version": "3.18.0-next.1", + "version": "3.17.3", "author": "Microsoft Corporation", "license": "MIT", "repository": {