hokein updated this revision to Diff 215107.
hokein marked an inline comment as done.
hokein added a comment.

avoid re-implementing of the method.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66211/new/

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
@@ -47,6 +47,20 @@
   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.
+  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 +103,8 @@
         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(


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
@@ -47,6 +47,20 @@
   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.
+  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 +103,8 @@
         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(
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to