我想弄清楚语言服务器协议中trace
设置的作用。所以根据规范:
初始跟踪设置。如果省略了跟踪被禁用('关闭')。
但这并不能说明我的意思。它嵌入在InitializeParams
interface:
interface InitializeParams {
/**
* The process Id of the parent process that started
* the server. Is null if the process has not been started by another process.
* If the parent process is not alive then the server should exit (see exit notification) its process.
*/
processId: number | null;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*
* @deprecated in favour of rootUri.
*/
rootPath?: string | null;
/**
* The rootUri of the workspace. Is null if no
* folder is open. If both `rootPath` and `rootUri` are set
* `rootUri` wins.
*/
rootUri: DocumentUri | null;
/**
* User provided initialization options.
*/
initializationOptions?: any;
/**
* The capabilities provided by the client (editor or tool)
*/
capabilities: ClientCapabilities;
/**
* The initial trace setting. If omitted trace is disabled ('off').
*/
trace?: 'off' | 'messages' | 'verbose';
/**
* The workspace folders configured in the client when the server starts.
* This property is only available if the client supports workspace folders.
* It can be `null` if the client supports workspace folders but none are
* configured.
*
* Since 3.6.0
*/
workspaceFolders?: WorkspaceFolder[] | null;
}
我在本地尝试使用测试语言服务器,但无论我投入什么价值(off
,messages
,verbose
),都没有真正改变。
它实际上做了什么?
答案 0 :(得分:0)
我一直在尝试使用Microsoft的示例(https://github.com/Microsoft/vscode-extension-samples)。在他们的lsp-sample
中,您可以通过设置ui更改trace的值:
结果是它打印出原始的JSON-RPC消息:
我还没有详细介绍,但是我假设在客户端设置'trace:verbose'会设置InitializeParams
中的值以传递给服务器,因此它可以添加自己的跟踪行。
这不是一个确定的答案,但希望您可以看到应该在哪里显示跟踪输出。