From cbf8b411b9ccce33926bfa2d20f86e0970a85235 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 13 Sep 2021 09:10:41 +0200 Subject: [PATCH] move TypeHierarchy-API to stable, https://github.com/microsoft/vscode/issues/15533 --- src/vs/vscode.d.ts | 107 +++++++++++++++++ src/vs/vscode.proposed.d.ts | 113 ------------------ .../workbench/api/common/extHost.api.impl.ts | 7 +- 3 files changed, 110 insertions(+), 117 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 3e35c909840db..25abfe52cadfc 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -4767,6 +4767,104 @@ declare module 'vscode' { provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult; } + /** + * Represents an item of a type hierarchy, like a class or an interface. + */ + export class TypeHierarchyItem { + /** + * The name of this item. + */ + name: string; + + /** + * The kind of this item. + */ + kind: SymbolKind; + + /** + * Tags for this item. + */ + tags?: ReadonlyArray; + + /** + * More detail for this item, e.g. the signature of a function. + */ + detail?: string; + + /** + * The resource identifier of this item. + */ + uri: Uri; + + /** + * The range enclosing this symbol not including leading/trailing whitespace + * but everything else, e.g. comments and code. + */ + range: Range; + + /** + * The range that should be selected and revealed when this symbol is being + * picked, e.g. the name of a class. Must be contained by the {@link TypeHierarchyItem.range range}-property. + */ + selectionRange: Range; + + /** + * Creates a new type hierarchy item. + * + * @param kind The kind of the item. + * @param name The name of the item. + * @param detail The details of the item. + * @param uri The Uri of the item. + * @param range The whole range of the item. + * @param selectionRange The selection range of the item. + */ + constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range); + } + + /** + * The type hierarchy provider interface describes the contract between extensions + * and the type hierarchy feature. + */ + export interface TypeHierarchyProvider { + + /** + * Bootstraps type hierarchy by returning the item that is denoted by the given document + * and position. This item will be used as entry into the type graph. Providers should + * return `undefined` or `null` when there is no item at the given location. + * + * @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. + * @returns One or multiple type hierarchy items or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined`, `null`, or an empty array. + */ + prepareTypeHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; + + /** + * Provide all supertypes for an item, e.g all types from which a type is derived/inherited. In graph terms this describes directed + * and annotated edges inside the type graph, e.g the given item is the starting node and the result is the nodes + * that can be reached. + * + * @param item The hierarchy item for which super types should be computed. + * @param token A cancellation token. + * @returns A set of direct supertypes or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + provideTypeHierarchySupertypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult; + + /** + * Provide all subtypes for an item, e.g all types which are derived/inherited from the given item. In + * graph terms this describes directed and annotated edges inside the type graph, e.g the given item is the starting + * node and the result is the nodes that can be reached. + * + * @param item The hierarchy item for which subtypes should be computed. + * @param token A cancellation token. + * @returns A set of direct subtypes or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + provideTypeHierarchySubtypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult; + } + /** * Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents. */ @@ -11520,6 +11618,15 @@ declare module 'vscode' { */ export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable; + /** + * Register a type hierarchy provider. + * + * @param selector A selector that defines the documents this provider is applicable to. + * @param provider A type hierarchy provider. + * @return {@link Disposable Disposable} that unregisters this provider when being disposed. + */ + export function registerTypeHierarchyProvider(selector: DocumentSelector, provider: TypeHierarchyProvider): Disposable; + /** * Register a linked editing range provider. * diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 726ec43319a80..ab1afb9c1b3a6 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -2816,119 +2816,6 @@ declare module 'vscode' { //#endregion - - //#region https://github.com/microsoft/vscode/issues/15533 --- Type hierarchy --- @eskibear - - /** - * Represents an item of a type hierarchy, like a class or an interface. - */ - export class TypeHierarchyItem { - /** - * The name of this item. - */ - name: string; - - /** - * The kind of this item. - */ - kind: SymbolKind; - - /** - * Tags for this item. - */ - tags?: ReadonlyArray; - - /** - * More detail for this item, e.g. the signature of a function. - */ - detail?: string; - - /** - * The resource identifier of this item. - */ - uri: Uri; - - /** - * The range enclosing this symbol not including leading/trailing whitespace - * but everything else, e.g. comments and code. - */ - range: Range; - - /** - * The range that should be selected and revealed when this symbol is being - * picked, e.g. the name of a class. Must be contained by the {@link TypeHierarchyItem.range range}-property. - */ - selectionRange: Range; - - /** - * Creates a new type hierarchy item. - * - * @param kind The kind of the item. - * @param name The name of the item. - * @param detail The details of the item. - * @param uri The Uri of the item. - * @param range The whole range of the item. - * @param selectionRange The selection range of the item. - */ - constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range); - } - - /** - * The type hierarchy provider interface describes the contract between extensions - * and the type hierarchy feature. - */ - export interface TypeHierarchyProvider { - - /** - * Bootstraps type hierarchy by returning the item that is denoted by the given document - * and position. This item will be used as entry into the type graph. Providers should - * return `undefined` or `null` when there is no item at the given location. - * - * @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. - * @returns One or multiple type hierarchy items or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined`, `null`, or an empty array. - */ - prepareTypeHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; - - /** - * Provide all supertypes for an item, e.g all types from which a type is derived/inherited. In graph terms this describes directed - * and annotated edges inside the type graph, e.g the given item is the starting node and the result is the nodes - * that can be reached. - * - * @param item The hierarchy item for which super types should be computed. - * @param token A cancellation token. - * @returns A set of supertypes or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined` or `null`. - */ - provideTypeHierarchySupertypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult; - - /** - * Provide all subtypes for an item, e.g all types which are derived/inherited from the given item. In - * graph terms this describes directed and annotated edges inside the type graph, e.g the given item is the starting - * node and the result is the nodes that can be reached. - * - * @param item The hierarchy item for which subtypes should be computed. - * @param token A cancellation token. - * @returns A set of subtypes or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined` or `null`. - */ - provideTypeHierarchySubtypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult; - } - - export namespace languages { - /** - * Register a type hierarchy provider. - * - * @param selector A selector that defines the documents this provider is applicable to. - * @param provider A type hierarchy provider. - * @return {@link Disposable Disposable} that unregisters this provider when being disposed. - */ - export function registerTypeHierarchyProvider(selector: DocumentSelector, provider: TypeHierarchyProvider): Disposable; - } - //#endregion - //#region https://github.com/microsoft/vscode/issues/129037 enum LanguageStatusSeverity { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 23e9e99b57dba..610aca22f35da 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -495,6 +495,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I registerCallHierarchyProvider(selector: vscode.DocumentSelector, provider: vscode.CallHierarchyProvider): vscode.Disposable { return extHostLanguageFeatures.registerCallHierarchyProvider(extension, selector, provider); }, + registerTypeHierarchyProvider(selector: vscode.DocumentSelector, provider: vscode.TypeHierarchyProvider): vscode.Disposable { + return extHostLanguageFeatures.registerTypeHierarchyProvider(extension, selector, provider); + }, setLanguageConfiguration: (language: string, configuration: vscode.LanguageConfiguration): vscode.Disposable => { return extHostLanguageFeatures.setLanguageConfiguration(extension, language, configuration); }, @@ -506,10 +509,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I checkProposedApiEnabled(extension); return extHostLanguageFeatures.registerInlayHintsProvider(extension, selector, provider); }, - registerTypeHierarchyProvider(selector: vscode.DocumentSelector, provider: vscode.TypeHierarchyProvider): vscode.Disposable { - checkProposedApiEnabled(extension); - return extHostLanguageFeatures.registerTypeHierarchyProvider(extension, selector, provider); - }, createLanguageStatusItem(id: string, selector: vscode.DocumentSelector): vscode.LanguageStatusItem { checkProposedApiEnabled(extension); return extHostLanguages.createLanguageStatusItem(extension, id, selector);