import { ExecuteCommandParams } from 'vscode-languageserver' ; export interface CommandHandler { ( ... args ) : void ; } export class CommandExecutor { private commands = new Map < string , CommandHandler > ( ) ; executeCommand ( params ) { if ( this . commands . has ( params . command ) ) { const handler = this . commands . get ( params . command ) ; return handler ( ... params . arguments ) ; } throw new Error ( `Command '${ params . command }' not found` ) ; } registerCommand ( commandId , handler ) { this . commands . set ( commandId , handler ) ; } } export const commandExecutor = new CommandExecutor ( ) ;