From b34379e8f711ea6eb69cd86bfe1e5ea9639d8f52 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 20 Sep 2017 18:34:24 -0700 Subject: [PATCH] Take context as last argument --- .../standalone/browser/standaloneLanguages.ts | 17 +------- src/vs/monaco.d.ts | 19 +------- src/vs/vscode.d.ts | 43 ++++--------------- .../api/node/extHostLanguageFeatures.ts | 5 +-- 4 files changed, 13 insertions(+), 71 deletions(-) diff --git a/src/vs/editor/standalone/browser/standaloneLanguages.ts b/src/vs/editor/standalone/browser/standaloneLanguages.ts index 78e9541da8e..a362d640897 100644 --- a/src/vs/editor/standalone/browser/standaloneLanguages.ts +++ b/src/vs/editor/standalone/browser/standaloneLanguages.ts @@ -556,16 +556,6 @@ export interface CompletionContext { triggerCharacter?: string; } -export namespace CompletionItemProvider { - export interface ProvideCompletionItems { - (document: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } - - export interface ProvideCompletionItemsForContext { - (document: editorCommon.IReadOnlyModel, position: Position, context: CompletionContext, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } -} - /** * The completion item provider interface defines the contract between extensions and * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). @@ -582,7 +572,7 @@ export interface CompletionItemProvider { /** * Provide completion items for the given position and document. */ - provideCompletionItems: CompletionItemProvider.ProvideCompletionItems | CompletionItemProvider.ProvideCompletionItemsForContext; + provideCompletionItems(document: editorCommon.IReadOnlyModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) @@ -670,10 +660,7 @@ class SuggestAdapter { } provideCompletionItems(model: editorCommon.IReadOnlyModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable { - const result = this._provider.provideCompletionItems.length <= 3 - ? (this._provider.provideCompletionItems as CompletionItemProvider.ProvideCompletionItems)(model, position, token) - : (this._provider.provideCompletionItems as CompletionItemProvider.ProvideCompletionItemsForContext)(model, position, context, token); - + const result = this._provider.provideCompletionItems(model, position, token, context); return toThenable(result).then(value => { const result: modes.ISuggestResult = { suggestions: [] diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 911e235a94d..d633e2bd6cb 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -4246,23 +4246,6 @@ declare module monaco.languages { triggerCharacter?: string; } - export namespace CompletionItemProvider { - interface ProvideCompletionItems { - (document: editor.IReadOnlyModel, position: Position, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } - interface ProvideCompletionItemsForContext { - (document: editor.IReadOnlyModel, position: Position, context: CompletionContext, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } - } - - interface ProvideCompletionItems { - (document: editor.IReadOnlyModel, position: Position, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } - - interface ProvideCompletionItemsForContext { - (document: editor.IReadOnlyModel, position: Position, context: CompletionContext, token: CancellationToken): CompletionItem[] | Thenable | CompletionList | Thenable; - } - /** * The completion item provider interface defines the contract between extensions and * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). @@ -4279,7 +4262,7 @@ declare module monaco.languages { /** * Provide completion items for the given position and document. */ - provideCompletionItems: CompletionItemProvider.ProvideCompletionItems | CompletionItemProvider.ProvideCompletionItemsForContext; + provideCompletionItems(document: editor.IReadOnlyModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable | CompletionList | Thenable; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) * or [details](#CompletionItem.detail). diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 4ba969a482d..bf5170ac593 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -2736,39 +2736,6 @@ declare module 'vscode' { readonly triggerCharacter?: string; } - - namespace CompletionItemProvider { - export interface ProvideCompletionItems { - /** - * Provide completion items for the given position and document. - * - * @deprecated Used [ProvideCompletionItemsForContext](#ProvideCompletionItemsForContext) instead - * - * @param document The document in which the command was invoked. - * @param position The position at which the command was invoked. - * @param token A cancellation token. - * - * @return An array of completions, a [completion list](#CompletionList), or a thenable that resolves to either. - * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array. - */ - (document: TextDocument, position: Position, token: CancellationToken): ProviderResult; - } - - export interface ProvideCompletionItemsForContext { - /** - * Provide completion items for the given position and document. - * - * @param document The document in which the command was invoked. - * @param position The position at which the command was invoked. - * @param context How the completion was triggered. - * @param token A cancellation token. - * - * @return An array of completions, a [completion list](#CompletionList), or a thenable that resolves to either. - * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array. - */ - (document: TextDocument, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult; - } - } /** * The completion item provider interface defines the contract between extensions and * [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). @@ -2787,8 +2754,16 @@ declare module 'vscode' { /** * Provide completion items for the given position and document. + * + * @param document The document in which the command was invoked. + * @param position The position at which the command was invoked. + * @param token A cancellation token. + * @param context How the completion was triggered. + * + * @return An array of completions, a [completion list](#CompletionList), or a thenable that resolves to either. + * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array. */ - provideCompletionItems: CompletionItemProvider.ProvideCompletionItems | CompletionItemProvider.ProvideCompletionItemsForContext; + provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): ProviderResult; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index 3718f434c24..8ae31ac1f2c 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -492,10 +492,7 @@ class SuggestAdapter { const pos = TypeConverters.toPosition(position); return asWinJsPromise(token => { - if (this._provider.provideCompletionItems.length <= 3) { - return (this._provider.provideCompletionItems as vscode.CompletionItemProvider.ProvideCompletionItems)(doc, pos, token); - } - return (this._provider.provideCompletionItems as vscode.CompletionItemProvider.ProvideCompletionItemsForContext)(doc, pos, context, token); + return this._provider.provideCompletionItems(doc, pos, token, context); }).then(value => { const _id = this._idPool++;