brintos

brintos / llvm-project-archived public Read only

0
0
Text · 738 B · 4623a5b Raw
26 lines · typescript
1import * as vscode from 'vscode';2import {MLIRContext} from './mlirContext';3 4/**5 * This class represents a base vscode command. It handles all of the necessary6 * command registration and disposal boilerplate.7 */8export abstract class Command extends vscode.Disposable {9  private disposable: vscode.Disposable;10  protected context: MLIRContext;11 12  constructor(command: string, context: MLIRContext) {13    super(() => this.dispose());14    this.disposable =15        vscode.commands.registerCommand(command, this.execute, this);16    this.context = context;17  }18 19  dispose() { this.disposable && this.disposable.dispose(); }20 21  /**22   * The function executed when this command is invoked.23   */24  abstract execute(...args: any[]): any;25}26