diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-24 13:47:27 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-24 13:47:27 +0000 |
commit | b052059f868e4b890425c43e1e16d195d3c453d9 (patch) | |
tree | d761a1ec0346286f20c511ff8f76111313d30957 /editors/code | |
parent | d77520fde3c953968beb09a3da80a0e7b17bbc04 (diff) | |
parent | ecab036d6ffcb85c45a288b312d79141bcd86fd9 (diff) |
Merge #302
302: WIP: Support tracing lsp requests. r=DJMcNab a=DJMcNab
EDIT: We need to work out a better way to handle settings before this can be merged. Help wanted
TODO: Debug why decorations are sent even when highlightingOn is disabled
This makes the log volume so high its impossible to work with anyway.
(Continuation of #84 [#99 only disabled using it, not making sure we don't send it]).
These logs can be used in https://microsoft.github.io/language-server-protocol/inspector/
Co-authored-by: DJMcNab <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 11 | ||||
-rw-r--r-- | editors/code/src/server.ts | 26 |
2 files changed, 36 insertions, 1 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index d53e44b21..2989a7016 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -131,6 +131,17 @@ | |||
131 | "type": "boolean", | 131 | "type": "boolean", |
132 | "default": true, | 132 | "default": true, |
133 | "description": "Highlight Rust code (overrides built-in syntax highlighting)" | 133 | "description": "Highlight Rust code (overrides built-in syntax highlighting)" |
134 | }, | ||
135 | "ra-lsp.trace.server": { | ||
136 | "type": "string", | ||
137 | "scope": "window", | ||
138 | "enum": [ | ||
139 | "off", | ||
140 | "messages", | ||
141 | "verbose" | ||
142 | ], | ||
143 | "default": "off", | ||
144 | "description": "Trace requests to the ra-lsp server" | ||
134 | } | 145 | } |
135 | } | 146 | } |
136 | }, | 147 | }, |
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 75e273f37..75bdf3207 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts | |||
@@ -22,7 +22,7 @@ export class Server { | |||
22 | const clientOptions: lc.LanguageClientOptions = { | 22 | const clientOptions: lc.LanguageClientOptions = { |
23 | documentSelector: [{ scheme: 'file', language: 'rust' }], | 23 | documentSelector: [{ scheme: 'file', language: 'rust' }], |
24 | initializationOptions: { | 24 | initializationOptions: { |
25 | publishDecorations: true, | 25 | publishDecorations: true |
26 | } | 26 | } |
27 | }; | 27 | }; |
28 | 28 | ||
@@ -32,6 +32,30 @@ export class Server { | |||
32 | serverOptions, | 32 | serverOptions, |
33 | clientOptions | 33 | clientOptions |
34 | ); | 34 | ); |
35 | // HACK: This is an awful way of filtering out the decorations notifications | ||
36 | // However, pending proper support, this is the most effecitve approach | ||
37 | // Proper support for this would entail a change to vscode-languageclient to allow not notifying on certain messages | ||
38 | // Or the ability to disable the serverside component of highlighting (but this means that to do tracing we need to disable hihlighting) | ||
39 | // This also requires considering our settings strategy, which is work which needs doing | ||
40 | // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests | ||
41 | Server.client._tracer = { | ||
42 | log: (messageOrDataObject: string | any, data?: string) => { | ||
43 | if (typeof messageOrDataObject === 'string') { | ||
44 | if ( | ||
45 | messageOrDataObject.includes('m/publishDecorations') || | ||
46 | messageOrDataObject.includes('m/decorationsRequest') | ||
47 | ) { | ||
48 | // Don't log publish decorations requests | ||
49 | } else { | ||
50 | // @ts-ignore This is just a utility function | ||
51 | Server.client.logTrace(messageOrDataObject, data); | ||
52 | } | ||
53 | } else { | ||
54 | // @ts-ignore | ||
55 | Server.client.logObjectTrace(messageOrDataObject); | ||
56 | } | ||
57 | } | ||
58 | }; | ||
35 | Server.client.onReady().then(() => { | 59 | Server.client.onReady().then(() => { |
36 | for (const [type, handler] of notificationHandlers) { | 60 | for (const [type, handler] of notificationHandlers) { |
37 | Server.client.onNotification(type, handler); | 61 | Server.client.onNotification(type, handler); |