|
| 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 { DocumentSymbol, Location } from 'vscode-languageserver-types'; |
| 9 | +import { TextDocumentRegistrationOptions, StaticRegistrationOptions, TextDocumentPositionParams } from './protocol'; |
| 10 | + |
| 11 | +export interface CallsClientCapabilities { |
| 12 | + /** |
| 13 | + * The text document client capabilities |
| 14 | + */ |
| 15 | + textDocument?: { |
| 16 | + /** |
| 17 | + * Capabilities specific to the `textDocument/calls` |
| 18 | + */ |
| 19 | + calls?: { |
| 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 CallsServerCapabilities { |
| 31 | + /** |
| 32 | + * The server provides Call Hierarchy support. |
| 33 | + */ |
| 34 | + callsProvider?: boolean | (TextDocumentRegistrationOptions & StaticRegistrationOptions); |
| 35 | +} |
| 36 | + |
| 37 | +/** |
| 38 | + * A request to resolve all calls at a given text document position of a symbol definition or a call the same. |
| 39 | + * The request's parameter is of type [CallsParams](#CallsParams), the response is of type [CallsResult](#CallsResult) or a |
| 40 | + * Thenable that resolves to such. |
| 41 | + * |
| 42 | + * |
| 43 | + */ |
| 44 | +export namespace CallsRequest { |
| 45 | + export const type = new RequestType<CallsParams, CallsResult, void, TextDocumentRegistrationOptions>('textDocument/calls'); |
| 46 | + export type HandlerSignature = RequestHandler<CallsParams, CallsResult | null, void>; |
| 47 | +} |
| 48 | + |
| 49 | +/** |
| 50 | + * The parameters of a `textDocument/calls` request. |
| 51 | + */ |
| 52 | +export interface CallsParams extends TextDocumentPositionParams { |
| 53 | + /** |
| 54 | + * Outgoing direction for callees. |
| 55 | + * The default is incoming for callers. |
| 56 | + */ |
| 57 | + direction?: CallDirection; |
| 58 | +} |
| 59 | + |
| 60 | +/** |
| 61 | + * Enum of call direction kinds |
| 62 | + */ |
| 63 | +export enum CallDirection { |
| 64 | + /** |
| 65 | + * Incoming calls aka. callers |
| 66 | + */ |
| 67 | + Incoming = "incoming", |
| 68 | + /** |
| 69 | + * Outgoing calls aka. callees |
| 70 | + */ |
| 71 | + Outgoing = "outgoing", |
| 72 | +} |
| 73 | + |
| 74 | +/** |
| 75 | + * The result of a `textDocument/calls` request. |
| 76 | + */ |
| 77 | +export interface CallsResult { |
| 78 | + /** |
| 79 | + * The symbol of a definition for which the request was made. |
| 80 | + * |
| 81 | + * If no definition is found at a given text document position, the symbol is undefined. |
| 82 | + */ |
| 83 | + symbol?: DocumentSymbol; |
| 84 | + /** |
| 85 | + * List of calls. |
| 86 | + */ |
| 87 | + calls: Call[]; |
| 88 | +} |
| 89 | + |
| 90 | +/** |
| 91 | + * Represents a directed call. |
| 92 | + */ |
| 93 | +export interface Call { |
| 94 | + /** |
| 95 | + * Direction of the call. |
| 96 | + */ |
| 97 | + direction: CallDirection; |
| 98 | + /** |
| 99 | + * Actual location of a call to a definition. |
| 100 | + */ |
| 101 | + callLocation: Location; |
| 102 | + /** |
| 103 | + * Symbol refered to by this call. For outgoing calls this is a callee, |
| 104 | + * otherwise a caller. |
| 105 | + */ |
| 106 | + symbol: DocumentSymbol; |
| 107 | + /** |
| 108 | + * Location of the symbol, which can be used for a follow-up request to obtain the next level of calls. |
| 109 | + */ |
| 110 | + symbolLocation: Location; |
| 111 | +} |
0 commit comments