class Byebug::DAP::ContextualCommand

Implementation of a DAP command that must be executed in-context. @abstract Subclasses must implement {#execute_in_context}

Public Class Methods

new(session, request, processor = nil) click to toggle source

Create a new instance of the receiver. @param session [Session] the debug session @param request [Protocol::Request] the DAP request @param processor [CommandProcessor] the command processor associated with the context

Calls superclass method Byebug::DAP::Command::new
# File lib/byebug/dap/contextual_command.rb, line 18
def initialize(session, request, processor = nil)
  super(session, request)
  @processor = processor
  @context = processor&.context
end
resolve!(session, request) click to toggle source

(see Command.resolve!) @note Raises an error if the resolved class is not a subclass of {ContextualCommand}

Calls superclass method Byebug::DAP::Command::resolve!
# File lib/byebug/dap/contextual_command.rb, line 7
def self.resolve!(session, request)
  return unless cls = super
  return cls if cls < ContextualCommand

  raise "Not a contextual command: #{command}"
end

Public Instance Methods

execute() click to toggle source

{#execute_in_context Execute in-context} if `processor` is defined. Otherwise, ensure debugging is {#started! started}, find the requested thread context, and {#forward_to_context forward the request}.

# File lib/byebug/dap/contextual_command.rb, line 27
def execute
  return execute_in_context if @processor

  started!

  forward_to_context find_thread(args.threadId)
end

Private Instance Methods

forward_to_context(ctx) click to toggle source

Forward the request to the context's thread. @param ctx [gem:byebug:Byebug::Context] the context @api private @!visibility public

# File lib/byebug/dap/contextual_command.rb, line 41
def forward_to_context(ctx)
  ctx.processor << @request
end