[clang-tools-extra] r368851 - [clangd][vscode] Surface the error when applying tweaks fails
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 06:38:52 PDT 2019
Author: hokein
Date: Wed Aug 14 06:38:52 2019
New Revision: 368851
URL: http://llvm.org/viewvc/llvm-project?rev=368851&view=rev
Log:
[clangd][vscode] Surface the error when applying tweaks fails
Summary:
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.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66211
Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=368851&r1=368850&r2=368851&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts (original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Wed Aug 14 06:38:52 2019
@@ -47,6 +47,23 @@ class FileStatus {
dispose() { this.statusBarItem.dispose(); }
}
+class ClangdLanguageClient extends vscodelc.LanguageClient {
+ // 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.
+ logFailedRequest(rpcReply: vscodelc.RPCMessageType, error: any) {
+ if (error instanceof vscodelc.ResponseError &&
+ rpcReply.method === "workspace/executeCommand")
+ vscode.window.showErrorMessage(error.message);
+ // Call default implementation.
+ super.logFailedRequest(rpcReply, error);
+ }
+}
+
/**
* this method is called when your extension is activate
* your extension is activated the very first time the command is executed
@@ -89,8 +106,8 @@ export function activate(context: vscode
revealOutputChannelOn: vscodelc.RevealOutputChannelOn.Never
};
- const clangdClient = new vscodelc.LanguageClient(
- 'Clang Language Server', serverOptions, clientOptions);
+ const clangdClient = new ClangdLanguageClient('Clang Language Server',
+ serverOptions, clientOptions);
console.log('Clang Language Server is now active!');
context.subscriptions.push(clangdClient.start());
context.subscriptions.push(vscode.commands.registerCommand(
More information about the cfe-commits
mailing list