From 9b1c6cb3fffa41f6e308f8221b53d3882ab163ca Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 27 Jun 2022 15:26:49 +0200 Subject: [PATCH] joh/issue152834 (#153298) * update sample * dynamically alias `ms-vscode.references-view` onto `vscode.references-view` --- .../references-view/src/references-view.d.ts | 24 +++++++++---------- .../workbench/api/common/extHost.api.impl.ts | 6 +++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/extensions/references-view/src/references-view.d.ts b/extensions/references-view/src/references-view.d.ts index 70fd932a19f..9ec370029a7 100644 --- a/extensions/references-view/src/references-view.d.ts +++ b/extensions/references-view/src/references-view.d.ts @@ -6,14 +6,14 @@ import * as vscode from 'vscode'; /** - * This interface describes the shape for the references viewlet API. It consists - * of a single `setInput` function which must be called with a full implementation + * This interface describes the shape for the references viewlet API. It consists + * of a single `setInput` function which must be called with a full implementation * of the `SymbolTreeInput`-interface. To acquire this API use the default mechanics, e.g: - * + * * ```ts * // get references viewlet API - * const api = await vscode.extensions.getExtension('ms-vscode.references-view').activate(); - * + * const api = await vscode.extensions.getExtension('vscode.references-view').activate(); + * * // instantiate and set input which updates the view * const myInput: SymbolTreeInput = ... * api.setInput(myInput) @@ -22,8 +22,8 @@ import * as vscode from 'vscode'; export interface SymbolTree { /** - * Set the contents of the references viewlet. - * + * Set the contents of the references viewlet. + * * @param input A symbol tree input object */ setInput(input: SymbolTreeInput): void; @@ -31,7 +31,7 @@ export interface SymbolTree { /** * A symbol tree input is the entry point for populating the references viewlet. - * Inputs must be anchored at a code location, they must have a title, and they + * Inputs must be anchored at a code location, they must have a title, and they * must resolve to a model. */ export interface SymbolTreeInput { @@ -54,17 +54,17 @@ export interface SymbolTreeInput { readonly location: vscode.Location; /** - * Resolve this input to a model that contains the actual data. When there are no result + * Resolve this input to a model that contains the actual data. When there are no result * than `undefined` or `null` should be returned. */ resolve(): vscode.ProviderResult>; /** * This function is called when re-running from history. The symbols tree has tracked - * the original location of this input and that is now passed to this input. The + * the original location of this input and that is now passed to this input. The * implementation of this function should return a clone where the `location`-property * uses the provided `location` - * + * * @param location The location at which the new input should be anchored. * @returns A new input which location is anchored at the position. */ @@ -94,7 +94,7 @@ export interface SymbolTreeModel { navigation?: SymbolItemNavigation; /** - * Optional support for editor highlights. WHen implemented, the editor will highlight + * Optional support for editor highlights. WHen implemented, the editor will highlight * symbol ranges in the source code. */ highlights?: SymbolItemEditorHighlights; diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index b438fb90ead..24d3391bc2c 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -92,6 +92,7 @@ import { ExtHostInteractive } from 'vs/workbench/api/common/extHostInteractive'; import { combinedDisposable } from 'vs/base/common/lifecycle'; import { checkProposedApiEnabled, ExtensionIdentifierSet, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions'; import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug'; +import { equalsIgnoreCase } from 'vs/base/common/strings'; export interface IExtensionRegistries { mine: ExtensionDescriptionRegistry; @@ -392,6 +393,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I const extensions: typeof vscode.extensions = { getExtension(extensionId: string, includeFromDifferentExtensionHosts?: boolean): vscode.Extension | undefined { + if (equalsIgnoreCase(extensionId, 'ms-vscode.references-view')) { + extHostApiDeprecation.report(`The extension 'ms-vscode.references-view' has been renamed.`, extension, `Use 'vscode.references-view' instead.`); + extensionId = 'vscode.references-view'; + } + if (!isProposedApiEnabled(extension, 'extensionsAny')) { includeFromDifferentExtensionHosts = false; }