[Mlir-commits] [mlir] 03b2d1a - [mlir-vscode] Create a proper output channel for the MLIRContext

River Riddle llvmlistbot at llvm.org
Fri Jul 30 16:54:30 PDT 2021


Author: River Riddle
Date: 2021-07-30T23:53:50Z
New Revision: 03b2d1a659228bc2fe7972357d9b8b41eda2f558

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

LOG: [mlir-vscode] Create a proper output channel for the MLIRContext

This allows for reusing the same output channel when the extension reloads after updating the server. Currently, whenever the extension restarts a new output channel is created (which can lead to a large number of seemingly dead output channels).

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/utils/vscode/src/extension.ts b/mlir/utils/vscode/src/extension.ts
index 2220c50327e5..7c8c9fd6b969 100644
--- a/mlir/utils/vscode/src/extension.ts
+++ b/mlir/utils/vscode/src/extension.ts
@@ -7,6 +7,9 @@ import {MLIRContext} from './mlirContext';
  *  activated the very first time a command is executed.
  */
 export function activate(context: vscode.ExtensionContext) {
+  const outputChannel = vscode.window.createOutputChannel('MLIR');
+  context.subscriptions.push(outputChannel);
+
   const mlirContext = new MLIRContext();
   context.subscriptions.push(mlirContext);
 
@@ -14,8 +17,8 @@ export function activate(context: vscode.ExtensionContext) {
   context.subscriptions.push(
       vscode.commands.registerCommand('mlir.restart', async () => {
         mlirContext.dispose();
-        await mlirContext.activate();
+        await mlirContext.activate(outputChannel);
       }));
 
-  mlirContext.activate();
+  mlirContext.activate(outputChannel);
 }

diff  --git a/mlir/utils/vscode/src/mlirContext.ts b/mlir/utils/vscode/src/mlirContext.ts
index 3b582187c373..b8a71b97e165 100644
--- a/mlir/utils/vscode/src/mlirContext.ts
+++ b/mlir/utils/vscode/src/mlirContext.ts
@@ -15,7 +15,7 @@ export class MLIRContext implements vscode.Disposable {
   /**
    *  Activate the MLIR context, and start the language client.
    */
-  async activate() {
+  async activate(outputChannel: vscode.OutputChannel) {
     // Get the path of the mlir-lsp-server that is used to provide language
     // functionality.
     const userDefinedServerPath = config.get<string>('server_path');
@@ -43,7 +43,8 @@ export class MLIRContext implements vscode.Disposable {
         // Notify the server about file changes to *.mlir files contained in the
         // workspace.
         fileEvents : vscode.workspace.createFileSystemWatcher('**/*.mlir')
-      }
+      },
+      outputChannel : outputChannel,
     };
 
     // Create the language client and start the client.


        


More information about the Mlir-commits mailing list