[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).
This commit is contained in:
River Riddle 2021-07-30 23:53:01 +00:00
parent 3e5906499f
commit 03b2d1a659
2 changed files with 8 additions and 4 deletions

View File

@ -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);
}

View File

@ -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.