Class: Byebug::DAP::ContextualCommand Abstract
- Defined in:
- lib/byebug/dap/contextual_command.rb
Overview
Subclasses must implement #execute_in_context
Implementation of a DAP command that must be executed in-context.
Direct Known Subclasses
Byebug::DAP::Command::Continue, Byebug::DAP::Command::ExceptionInfo, Byebug::DAP::Command::Next, Byebug::DAP::Command::Pause, Byebug::DAP::Command::StepIn, Byebug::DAP::Command::StepOut
Constant Summary
Constants inherited from Command
Byebug::DAP::Command::EVAL_ERROR
Class Method Summary collapse
-
.resolve!(session, request) ⇒ std:Class
Resolve the requested command.
Instance Method Summary collapse
-
#execute ⇒ Object
Execute in-context if ‘processor` is defined.
-
#forward_to_context(ctx) ⇒ Object
private
Forward the request to the context’s thread.
-
#initialize(session, request, processor = nil) ⇒ ContextualCommand
constructor
Create a new instance of the receiver.
Methods inherited from Command
command, execute, #execute_on_thread, #log, register!, #safe_execute, #started!, #stopped!
Methods included from SafeHelpers
Constructor Details
#initialize(session, request, processor = nil) ⇒ ContextualCommand
Create a new instance of the receiver.
18 19 20 21 22 |
# File 'lib/byebug/dap/contextual_command.rb', line 18 def initialize(session, request, processor = nil) super(session, request) @processor = processor @context = processor&.context end |
Class Method Details
.resolve!(session, request) ⇒ std:Class
Raises an error if the resolved class is not a subclass of Byebug::DAP::ContextualCommand
Resolve the requested command. Calls Session#respond! indicating a failed request if the command cannot be found.
7 8 9 10 11 12 |
# 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 |
Instance Method Details
#execute ⇒ Object
Execute in-context if ‘processor` is defined. Otherwise, ensure debugging is started, find the requested thread context, and forward the request.
27 28 29 30 31 32 33 |
# 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 |
#forward_to_context(ctx) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Forward the request to the context’s thread.
41 42 43 |
# File 'lib/byebug/dap/contextual_command.rb', line 41 def forward_to_context(ctx) ctx.processor << @request end |