Files
whetstone_DSL/editor/src/DAPBreakpointHitDispatcher.h
Bill 99cc6319c0 Sprint 281: DAP Hardening (steps 1933–1937)
DAPRequestValidator, DAPCapabilityNegotiator, DAPEventBroadcaster,
DAPBreakpointHitDispatcher — 26/26 tests pass.
Integration step 1937: Python+Rust DAP session round-trip verified.
Also adds allBreakpoints() to ASTNodeBreakpointMapper.
Metrics: 8 whetstone calls, 8853 tokens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 21:45:53 -07:00

48 lines
1.6 KiB
C++

#pragma once
#include "ASTNodeBreakpointMapper.h"
#include "DebugAdapterRouter.h"
#include <string>
#include <vector>
namespace whetstone {
struct HitResult {
std::string language;
std::string astNodeId;
int line = 0;
bool dispatched = false;
};
class DAPBreakpointHitDispatcher {
public:
// Find the first active breakpoint at source:line, set router to its language.
HitResult dispatch(const std::string& source, int line,
const ASTNodeBreakpointMapper& mapper,
DebugAdapterRouter& router) const {
for (const auto& bp : mapper.allBreakpoints()) {
if (bp.active && bp.source == source && bp.line == line) {
router.setActiveLanguage(bp.language);
return {bp.language, bp.astNodeId, bp.line, true};
}
}
return {"", "", line, false};
}
// Return a HitResult for every active breakpoint at source:line.
// Router ends at the language of the last match.
std::vector<HitResult> dispatchAll(const std::string& source, int line,
const ASTNodeBreakpointMapper& mapper,
DebugAdapterRouter& router) const {
std::vector<HitResult> results;
for (const auto& bp : mapper.allBreakpoints()) {
if (bp.active && bp.source == source && bp.line == line) {
router.setActiveLanguage(bp.language);
results.push_back({bp.language, bp.astNodeId, bp.line, true});
}
}
return results;
}
};
} // namespace whetstone