|
| 1 | +/* -------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) TypeFox and others. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + * ------------------------------------------------------------------------------------------ */ |
| 5 | +'use strict'; |
| 6 | + |
| 7 | +import { RequestType, RequestHandler } from 'vscode-jsonrpc'; |
| 8 | +import { Location, SymbolKind, Range } from 'vscode-languageserver-types'; |
| 9 | +import { TextDocumentRegistrationOptions, StaticRegistrationOptions, TextDocumentPositionParams } from './protocol'; |
| 10 | + |
| 11 | +export interface CallHierarchyClientCapabilities { |
| 12 | + /** |
| 13 | + * The text document client capabilities |
| 14 | + */ |
| 15 | + textDocument?: { |
| 16 | + /** |
| 17 | + * Capabilities specific to the `textDocument/callHierarchy` |
| 18 | + */ |
| 19 | + callHierarchy?: { |
| 20 | + /** |
| 21 | + * Whether implementation supports dynamic registration. If this is set to `true` |
| 22 | + * the client supports the new `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` |
| 23 | + * return value for the corresponding server capability as well. |
| 24 | + */ |
| 25 | + dynamicRegistration?: boolean; |
| 26 | + }; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +export interface CallHierarchyServerCapabilities { |
| 31 | + /** |
| 32 | + * The server provides Call Hierarchy support. |
| 33 | + */ |
| 34 | + callHierarchyProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions); |
| 35 | +} |
| 36 | + |
| 37 | +/** |
| 38 | + * Request to request the call hierarchy at a given text document position. |
| 39 | + * |
| 40 | + * The request's parameter for the first request is of type [CallHierarchyParams](#CallHierarchyParams). The request's |
| 41 | + * parameter for the subsequent requests is of type [ResolveCallHierarchyItemParams](#ResolveCallHierarchyItemParams). |
| 42 | + * |
| 43 | + * The response is of type [CallHierarchyItem](#CallHierarchyItem) or a Thenable that resolves to such. |
| 44 | + */ |
| 45 | +export namespace CallHierarchyRequest { |
| 46 | + export const type = new RequestType<CallHierarchyParams | ResolveCallHierarchyItemParams, CallHierarchyItem, void, TextDocumentRegistrationOptions>('textDocument/callHierarchy'); |
| 47 | + export type HandlerSignature = RequestHandler<CallHierarchyParams | ResolveCallHierarchyItemParams, CallHierarchyItem | null, void>; |
| 48 | +} |
| 49 | + |
| 50 | +/** |
| 51 | + * The parameters of a `textDocument/callHierarchy` request. |
| 52 | + */ |
| 53 | +export interface CallHierarchyParams extends TextDocumentPositionParams { |
| 54 | + /** |
| 55 | + * The number of levels to resolve. |
| 56 | + */ |
| 57 | + resolve?: number; |
| 58 | + /** |
| 59 | + * Outgoing direction for callees. |
| 60 | + * The default is incoming for callers. |
| 61 | + */ |
| 62 | + direction?: 'incoming' | 'outgoing'; |
| 63 | +} |
| 64 | + |
| 65 | +/** |
| 66 | + * The parameters of a `textDocument/callHierarchy` request. |
| 67 | + */ |
| 68 | +export interface ResolveCallHierarchyItemParams { |
| 69 | + /** |
| 70 | + * Unresolved item. |
| 71 | + */ |
| 72 | + item: CallHierarchyItem; |
| 73 | + /** |
| 74 | + * The number of levels to resolve. |
| 75 | + */ |
| 76 | + resolve: number; |
| 77 | + /** |
| 78 | + * Outgoing direction for callees. |
| 79 | + * The default is incoming for callers. |
| 80 | + */ |
| 81 | + direction: 'incoming' | 'outgoing'; |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * The result of a `textDocument/callHierarchy` request. |
| 86 | + */ |
| 87 | +export interface CallHierarchyItem { |
| 88 | + /** |
| 89 | + * The name of the symbol targeted by the call hierarchy request. |
| 90 | + */ |
| 91 | + name: string; |
| 92 | + /** |
| 93 | + * More detail for this symbol, e.g the signature of a function. |
| 94 | + */ |
| 95 | + detail?: string; |
| 96 | + /** |
| 97 | + * The kind of this symbol. |
| 98 | + */ |
| 99 | + kind: SymbolKind; |
| 100 | + /** |
| 101 | + * URI of the document containing the symbol. |
| 102 | + */ |
| 103 | + uri: string; |
| 104 | + /** |
| 105 | + * The range enclosing this symbol not including leading/trailing whitespace but everything else |
| 106 | + * like comments. This information is typically used to determine if the the clients cursor is |
| 107 | + * inside the symbol to reveal in the symbol in the UI. |
| 108 | + */ |
| 109 | + range: Range; |
| 110 | + /** |
| 111 | + * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. |
| 112 | + * Must be contained by the the `range`. |
| 113 | + */ |
| 114 | + selectionRange: Range; |
| 115 | + |
| 116 | + /** |
| 117 | + * The actual location of the call. |
| 118 | + * |
| 119 | + * **Must be defined** in resolved callers/callees. |
| 120 | + */ |
| 121 | + callLocation?: Location; |
| 122 | + |
| 123 | + /** |
| 124 | + * List of incoming calls. |
| 125 | + * |
| 126 | + * *Note*: The items is _unresolved_ if `callers` and `callees` is undefined. |
| 127 | + */ |
| 128 | + callers?: CallHierarchyItem[]; |
| 129 | + /** |
| 130 | + * List of outgoing calls. |
| 131 | + * |
| 132 | + * *Note*: The items is _unresolved_ if `callers` and `callees` is undefined. |
| 133 | + */ |
| 134 | + callees?: CallHierarchyItem[]; |
| 135 | +} |
0 commit comments