hokein created this revision. hokein added a reviewer: ilya-biryukov. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay. Herald added a project: clang.
The current behavior for a failed request is just to log it in the output panel. When applyTweak fails for whatever reason, users usually don't get informed (unless they open the output panel and dig the log). this patch is to surface these errors by prompting up a message diag. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D66211 Files: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts =================================================================== --- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts +++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts @@ -91,6 +91,26 @@ const clangdClient = new vscodelc.LanguageClient( 'Clang Language Server', serverOptions, clientOptions); + + // We override the default implementation for failed requests. The default + // behavior is just to log failures in the output panel, however output panel + // is designed for extension debugging purpose, normal users will not open it, + // thus when the failure occurs, normal users doesn't know that. + // + // For user-interactive operations (e.g. applyFixIt, applyTweaks), we will prompt + // up the failure to users. + clangdClient.logFailedRequest = + (rpcReply: vscodelc.RPCMessageType, error: any) => { + if (error instanceof vscodelc.ResponseError && + rpcReply.method === "workspace/executeCommand") + vscode.window.showErrorMessage(error.message); + + // Keep the default behavior. + if (error instanceof vscodelc.ResponseError && + error.code === vscodelc.ErrorCodes.RequestCancelled) + return; + clangdClient.error(`Request ${rpcReply.method} failed.`, error); + }; console.log('Clang Language Server is now active!'); context.subscriptions.push(clangdClient.start()); context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts =================================================================== --- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts +++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts @@ -91,6 +91,26 @@ const clangdClient = new vscodelc.LanguageClient( 'Clang Language Server', serverOptions, clientOptions); + + // We override the default implementation for failed requests. The default + // behavior is just to log failures in the output panel, however output panel + // is designed for extension debugging purpose, normal users will not open it, + // thus when the failure occurs, normal users doesn't know that. + // + // For user-interactive operations (e.g. applyFixIt, applyTweaks), we will prompt + // up the failure to users. + clangdClient.logFailedRequest = + (rpcReply: vscodelc.RPCMessageType, error: any) => { + if (error instanceof vscodelc.ResponseError && + rpcReply.method === "workspace/executeCommand") + vscode.window.showErrorMessage(error.message); + + // Keep the default behavior. + if (error instanceof vscodelc.ResponseError && + error.code === vscodelc.ErrorCodes.RequestCancelled) + return; + clangdClient.error(`Request ${rpcReply.method} failed.`, error); + }; console.log('Clang Language Server is now active!'); context.subscriptions.push(clangdClient.start()); context.subscriptions.push(vscode.commands.registerCommand(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits