You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
1.1 KiB

/******************************************************************************
* Copyright 2022 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { CancellationToken } from '../utils/cancellation.js';
export class AbstractExecuteCommandHandler {
get commands() {
return Array.from(this.registeredCommands.keys());
}
constructor() {
this.registeredCommands = new Map();
this.registerCommands(this.createCommandAcceptor());
}
async executeCommand(name, args, cancelToken = CancellationToken.None) {
const command = this.registeredCommands.get(name);
if (command) {
return command(args, cancelToken);
}
else {
return undefined;
}
}
createCommandAcceptor() {
return (name, execute) => this.registeredCommands.set(name, execute);
}
}
//# sourceMappingURL=execute-command-handler.js.map