Hover 请求

悬停请求从客户端发送到服务器,以请求给定文本文档位置的悬停信息。

hover

客户端能力(Client capability):

  • 属性路径: textDocument.hover
  • 属性类型: HoverClientCapabilities, 定义如下:
export interface HoverClientCapabilities {
	/**
	 * Whether hover supports dynamic registration.
	 */
	dynamicRegistration?: boolean;

	/**
	 * Client supports the follow content formats if the content
	 * property refers to a `literal of type MarkupContent`.
	 * The order describes the preferred format of the client.
	 */
	contentFormat?: MarkupKind[];
}

服务端能力(Server capability):

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

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

export interface HoverRegistrationOptions
	extends TextDocumentRegistrationOptions, HoverOptions {
}

请求(Request):

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

响应(Response):

  • result: Hover | null, 定义如下:
/**
 * The result of a hover request.
 */
export interface Hover {
	/**
	 * The hover's content
	 */
	contents: MarkedString | MarkedString[] | MarkupContent;

	/**
	 * An optional range is a range inside a text document
	 * that is used to visualize a hover, e.g. by changing the background color.
	 */
	range?: Range;
}
/**
 * MarkedString can be used to render human readable text. It is either a
 * markdown string or a code-block that provides a language and a code snippet.
 * The language identifier is semantically equal to the optional language
 * identifier in fenced code blocks in GitHub issues.
 *
 * The pair of a language and a value is an equivalent to markdown:
 * ```${language}
 * ${value}
 * ```
 *
 * Note that markdown strings will be sanitized - that means html will be
 * escaped.
 *
 * @deprecated use MarkupContent instead.
 */
type MarkedString = string | { language: string; value: string };
  • error: codemessage,以防在请求期间发生异常。