From 03b2d1a659228bc2fe7972357d9b8b41eda2f558 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Fri, 30 Jul 2021 23:53:01 +0000 Subject: [PATCH] [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). --- mlir/utils/vscode/src/extension.ts | 7 +++++-- mlir/utils/vscode/src/mlirContext.ts | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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('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.