Type Hierarchy

Prepare Type Hierarchy 请求

从版本 3.17.0 开始

类型层次结构请求从客户端发送到服务器,以返回给定文本文档位置的语言元素的类型层次结构。如果服务器无法从该位置推断出有效类型,则将返回 null。类型层次结构请求分两个步骤执行:

  • 首先,为给定的文本文档位置准备类型层次结构项。

  • 对于类型层次结构项,将解析超类型或子类型层次结构项。

客户端能力(Client capability):

  • 属性路径: textDocument.typeHierarchy
  • 属性类型: TypeHierarchyClientCapabilities, 定义如下:
type TypeHierarchyClientCapabilities = {
	/**
	 * 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):

  • 属性路径: typeHierarchyProvider
  • 属性类型: boolean | TypeHierarchyOptions | TypeHierarchyRegistrationOptions, TypeHierarchyOptions 定义如下:
export interface TypeHierarchyOptions extends WorkDoneProgressOptions {
}

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

export interface TypeHierarchyRegistrationOptions extends
	TextDocumentRegistrationOptions, TypeHierarchyOptions,
	StaticRegistrationOptions {
}

请求(Request):

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

响应(Response):

  • result: TypeHierarchyItem[] | null, 定义如下:
export interface TypeHierarchyItem {
	/**
	 * 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`](#TypeHierarchyItem.range).
	 */
	selectionRange: Range;

	/**
	 * A data entry field that is preserved between a type hierarchy prepare and
	 * supertypes or subtypes requests. It could also be used to identify the
	 * type hierarchy in the server, helping improve the performance on
	 * resolving supertypes and subtypes.
	 */
	data?: LSPAny;
}
  • error: codemessage,以防在请求期间发生异常。

Type Hierarchy Supertypes 调用

从版本 3.17.0 开始

请求从客户端发送到服务器,以解析给定类型层次结构项的超类型。如果服务器无法从参数中的项推断出有效类型,则将返回 null。请求未定义自己的客户端和服务器功能。仅当服务器注册 textDocument/prepareTypeHierarchy 请求时,才会发出它。

请求(Request):

  • method: "typeHierarchy/supertypes"
  • params: TypeHierarchySupertypesParams, 定义如下:
export interface TypeHierarchySupertypesParams extends
	WorkDoneProgressParams, PartialResultParams {
	item: TypeHierarchyItem;
}

响应(Response):

  • result: TypeHierarchyItem[] | null
  • partial result: TypeHierarchyItem[]
  • error: codemessage,以防在请求期间发生异常。

Type Hierarchy Subtypes 调用

从版本 3.17.0 开始

请求从客户端发送到服务器,以解析给定类型层次结构项的子类型。如果服务器无法从参数中的项推断出有效类型,则将返回 null。请求未定义自己的客户端和服务器功能。仅当服务器注册 textDocument/prepareTypeHierarchy 请求时,才会发出它。

请求(Request):

  • method: "typeHierarchy/subtypes"
  • params: TypeHierarchySubtypesParams, 定义如下:
export interface TypeHierarchySubtypesParams extends
	WorkDoneProgressParams, PartialResultParams {
	item: TypeHierarchyItem;
}

响应(Response):

  • result: TypeHierarchyItem[] | null
  • partial result: TypeHierarchyItem[]
  • error: codemessage,以防在请求期间发生异常。