From df17be45e3035d9642f59136a07cd7452ef55060 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 28 Oct 2019 17:36:32 +0100 Subject: [PATCH] move call hierarchy API to stable, #70231 --- src/vs/vscode.d.ts | 152 +++++++++++++++++ src/vs/vscode.proposed.d.ts | 157 ------------------ .../workbench/api/common/extHost.api.impl.ts | 1 - 3 files changed, 152 insertions(+), 158 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index e8c81c72b4b26..908e242693e69 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3877,6 +3877,149 @@ declare module 'vscode' { provideSelectionRanges(document: TextDocument, positions: Position[], token: CancellationToken): ProviderResult; } + /** + * Represents programming constructs like functions or constructors in the context + * of call hierarchy. + */ + export class CallHierarchyItem { + /** + * 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 function. + * Must be contained by the [`range`](#CallHierarchyItem.range). + */ + selectionRange: Range; + + /** + * Creates a new call hierarchy item. + */ + constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range); + } + + /** + * Represents an incoming call, e.g. a caller of a method or constructor. + */ + export class CallHierarchyIncomingCall { + + /** + * The item that makes the call. + */ + from: CallHierarchyItem; + + /** + * The range at which at which the calls appears. This is relative to the caller + * denoted by [`this.from`](#CallHierarchyIncomingCall.from). + */ + fromRanges: Range[]; + + /** + * Create a new call object. + * + * @param item The item making the call. + * @param fromRanges The ranges at which the calls appear. + */ + constructor(item: CallHierarchyItem, fromRanges: Range[]); + } + + /** + * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. + */ + export class CallHierarchyOutgoingCall { + + /** + * The item that is called. + */ + to: CallHierarchyItem; + + /** + * The range at which this item is called. This is the range relative to the caller, e.g the item + * passed to [`provideCallHierarchyOutgoingCalls`](#CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls) + * and not [`this.to`](#CallHierarchyOutgoingCall.to). + */ + fromRanges: Range[]; + + /** + * Create a new call object. + * + * @param item The item being called + * @param fromRanges The ranges at which the calls appear. + */ + constructor(item: CallHierarchyItem, fromRanges: Range[]); + } + + /** + * The call hierarchy provider interface describes the constract between extensions + * and the call hierarchy feature which allows to browse calls and caller of function, + * methods, constructor etc. + */ + export interface CallHierarchyProvider { + + /** + * Bootstraps call hierarchy by returning the item that is denoted by the given document + * and position. This item will be used as entry into the call 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 A call hierarchy item or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + prepareCallHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; + + /** + * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed + * and annotated edges inside the call 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 incoming calls should be computed. + * @param token A cancellation token. + * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult; + + /** + * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In + * graph terms this describes directed and annotated edges inside the call 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 outgoing calls should be computed. + * @param token A cancellation token. + * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be + * signaled by returning `undefined` or `null`. + */ + provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult; + } + /** * A tuple of two characters, like a pair of * opening and closing brackets. @@ -8693,6 +8836,15 @@ declare module 'vscode' { */ export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable; + /** + * Register a call hierarchy provider. + * + * @param selector A selector that defines the documents this provider is applicable to. + * @param provider A call hierarchy provider. + * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + */ + export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable; + /** * Set a [language configuration](#LanguageConfiguration) for a language. * diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index ffa39a2d38a2b..61705756a25ef 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -16,163 +16,6 @@ declare module 'vscode' { - //#region Joh - call hierarchy: https://github.com/microsoft/vscode/issues/70231 - - /** - * Represents programming constructs like functions or constructors in the context - * of call hierarchy. - */ - export class CallHierarchyItem { - /** - * 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 function. - * Must be contained by the [`range`](#CallHierarchyItem.range). - */ - selectionRange: Range; - - constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range); - } - - /** - * Represents an incoming call, e.g. a caller of a method or constructor. - */ - export class CallHierarchyIncomingCall { - - /** - * The item that makes the call. - */ - from: CallHierarchyItem; - - /** - * The range at which at which the calls appears. This is relative to the caller - * denoted by [`this.from`](#CallHierarchyIncomingCall.from). - */ - fromRanges: Range[]; - - /** - * Create a new call object. - * - * @param item The item making the call. - * @param fromRanges The ranges at which the calls appear. - */ - constructor(item: CallHierarchyItem, fromRanges: Range[]); - } - - /** - * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc. - */ - export class CallHierarchyOutgoingCall { - - /** - * The item that is called. - */ - to: CallHierarchyItem; - - /** - * The range at which this item is called. This is the range relative to the caller, e.g the item - * passed to [`provideCallHierarchyOutgoingCalls`](#CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls) - * and not [`this.to`](#CallHierarchyOutgoingCall.to). - */ - fromRanges: Range[]; - - /** - * Create a new call object. - * - * @param item The item being called - * @param fromRanges The ranges at which the calls appear. - */ - constructor(item: CallHierarchyItem, fromRanges: Range[]); - } - - /** - * The call hierarchy provider interface describes the constract between extensions - * and the call hierarchy feature which allows to browse calls and caller of function, - * methods, constructor etc. - */ - export interface CallHierarchyProvider { - - /** - * Bootstraps call hierarchy by returning the item that is denoted by the given document - * and position. This item will be used as entry into the call 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 A call hierarchy item or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined` or `null`. - */ - prepareCallHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; - - /** - * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed - * and annotated edges inside the call 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 incoming calls should be computed. - * @param token A cancellation token. - * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined` or `null`. - */ - provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult; - - /** - * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In - * graph terms this describes directed and annotated edges inside the call 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 outgoing calls should be computed. - * @param token A cancellation token. - * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be - * signaled by returning `undefined` or `null`. - */ - provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult; - } - - export namespace languages { - - /** - * Register a call hierarchy provider. - * - * @param selector A selector that defines the documents this provider is applicable to. - * @param provider A call hierarchy provider. - * @return A [disposable](#Disposable) that unregisters this provider when being disposed. - */ - export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable; - } - - //#endregion - - //#region Alex - resolvers export interface RemoteAuthorityResolverContext { diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 4f307b0d3a488..11968b623782f 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -370,7 +370,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostLanguageFeatures.registerSelectionRangeProvider(extension, selector, provider); }, registerCallHierarchyProvider(selector: vscode.DocumentSelector, provider: vscode.CallHierarchyProvider): vscode.Disposable { - checkProposedApiEnabled(extension); return extHostLanguageFeatures.registerCallHierarchyProvider(extension, selector, provider); }, setLanguageConfiguration: (language: string, configuration: vscode.LanguageConfiguration): vscode.Disposable => {