diff --git a/extensions/emmet/tsconfig.json b/extensions/emmet/tsconfig.json index ad07467f4ea..994fa239537 100644 --- a/extensions/emmet/tsconfig.json +++ b/extensions/emmet/tsconfig.json @@ -9,7 +9,6 @@ ], "include": [ "src/**/*", - "../../src/vscode-dts/vscode.d.ts", - "../../src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts", + "../../src/vscode-dts/vscode.d.ts" ] } diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index f2990a7c1e2..52cd8c59cb3 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -550,13 +550,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I } return extHostLanguageFeatures.registerInlineCompletionsProvider(extension, checkSelector(selector), provider); }, - registerInlineCompletionItemProviderNew(selector: vscode.DocumentSelector, provider: vscode.InlineCompletionItemProviderNew): vscode.Disposable { - checkProposedApiEnabled(extension, 'inlineCompletionsNew'); - if (provider.handleDidShowCompletionItem && !isProposedApiEnabled(extension, 'inlineCompletionsAdditions')) { - throw new Error(`When the method "handleDidShowCompletionItem" is implemented on a provider, the usage of the proposed api 'inlineCompletionsAdditions' must be declared!`); - } - return extHostLanguageFeatures.registerInlineCompletionsProviderNew(extension, checkSelector(selector), provider); - }, registerDocumentLinkProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable { return extHostLanguageFeatures.registerDocumentLinkProvider(extension, checkSelector(selector), provider); }, @@ -1259,7 +1252,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I InlineValueVariableLookup: extHostTypes.InlineValueVariableLookup, InlineValueEvaluatableExpression: extHostTypes.InlineValueEvaluatableExpression, InlineCompletionTriggerKind: extHostTypes.InlineCompletionTriggerKind, - InlineCompletionTriggerKindNew: extHostTypes.InlineCompletionTriggerKindNew, EventEmitter: Emitter, ExtensionKind: extHostTypes.ExtensionKind, ExtensionMode: extHostTypes.ExtensionMode, @@ -1273,9 +1265,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I FoldingRangeKind: extHostTypes.FoldingRangeKind, FunctionBreakpoint: extHostTypes.FunctionBreakpoint, InlineCompletionItem: extHostTypes.InlineSuggestion, - InlineCompletionItemNew: extHostTypes.InlineSuggestionNew, InlineCompletionList: extHostTypes.InlineSuggestionList, - InlineCompletionListNew: extHostTypes.InlineSuggestionsNew, Hover: extHostTypes.Hover, IndentAction: languageConfiguration.IndentAction, Location: extHostTypes.Location, diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index 0edeb1100bc..8a6ca7a4dc5 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -7,7 +7,7 @@ import { URI, UriComponents } from 'vs/base/common/uri'; import { mixin } from 'vs/base/common/objects'; import type * as vscode from 'vscode'; import * as typeConvert from 'vs/workbench/api/common/extHostTypeConverters'; -import { Range, Disposable, CompletionList, SnippetString, CodeActionKind, SymbolInformation, DocumentSymbol, SemanticTokensEdits, SemanticTokens, SemanticTokensEdit, Location, InlineCompletionTriggerKindNew, InlineCompletionTriggerKind } from 'vs/workbench/api/common/extHostTypes'; +import { Range, Disposable, CompletionList, SnippetString, CodeActionKind, SymbolInformation, DocumentSymbol, SemanticTokensEdits, SemanticTokens, SemanticTokensEdit, Location, InlineCompletionTriggerKind } from 'vs/workbench/api/common/extHostTypes'; import { ISingleEditOperation } from 'vs/editor/common/core/editOperation'; import * as languages from 'vs/editor/common/languages'; import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments'; @@ -1184,110 +1184,6 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase { } } -class InlineCompletionAdapterNew extends InlineCompletionAdapterBase { - private readonly _references = new ReferenceMap<{ - dispose(): void; - items: readonly vscode.InlineCompletionItemNew[]; - }>(); - - private readonly isAdditionProposedApiEnabled = isProposedApiEnabled(this.extension, 'inlineCompletionsAdditions'); - - constructor( - private readonly extension: IExtensionDescription, - private readonly _documents: ExtHostDocuments, - private readonly _provider: vscode.InlineCompletionItemProviderNew, - private readonly _commands: CommandsConverter, - ) { - super(); - } - - private readonly languageTriggerKindToVSCodeTriggerKind: Record = { - [languages.InlineCompletionTriggerKind.Automatic]: InlineCompletionTriggerKindNew.Automatic, - [languages.InlineCompletionTriggerKind.Explicit]: InlineCompletionTriggerKindNew.Invoke, - }; - - override async provideInlineCompletions(resource: URI, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise { - const doc = this._documents.getDocument(resource); - const pos = typeConvert.Position.to(position); - - const result = await this._provider.provideInlineCompletionItems(doc, pos, { - selectedCompletionInfo: - context.selectedSuggestionInfo - ? { - range: typeConvert.Range.to(context.selectedSuggestionInfo.range), - text: context.selectedSuggestionInfo.text - } - : undefined, - triggerKind: this.languageTriggerKindToVSCodeTriggerKind[context.triggerKind] - }, token); - - if (!result) { - // undefined and null are valid results - return undefined; - } - - if (token.isCancellationRequested) { - // cancelled -> return without further ado, esp no caching - // of results as they will leak - return undefined; - } - - const normalizedResult = Array.isArray(result) ? result : result.items; - const commands = Array.isArray(result) ? [] : result.commands || []; - - let disposableStore: DisposableStore | undefined = undefined; - const pid = this._references.createReferenceId({ - dispose() { - disposableStore?.dispose(); - }, - items: normalizedResult - }); - - return { - pid, - items: normalizedResult.map((item, idx) => { - let command: languages.Command | undefined = undefined; - if (item.command) { - if (!disposableStore) { - disposableStore = new DisposableStore(); - } - command = this._commands.toInternal(item.command, disposableStore); - } - - const insertText = item.insertText; - return ({ - insertText: typeof insertText === 'string' ? insertText : { snippet: insertText.value }, - filterText: item.filterText, - range: item.range ? typeConvert.Range.from(item.range) : undefined, - command, - idx: idx, - completeBracketPairs: this.isAdditionProposedApiEnabled ? item.completeBracketPairs : false - }); - }), - commands: commands.map(c => { - if (!disposableStore) { - disposableStore = new DisposableStore(); - } - return this._commands.toInternal(c, disposableStore); - }) - }; - } - - override disposeCompletions(pid: number) { - const data = this._references.disposeReferenceId(pid); - data?.dispose(); - } - - override handleDidShowCompletionItem(pid: number, idx: number): void { - const completionItem = this._references.get(pid)?.items[idx]; - if (completionItem) { - if (this._provider.handleDidShowCompletionItem && this.isAdditionProposedApiEnabled) { - this._provider.handleDidShowCompletionItem(completionItem); - } - } - } -} - class ReferenceMap { private readonly _references = new Map(); private _idPool = 1; @@ -1821,7 +1717,7 @@ type Adapter = DocumentSymbolAdapter | CodeLensAdapter | DefinitionAdapter | Hov | SelectionRangeAdapter | CallHierarchyAdapter | TypeHierarchyAdapter | DocumentSemanticTokensAdapter | DocumentRangeSemanticTokensAdapter | EvaluatableExpressionAdapter | InlineValuesAdapter - | LinkedEditingRangeAdapter | InlayHintsAdapter | InlineCompletionAdapter | InlineCompletionAdapterNew + | LinkedEditingRangeAdapter | InlayHintsAdapter | InlineCompletionAdapter | DocumentOnDropEditAdapter; class AdapterData { @@ -2253,12 +2149,6 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF return this._createDisposable(handle); } - registerInlineCompletionsProviderNew(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.InlineCompletionItemProviderNew): vscode.Disposable { - const handle = this._addNewAdapter(new InlineCompletionAdapterNew(extension, this._documents, provider, this._commands.converter), extension); - this._proxy.$registerInlineCompletionsSupport(handle, this._transformDocumentSelector(selector), true); - return this._createDisposable(handle); - } - $provideInlineCompletions(handle: number, resource: UriComponents, position: IPosition, context: languages.InlineCompletionContext, token: CancellationToken): Promise { return this._withAdapter(handle, InlineCompletionAdapterBase, adapter => adapter.provideInlineCompletions(URI.revive(resource), position, context, token), undefined, token); } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 3b555773c29..4c8ac5c6bce 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1719,40 +1719,15 @@ export class InlineSuggestion implements vscode.InlineCompletionItem { @es5ClassCompat export class InlineSuggestionList implements vscode.InlineCompletionList { - items: vscode.InlineCompletionItemNew[]; + items: vscode.InlineCompletionItem[]; commands: vscode.Command[] | undefined = undefined; - constructor(items: vscode.InlineCompletionItemNew[]) { + constructor(items: vscode.InlineCompletionItem[]) { this.items = items; } } -@es5ClassCompat -export class InlineSuggestionNew implements vscode.InlineCompletionItemNew { - insertText: string; - range?: Range; - command?: vscode.Command; - - constructor(insertText: string, range?: Range, command?: vscode.Command) { - this.insertText = insertText; - this.range = range; - this.command = command; - } -} - -@es5ClassCompat -export class InlineSuggestionsNew implements vscode.InlineCompletionListNew { - items: vscode.InlineCompletionItemNew[]; - - commands: vscode.Command[] | undefined; - - constructor(items: vscode.InlineCompletionItemNew[], commands?: vscode.Command[]) { - this.items = items; - this.commands = commands; - } -} - export enum ViewColumn { Active = -1, Beside = -2, @@ -2881,11 +2856,6 @@ export enum InlineCompletionTriggerKind { Automatic = 1, } -export enum InlineCompletionTriggerKindNew { - Invoke = 0, - Automatic = 1, -} - @es5ClassCompat export class InlineValueText implements vscode.InlineValueText { readonly range: Range; diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 99661eff533..fc3c907c52f 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -37,7 +37,6 @@ export const allApiProposals = Object.freeze({ fsChunks: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.fsChunks.d.ts', idToken: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.idToken.d.ts', inlineCompletionsAdditions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts', - inlineCompletionsNew: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts', interactiveWindow: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.interactiveWindow.d.ts', ipc: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.ipc.d.ts', notebookCellExecutionState: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookCellExecutionState.d.ts', diff --git a/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts b/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts index 8ec3e6109f8..3b6a8722e4e 100644 --- a/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts +++ b/src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts @@ -7,19 +7,6 @@ declare module 'vscode' { // https://github.com/microsoft/vscode/issues/124024 @hediet @alexdima - export interface InlineCompletionItemNew { - /** - * If set to `true`, unopened closing brackets are removed and unclosed opening brackets are closed. - * Defaults to `false`. - */ - completeBracketPairs?: boolean; - } - - export interface InlineCompletionItemProviderNew { - // eslint-disable-next-line local/vscode-dts-provider-naming - handleDidShowCompletionItem?(completionItem: InlineCompletionItemNew): void; - } - export interface InlineCompletionItem { /** * If set to `true`, unopened closing brackets are removed and unclosed opening brackets are closed. diff --git a/src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts b/src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts deleted file mode 100644 index 16802c3369a..00000000000 --- a/src/vscode-dts/vscode.proposed.inlineCompletionsNew.d.ts +++ /dev/null @@ -1,168 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare module 'vscode' { - - // https://github.com/microsoft/vscode/issues/124024 @hediet @alexdima - // Temporary API to allow for safe migration. - - export namespace languages { - - /** - * Registers an inline completion provider. - * - * Multiple providers can be registered for a language. In that case providers are asked in - * parallel and the results are merged. A failing provider (rejected promise or exception) will - * not cause a failure of the whole operation. - * - * @param selector A selector that defines the documents this provider is applicable to. - * @param provider An inline completion provider. - * @return A {@link Disposable} that unregisters this provider when being disposed. - */ - export function registerInlineCompletionItemProviderNew(selector: DocumentSelector, provider: InlineCompletionItemProviderNew): Disposable; - } - - /** - * The inline completion item provider interface defines the contract between extensions and - * the inline completion feature. - * - * Providers are asked for completions either explicitly by a user gesture or implicitly when typing. - */ - export interface InlineCompletionItemProviderNew { - - /** - * Provides inline completion items for the given position and document. - * If inline completions are enabled, this method will be called whenever the user stopped typing. - * It will also be called when the user explicitly triggers inline completions or explicitly asks for the next or previous inline completion. - * In that case, all available inline completions should be returned. - * `context.triggerKind` can be used to distinguish between these scenarios. - * - * @param document The document inline completions are requested for. - * @param position The position inline completions are requested for. - * @param context A context object with additional information. - * @param token A cancellation token. - * @return An array of completion items or a thenable that resolves to an array of completion items. - */ - provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContextNew, token: CancellationToken): ProviderResult; - } - - /** - * Provides information about the context in which an inline completion was requested. - */ - export interface InlineCompletionContextNew { - /** - * Describes how the inline completion was triggered. - */ - readonly triggerKind: InlineCompletionTriggerKindNew; - - /** - * Provides information about the currently selected item in the autocomplete widget if it is visible. - * - * If set, provided inline completions must extend the text of the selected item - * and use the same range, otherwise they are not shown as preview. - * As an example, if the document text is `console.` and the selected item is `.log` replacing the `.` in the document, - * the inline completion must also replace `.` and start with `.log`, for example `.log()`. - * - * Inline completion providers are requested again whenever the selected item changes. - */ - readonly selectedCompletionInfo: SelectedCompletionInfoNew | undefined; - } - - /** - * Describes the currently selected completion item. - */ - export interface SelectedCompletionInfoNew { - /** - * The range that will be replaced if this completion item is accepted. - */ - readonly range: Range; - - /** - * The text the range will be replaced with if this completion is accepted. - */ - readonly text: string; - } - - /** - * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered. - */ - export enum InlineCompletionTriggerKindNew { - /** - * Completion was triggered explicitly by a user gesture. - * Return multiple completion items to enable cycling through them. - */ - Invoke = 0, - - /** - * Completion was triggered automatically while editing. - * It is sufficient to return a single completion item in this case. - */ - Automatic = 1, - } - - /** - * Represents a collection of {@link InlineCompletionItemNew inline completion items} to be presented - * in the editor. - */ - export class InlineCompletionListNew { - /** - * The inline completion items. - */ - items: InlineCompletionItemNew[]; - - /** - * A list of commands associated with the inline completions of this list. - */ - commands?: Command[]; - - /** - * Creates a new list of inline completion items with optionally given commands. - */ - constructor(items: InlineCompletionItemNew[], commands?: Command[]); - } - - /** - * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed. - * - * @see {@link InlineCompletionItemProviderNew.provideInlineCompletionItems} - */ - export class InlineCompletionItemNew { - /** - * The text to replace the range with. Must be set. - * Is used both for the preview and the accept operation. - */ - insertText: string | SnippetString; - - /** - * A text that is used to decide if this inline completion should be shown. When `falsy` - * the {@link InlineCompletionItemNew.insertText} is used. - * - * An inline completion is shown if the text to replace is a prefix of the filter text. - */ - filterText?: string; - - /** - * The range to replace. - * Must begin and end on the same line. - * - * Prefer replacements over insertions to provide a better experience when the user deletes typed text. - */ - range?: Range; - - /** - * An optional {@link Command} that is executed *after* inserting this completion. - */ - command?: Command; - - /** - * Creates a new inline completion item. - * - * @param insertText The text to replace the range with. - * @param range The range to replace. If not set, the word at the requested position will be used. - * @param command An optional {@link Command} that is executed *after* inserting this completion. - */ - constructor(insertText: string | SnippetString, range?: Range, command?: Command); - } -}