[Mlir-commits] [mlir] e93ba84 - [mlir-vscode] Don't emit errors if the user didn't set the server path

River Riddle llvmlistbot at llvm.org
Mon Apr 11 15:41:44 PDT 2022


Author: River Riddle
Date: 2022-04-11T15:41:19-07:00
New Revision: e93ba84262a98595fa5b13bdc47d4ee02d6fcd36

URL: https://github.com/llvm/llvm-project/commit/e93ba84262a98595fa5b13bdc47d4ee02d6fcd36
DIFF: https://github.com/llvm/llvm-project/commit/e93ba84262a98595fa5b13bdc47d4ee02d6fcd36.diff

LOG: [mlir-vscode] Don't emit errors if the user didn't set the server path

This avoids emitting errors in situations where the user doesn't have a server
setup, and doesn't mean to (e.g. when they merely want syntax highlighting).

Differential Revision: https://reviews.llvm.org/D123240

Added: 
    

Modified: 
    mlir/utils/vscode/package.json
    mlir/utils/vscode/src/extension.ts
    mlir/utils/vscode/src/mlirContext.ts

Removed: 
    


################################################################################
diff  --git a/mlir/utils/vscode/package.json b/mlir/utils/vscode/package.json
index 74072d9e1858a..230124a6a6297 100644
--- a/mlir/utils/vscode/package.json
+++ b/mlir/utils/vscode/package.json
@@ -2,7 +2,7 @@
   "name": "vscode-mlir",
   "displayName": "MLIR",
   "description": "MLIR Language Extension",
-  "version": "0.0.5",
+  "version": "0.0.6",
   "publisher": "llvm-vs-code-extensions",
   "homepage": "https://mlir.llvm.org/",
   "icon": "icon.png",

diff  --git a/mlir/utils/vscode/src/extension.ts b/mlir/utils/vscode/src/extension.ts
index 664146c84fbaf..7d2d4a7383ebc 100644
--- a/mlir/utils/vscode/src/extension.ts
+++ b/mlir/utils/vscode/src/extension.ts
@@ -16,13 +16,10 @@ export function activate(context: vscode.ExtensionContext) {
   // Initialize the commands of the extension.
   context.subscriptions.push(
       vscode.commands.registerCommand('mlir.restart', async () => {
-        // Dispose and reactivate the context. This is essentially the same as
-        // the start of the extension, but we don't re-emit warnings for
-        // uninitialized settings.
+        // Dispose and reactivate the context.
         mlirContext.dispose();
-        await mlirContext.activate(outputChannel,
-                                   /*warnOnEmptyServerPath=*/ false);
+        await mlirContext.activate(outputChannel);
       }));
 
-  mlirContext.activate(outputChannel, /*warnOnEmptyServerPath=*/ true);
+  mlirContext.activate(outputChannel);
 }

diff  --git a/mlir/utils/vscode/src/mlirContext.ts b/mlir/utils/vscode/src/mlirContext.ts
index 067856c0e0070..3827fcc86d331 100644
--- a/mlir/utils/vscode/src/mlirContext.ts
+++ b/mlir/utils/vscode/src/mlirContext.ts
@@ -29,8 +29,7 @@ export class MLIRContext implements vscode.Disposable {
   /**
    *  Activate the MLIR context, and start the language clients.
    */
-  async activate(outputChannel: vscode.OutputChannel,
-                 warnOnEmptyServerPath: boolean) {
+  async activate(outputChannel: vscode.OutputChannel) {
     // This lambda is used to lazily start language clients for the given
     // document. It removes the need to pro-actively start language clients for
     // every folder within the workspace and every language type we provide.
@@ -64,7 +63,7 @@ export class MLIRContext implements vscode.Disposable {
       if (!folderContext.clients.has(document.languageId)) {
         let client = await this.activateWorkspaceFolder(
             workspaceFolder, serverSettingName, document.languageId,
-            outputChannel, warnOnEmptyServerPath);
+            outputChannel);
         folderContext.clients.set(document.languageId, client);
       }
     };
@@ -92,12 +91,10 @@ export class MLIRContext implements vscode.Disposable {
    */
   async activateWorkspaceFolder(workspaceFolder: vscode.WorkspaceFolder,
                                 serverSettingName: string, languageName: string,
-                                outputChannel: vscode.OutputChannel,
-                                warnOnEmptyServerPath: boolean):
+                                outputChannel: vscode.OutputChannel):
       Promise<vscodelc.LanguageClient> {
     const [server, serverPath] = await this.startLanguageClient(
-        workspaceFolder, outputChannel, warnOnEmptyServerPath,
-        serverSettingName, languageName);
+        workspaceFolder, outputChannel, serverSettingName, languageName);
 
     // Watch for configuration changes on this folder.
     await configWatcher.activate(this, workspaceFolder, serverSettingName,
@@ -112,7 +109,6 @@ export class MLIRContext implements vscode.Disposable {
    */
   async startLanguageClient(workspaceFolder: vscode.WorkspaceFolder,
                             outputChannel: vscode.OutputChannel,
-                            warnOnEmptyServerPath: boolean,
                             serverSettingName: string, languageName: string):
       Promise<[ vscodelc.LanguageClient, string ]> {
     const clientTitle = languageName.toUpperCase() + ' Language Client';
@@ -122,14 +118,14 @@ export class MLIRContext implements vscode.Disposable {
     var serverPath =
         await this.resolveServerPath(serverSettingName, workspaceFolder);
 
-    // If we aren't emitting warnings on an empty server path, and the server
-    // path is empty, bail.
-    if (!warnOnEmptyServerPath && serverPath === '') {
+    // If the server path is empty, bail. We don't emit errors if the user
+    // hasn't explicitly configured the server.
+    if (serverPath === '') {
       return [ null, serverPath ];
     }
 
     // Check that the file actually exists.
-    if (serverPath === '' || !fs.existsSync(serverPath)) {
+    if (!fs.existsSync(serverPath)) {
       vscode.window
           .showErrorMessage(
               `${clientTitle}: Unable to resolve path for '${


        


More information about the Mlir-commits mailing list