mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 07:37:30 +00:00
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 <36049421+djmcnab@users.noreply.github.com>
This commit is contained in:
commit
b052059f86
4 changed files with 47 additions and 9 deletions
|
@ -22,7 +22,7 @@ export class Server {
|
|||
const clientOptions: lc.LanguageClientOptions = {
|
||||
documentSelector: [{ scheme: 'file', language: 'rust' }],
|
||||
initializationOptions: {
|
||||
publishDecorations: true,
|
||||
publishDecorations: true
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,30 @@ export class Server {
|
|||
serverOptions,
|
||||
clientOptions
|
||||
);
|
||||
// HACK: This is an awful way of filtering out the decorations notifications
|
||||
// However, pending proper support, this is the most effecitve approach
|
||||
// Proper support for this would entail a change to vscode-languageclient to allow not notifying on certain messages
|
||||
// Or the ability to disable the serverside component of highlighting (but this means that to do tracing we need to disable hihlighting)
|
||||
// This also requires considering our settings strategy, which is work which needs doing
|
||||
// @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests
|
||||
Server.client._tracer = {
|
||||
log: (messageOrDataObject: string | any, data?: string) => {
|
||||
if (typeof messageOrDataObject === 'string') {
|
||||
if (
|
||||
messageOrDataObject.includes('m/publishDecorations') ||
|
||||
messageOrDataObject.includes('m/decorationsRequest')
|
||||
) {
|
||||
// Don't log publish decorations requests
|
||||
} else {
|
||||
// @ts-ignore This is just a utility function
|
||||
Server.client.logTrace(messageOrDataObject, data);
|
||||
}
|
||||
} else {
|
||||
// @ts-ignore
|
||||
Server.client.logObjectTrace(messageOrDataObject);
|
||||
}
|
||||
}
|
||||
};
|
||||
Server.client.onReady().then(() => {
|
||||
for (const [type, handler] of notificationHandlers) {
|
||||
Server.client.onNotification(type, handler);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue