|
| 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 { 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 provide the call hierarchy at a given text document position. |
| 39 | + * |
| 40 | + * The request's parameter is of type [CallHierarchyParams](#CallHierarchyParams). The response |
| 41 | + * is of type [CallHierarchyCall[]](#CallHierarchyCall) or a Thenable that resolves to such. |
| 42 | + * |
| 43 | + * Evaluates the symbol defined (or referenced) at the given position, and returns all incoming or outgoing calls to the symbol(s). |
| 44 | + */ |
| 45 | +export namespace CallHierarchyRequest { |
| 46 | + export const type = new RequestType<CallHierarchyParams, CallHierarchyCall[], void, TextDocumentRegistrationOptions>('textDocument/callHierarchy'); |
| 47 | + export type HandlerSignature = RequestHandler<CallHierarchyParams, CallHierarchyCall[] | null, void>; |
| 48 | +} |
| 49 | + |
| 50 | +/** |
| 51 | + * The parameter of a `textDocument/callHierarchy` request extends the `TextDocumentPositionParams` with the direction of calls to resolve. |
| 52 | + */ |
| 53 | +export interface CallHierarchyParams extends TextDocumentPositionParams { |
| 54 | + /** |
| 55 | + * The direction of calls to provide. |
| 56 | + */ |
| 57 | + direction: CallHierarchyDirection; |
| 58 | +} |
| 59 | + |
| 60 | +/** |
| 61 | + * The direction of a call hierarchy request. |
| 62 | + */ |
| 63 | +export namespace CallHierarchyDirection { |
| 64 | + /** |
| 65 | + * The callers of a symbol. |
| 66 | + */ |
| 67 | + export const Incoming: 1 = 1; |
| 68 | + |
| 69 | + /** |
| 70 | + * The callees of a symbol. |
| 71 | + */ |
| 72 | + export const Outgoing: 2 = 2; |
| 73 | +} |
| 74 | + |
| 75 | +export type CallHierarchyDirection = 1 | 2; |
| 76 | + |
| 77 | +/** |
| 78 | + * The result of a `textDocument/callHierarchy` request. |
| 79 | + */ |
| 80 | +export interface CallHierarchyCall { |
| 81 | + |
| 82 | + /** |
| 83 | + * The source range of the reference. The range is a sub range of the `from` symbol range. |
| 84 | + */ |
| 85 | + range: Range; |
| 86 | + |
| 87 | + /** |
| 88 | + * The symbol that contains the reference. |
| 89 | + */ |
| 90 | + from: CallHierarchySymbol; |
| 91 | + |
| 92 | + /** |
| 93 | + * The symbol that is referenced. |
| 94 | + */ |
| 95 | + to: CallHierarchySymbol; |
| 96 | +} |
| 97 | + |
| 98 | +export interface CallHierarchySymbol { |
| 99 | + |
| 100 | + /** |
| 101 | + * The name of the symbol targeted by the call hierarchy request. |
| 102 | + */ |
| 103 | + name: string; |
| 104 | + |
| 105 | + /** |
| 106 | + * More detail for this symbol, e.g the signature of a function. |
| 107 | + */ |
| 108 | + detail?: string; |
| 109 | + |
| 110 | + /** |
| 111 | + * The kind of this symbol. |
| 112 | + */ |
| 113 | + kind: SymbolKind; |
| 114 | + |
| 115 | + /** |
| 116 | + * URI of the document containing the symbol. |
| 117 | + */ |
| 118 | + uri: string; |
| 119 | + |
| 120 | + /** |
| 121 | + * The range enclosing this symbol not including leading/trailing whitespace but everything else |
| 122 | + * like comments. This information is typically used to determine if the the clients cursor is |
| 123 | + * inside the symbol to reveal in the symbol in the UI. |
| 124 | + */ |
| 125 | + range: Range; |
| 126 | + |
| 127 | + /** |
| 128 | + * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. |
| 129 | + * Must be contained by the the `range`. |
| 130 | + */ |
| 131 | + selectionRange: Range; |
| 132 | +} |
0 commit comments