Theia API Documentation v1.75.0
    Preparing search index...

    The command registry manages commands and handlers.

    Implements

    Index

    Constructors

    Properties

    _aliases: Map<string, Set<string>> = ...

    Unidirectional alias map from a target command id to the alias command ids registered for it. When the target (for instance a native Theia command) is executed, events also fire for its aliases (for instance the VS Code command ids).

    _commands: { [id: string]: Command } = {}
    _handlers: { [id: string]: CommandHandler[] } = {}
    _recent: string[] = []

    List of recently used commands.

    executionDepth: Map<string, number> = ...

    How often each command is currently executing, so that an alias event can be skipped while the alias command itself is on the stack.

    fireDidChange: (...arguments: []) => Promise<void> = ...
    logger: ILogger
    onCommandsChanged: Event<void> = ...
    onCommandsChangedEmitter: Emitter<void> = ...
    onDidExecuteCommand: Event<CommandEvent> = ...

    An event is emitted when a command was executed.

    onDidExecuteCommandEmitter: Emitter<CommandEvent> = ...
    onWillExecuteCommand: Event<WillExecuteCommandEvent> = ...

    An event is emitted when a command is about to be executed.

    It can be used to install or activate a command handler.

    onWillExecuteCommandEmitter: Emitter<WillExecuteCommandEvent> = ...
    toUnregisterCommands: Map<string, Disposable> = ...

    Accessors

    Methods

    • eslint-disable-next-line @typescript-eslint/no-explicit-any

      Parameters

      • commandId: string
      • args: any[] = []

      Returns Promise<void>

    • Returns the alias ids registered for the given command id.

      Parameters

      • commandId: string

      Returns readonly string[]

    • The aliases of the given command that are not executing themselves, and for which events are therefore still owed.

      Parameters

      • commandId: string

      Returns readonly string[]

    • eslint-disable-next-line @typescript-eslint/no-explicit-any

      Parameters

      • command: string
      • ...args: any[]

      Returns boolean

    • eslint-disable-next-line @typescript-eslint/no-explicit-any

      Parameters

      • command: string
      • ...args: any[]

      Returns boolean

    • eslint-disable-next-line @typescript-eslint/no-explicit-any

      Parameters

      • command: string
      • ...args: any[]

      Returns boolean

    • Register a unidirectional alias from a target command to an alias command. When the target command is executed, onDidExecuteCommand and onWillExecuteCommand fire for the alias id as well.

      This does not affect command handlers, enablement or visibility, only event emission. A target may carry several aliases.

      No event is fired for an alias while that alias is executing, which keeps an alias command that delegates to its target from reporting itself twice. The check is by command id rather than by call stack, so an unrelated execution of the alias that happens to overlap suppresses the event as well.

      Parameters

      • aliasId: string

        the alias command id, for instance a VS Code command id

      • targetId: string

        the target command id, for instance the native Theia command id

      Returns Disposable

      a Disposable that removes this alias again

    • Register the given handler for the given command identifier.

      If there is already a handler for the given command then the given handler is registered as more specific, and has higher priority during enablement, visibility and toggle state evaluations.

      Parameters

      Returns Disposable