Call Hierarchy

Prepare Call Hierarchy 请求

调用层次结构请求从客户端发送到服务器,以返回给定文本文档位置的语言元素的调用层次结构。调用层次结构请求分两个步骤执行:

  • 首先,为给定的文本文档位置解析调用层次结构项

  • 对于调用层次结构项,将解析传入或传出调用层次结构项。

call-hierarchy

客户端能力(Client capability):

  • 属性路径: textDocument.callHierarchy
  • 属性类型: CallHierarchyClientCapabilities, 定义如下:
interface CallHierarchyClientCapabilities {
	/**
	 * Whether implementation supports dynamic registration. If this is set to
	 * `true` the client supports the new `(TextDocumentRegistrationOptions &
	 * StaticRegistrationOptions)` return value for the corresponding server
	 * capability as well.
	 */
	dynamicRegistration?: boolean;
}

服务端能力(Server capability):

  • 属性路径: callHierarchyProvider
  • 属性类型: boolean | CallHierarchyOptions | CallHierarchyRegistrationOptions, CallHierarchyOptions 定义如下:
export interface CallHierarchyOptions extends WorkDoneProgressOptions {
}

注册选项(Registration Options): CallHierarchyRegistrationOptions, 定义如下:

export interface CallHierarchyRegistrationOptions extends
	TextDocumentRegistrationOptions, CallHierarchyOptions,
	StaticRegistrationOptions {
}

请求(Request):

  • method: "textDocument/prepareCallHierarchy"
  • params: CallHierarchyPrepareParams, 定义如下:
export interface CallHierarchyPrepareParams extends TextDocumentPositionParams,
	WorkDoneProgressParams {
}

响应(Response):

  • result: CallHierarchyItem[] | null, 定义如下:
export interface CallHierarchyItem {
	/**
	 * The name of this item.
	 */
	name: string;

	/**
	 * The kind of this item.
	 */
	kind: SymbolKind;

	/**
	 * Tags for this item.
	 */
	tags?: SymbolTag[];

	/**
	 * More detail for this item, e.g. the signature of a function.
	 */
	detail?: string;

	/**
	 * The resource identifier of this item.
	 */
	uri: DocumentUri;

	/**
	 * 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;

	/**
	 * A data entry field that is preserved between a call hierarchy prepare and
	 * incoming calls or outgoing calls requests.
	 */
	data?: unknown;
}
  • error: codemessage,以防在请求期间发生异常。

Call Hierarchy Incoming Calls 请求

从版本 3.16.0 开始

请求从客户端发送到服务器,以解决给定调用层次结构项的传入调用。请求未定义自己的客户端和服务器能力。仅当服务器注册 textDocument/prepareCallHierarchy 请求时,才会发出它。

call-hierarchy-incoming-calls

请求(Request):

  • method: "callHierarchy/incomingCalls"
  • params: CallHierarchyIncomingCallsParams, 定义如下:
export interface CallHierarchyIncomingCallsParams extends
	WorkDoneProgressParams, PartialResultParams {
	item: CallHierarchyItem;
}

响应(Response):

  • result: CallHierarchyIncomingCall[] | null, 定义如下:
export interface CallHierarchyIncomingCall {

	/**
	 * The item that makes the call.
	 */
	from: CallHierarchyItem;

	/**
	 * The ranges at which the calls appear. This is relative to the caller
	 * denoted by [`this.from`](#CallHierarchyIncomingCall.from).
	 */
	fromRanges: Range[];
}
  • partial result: CallHierarchyIncomingCall[]
  • error: codemessage,以防在请求期间发生异常。

Call Hierarchy Outgoing Calls 请求

请求从客户端发送到服务器,以解决给定调用层次结构项的传出调用。请求未定义自己的客户端和服务器能力。仅当服务器注册 textDocument/prepareCallHierarchy 请求时,才会发出它。

call-hierarchy-outgoing-calls

请求(Request):

  • method: "callHierarchy/outgoingCalls"
  • params: CallHierarchyOutgoingCallsParams, 定义如下:
export interface CallHierarchyOutgoingCallsParams extends
	WorkDoneProgressParams, PartialResultParams {
	item: CallHierarchyItem;
}

响应(Response):

  • result: CallHierarchyOutgoingCall[] | null, 定义如下:
export interface 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 `callHierarchy/outgoingCalls` request.
	 */
	fromRanges: Range[];
}
  • partial result: CallHierarchyOutgoingCall[]
  • error: codemessage,以防在请求期间发生异常。