ShowMessage
ShowMessage 通知
通知从服务器发送到客户端,以要求客户端在用户界面中显示特定消息。
通知(Notification):
- method: "window/showMessage"
- params:
ShowMessageParams
, 定义如下:
interface ShowMessageParams {
/**
* The message type. See {@link MessageType}.
*/
type: MessageType;
/**
* The actual message.
*/
message: string;
}
export namespace MessageType {
/**
* An error message.
*/
export const Error = 1;
/**
* A warning message.
*/
export const Warning = 2;
/**
* An information message.
*/
export const Info = 3;
/**
* A log message.
*/
export const Log = 4;
/**
* A debug message.
*
* @since 3.18.0
* @proposed
*/
export const Debug = 5;
}
export type MessageType = 1 | 2 | 3 | 4 | 5;
ShowMessage 请求
请求从服务器发送到客户端,以要求客户端在用户界面中显示特定消息。除了显示消息通知外,该请求还允许传递操作并等待客户端的答复。
客户端能力(Client capability):
- 属性路径:
window.showMessage
- 属性类型:
ShowMessageRequestClientCapabilities
, 定义如下:
/**
* Show message request client capabilities
*/
export interface ShowMessageRequestClientCapabilities {
/**
* Capabilities specific to the `MessageActionItem` type.
*/
messageActionItem?: {
/**
* Whether the client supports additional attributes which
* are preserved and sent back to the server in the
* request's response.
*/
additionalPropertiesSupport?: boolean;
};
}
请求(Request):
- method: "window/showMessageRequest"
- params:
ShowMessageRequestParams
, 定义如下:
interface ShowMessageRequestParams {
/**
* The message type. See {@link MessageType}
*/
type: MessageType;
/**
* The actual message
*/
message: string;
/**
* The message action items to present.
*/
actions?: MessageActionItem[];
}
interface MessageActionItem {
/**
* A short title like 'Retry', 'Open Log' etc.
*/
title: string;
}
响应(Response):
- result:
MessageActionItem | null
,MessageActionItem
是被选择的项,如果没被选择返回null
。 - error:
code
和message
,以防在请求期间发生异常。