(config: InitConfig = {})
| 25 | |
| 26 | |
| 27 | export function initContextMenuSystem(config: InitConfig = {}): void { |
| 28 | const { |
| 29 | registerBuiltinCommands = true, |
| 30 | registerBuiltinProviders = true, |
| 31 | debug = false, |
| 32 | customCommands = [], |
| 33 | customProviders = [] |
| 34 | } = config; |
| 35 | |
| 36 | let commandCount = 0; |
| 37 | let providerCount = 0; |
| 38 | |
| 39 | |
| 40 | if (registerBuiltinCommands) { |
| 41 | const builtinCommands = getBuiltinCommands(); |
| 42 | builtinCommands.forEach(command => { |
| 43 | try { |
| 44 | commandRegistry.register(command); |
| 45 | commandCount++; |
| 46 | } catch (error) { |
| 47 | log.error('Failed to register command', { commandId: command.id, error }); |
| 48 | } |
| 49 | }); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | customCommands.forEach(command => { |
| 54 | try { |
| 55 | commandRegistry.register(command); |
| 56 | commandCount++; |
| 57 | } catch (error) { |
| 58 | log.error('Failed to register custom command', error as Error); |
| 59 | } |
| 60 | }); |
| 61 | |
| 62 | |
| 63 | if (registerBuiltinProviders) { |
| 64 | const builtinProviders = getBuiltinProviders(); |
| 65 | builtinProviders.forEach(provider => { |
| 66 | try { |
| 67 | contextMenuRegistry.register(provider); |
| 68 | providerCount++; |
| 69 | } catch (error) { |
| 70 | log.error('Failed to register provider', { providerId: provider.id, error }); |
| 71 | } |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | customProviders.forEach(provider => { |
| 77 | try { |
| 78 | contextMenuRegistry.register(provider); |
| 79 | providerCount++; |
| 80 | } catch (error) { |
| 81 | log.error('Failed to register custom provider', error); |
| 82 | } |
| 83 | }); |
| 84 |
no test coverage detected