This commit is contained in:
Pine Wu 2018-08-19 23:20:15 -07:00
Родитель eabf89eaf6
Коммит b400cdbab8
1 изменённых файлов: 39 добавлений и 2 удалений

Просмотреть файл

@ -12,9 +12,9 @@ Try it at https://microsoft.github.io/language-server-protocol/inspector/.
## Motivation
When you are using [vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) to develop a language server, it's possible to specify a setting `"[langId]".trace.server: "verbose"` to make the Language Client log the LSP communication. This log is useful for developing and testing the Language Server, but the log can be lengthy — 5 seconds of usage might generate 5000 lines LSP log. This makes it hard to gain insight from the logs.
When you are using [vscode-languageserver-node](https://github.com/Microsoft/vscode-languageserver-node) to develop a language server, it's possible to specify a setting `"[langId].trace.server": "verbose"` to make the Language Client log the LSP communication. This log is useful for developing and testing the Language Server, but the log can be lengthy — using the editor for 5 seconds could generate 5000 lines of LSP log. This makes it hard to gain insight from the logs.
This inspector visualizes the logs to make it easy to understand the communication between the Language Client / Server. It also lets you filter down the logs by search query or language features, so you can quickly identify the logs you are interested in.
This inspector visualizes the logs to make it easy to understand the communication between the Language Client / Server. It also lets you filter the logs by search query or language features, so you can quickly identify the logs you are interested in.
![lsp-inspector](https://user-images.githubusercontent.com/4033249/41323525-ba73697a-6e63-11e8-92a3-c655b34126f6.gif)
@ -31,6 +31,43 @@ This inspector visualizes the logs to make it easy to understand the communicati
- Load it from the web app.
- You can try it on real-world logs file at `/tests/unit/logParser/fixture`.
## Log Format
The Inspector takes two log formats: `Text` and `JSON`.
- `Text`:
- Logs generated by setting `"[langId].trace.server": "verbose"`.
- Logs generated by setting `"[langId].trace.server": { "format": "Text" }`
- `JSON`: Logs generated by setting: `"[langId].trace.server": { "format": "JSON" }`
The Inspector could load any JSON logs, as long as they follow this format:
```ts
export type MsgKind =
| 'send-notification'
| 'recv-notification'
| 'send-request'
| 'recv-request'
| 'send-response'
| 'recv-response'
export interface LspItem {
type: MsgKind
message: any
timestamp: unix timestamp
}
```
Each line is terminated with `\r\n`.
Here is a sample:
```
{"type":"receive-response","message":{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":true}}}},"timestamp":1534721620392}\r\n
{"type":"send-notification","message":{"jsonrpc":"2.0","method":"initialized","params":{}},"timestamp":1534721620393}\r\n
```
## Running & Developing
- `yarn`